[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: svn commit: r1415850 [10/15] - in /commons/proper/io/trunk/src: main/java/org/apache/commons/io/ mai
From: ggregory () apache ! org
Date: 2012-11-30 20:52:08
Message-ID: 20121130205235.A905E2388C02 () eris ! apache ! org
[Download RAW message or body]
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/com \
mons/io/FileUtilsWaitForTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff \
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java \
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java \
Fri Nov 30 20:51:39 2012 @@ -30,7 +30,7 @@ public class FileUtilsWaitForTestCase ex
// This class has been broken out from FileUtilsTestCase
// to solve issues as per BZ 38927
- public FileUtilsWaitForTestCase(String name) {
+ public FileUtilsWaitForTestCase(final String name) {
super(name);
}
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java \
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java \
Fri Nov 30 20:51:39 2012 @@ -34,13 +34,13 @@ public class FilenameUtilsTestCase exten
private static final String SEP = "" + File.separatorChar;
private static final boolean WINDOWS = File.separatorChar == '\\';
- private File testFile1;
- private File testFile2;
+ private final File testFile1;
+ private final File testFile2;
- private int testFile1Size;
- private int testFile2Size;
+ private final int testFile1Size;
+ private final int testFile2Size;
- public FilenameUtilsTestCase(String name) {
+ public FilenameUtilsTestCase(final String name) {
super(name);
testFile1 = new File(getTestDirectory(), "file1-test.txt");
@@ -821,19 +821,19 @@ public class FilenameUtilsTestCase exten
try {
FilenameUtils.equalsNormalizedOnSystem("//file.txt", "file.txt");
fail("Invalid normalized first file");
- } catch(NullPointerException e) {
+ } catch(final NullPointerException e) {
// expected result
}
try {
FilenameUtils.equalsNormalizedOnSystem("file.txt", "//file.txt");
fail("Invalid normalized second file");
- } catch(NullPointerException e) {
+ } catch(final NullPointerException e) {
// expected result
}
try {
FilenameUtils.equalsNormalizedOnSystem("//file.txt", "//file.txt");
fail("Invalid normalized both filse");
- } catch(NullPointerException e) {
+ } catch(final NullPointerException e) {
// expected result
}
}
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/com \
mons/io/FilenameUtilsWildcardTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java \
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java \
Fri Nov 30 20:51:39 2012 @@ -25,7 +25,7 @@ public class FilenameUtilsWildcardTestCa
private static final boolean WINDOWS = File.separatorChar == '\\';
- public FilenameUtilsWildcardTestCase(String name) {
+ public FilenameUtilsWildcardTestCase(final String name) {
super(name);
}
@@ -127,14 +127,14 @@ public class FilenameUtilsWildcardTestCa
assertArrayEquals( new String[] { "" }, FilenameUtils.splitOnTokens("") );
}
- private void assertArrayEquals(Object[] a1, Object[] a2) {
+ private void assertArrayEquals(final Object[] a1, final Object[] a2) {
assertEquals(a1.length, a2.length);
for(int i=0; i<a1.length; i++) {
assertEquals(a1[i], a2[i]);
}
}
- private void assertMatch(String text, String wildcard, boolean expected) {
+ private void assertMatch(final String text, final String wildcard, final boolean \
expected) {
assertEquals(text + " " + wildcard, expected, \
FilenameUtils.wildcardMatch(text, wildcard)); }
@@ -213,11 +213,11 @@ public class FilenameUtilsWildcardTestCa
}
public void testLocaleIndependence() {
- Locale orig = Locale.getDefault();
+ final Locale orig = Locale.getDefault();
- Locale[] locales = Locale.getAvailableLocales();
+ final Locale[] locales = Locale.getAvailableLocales();
- String[][] data = {
+ final String[][] data = {
{ "I", "i"},
{ "i", "I"},
{ "i", "\u0130"},
@@ -229,10 +229,10 @@ public class FilenameUtilsWildcardTestCa
try {
for (int i = 0; i < data.length; i++) {
- for (Locale locale : locales) {
+ for (final Locale locale : locales) {
Locale.setDefault(locale);
assertTrue("Test data corrupt: " + i, \
data[i][0].equalsIgnoreCase(data[i][1]));
- boolean match = FilenameUtils.wildcardMatch(data[i][0], \
data[i][1], IOCase.INSENSITIVE); + final boolean match = \
FilenameUtils.wildcardMatch(data[i][0], data[i][1], \
IOCase.INSENSITIVE);
assertTrue(Locale.getDefault().toString() + ": " + i, match);
}
}
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/HexDumpTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/HexDumpTest.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/HexDumpTest.java \
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/HexDumpTest.java Fri \
Nov 30 20:51:39 2012 @@ -35,12 +35,12 @@ public class HexDumpTest extends TestCas
* @param name
*/
- public HexDumpTest(String name) {
+ public HexDumpTest(final String name) {
super(name);
}
- private char toHex(int n) {
- char[] hexChars =
+ private char toHex(final int n) {
+ final char[] hexChars =
{
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
@@ -57,7 +57,7 @@ public class HexDumpTest extends TestCas
public void testDump()
throws IOException {
- byte[] testArray = new byte[256];
+ final byte[] testArray = new byte[256];
for (int j = 0; j < 256; j++) {
testArray[j] = (byte) j;
@@ -186,7 +186,7 @@ public class HexDumpTest extends TestCas
outputArray[offset++] = (byte) '1';
outputArray[offset++] = (byte) ' ';
for (int k = 0; k < 16; k++) {
- int index = 0x81 + (j * 16) + k;
+ final int index = 0x81 + (j * 16) + k;
if (index < 0x100) {
outputArray[offset++] = (byte) toHex(index / 16);
@@ -198,7 +198,7 @@ public class HexDumpTest extends TestCas
outputArray[offset++] = (byte) ' ';
}
for (int k = 0; k < 16; k++) {
- int index = 0x81 + (j * 16) + k;
+ final int index = 0x81 + (j * 16) + k;
if (index < 0x100) {
outputArray[offset++] = (byte) toAscii(index);
@@ -220,7 +220,7 @@ public class HexDumpTest extends TestCas
HexDump.dump(testArray, 0x10000000, new ByteArrayOutputStream(),
-1);
fail("should have caught ArrayIndexOutOfBoundsException on negative \
index");
- } catch (ArrayIndexOutOfBoundsException ignored_exception) {
+ } catch (final ArrayIndexOutOfBoundsException ignored_exception) {
// as expected
}
@@ -230,7 +230,7 @@ public class HexDumpTest extends TestCas
HexDump.dump(testArray, 0x10000000, new ByteArrayOutputStream(),
testArray.length);
fail("should have caught ArrayIndexOutOfBoundsException on large \
index");
- } catch (ArrayIndexOutOfBoundsException ignored_exception) {
+ } catch (final ArrayIndexOutOfBoundsException ignored_exception) {
// as expected
}
@@ -239,13 +239,13 @@ public class HexDumpTest extends TestCas
try {
HexDump.dump(testArray, 0x10000000, null, 0);
fail("should have caught IllegalArgumentException on negative index");
- } catch (IllegalArgumentException ignored_exception) {
+ } catch (final IllegalArgumentException ignored_exception) {
// as expected
}
}
- private char toAscii(int c) {
+ private char toAscii(final int c) {
char rval = '.';
if ((c >= 32) && (c <= 126)) {
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOCaseTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOCaseTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOCaseTestCase.java \
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOCaseTestCase.java \
Fri Nov 30 20:51:39 2012 @@ -33,7 +33,7 @@ public class IOCaseTestCase extends File
private static final boolean WINDOWS = File.separatorChar == '\\';
- public IOCaseTestCase(String name) {
+ public IOCaseTestCase(final String name) {
super(name);
}
@@ -54,11 +54,11 @@ public class IOCaseTestCase extends File
try {
IOCase.forName("Blah");
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
IOCase.forName(null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
public void test_serialization() throws Exception {
@@ -96,15 +96,15 @@ public class IOCaseTestCase extends File
try {
IOCase.SENSITIVE.checkCompareTo("ABC", null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkCompareTo(null, "ABC");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkCompareTo(null, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void test_checkCompare_case() throws Exception {
@@ -137,15 +137,15 @@ public class IOCaseTestCase extends File
try {
IOCase.SENSITIVE.checkEquals("ABC", null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkEquals(null, "ABC");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkEquals(null, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void test_checkEquals_case() throws Exception {
@@ -174,15 +174,15 @@ public class IOCaseTestCase extends File
try {
IOCase.SENSITIVE.checkStartsWith("ABC", null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkStartsWith(null, "ABC");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkStartsWith(null, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void test_checkStartsWith_case() throws Exception {
@@ -211,15 +211,15 @@ public class IOCaseTestCase extends File
try {
IOCase.SENSITIVE.checkEndsWith("ABC", null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkEndsWith(null, "ABC");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkEndsWith(null, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void test_checkEndsWith_case() throws Exception {
@@ -275,15 +275,15 @@ public class IOCaseTestCase extends File
try {
IOCase.SENSITIVE.checkIndexOf("ABC", 0, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkIndexOf(null, 0, "ABC");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkIndexOf(null, 0, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void test_checkIndexOf_case() throws Exception {
@@ -322,27 +322,27 @@ public class IOCaseTestCase extends File
try {
IOCase.SENSITIVE.checkRegionMatches("ABC", 0, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkRegionMatches(null, 0, "ABC");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkRegionMatches(null, 0, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkRegionMatches("ABC", 1, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkRegionMatches(null, 1, "ABC");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
IOCase.SENSITIVE.checkRegionMatches(null, 1, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void test_checkRegionMatches_case() throws Exception {
@@ -357,15 +357,15 @@ public class IOCaseTestCase extends File
}
//-----------------------------------------------------------------------
- private IOCase serialize(IOCase value) throws Exception {
- ByteArrayOutputStream buf = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(buf);
+ private IOCase serialize(final IOCase value) throws Exception {
+ final ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(buf);
out.writeObject(value);
out.flush();
out.close();
- ByteArrayInputStream bufin = new ByteArrayInputStream(buf.toByteArray());
- ObjectInputStream in = new ObjectInputStream(bufin);
+ final ByteArrayInputStream bufin = new \
ByteArrayInputStream(buf.toByteArray()); + final ObjectInputStream in = new \
ObjectInputStream(bufin); return (IOCase) in.readObject();
}
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/com \
mons/io/IOExceptionWithCauseTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff \
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java \
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java \
Fri Nov 30 20:51:39 2012 @@ -30,8 +30,8 @@ public class IOExceptionWithCauseTestCas
* Tests the {@link IOExceptionWithCause#IOExceptionWithCause(String,Throwable)} \
constructor.
*/
public void testIOExceptionStringThrowable() {
- Throwable cause = new IllegalArgumentException("cause");
- IOExceptionWithCause exception = new IOExceptionWithCause("message", cause);
+ final Throwable cause = new IllegalArgumentException("cause");
+ final IOExceptionWithCause exception = new IOExceptionWithCause("message", \
cause); this.validate(exception, cause, "message");
}
@@ -39,12 +39,12 @@ public class IOExceptionWithCauseTestCas
* Tests the {@link IOExceptionWithCause#IOExceptionWithCause(Throwable)} \
constructor.
*/
public void testIOExceptionThrowable() {
- Throwable cause = new IllegalArgumentException("cause");
- IOExceptionWithCause exception = new IOExceptionWithCause(cause);
+ final Throwable cause = new IllegalArgumentException("cause");
+ final IOExceptionWithCause exception = new IOExceptionWithCause(cause);
this.validate(exception, cause, "java.lang.IllegalArgumentException: \
cause"); }
- void validate(Throwable throwable, Throwable expectedCause, String \
expectedMessage) { + void validate(final Throwable throwable, final Throwable \
expectedCause, final String expectedMessage) { assertEquals(expectedMessage, \
throwable.getMessage()); assertEquals(expectedCause, throwable.getCause());
assertSame(expectedCause, throwable.getCause());
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java \
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java \
Fri Nov 30 20:51:39 2012 @@ -52,9 +52,9 @@ public class IOUtilsCopyTestCase extends
private static final int FILE_SIZE = 1024 * 4 + 1;
- private byte[] inData = generateTestData(FILE_SIZE);
+ private final byte[] inData = generateTestData(FILE_SIZE);
- public IOUtilsCopyTestCase(String testName) {
+ public IOUtilsCopyTestCase(final String testName) {
super(testName);
}
@@ -75,10 +75,10 @@ public class IOUtilsCopyTestCase extends
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, \
true);
- int count = IOUtils.copy(in, out);
+ final int count = IOUtils.copy(in, out);
assertEquals("Not all bytes were read", 0, in.available());
assertEquals("Sizes differ", inData.length, baout.size());
@@ -104,14 +104,14 @@ public class IOUtilsCopyTestCase extends
testCopy_inputStreamToOutputStreamWithBufferSize(16384);
}
- private void testCopy_inputStreamToOutputStreamWithBufferSize(int bufferSize) \
throws Exception { + private void \
testCopy_inputStreamToOutputStreamWithBufferSize(final int bufferSize) throws \
Exception { InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, \
true);
- long count = IOUtils.copy(in, out, bufferSize);
+ final long count = IOUtils.copy(in, out, bufferSize);
assertEquals("Not all bytes were read", 0, in.available());
assertEquals("Sizes differ", inData.length, baout.size());
@@ -120,28 +120,28 @@ public class IOUtilsCopyTestCase extends
}
public void testCopy_inputStreamToOutputStream_nullIn() throws Exception {
- OutputStream out = new ByteArrayOutputStream();
+ final OutputStream out = new ByteArrayOutputStream();
try {
IOUtils.copy((InputStream) null, out);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void testCopy_inputStreamToOutputStream_nullOut() throws Exception {
- InputStream in = new ByteArrayInputStream(inData);
+ final InputStream in = new ByteArrayInputStream(inData);
try {
IOUtils.copy(in, (OutputStream) null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
/**
* Test Copying file > 2GB - see issue# IO-84
*/
public void testCopy_inputStreamToOutputStream_IO84() throws Exception {
- long size = (long)Integer.MAX_VALUE + (long)1;
- InputStream in = new NullInputStream(size);
- OutputStream out = new NullOutputStream();
+ final long size = (long)Integer.MAX_VALUE + (long)1;
+ final InputStream in = new NullInputStream(size);
+ final OutputStream out = new NullOutputStream();
// Test copy() method
assertEquals(-1, IOUtils.copy(in, out));
@@ -158,9 +158,9 @@ public class IOUtilsCopyTestCase extends
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- YellOnFlushAndCloseOutputStream out = new \
YellOnFlushAndCloseOutputStream(baout, true, true);
- Writer writer = new OutputStreamWriter(baout, "US-ASCII");
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final YellOnFlushAndCloseOutputStream out = new \
YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = \
new OutputStreamWriter(baout, "US-ASCII");
IOUtils.copy(in, writer);
out.off();
@@ -172,21 +172,21 @@ public class IOUtilsCopyTestCase extends
}
public void testCopy_inputStreamToWriter_nullIn() throws Exception {
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
- Writer writer = new OutputStreamWriter(out, "US-ASCII");
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, \
true); + final Writer writer = new OutputStreamWriter(out, "US-ASCII");
try {
IOUtils.copy((InputStream) null, writer);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void testCopy_inputStreamToWriter_nullOut() throws Exception {
- InputStream in = new ByteArrayInputStream(inData);
+ final InputStream in = new ByteArrayInputStream(inData);
try {
IOUtils.copy(in, (Writer) null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
//-----------------------------------------------------------------------
@@ -194,9 +194,9 @@ public class IOUtilsCopyTestCase extends
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- YellOnFlushAndCloseOutputStream out = new \
YellOnFlushAndCloseOutputStream(baout, true, true);
- Writer writer = new OutputStreamWriter(baout, "US-ASCII");
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final YellOnFlushAndCloseOutputStream out = new \
YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = \
new OutputStreamWriter(baout, "US-ASCII");
IOUtils.copy(in, writer, "UTF8");
out.off();
@@ -209,30 +209,30 @@ public class IOUtilsCopyTestCase extends
}
public void testCopy_inputStreamToWriter_Encoding_nullIn() throws Exception {
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
- Writer writer = new OutputStreamWriter(out, "US-ASCII");
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, \
true); + final Writer writer = new OutputStreamWriter(out, "US-ASCII");
try {
IOUtils.copy((InputStream) null, writer, "UTF8");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void testCopy_inputStreamToWriter_Encoding_nullOut() throws Exception {
- InputStream in = new ByteArrayInputStream(inData);
+ final InputStream in = new ByteArrayInputStream(inData);
try {
IOUtils.copy(in, (Writer) null, "UTF8");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void testCopy_inputStreamToWriter_Encoding_nullEncoding() throws \
Exception { InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- YellOnFlushAndCloseOutputStream out = new \
YellOnFlushAndCloseOutputStream(baout, true, true);
- Writer writer = new OutputStreamWriter(baout, "US-ASCII");
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final YellOnFlushAndCloseOutputStream out = new \
YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = \
new OutputStreamWriter(baout, "US-ASCII");
IOUtils.copy(in, writer, (String) null);
out.off();
@@ -247,10 +247,10 @@ public class IOUtilsCopyTestCase extends
public void testCopy_readerToOutputStream() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- Reader reader = new InputStreamReader(in, "US-ASCII");
+ final Reader reader = new InputStreamReader(in, "US-ASCII");
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, \
true);
IOUtils.copy(reader, out);
//Note: this method *does* flush. It is equivalent to:
@@ -265,32 +265,32 @@ public class IOUtilsCopyTestCase extends
}
public void testCopy_readerToOutputStream_nullIn() throws Exception {
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, \
true); try {
IOUtils.copy((Reader) null, out);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void testCopy_readerToOutputStream_nullOut() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- Reader reader = new InputStreamReader(in, "US-ASCII");
+ final Reader reader = new InputStreamReader(in, "US-ASCII");
try {
IOUtils.copy(reader, (OutputStream) null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
//-----------------------------------------------------------------------
public void testCopy_readerToOutputStream_Encoding() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- Reader reader = new InputStreamReader(in, "US-ASCII");
+ final Reader reader = new InputStreamReader(in, "US-ASCII");
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, \
true);
IOUtils.copy(reader, out, "UTF16");
// note: this method *does* flush.
@@ -302,31 +302,31 @@ public class IOUtilsCopyTestCase extends
}
public void testCopy_readerToOutputStream_Encoding_nullIn() throws Exception {
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, \
true); try {
IOUtils.copy((Reader) null, out, "UTF16");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void testCopy_readerToOutputStream_Encoding_nullOut() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- Reader reader = new InputStreamReader(in, "US-ASCII");
+ final Reader reader = new InputStreamReader(in, "US-ASCII");
try {
IOUtils.copy(reader, (OutputStream) null, "UTF16");
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void testCopy_readerToOutputStream_Encoding_nullEncoding() throws \
Exception { InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- Reader reader = new InputStreamReader(in, "US-ASCII");
+ final Reader reader = new InputStreamReader(in, "US-ASCII");
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, \
true);
IOUtils.copy(reader, out, (String) null);
// note: this method *does* flush.
@@ -340,13 +340,13 @@ public class IOUtilsCopyTestCase extends
public void testCopy_readerToWriter() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- Reader reader = new InputStreamReader(in, "US-ASCII");
+ final Reader reader = new InputStreamReader(in, "US-ASCII");
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- YellOnFlushAndCloseOutputStream out = new \
YellOnFlushAndCloseOutputStream(baout, true, true);
- Writer writer = new OutputStreamWriter(baout, "US-ASCII");
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final YellOnFlushAndCloseOutputStream out = new \
YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = \
new OutputStreamWriter(baout, "US-ASCII");
- int count = IOUtils.copy(reader, writer);
+ final int count = IOUtils.copy(reader, writer);
out.off();
writer.flush();
assertEquals("The number of characters returned by copy is wrong", \
inData.length, count); @@ -355,32 +355,32 @@ public class IOUtilsCopyTestCase extends
}
public void testCopy_readerToWriter_nullIn() throws Exception {
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
- Writer writer = new OutputStreamWriter(out, "US-ASCII");
+ final ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, \
true); + final Writer writer = new OutputStreamWriter(out, "US-ASCII");
try {
IOUtils.copy((Reader) null, writer);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
public void testCopy_readerToWriter_nullOut() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStream(in);
- Reader reader = new InputStreamReader(in, "US-ASCII");
+ final Reader reader = new InputStreamReader(in, "US-ASCII");
try {
IOUtils.copy(reader, (Writer) null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
/**
* Test Copying file > 2GB - see issue# IO-84
*/
public void testCopy_readerToWriter_IO84() throws Exception {
- long size = (long)Integer.MAX_VALUE + (long)1;
- Reader reader = new NullReader(size);
- Writer writer = new NullWriter();
+ final long size = (long)Integer.MAX_VALUE + (long)1;
+ final Reader reader = new NullReader(size);
+ final Writer writer = new NullWriter();
// Test copy() method
assertEquals(-1, IOUtils.copy(reader, writer));
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java \
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java \
Fri Nov 30 20:51:39 2012 @@ -75,12 +75,12 @@ public class IOUtilsTestCase extends Fil
private File m_testFile;
- public IOUtilsTestCase(String name) {
+ public IOUtilsTestCase(final String name) {
super(name);
}
/** Assert that the contents of two byte arrays are the same. */
- private void assertEqualContent(byte[] b0, byte[] b1) {
+ private void assertEqualContent(final byte[] b0, final byte[] b1) {
assertTrue("Content not equal according to java.util.Arrays#equals()", \
Arrays.equals(b0, b1)); }
@@ -91,7 +91,7 @@ public class IOUtilsTestCase extends Fil
m_testFile = new File(getTestDirectory(), "file2-test.txt");
createFile(m_testFile, FILE_SIZE);
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
throw new RuntimeException("Can't run this test because the environment \
could not be built: " + ioe.getMessage());
}
@@ -114,7 +114,7 @@ public class IOUtilsTestCase extends Fil
iarr = null;
try {
FileUtils.deleteDirectory(getTestDirectory());
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException("Could not clear up " + getTestDirectory() + \
": " + e); }
}
@@ -131,14 +131,14 @@ public class IOUtilsTestCase extends Fil
Selector selector = null;
try {
selector = Selector.open();
- } catch (IOException e) {
+ } catch (final IOException e) {
} finally {
IOUtils.closeQuietly(selector);
}
}
public void testCloseQuietly_SelectorIOException() {
- Selector selector = new SelectorAdapter() {
+ final Selector selector = new SelectorAdapter() {
@Override
public void close() throws IOException {
throw new IOException();
@@ -148,7 +148,7 @@ public class IOUtilsTestCase extends Fil
}
public void testCloseQuietly_SelectorNull() {
- Selector selector = null;
+ final Selector selector = null;
IOUtils.closeQuietly(selector);
}
@@ -156,7 +156,7 @@ public class IOUtilsTestCase extends Fil
Selector selector = null;
try {
selector = Selector.open();
- } catch (IOException e) {
+ } catch (final IOException e) {
} finally {
IOUtils.closeQuietly(selector);
IOUtils.closeQuietly(selector);
@@ -241,8 +241,8 @@ public class IOUtilsTestCase extends Fil
@SuppressWarnings("deprecation")
// testing deprecated method
public void testCopy_ByteArray_OutputStream() throws Exception {
- File destination = newFile("copy8.txt");
- FileInputStream fin = new FileInputStream(m_testFile);
+ final File destination = newFile("copy8.txt");
+ final FileInputStream fin = new FileInputStream(m_testFile);
byte[] in;
try {
// Create our byte[]. Rely on testInputStreamToByteArray() to make sure \
this is valid. @@ -251,7 +251,7 @@ public class IOUtilsTestCase extends Fil
fin.close();
}
- FileOutputStream fout = new FileOutputStream(destination);
+ final FileOutputStream fout = new FileOutputStream(destination);
try {
CopyUtils.copy(in, fout);
@@ -268,8 +268,8 @@ public class IOUtilsTestCase extends Fil
@SuppressWarnings("deprecation")
// testing deprecated method
public void testCopy_ByteArray_Writer() throws Exception {
- File destination = newFile("copy7.txt");
- FileInputStream fin = new FileInputStream(m_testFile);
+ final File destination = newFile("copy7.txt");
+ final FileInputStream fin = new FileInputStream(m_testFile);
byte[] in;
try {
// Create our byte[]. Rely on testInputStreamToByteArray() to make sure \
this is valid. @@ -278,7 +278,7 @@ public class IOUtilsTestCase extends Fil
fin.close();
}
- FileWriter fout = new FileWriter(destination);
+ final FileWriter fout = new FileWriter(destination);
try {
CopyUtils.copy(in, fout);
fout.flush();
@@ -293,8 +293,8 @@ public class IOUtilsTestCase extends Fil
@SuppressWarnings("deprecation")
// testing deprecated method
public void testCopy_String_Writer() throws Exception {
- File destination = newFile("copy6.txt");
- FileReader fin = new FileReader(m_testFile);
+ final File destination = newFile("copy6.txt");
+ final FileReader fin = new FileReader(m_testFile);
String str;
try {
// Create our String. Rely on testReaderToString() to make sure this is \
valid. @@ -303,7 +303,7 @@ public class IOUtilsTestCase extends Fil
fin.close();
}
- FileWriter fout = new FileWriter(destination);
+ final FileWriter fout = new FileWriter(destination);
try {
CopyUtils.copy(str, fout);
fout.flush();
@@ -327,7 +327,7 @@ public class IOUtilsTestCase extends Fil
// Test our copy method
// for extra length, it reads till EOF
assertEquals(200, IOUtils.copyLarge(is, os, 0, 2000));
- char[] oarr = os.toCharArray();
+ final char[] oarr = os.toCharArray();
// check that output length is correct
assertEquals(200, oarr.length);
@@ -352,7 +352,7 @@ public class IOUtilsTestCase extends Fil
// Test our copy method
assertEquals(200, IOUtils.copyLarge(is, os, 0, -1));
- char[] oarr = os.toCharArray();
+ final char[] oarr = os.toCharArray();
// check that output length is correct
assertEquals(200, oarr.length);
@@ -377,7 +377,7 @@ public class IOUtilsTestCase extends Fil
// Test our copy method
assertEquals(100, IOUtils.copyLarge(is, os, 0, 100));
- char[] oarr = os.toCharArray();
+ final char[] oarr = os.toCharArray();
// check that output length is correct
assertEquals(100, oarr.length);
@@ -402,7 +402,7 @@ public class IOUtilsTestCase extends Fil
// Test our copy method
assertEquals(100, IOUtils.copyLarge(is, os, 10, 100));
- char[] oarr = os.toCharArray();
+ final char[] oarr = os.toCharArray();
// check that output length is correct
assertEquals(100, oarr.length);
@@ -428,7 +428,7 @@ public class IOUtilsTestCase extends Fil
// Test our copy method
IOUtils.copyLarge(is, os, 1000, 100);
fail("Should have thrown EOFException");
- } catch (EOFException eofe) {
+ } catch (final EOFException eofe) {
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
@@ -446,7 +446,7 @@ public class IOUtilsTestCase extends Fil
// Test our copy method
// for extra length, it reads till EOF
assertEquals(200, IOUtils.copyLarge(is, os, 0, 2000));
- byte[] oarr = os.toByteArray();
+ final byte[] oarr = os.toByteArray();
// check that output length is correct
assertEquals(200, oarr.length);
@@ -471,7 +471,7 @@ public class IOUtilsTestCase extends Fil
// Test our copy method
assertEquals(200, IOUtils.copyLarge(is, os, 0, -1));
- byte[] oarr = os.toByteArray();
+ final byte[] oarr = os.toByteArray();
// check that output length is correct
assertEquals(200, oarr.length);
@@ -496,7 +496,7 @@ public class IOUtilsTestCase extends Fil
// Test our copy method
assertEquals(100, IOUtils.copyLarge(is, os, 0, 100));
- byte[] oarr = os.toByteArray();
+ final byte[] oarr = os.toByteArray();
// check that output length is correct
assertEquals(100, oarr.length);
@@ -521,7 +521,7 @@ public class IOUtilsTestCase extends Fil
// Test our copy method
assertEquals(100, IOUtils.copyLarge(is, os, 10, 100));
- byte[] oarr = os.toByteArray();
+ final byte[] oarr = os.toByteArray();
// check that output length is correct
assertEquals(100, oarr.length);
@@ -547,7 +547,7 @@ public class IOUtilsTestCase extends Fil
// Test our copy method
IOUtils.copyLarge(is, os, 1000, 100);
fail("Should have thrown EOFException");
- } catch (EOFException eofe) {
+ } catch (final EOFException eofe) {
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
@@ -555,9 +555,9 @@ public class IOUtilsTestCase extends Fil
}
public void testRead_ReadableByteChannel() throws Exception {
- ByteBuffer buffer = ByteBuffer.allocate(FILE_SIZE);
+ final ByteBuffer buffer = ByteBuffer.allocate(FILE_SIZE);
final FileInputStream fileInputStream = new FileInputStream(m_testFile);
- FileChannel input = fileInputStream.getChannel();
+ final FileChannel input = fileInputStream.getChannel();
try {
assertEquals(FILE_SIZE, IOUtils.read(input, buffer));
assertEquals(0, IOUtils.read(input, buffer));
@@ -567,7 +567,7 @@ public class IOUtilsTestCase extends Fil
try {
IOUtils.readFully(input, buffer);
fail("Should have failed with EOFxception");
- } catch (EOFException expected) {
+ } catch (final EOFException expected) {
// expected
}
} finally {
@@ -578,13 +578,13 @@ public class IOUtilsTestCase extends Fil
public void testReadFully_InputStream_ByteArray() throws Exception {
final int size = 1027;
- byte[] buffer = new byte[size];
+ final byte[] buffer = new byte[size];
- InputStream input = new ByteArrayInputStream(new byte[size]);
+ final InputStream input = new ByteArrayInputStream(new byte[size]);
try {
IOUtils.readFully(input, buffer, 0, -1);
fail("Should have failed with IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
// expected
}
IOUtils.readFully(input, buffer, 0, 0);
@@ -592,7 +592,7 @@ public class IOUtilsTestCase extends Fil
try {
IOUtils.readFully(input, buffer, 0, 2);
fail("Should have failed with EOFxception");
- } catch (EOFException expected) {
+ } catch (final EOFException expected) {
// expected
}
IOUtils.closeQuietly(input);
@@ -600,18 +600,18 @@ public class IOUtilsTestCase extends Fil
}
public void testReadFully_InputStream_Offset() throws Exception {
- byte[] bytes = "abcd1234".getBytes("UTF-8");
- ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
- byte[] buffer = "wx00000000".getBytes("UTF-8");
+ final byte[] bytes = "abcd1234".getBytes("UTF-8");
+ final ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+ final byte[] buffer = "wx00000000".getBytes("UTF-8");
IOUtils.readFully(stream, buffer, 2, 8);
assertEquals("wxabcd1234", new String(buffer, 0, buffer.length, "UTF-8"));
IOUtils.closeQuietly(stream);
}
public void testReadFully_ReadableByteChannel() throws Exception {
- ByteBuffer buffer = ByteBuffer.allocate(FILE_SIZE);
+ final ByteBuffer buffer = ByteBuffer.allocate(FILE_SIZE);
final FileInputStream fileInputStream = new FileInputStream(m_testFile);
- FileChannel input = fileInputStream.getChannel();
+ final FileChannel input = fileInputStream.getChannel();
try {
IOUtils.readFully(input, buffer);
assertEquals(FILE_SIZE, buffer.position());
@@ -626,7 +626,7 @@ public class IOUtilsTestCase extends Fil
try {
IOUtils.readFully(input, buffer);
fail("Should have failed with EOFxception");
- } catch (EOFException expected) {
+ } catch (final EOFException expected) {
// expected
}
} finally {
@@ -638,43 +638,43 @@ public class IOUtilsTestCase extends Fil
public void testReadFully_Reader() throws Exception {
final int size = 1027;
- char[] buffer = new char[size];
+ final char[] buffer = new char[size];
- Reader input = new CharArrayReader(new char[size]);
+ final Reader input = new CharArrayReader(new char[size]);
IOUtils.readFully(input, buffer, 0, 0);
IOUtils.readFully(input, buffer, 0, size - 3);
try {
IOUtils.readFully(input, buffer, 0, -1);
fail("Should have failed with IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
// expected
}
try {
IOUtils.readFully(input, buffer, 0, 5);
fail("Should have failed with EOFException");
- } catch (EOFException expected) {
+ } catch (final EOFException expected) {
// expected
}
IOUtils.closeQuietly(input);
}
public void testReadFully_Reader_Offset() throws Exception {
- Reader reader = new StringReader("abcd1234");
- char[] buffer = "wx00000000".toCharArray();
+ final Reader reader = new StringReader("abcd1234");
+ final char[] buffer = "wx00000000".toCharArray();
IOUtils.readFully(reader, buffer, 2, 8);
assertEquals("wxabcd1234", new String(buffer));
IOUtils.closeQuietly(reader);
}
public void testReadLines_InputStream() throws Exception {
- File file = newFile("lines.txt");
+ final File file = newFile("lines.txt");
InputStream in = null;
try {
- String[] data = new String[] { "hello", "world", "", "this is", "some \
text" }; + final String[] data = new String[] { "hello", "world", "", \
"this is", "some text" }; createLineBasedFile(file, data);
in = new FileInputStream(file);
- List<String> lines = IOUtils.readLines(in);
+ final List<String> lines = IOUtils.readLines(in);
assertEquals(Arrays.asList(data), lines);
assertEquals(-1, in.read());
} finally {
@@ -684,14 +684,14 @@ public class IOUtilsTestCase extends Fil
}
public void testReadLines_InputStream_String() throws Exception {
- File file = newFile("lines.txt");
+ final File file = newFile("lines.txt");
InputStream in = null;
try {
- String[] data = new String[] { "hello", "/u1234", "", "this is", "some \
text" }; + final String[] data = new String[] { "hello", "/u1234", "", \
"this is", "some text" }; createLineBasedFile(file, data);
in = new FileInputStream(file);
- List<String> lines = IOUtils.readLines(in, "UTF-8");
+ final List<String> lines = IOUtils.readLines(in, "UTF-8");
assertEquals(Arrays.asList(data), lines);
assertEquals(-1, in.read());
} finally {
@@ -701,14 +701,14 @@ public class IOUtilsTestCase extends Fil
}
public void testReadLines_Reader() throws Exception {
- File file = newFile("lines.txt");
+ final File file = newFile("lines.txt");
Reader in = null;
try {
- String[] data = new String[] { "hello", "/u1234", "", "this is", "some \
text" }; + final String[] data = new String[] { "hello", "/u1234", "", \
"this is", "some text" }; createLineBasedFile(file, data);
in = new InputStreamReader(new FileInputStream(file));
- List<String> lines = IOUtils.readLines(in);
+ final List<String> lines = IOUtils.readLines(in);
assertEquals(Arrays.asList(data), lines);
assertEquals(-1, in.read());
} finally {
@@ -718,7 +718,7 @@ public class IOUtilsTestCase extends Fil
}
public void testSkip_FileReader() throws Exception {
- FileReader in = new FileReader(m_testFile);
+ final FileReader in = new FileReader(m_testFile);
try {
assertEquals(FILE_SIZE - 10, IOUtils.skip(in, FILE_SIZE - 10));
assertEquals(10, IOUtils.skip(in, 20));
@@ -729,7 +729,7 @@ public class IOUtilsTestCase extends Fil
}
public void testSkip_InputStream() throws Exception {
- InputStream in = new FileInputStream(m_testFile);
+ final InputStream in = new FileInputStream(m_testFile);
try {
assertEquals(FILE_SIZE - 10, IOUtils.skip(in, FILE_SIZE - 10));
assertEquals(10, IOUtils.skip(in, 20));
@@ -740,8 +740,8 @@ public class IOUtilsTestCase extends Fil
}
public void testSkip_ReadableByteChannel() throws Exception {
- FileInputStream fileInputStream = new FileInputStream(m_testFile);
- FileChannel fileChannel = fileInputStream.getChannel();
+ final FileInputStream fileInputStream = new FileInputStream(m_testFile);
+ final FileChannel fileChannel = fileInputStream.getChannel();
try {
assertEquals(FILE_SIZE - 10, IOUtils.skip(fileChannel, FILE_SIZE - 10));
assertEquals(10, IOUtils.skip(fileChannel, 20));
@@ -755,11 +755,11 @@ public class IOUtilsTestCase extends Fil
public void testSkipFully_InputStream() throws Exception {
final int size = 1027;
- InputStream input = new ByteArrayInputStream(new byte[size]);
+ final InputStream input = new ByteArrayInputStream(new byte[size]);
try {
IOUtils.skipFully(input, -1);
fail("Should have failed with IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
// expected
}
IOUtils.skipFully(input, 0);
@@ -767,7 +767,7 @@ public class IOUtilsTestCase extends Fil
try {
IOUtils.skipFully(input, 2);
fail("Should have failed with IOException");
- } catch (IOException expected) {
+ } catch (final IOException expected) {
// expected
}
IOUtils.closeQuietly(input);
@@ -775,13 +775,13 @@ public class IOUtilsTestCase extends Fil
}
public void testSkipFully_ReadableByteChannel() throws Exception {
- FileInputStream fileInputStream = new FileInputStream(m_testFile);
- FileChannel fileChannel = fileInputStream.getChannel();
+ final FileInputStream fileInputStream = new FileInputStream(m_testFile);
+ final FileChannel fileChannel = fileInputStream.getChannel();
try {
try {
IOUtils.skipFully(fileChannel, -1);
fail("Should have failed with IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
// expected
}
IOUtils.skipFully(fileChannel, 0);
@@ -789,7 +789,7 @@ public class IOUtilsTestCase extends Fil
try {
IOUtils.skipFully(fileChannel, 2);
fail("Should have failed with IOException");
- } catch (IOException expected) {
+ } catch (final IOException expected) {
// expected
}
} finally {
@@ -801,19 +801,19 @@ public class IOUtilsTestCase extends Fil
public void testSkipFully_Reader() throws Exception {
final int size = 1027;
- Reader input = new CharArrayReader(new char[size]);
+ final Reader input = new CharArrayReader(new char[size]);
IOUtils.skipFully(input, 0);
IOUtils.skipFully(input, size - 3);
try {
IOUtils.skipFully(input, -1);
fail("Should have failed with IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
// expected
}
try {
IOUtils.skipFully(input, 5);
fail("Should have failed with IOException");
- } catch (IOException expected) {
+ } catch (final IOException expected) {
// expected
}
IOUtils.closeQuietly(input);
@@ -822,8 +822,8 @@ public class IOUtilsTestCase extends Fil
@SuppressWarnings("deprecation")
// testing deprecated method
public void testStringToOutputStream() throws Exception {
- File destination = newFile("copy5.txt");
- FileReader fin = new FileReader(m_testFile);
+ final File destination = newFile("copy5.txt");
+ final FileReader fin = new FileReader(m_testFile);
String str;
try {
// Create our String. Rely on testReaderToString() to make sure this is \
valid. @@ -832,7 +832,7 @@ public class IOUtilsTestCase extends Fil
fin.close();
}
- FileOutputStream fout = new FileOutputStream(destination);
+ final FileOutputStream fout = new FileOutputStream(destination);
try {
CopyUtils.copy(str, fout);
// Note: this method *does* flush. It is equivalent to:
@@ -851,10 +851,10 @@ public class IOUtilsTestCase extends Fil
}
public void testToBufferedInputStream_InputStream() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
- InputStream in = IOUtils.toBufferedInputStream(fin);
- byte[] out = IOUtils.toByteArray(in);
+ final InputStream in = IOUtils.toBufferedInputStream(fin);
+ final byte[] out = IOUtils.toByteArray(in);
assertNotNull(out);
assertEquals("Not all bytes were read", 0, fin.available());
assertEquals("Wrong output size", FILE_SIZE, out.length);
@@ -865,9 +865,9 @@ public class IOUtilsTestCase extends Fil
}
public void testToByteArray_InputStream() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
- byte[] out = IOUtils.toByteArray(fin);
+ final byte[] out = IOUtils.toByteArray(fin);
assertNotNull(out);
assertEquals("Not all bytes were read", 0, fin.available());
assertEquals("Wrong output size", FILE_SIZE, out.length);
@@ -878,12 +878,12 @@ public class IOUtilsTestCase extends Fil
}
public void testToByteArray_InputStream_NegativeSize() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
IOUtils.toByteArray(fin, -1);
fail("IllegalArgumentException excepted");
- } catch (IllegalArgumentException exc) {
+ } catch (final IllegalArgumentException exc) {
assertTrue("Exception message does not start with \"Size must be equal \
or greater than zero\"", exc
.getMessage().startsWith("Size must be equal or greater than \
zero")); } finally {
@@ -893,9 +893,9 @@ public class IOUtilsTestCase extends Fil
}
public void testToByteArray_InputStream_Size() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
- byte[] out = IOUtils.toByteArray(fin, m_testFile.length());
+ final byte[] out = IOUtils.toByteArray(fin, m_testFile.length());
assertNotNull(out);
assertEquals("Not all bytes were read", 0, fin.available());
assertEquals("Wrong output size: out.length=" + out.length + "!=" + \
FILE_SIZE, FILE_SIZE, out.length); @@ -906,12 +906,12 @@ public class IOUtilsTestCase \
extends Fil }
public void testToByteArray_InputStream_SizeIllegal() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
IOUtils.toByteArray(fin, m_testFile.length() + 1);
fail("IOException excepted");
- } catch (IOException exc) {
+ } catch (final IOException exc) {
assertTrue("Exception message does not start with \"Unexpected readed \
size\"",
exc.getMessage().startsWith("Unexpected readed size"));
} finally {
@@ -921,12 +921,12 @@ public class IOUtilsTestCase extends Fil
}
public void testToByteArray_InputStream_SizeLong() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
IOUtils.toByteArray(fin, (long) Integer.MAX_VALUE + 1);
fail("IOException excepted");
- } catch (IllegalArgumentException exc) {
+ } catch (final IllegalArgumentException exc) {
assertTrue("Exception message does not start with \"Size cannot be \
greater than Integer max value\"", exc
.getMessage().startsWith("Size cannot be greater than Integer \
max value")); } finally {
@@ -936,10 +936,10 @@ public class IOUtilsTestCase extends Fil
}
public void testToByteArray_InputStream_SizeZero() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
- byte[] out = IOUtils.toByteArray(fin, 0);
+ final byte[] out = IOUtils.toByteArray(fin, 0);
assertNotNull("Out cannot be null", out);
assertEquals("Out length must be 0", 0, out.length);
} finally {
@@ -959,12 +959,12 @@ public class IOUtilsTestCase extends Fil
@SuppressWarnings("deprecation")
// testing deprecated method
public void testToByteArray_String() throws Exception {
- FileReader fin = new FileReader(m_testFile);
+ final FileReader fin = new FileReader(m_testFile);
try {
// Create our String. Rely on testReaderToString() to make sure this is \
valid.
- String str = IOUtils.toString(fin);
+ final String str = IOUtils.toString(fin);
- byte[] out = IOUtils.toByteArray(str);
+ final byte[] out = IOUtils.toByteArray(str);
assertEqualContent(str.getBytes(), out);
} finally {
fin.close();
@@ -972,19 +972,19 @@ public class IOUtilsTestCase extends Fil
}
public void testToByteArray_URI() throws Exception {
- URI url = m_testFile.toURI();
- byte[] actual = IOUtils.toByteArray(url);
+ final URI url = m_testFile.toURI();
+ final byte[] actual = IOUtils.toByteArray(url);
Assert.assertEquals(FILE_SIZE, actual.length);
}
public void testToByteArray_URL() throws Exception {
- URL url = m_testFile.toURI().toURL();
- byte[] actual = IOUtils.toByteArray(url);
+ final URL url = m_testFile.toURI().toURL();
+ final byte[] actual = IOUtils.toByteArray(url);
Assert.assertEquals(FILE_SIZE, actual.length);
}
public void testToByteArray_URLConnection() throws Exception {
- URLConnection urlConn = m_testFile.toURI().toURL().openConnection();
+ final URLConnection urlConn = m_testFile.toURI().toURL().openConnection();
byte[] actual;
try {
actual = IOUtils.toByteArray(urlConn);
@@ -995,9 +995,9 @@ public class IOUtilsTestCase extends Fil
}
public void testToCharArray_InputStream() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
- char[] out = IOUtils.toCharArray(fin);
+ final char[] out = IOUtils.toCharArray(fin);
assertNotNull(out);
assertEquals("Not all chars were read", 0, fin.available());
assertEquals("Wrong output size", FILE_SIZE, out.length);
@@ -1008,9 +1008,9 @@ public class IOUtilsTestCase extends Fil
}
public void testToCharArray_InputStream_CharsetName() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
- char[] out = IOUtils.toCharArray(fin, "UTF-8");
+ final char[] out = IOUtils.toCharArray(fin, "UTF-8");
assertNotNull(out);
assertEquals("Not all chars were read", 0, fin.available());
assertEquals("Wrong output size", FILE_SIZE, out.length);
@@ -1021,9 +1021,9 @@ public class IOUtilsTestCase extends Fil
}
public void testToCharArray_Reader() throws Exception {
- FileReader fr = new FileReader(m_testFile);
+ final FileReader fr = new FileReader(m_testFile);
try {
- char[] out = IOUtils.toCharArray(fr);
+ final char[] out = IOUtils.toCharArray(fr);
assertNotNull(out);
assertEquals("Wrong output size", FILE_SIZE, out.length);
assertEqualContent(out, m_testFile);
@@ -1041,7 +1041,7 @@ public class IOUtilsTestCase extends Fil
* on error
*/
public void testToInputStream_CharSequence() throws Exception {
- CharSequence csq = new StringBuilder("Abc123Xyz!");
+ final CharSequence csq = new StringBuilder("Abc123Xyz!");
InputStream inStream = IOUtils.toInputStream(csq);
byte[] bytes = IOUtils.toByteArray(inStream);
assertEqualContent(csq.toString().getBytes(), bytes);
@@ -1064,7 +1064,7 @@ public class IOUtilsTestCase extends Fil
* on error
*/
public void testToInputStream_String() throws Exception {
- String str = "Abc123Xyz!";
+ final String str = "Abc123Xyz!";
InputStream inStream = IOUtils.toInputStream(str);
byte[] bytes = IOUtils.toByteArray(inStream);
assertEqualContent(str.getBytes(), bytes);
@@ -1079,11 +1079,11 @@ public class IOUtilsTestCase extends Fil
@SuppressWarnings("deprecation")
// testing deprecated method
public void testToString_ByteArray() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
- byte[] in = IOUtils.toByteArray(fin);
+ final byte[] in = IOUtils.toByteArray(fin);
// Create our byte[]. Rely on testInputStreamToByteArray() to make sure \
this is valid.
- String str = IOUtils.toString(in);
+ final String str = IOUtils.toString(in);
assertEqualContent(in, str.getBytes());
} finally {
fin.close();
@@ -1091,9 +1091,9 @@ public class IOUtilsTestCase extends Fil
}
public void testToString_InputStream() throws Exception {
- FileInputStream fin = new FileInputStream(m_testFile);
+ final FileInputStream fin = new FileInputStream(m_testFile);
try {
- String out = IOUtils.toString(fin);
+ final String out = IOUtils.toString(fin);
assertNotNull(out);
assertEquals("Not all bytes were read", 0, fin.available());
assertEquals("Wrong output size", FILE_SIZE, out.length());
@@ -1103,9 +1103,9 @@ public class IOUtilsTestCase extends Fil
}
public void testToString_Reader() throws Exception {
- FileReader fin = new FileReader(m_testFile);
+ final FileReader fin = new FileReader(m_testFile);
try {
- String out = IOUtils.toString(fin);
+ final String out = IOUtils.toString(fin);
assertNotNull(out);
assertEquals("Wrong output size", FILE_SIZE, out.length());
} finally {
@@ -1114,15 +1114,15 @@ public class IOUtilsTestCase extends Fil
}
public void testToString_URI() throws Exception {
- URI url = m_testFile.toURI();
- String out = IOUtils.toString(url);
+ final URI url = m_testFile.toURI();
+ final String out = IOUtils.toString(url);
assertNotNull(out);
assertEquals("Wrong output size", FILE_SIZE, out.length());
}
- private void testToString_URI(String encoding) throws Exception {
- URI uri = m_testFile.toURI();
- String out = IOUtils.toString(uri, encoding);
+ private void testToString_URI(final String encoding) throws Exception {
+ final URI uri = m_testFile.toURI();
+ final String out = IOUtils.toString(uri, encoding);
assertNotNull(out);
assertEquals("Wrong output size", FILE_SIZE, out.length());
}
@@ -1136,15 +1136,15 @@ public class IOUtilsTestCase extends Fil
}
public void testToString_URL() throws Exception {
- URL url = m_testFile.toURI().toURL();
- String out = IOUtils.toString(url);
+ final URL url = m_testFile.toURI().toURL();
+ final String out = IOUtils.toString(url);
assertNotNull(out);
assertEquals("Wrong output size", FILE_SIZE, out.length());
}
- private void testToString_URL(String encoding) throws Exception {
- URL url = m_testFile.toURI().toURL();
- String out = IOUtils.toString(url, encoding);
+ private void testToString_URL(final String encoding) throws Exception {
+ final URL url = m_testFile.toURI().toURL();
+ final String out = IOUtils.toString(url, encoding);
assertNotNull(out);
assertEquals("Wrong output size", FILE_SIZE, out.length());
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic