commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1429868 [4/6] - in /commons/proper/codec/trunk/src: main/java/org/apache/commons/codec/ main/java/org/apache/commons/codec/binary/ main/java/org/apache/commons/codec/digest/ main/java/org/apache/commons/codec/language/ main/java/org/apache...
Date Mon, 07 Jan 2013 16:08:07 GMT
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32InputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32InputStreamTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32InputStreamTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32InputStreamTest.java Mon Jan  7 16:08:05 2013
@@ -46,19 +46,19 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testCodec130() throws IOException {
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        Base32OutputStream base32os = new Base32OutputStream(bos);
+        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        final Base32OutputStream base32os = new Base32OutputStream(bos);
 
         base32os.write(StringUtils.getBytesUtf8(STRING_FIXTURE));
         base32os.close();
 
-        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-        Base32InputStream ins = new Base32InputStream(bis);
+        final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+        final Base32InputStream ins = new Base32InputStream(bis);
 
         // we skip the first character read from the reader
         ins.skip(1);
-        byte[] decodedBytes = Base32TestData.streamToBytes(ins, new byte[64]);
-        String str = StringUtils.newStringUtf8(decodedBytes);
+        final byte[] decodedBytes = Base32TestData.streamToBytes(ins, new byte[64]);
+        final String str = StringUtils.newStringUtf8(decodedBytes);
 
         assertEquals(STRING_FIXTURE.substring(1), str);
     }
@@ -68,7 +68,7 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testCodec105() throws IOException {
-        Base32InputStream in = new Base32InputStream(new Codec105ErrorInputStream(), true, 0, null);
+        final Base32InputStream in = new Base32InputStream(new Codec105ErrorInputStream(), true, 0, null);
         try {
             for (int i = 0; i < 5; i++) {
                 in.read();
@@ -151,8 +151,8 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testAvailable() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
-        Base32InputStream b32stream = new Base32InputStream(ins);
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
+        final Base32InputStream b32stream = new Base32InputStream(ins);
         assertEquals(1, b32stream.available());
         assertEquals(3, b32stream.skip(10));
         // End of stream reached
@@ -185,9 +185,9 @@ public class Base32InputStreamTest {
         testBase32EmptyInputStream(BaseNCodec.PEM_CHUNK_SIZE);
     }
 
-    private void testBase32EmptyInputStream(int chuckSize) throws Exception {
-        byte[] emptyEncoded = new byte[0];
-        byte[] emptyDecoded = new byte[0];
+    private void testBase32EmptyInputStream(final int chuckSize) throws Exception {
+        final byte[] emptyEncoded = new byte[0];
+        final byte[] emptyDecoded = new byte[0];
         testByteByByte(emptyEncoded, emptyDecoded, chuckSize, CRLF);
         testByChunk(emptyEncoded, emptyDecoded, chuckSize, CRLF);
     }
@@ -222,9 +222,9 @@ public class Base32InputStreamTest {
         // testByChunk(encoded, decoded, 0, LF);
 
         // test random data of sizes 0 thru 150
-        BaseNCodec codec = new Base32();
+        final BaseNCodec codec = new Base32();
         for (int i = 0; i <= 150; i++) {
-            byte[][] randomData = Base32TestData.randomData(codec, i);
+            final byte[][] randomData = Base32TestData.randomData(codec, i);
             encoded = randomData[1];
             decoded = randomData[0];
             testByChunk(encoded, decoded, 0, LF);
@@ -256,9 +256,9 @@ public class Base32InputStreamTest {
         // testByteByByte(encoded, decoded, 0, LF);
 
         // test random data of sizes 0 thru 150
-        BaseNCodec codec = new Base32();
+        final BaseNCodec codec = new Base32();
         for (int i = 0; i <= 150; i++) {
-            byte[][] randomData = Base32TestData.randomData(codec, i);
+            final byte[][] randomData = Base32TestData.randomData(codec, i);
             encoded = randomData[1];
             decoded = randomData[0];
             testByteByByte(encoded, decoded, 0, LF);
@@ -283,7 +283,7 @@ public class Base32InputStreamTest {
      * @throws Exception
      *             Usually signifies a bug in the Base32 commons-codec implementation.
      */
-    private void testByChunk(byte[] encoded, byte[] decoded, int chunkSize, byte[] seperator) throws Exception {
+    private void testByChunk(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] seperator) throws Exception {
 
         // Start with encode.
         InputStream in;
@@ -335,7 +335,7 @@ public class Base32InputStreamTest {
      * @throws Exception
      *             Usually signifies a bug in the Base32 commons-codec implementation.
      */
-    private void testByteByByte(byte[] encoded, byte[] decoded, int chunkSize, byte[] seperator) throws Exception {
+    private void testByteByByte(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] seperator) throws Exception {
 
         // Start with encode.
         InputStream in;
@@ -387,9 +387,9 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testMarkSupported() throws Exception {
-        byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
-        ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
-        Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
+        final byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
+        final ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
+        final Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
         // Always returns false for now.
         assertFalse("Base32InputStream.markSupported() is false", in.markSupported());
         in.close();
@@ -402,11 +402,11 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testRead0() throws Exception {
-        byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
-        byte[] buf = new byte[1024];
+        final byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
+        final byte[] buf = new byte[1024];
         int bytesRead = 0;
-        ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
-        Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
+        final ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
+        final Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
         bytesRead = in.read(buf, 0, 0);
         assertEquals("Base32InputStream.read(buf, 0, 0) returns 0", 0, bytesRead);
         in.close();
@@ -420,13 +420,13 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testReadNull() throws Exception {
-        byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
-        ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
-        Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
+        final byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
+        final ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
+        final Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
         try {
             in.read(null, 0, 0);
             fail("Base32InputStream.read(null, 0, 0) to throw a NullPointerException");
-        } catch (NullPointerException e) {
+        } catch (final NullPointerException e) {
             // Expected
         }
         in.close();
@@ -439,36 +439,36 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testReadOutOfBounds() throws Exception {
-        byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
-        byte[] buf = new byte[1024];
-        ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
-        Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
+        final byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
+        final byte[] buf = new byte[1024];
+        final ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
+        final Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
 
         try {
             in.read(buf, -1, 0);
             fail("Expected Base32InputStream.read(buf, -1, 0) to throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
+        } catch (final IndexOutOfBoundsException e) {
             // Expected
         }
 
         try {
             in.read(buf, 0, -1);
             fail("Expected Base32InputStream.read(buf, 0, -1) to throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
+        } catch (final IndexOutOfBoundsException e) {
             // Expected
         }
 
         try {
             in.read(buf, buf.length + 1, 0);
             fail("Base32InputStream.read(buf, buf.length + 1, 0) throws IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
+        } catch (final IndexOutOfBoundsException e) {
             // Expected
         }
 
         try {
             in.read(buf, buf.length - 1, 2);
             fail("Base32InputStream.read(buf, buf.length - 1, 2) throws IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
+        } catch (final IndexOutOfBoundsException e) {
             // Expected
         }
         in.close();
@@ -481,9 +481,9 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testSkipNone() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
-        Base32InputStream b32stream = new Base32InputStream(ins);
-        byte[] actualBytes = new byte[6];
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
+        final Base32InputStream b32stream = new Base32InputStream(ins);
+        final byte[] actualBytes = new byte[6];
         assertEquals(0, b32stream.skip(0));
         b32stream.read(actualBytes, 0, actualBytes.length);
         assertArrayEquals(actualBytes, new byte[] { 102, 111, 111, 0, 0, 0 });
@@ -499,8 +499,8 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testSkipBig() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
-        Base32InputStream b32stream = new Base32InputStream(ins);
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
+        final Base32InputStream b32stream = new Base32InputStream(ins);
         assertEquals(3, b32stream.skip(1024));
         // End of stream reached
         assertEquals(-1, b32stream.read());
@@ -515,8 +515,8 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testSkipPastEnd() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
-        Base32InputStream b32stream = new Base32InputStream(ins);
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
+        final Base32InputStream b32stream = new Base32InputStream(ins);
         // due to CODEC-130, skip now skips correctly decoded characters rather than encoded
         assertEquals(3, b32stream.skip(10));
         // End of stream reached
@@ -532,8 +532,8 @@ public class Base32InputStreamTest {
      */
     @Test
     public void testSkipToEnd() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
-        Base32InputStream b32stream = new Base32InputStream(ins);
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
+        final Base32InputStream b32stream = new Base32InputStream(ins);
         // due to CODEC-130, skip now skips correctly decoded characters rather than encoded
         assertEquals(3, b32stream.skip(3));
         // End of stream reached
@@ -549,8 +549,8 @@ public class Base32InputStreamTest {
      */
     @Test(expected=IllegalArgumentException.class)
     public void testSkipWrongArgument() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
-        Base32InputStream b32stream = new Base32InputStream(ins);
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO));
+        final Base32InputStream b32stream = new Base32InputStream(ins);
         b32stream.skip(-10);
         b32stream.close();
     }

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32OutputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32OutputStreamTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32OutputStreamTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32OutputStreamTest.java Mon Jan  7 16:08:05 2013
@@ -80,9 +80,9 @@ public class Base32OutputStreamTest {
         testBase32EmptyOutputStream(BaseNCodec.PEM_CHUNK_SIZE);
     }
 
-    private void testBase32EmptyOutputStream(int chunkSize) throws Exception {
-        byte[] emptyEncoded = new byte[0];
-        byte[] emptyDecoded = new byte[0];
+    private void testBase32EmptyOutputStream(final int chunkSize) throws Exception {
+        final byte[] emptyEncoded = new byte[0];
+        final byte[] emptyDecoded = new byte[0];
         testByteByByte(emptyEncoded, emptyDecoded, chunkSize, CRLF);
         testByChunk(emptyEncoded, emptyDecoded, chunkSize, CRLF);
     }
@@ -113,9 +113,9 @@ public class Base32OutputStreamTest {
 //        testByChunk(encoded, decoded, 0, LF);
 
         // test random data of sizes 0 thru 150
-        BaseNCodec codec = new Base32();
+        final BaseNCodec codec = new Base32();
         for (int i = 0; i <= 150; i++) {
-            byte[][] randomData = Base32TestData.randomData(codec, i);
+            final byte[][] randomData = Base32TestData.randomData(codec, i);
             encoded = randomData[1];
             decoded = randomData[0];
             testByChunk(encoded, decoded, 0, LF);
@@ -148,9 +148,9 @@ public class Base32OutputStreamTest {
 //        testByteByByte(encoded, decoded, 0, LF);
 
         // test random data of sizes 0 thru 150
-        BaseNCodec codec = new Base32();
+        final BaseNCodec codec = new Base32();
         for (int i = 0; i <= 150; i++) {
-            byte[][] randomData = Base32TestData.randomData(codec, i);
+            final byte[][] randomData = Base32TestData.randomData(codec, i);
             encoded = randomData[1];
             decoded = randomData[0];
             testByteByByte(encoded, decoded, 0, LF);
@@ -175,7 +175,7 @@ public class Base32OutputStreamTest {
      * @throws Exception
      *             Usually signifies a bug in the Base32 commons-codec implementation.
      */
-    private void testByChunk(byte[] encoded, byte[] decoded, int chunkSize, byte[] seperator) throws Exception {
+    private void testByChunk(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] seperator) throws Exception {
 
         // Start with encode.
         ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
@@ -225,12 +225,12 @@ public class Base32OutputStreamTest {
      * @throws Exception
      *             Usually signifies a bug in the Base32 commons-codec implementation.
      */
-    private void testByteByByte(byte[] encoded, byte[] decoded, int chunkSize, byte[] seperator) throws Exception {
+    private void testByteByByte(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] seperator) throws Exception {
 
         // Start with encode.
         ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
         OutputStream out = new Base32OutputStream(byteOut, true, chunkSize, seperator);
-        for (byte element : decoded) {
+        for (final byte element : decoded) {
             out.write(element);
         }
         out.close();
@@ -240,7 +240,7 @@ public class Base32OutputStreamTest {
         // Now let's try decode.
         byteOut = new ByteArrayOutputStream();
         out = new Base32OutputStream(byteOut, false);
-        for (byte element : encoded) {
+        for (final byte element : encoded) {
             out.write(element);
         }
         out.close();
@@ -250,7 +250,7 @@ public class Base32OutputStreamTest {
         // Now let's try decode with tonnes of flushes.
         byteOut = new ByteArrayOutputStream();
         out = new Base32OutputStream(byteOut, false);
-        for (byte element : encoded) {
+        for (final byte element : encoded) {
             out.write(element);
             out.flush();
         }
@@ -265,7 +265,7 @@ public class Base32OutputStreamTest {
             out = new Base32OutputStream(out, false);
             out = new Base32OutputStream(out, true, chunkSize, seperator);
         }
-        for (byte element : decoded) {
+        for (final byte element : decoded) {
             out.write(element);
         }
         out.close();
@@ -282,35 +282,35 @@ public class Base32OutputStreamTest {
      */
     @Test
     public void testWriteOutOfBounds() throws Exception {
-        byte[] buf = new byte[1024];
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        Base32OutputStream out = new Base32OutputStream(bout);
+        final byte[] buf = new byte[1024];
+        final ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        final Base32OutputStream out = new Base32OutputStream(bout);
 
         try {
             out.write(buf, -1, 1);
             fail("Expected Base32OutputStream.write(buf, -1, 1) to throw a IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ioobe) {
+        } catch (final IndexOutOfBoundsException ioobe) {
             // Expected
         }
 
         try {
             out.write(buf, 1, -1);
             fail("Expected Base32OutputStream.write(buf, 1, -1) to throw a IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ioobe) {
+        } catch (final IndexOutOfBoundsException ioobe) {
             // Expected
         }
 
         try {
             out.write(buf, buf.length + 1, 0);
             fail("Expected Base32OutputStream.write(buf, buf.length + 1, 0) to throw a IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ioobe) {
+        } catch (final IndexOutOfBoundsException ioobe) {
             // Expected
         }
 
         try {
             out.write(buf, buf.length - 1, 2);
             fail("Expected Base32OutputStream.write(buf, buf.length - 1, 2) to throw a IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ioobe) {
+        } catch (final IndexOutOfBoundsException ioobe) {
             // Expected
         }
         out.close();
@@ -324,12 +324,12 @@ public class Base32OutputStreamTest {
      */
     @Test
     public void testWriteToNullCoverage() throws Exception {
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        Base32OutputStream out = new Base32OutputStream(bout);
+        final ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        final Base32OutputStream out = new Base32OutputStream(bout);
         try {
             out.write(null, 0, 0);
             fail("Expcted Base32OutputStream.write(null) to throw a NullPointerException");
-        } catch (NullPointerException e) {
+        } catch (final NullPointerException e) {
             // Expected
         }
         out.close();

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32Test.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32Test.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32Test.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32Test.java Mon Jan  7 16:08:05 2013
@@ -61,24 +61,24 @@ public class Base32Test {
 
     @Test
     public void testBase32Samples() throws Exception {
-        Base32 codec = new Base32();
-        for (String[] element : BASE32_TEST_CASES) {
+        final Base32 codec = new Base32();
+        for (final String[] element : BASE32_TEST_CASES) {
                 assertEquals(element[1], codec.encodeAsString(element[0].getBytes(Charsets.UTF_8)));
         }
     }
 
     @Test
     public void testBase32HexSamples() throws Exception {
-        Base32 codec = new Base32(true);
-        for (String[] element : BASE32HEX_TEST_CASES) {
+        final Base32 codec = new Base32(true);
+        for (final String[] element : BASE32HEX_TEST_CASES) {
                 assertEquals(element[1], codec.encodeAsString(element[0].getBytes(Charsets.UTF_8)));
         }
     }
 
     @Test
     public void testBase32Chunked () throws Exception {
-        Base32 codec = new Base32(20);
-        for (String[] element : BASE32_TEST_CASES_CHUNKED) {
+        final Base32 codec = new Base32(20);
+        for (final String[] element : BASE32_TEST_CASES_CHUNKED) {
                 assertEquals(element[1], codec.encodeAsString(element[0].getBytes(Charsets.UTF_8)));
         }
     }
@@ -87,15 +87,15 @@ public class Base32Test {
     public void testSingleCharEncoding() {
         for (int i = 0; i < 20; i++) {
             Base32 codec = new Base32();
-            BaseNCodec.Context context = new BaseNCodec.Context();
-            byte unencoded[] = new byte[i];
-            byte allInOne[] = codec.encode(unencoded);
+            final BaseNCodec.Context context = new BaseNCodec.Context();
+            final byte unencoded[] = new byte[i];
+            final byte allInOne[] = codec.encode(unencoded);
             codec = new Base32();
             for (int j=0; j< unencoded.length; j++) {
                 codec.encode(unencoded, j, 1, context);
             }
             codec.encode(unencoded, 0, -1, context);
-            byte singly[] = new byte[allInOne.length];
+            final byte singly[] = new byte[allInOne.length];
             codec.readResults(singly, 0, 100, context);
             if (!Arrays.equals(allInOne, singly)){
                 fail();
@@ -106,8 +106,8 @@ public class Base32Test {
     @Test
     public void testRandomBytes() {
         for (int i = 0; i < 20; i++) {
-            Base32 codec = new Base32();
-            byte[][] b = Base32TestData.randomData(codec, i);
+            final Base32 codec = new Base32();
+            final byte[][] b = Base32TestData.randomData(codec, i);
             assertEquals(""+i+" "+codec.lineLength,b[1].length,codec.getEncodedLength(b[0]));
             //assertEquals(b[0],codec.decode(b[1]));
         }
@@ -116,8 +116,8 @@ public class Base32Test {
     @Test
     public void testRandomBytesChunked() {
         for (int i = 0; i < 20; i++) {
-            Base32 codec = new Base32(10);
-            byte[][] b = Base32TestData.randomData(codec, i);
+            final Base32 codec = new Base32(10);
+            final byte[][] b = Base32TestData.randomData(codec, i);
             assertEquals(""+i+" "+codec.lineLength,b[1].length,codec.getEncodedLength(b[0]));
             //assertEquals(b[0],codec.decode(b[1]));
         }
@@ -126,8 +126,8 @@ public class Base32Test {
     @Test
     public void testRandomBytesHex() {
         for (int i = 0; i < 20; i++) {
-            Base32 codec = new Base32(true);
-            byte[][] b = Base32TestData.randomData(codec, i);
+            final Base32 codec = new Base32(true);
+            final byte[][] b = Base32TestData.randomData(codec, i);
             assertEquals(""+i+" "+codec.lineLength,b[1].length,codec.getEncodedLength(b[0]));
             //assertEquals(b[0],codec.decode(b[1]));
         }

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32TestData.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32TestData.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32TestData.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32TestData.java Mon Jan  7 16:08:05 2013
@@ -58,7 +58,7 @@ public class Base32TestData {
                 lastRead = status[LAST_READ_KEY];
             }
             if (buf.length != size) {
-                byte[] smallerBuf = new byte[size];
+                final byte[] smallerBuf = new byte[size];
                 System.arraycopy(buf, 0, smallerBuf, 0, size);
                 buf = smallerBuf;
             }
@@ -86,7 +86,7 @@ public class Base32TestData {
     }
 
     private static byte[] resizeArray(final byte[] bytes) {
-        byte[] biggerBytes = new byte[bytes.length * 2];
+        final byte[] biggerBytes = new byte[bytes.length * 2];
         System.arraycopy(bytes, 0, biggerBytes, 0, bytes.length);
         return biggerBytes;
     }
@@ -99,11 +99,11 @@ public class Base32TestData {
      * @param size amount of random data to generate and encode
      * @return two byte[] arrays:  [0] = decoded, [1] = encoded
      */
-    static byte[][] randomData(BaseNCodec codec, int size) {
-        Random r = new Random();
-        byte[] decoded = new byte[size];
+    static byte[][] randomData(final BaseNCodec codec, final int size) {
+        final Random r = new Random();
+        final byte[] decoded = new byte[size];
         r.nextBytes(decoded);
-        byte[] encoded = codec.encode(decoded);
+        final byte[] encoded = codec.encode(decoded);
         return new byte[][] {decoded, encoded};
     }
 
@@ -114,8 +114,8 @@ public class Base32TestData {
      * @param c byte to look for
      * @return true if bytes contains c, false otherwise
      */
-    static boolean bytesContain(byte[] bytes, byte c) {
-        for (byte b : bytes) {
+    static boolean bytesContain(final byte[] bytes, final byte c) {
+        for (final byte b : bytes) {
             if (b == c) { return true; }
         }
         return false;

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java Mon Jan  7 16:08:05 2013
@@ -50,7 +50,7 @@ public class Base64Codec13Test {
 
     /* These strings were generated from random byte[] arrays fed into commons-codec-1.3.jar */
     private static void initSTRINGS() {
-        String[] s = STRINGS;
+        final String[] s = STRINGS;
         s[0] = "";
         s[1] = "uA==";
         s[2] = "z9w=";
@@ -152,7 +152,7 @@ public class Base64Codec13Test {
 
     /* These are chunked versions of the strings above (chunked by commons-codec-1.3.jar) */
     private static void initCHUNKED_STRINGS() {
-        String[] c = CHUNKED_STRINGS;
+        final String[] c = CHUNKED_STRINGS;
         c[0] = "";
         c[1] = "uA==\r\n";
         c[2] = "z9w=\r\n";
@@ -255,7 +255,7 @@ public class Base64Codec13Test {
 
     /* Here are the randomly generated byte[] arrays we generated to exercise commons-codec-1.3.jar */
     private static void initBYTES() {
-        byte[][] b = BYTES;
+        final byte[][] b = BYTES;
         b[0] = new byte[]{};
         b[1] = new byte[]{-72};
         b[2] = new byte[]{-49, -36};
@@ -363,12 +363,12 @@ public class Base64Codec13Test {
      */
     @Test
     public void testEncoder() throws EncoderException {
-        Encoder enc = new Base64();
+        final Encoder enc = new Base64();
         for (int i = 0; i < STRINGS.length; i++) {
             if (STRINGS[i] != null) {
-                byte[] base64 = utf8(STRINGS[i]);
-                byte[] binary = BYTES[i];
-                boolean b = Arrays.equals(base64, (byte[]) enc.encode(binary));
+                final byte[] base64 = utf8(STRINGS[i]);
+                final byte[] binary = BYTES[i];
+                final boolean b = Arrays.equals(base64, (byte[]) enc.encode(binary));
                 assertTrue("Encoder test-" + i, b);
             }
         }
@@ -382,12 +382,12 @@ public class Base64Codec13Test {
      */
     @Test
     public void testDecoder() throws DecoderException {
-        Decoder dec = new Base64();
+        final Decoder dec = new Base64();
         for (int i = 0; i < STRINGS.length; i++) {
             if (STRINGS[i] != null) {
-                byte[] base64 = utf8(STRINGS[i]);
-                byte[] binary = BYTES[i];
-                boolean b = Arrays.equals(binary, (byte[]) dec.decode(base64));
+                final byte[] base64 = utf8(STRINGS[i]);
+                final byte[] binary = BYTES[i];
+                final boolean b = Arrays.equals(binary, (byte[]) dec.decode(base64));
                 assertTrue("Decoder test-" + i, b);
             }
         }
@@ -401,12 +401,12 @@ public class Base64Codec13Test {
      */
     @Test
     public void testBinaryEncoder() throws EncoderException {
-        BinaryEncoder enc = new Base64();
+        final BinaryEncoder enc = new Base64();
         for (int i = 0; i < STRINGS.length; i++) {
             if (STRINGS[i] != null) {
-                byte[] base64 = utf8(STRINGS[i]);
-                byte[] binary = BYTES[i];
-                boolean b = Arrays.equals(base64, enc.encode(binary));
+                final byte[] base64 = utf8(STRINGS[i]);
+                final byte[] binary = BYTES[i];
+                final boolean b = Arrays.equals(base64, enc.encode(binary));
                 assertTrue("BinaryEncoder test-" + i, b);
             }
         }
@@ -420,12 +420,12 @@ public class Base64Codec13Test {
      */
     @Test
     public void testBinaryDecoder() throws DecoderException {
-        BinaryDecoder dec = new Base64();
+        final BinaryDecoder dec = new Base64();
         for (int i = 0; i < STRINGS.length; i++) {
             if (STRINGS[i] != null) {
-                byte[] base64 = utf8(STRINGS[i]);
-                byte[] binary = BYTES[i];
-                boolean b = Arrays.equals(binary, dec.decode(base64));
+                final byte[] base64 = utf8(STRINGS[i]);
+                final byte[] binary = BYTES[i];
+                final boolean b = Arrays.equals(binary, dec.decode(base64));
                 assertTrue("BinaryDecoder test-" + i, b);
             }
         }
@@ -441,9 +441,9 @@ public class Base64Codec13Test {
     public void testStaticEncode() throws EncoderException {
         for (int i = 0; i < STRINGS.length; i++) {
             if (STRINGS[i] != null) {
-                byte[] base64 = utf8(STRINGS[i]);
-                byte[] binary = BYTES[i];
-                boolean b = Arrays.equals(base64, Base64.encodeBase64(binary));
+                final byte[] base64 = utf8(STRINGS[i]);
+                final byte[] binary = BYTES[i];
+                final boolean b = Arrays.equals(base64, Base64.encodeBase64(binary));
                 assertTrue("static Base64.encodeBase64() test-" + i, b);
             }
         }
@@ -459,9 +459,9 @@ public class Base64Codec13Test {
     public void testStaticDecode() throws DecoderException {
         for (int i = 0; i < STRINGS.length; i++) {
             if (STRINGS[i] != null) {
-                byte[] base64 = utf8(STRINGS[i]);
-                byte[] binary = BYTES[i];
-                boolean b = Arrays.equals(binary, Base64.decodeBase64(base64));
+                final byte[] base64 = utf8(STRINGS[i]);
+                final byte[] binary = BYTES[i];
+                final boolean b = Arrays.equals(binary, Base64.decodeBase64(base64));
                 assertTrue("static Base64.decodeBase64() test-" + i, b);
             }
         }
@@ -477,9 +477,9 @@ public class Base64Codec13Test {
     public void testStaticEncodeChunked() throws EncoderException {
         for (int i = 0; i < STRINGS.length; i++) {
             if (STRINGS[i] != null) {
-                byte[] base64Chunked = utf8(CHUNKED_STRINGS[i]);
-                byte[] binary = BYTES[i];
-                boolean b = Arrays.equals(base64Chunked, Base64.encodeBase64Chunked(binary));
+                final byte[] base64Chunked = utf8(CHUNKED_STRINGS[i]);
+                final byte[] binary = BYTES[i];
+                final boolean b = Arrays.equals(base64Chunked, Base64.encodeBase64Chunked(binary));
                 assertTrue("static Base64.encodeBase64Chunked() test-" + i, b);
             }
         }
@@ -496,15 +496,15 @@ public class Base64Codec13Test {
     public void testStaticDecodeChunked() throws DecoderException {
         for (int i = 0; i < STRINGS.length; i++) {
             if (STRINGS[i] != null) {
-                byte[] base64Chunked = utf8(CHUNKED_STRINGS[i]);
-                byte[] binary = BYTES[i];
-                boolean b = Arrays.equals(binary, Base64.decodeBase64(base64Chunked));
+                final byte[] base64Chunked = utf8(CHUNKED_STRINGS[i]);
+                final byte[] binary = BYTES[i];
+                final boolean b = Arrays.equals(binary, Base64.decodeBase64(base64Chunked));
                 assertTrue("static Base64.decodeBase64Chunked() test-" + i, b);
             }
         }
     }
 
-    private static byte[] utf8(String s) {
+    private static byte[] utf8(final String s) {
 
         // We would use commons-codec-1.4.jar own utility method for this, but we
         // need this class to be able to run against commons-codec-1.3.jar, hence the

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java Mon Jan  7 16:08:05 2013
@@ -56,19 +56,19 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testCodec130() throws IOException {
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        Base64OutputStream base64os = new Base64OutputStream(bos);
+        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        final Base64OutputStream base64os = new Base64OutputStream(bos);
 
         base64os.write(StringUtils.getBytesUtf8(STRING_FIXTURE));
         base64os.close();
 
-        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-        Base64InputStream ins = new Base64InputStream(bis);
+        final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+        final Base64InputStream ins = new Base64InputStream(bis);
 
         // we skip the first character read from the reader
         ins.skip(1);
-        byte[] decodedBytes = Base64TestData.streamToBytes(ins, new byte[64]);
-        String str = StringUtils.newStringUtf8(decodedBytes);
+        final byte[] decodedBytes = Base64TestData.streamToBytes(ins, new byte[64]);
+        final String str = StringUtils.newStringUtf8(decodedBytes);
 
         assertEquals(STRING_FIXTURE.substring(1), str);
     }
@@ -78,7 +78,7 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testCodec105() throws IOException {
-        Base64InputStream in = new Base64InputStream(new Codec105ErrorInputStream(), true, 0, null);
+        final Base64InputStream in = new Base64InputStream(new Codec105ErrorInputStream(), true, 0, null);
         try {
             for (int i = 0; i < 5; i++) {
                 in.read();
@@ -96,10 +96,10 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testCodec101() throws Exception {
-        byte[] codec101 = StringUtils.getBytesUtf8(Base64TestData.CODEC_101_MULTIPLE_OF_3);
-        ByteArrayInputStream bais = new ByteArrayInputStream(codec101);
-        Base64InputStream in = new Base64InputStream(bais);
-        byte[] result = new byte[8192];
+        final byte[] codec101 = StringUtils.getBytesUtf8(Base64TestData.CODEC_101_MULTIPLE_OF_3);
+        final ByteArrayInputStream bais = new ByteArrayInputStream(codec101);
+        final Base64InputStream in = new Base64InputStream(bais);
+        final byte[] result = new byte[8192];
         int c = in.read(result);
         assertTrue("Codec101: First read successful [c=" + c + "]", c > 0);
 
@@ -125,12 +125,12 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testInputStreamReader() throws Exception {
-        byte[] codec101 = StringUtils.getBytesUtf8(Base64TestData.CODEC_101_MULTIPLE_OF_3);
-        ByteArrayInputStream bais = new ByteArrayInputStream(codec101);
-        Base64InputStream in = new Base64InputStream(bais);
-        InputStreamReader isr = new InputStreamReader(in);
-        BufferedReader br = new BufferedReader(isr);
-        String line = br.readLine();
+        final byte[] codec101 = StringUtils.getBytesUtf8(Base64TestData.CODEC_101_MULTIPLE_OF_3);
+        final ByteArrayInputStream bais = new ByteArrayInputStream(codec101);
+        final Base64InputStream in = new Base64InputStream(bais);
+        final InputStreamReader isr = new InputStreamReader(in);
+        final BufferedReader br = new BufferedReader(isr);
+        final String line = br.readLine();
         assertNotNull("Codec101:  InputStreamReader works!", line);
         br.close();
     }
@@ -143,14 +143,14 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testCodec98NPE() throws Exception {
-        byte[] codec98 = StringUtils.getBytesUtf8(Base64TestData.CODEC_98_NPE);
-        ByteArrayInputStream data = new ByteArrayInputStream(codec98);
-        Base64InputStream stream = new Base64InputStream(data);
+        final byte[] codec98 = StringUtils.getBytesUtf8(Base64TestData.CODEC_98_NPE);
+        final ByteArrayInputStream data = new ByteArrayInputStream(codec98);
+        final Base64InputStream stream = new Base64InputStream(data);
 
         // This line causes an NPE in commons-codec-1.4.jar:
-        byte[] decodedBytes = Base64TestData.streamToBytes(stream, new byte[1024]);
+        final byte[] decodedBytes = Base64TestData.streamToBytes(stream, new byte[1024]);
 
-        String decoded = StringUtils.newStringUtf8(decodedBytes);
+        final String decoded = StringUtils.newStringUtf8(decodedBytes);
         assertEquals("codec-98 NPE Base64InputStream", Base64TestData.CODEC_98_NPE_DECODED, decoded);
     }
 
@@ -161,8 +161,8 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testAvailable() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
-        Base64InputStream b64stream = new Base64InputStream(ins);
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
+        final Base64InputStream b64stream = new Base64InputStream(ins);
         assertEquals(1, b64stream.available());
         assertEquals(6, b64stream.skip(10));
         // End of stream reached
@@ -195,9 +195,9 @@ public class Base64InputStreamTest {
         testBase64EmptyInputStream(BaseNCodec.PEM_CHUNK_SIZE);
     }
 
-    private void testBase64EmptyInputStream(int chuckSize) throws Exception {
-        byte[] emptyEncoded = new byte[0];
-        byte[] emptyDecoded = new byte[0];
+    private void testBase64EmptyInputStream(final int chuckSize) throws Exception {
+        final byte[] emptyEncoded = new byte[0];
+        final byte[] emptyDecoded = new byte[0];
         testByteByByte(emptyEncoded, emptyDecoded, chuckSize, CRLF);
         testByChunk(emptyEncoded, emptyDecoded, chuckSize, CRLF);
     }
@@ -226,14 +226,14 @@ public class Base64InputStreamTest {
         testByChunk(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF);
 
         // Single Line test.
-        String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");
+        final String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");
         encoded = StringUtils.getBytesUtf8(singleLine);
         decoded = Base64TestData.DECODED;
         testByChunk(encoded, decoded, 0, LF);
 
         // test random data of sizes 0 thru 150
         for (int i = 0; i <= 150; i++) {
-            byte[][] randomData = Base64TestData.randomData(i, false);
+            final byte[][] randomData = Base64TestData.randomData(i, false);
             encoded = randomData[1];
             decoded = randomData[0];
             testByChunk(encoded, decoded, 0, LF);
@@ -264,14 +264,14 @@ public class Base64InputStreamTest {
         testByteByByte(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF);
 
         // Single Line test.
-        String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");
+        final String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");
         encoded = StringUtils.getBytesUtf8(singleLine);
         decoded = Base64TestData.DECODED;
         testByteByByte(encoded, decoded, 0, LF);
 
         // test random data of sizes 0 thru 150
         for (int i = 0; i <= 150; i++) {
-            byte[][] randomData = Base64TestData.randomData(i, false);
+            final byte[][] randomData = Base64TestData.randomData(i, false);
             encoded = randomData[1];
             decoded = randomData[0];
             testByteByByte(encoded, decoded, 0, LF);
@@ -296,7 +296,7 @@ public class Base64InputStreamTest {
      * @throws Exception
      *             Usually signifies a bug in the Base64 commons-codec implementation.
      */
-    private void testByChunk(byte[] encoded, byte[] decoded, int chunkSize, byte[] seperator) throws Exception {
+    private void testByChunk(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] seperator) throws Exception {
 
         // Start with encode.
         InputStream in;
@@ -349,7 +349,7 @@ public class Base64InputStreamTest {
      * @throws Exception
      *             Usually signifies a bug in the Base64 commons-codec implementation.
      */
-    private void testByteByByte(byte[] encoded, byte[] decoded, int chunkSize, byte[] seperator) throws Exception {
+    private void testByteByByte(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] seperator) throws Exception {
 
         // Start with encode.
         InputStream in;
@@ -401,9 +401,9 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testMarkSupported() throws Exception {
-        byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
-        ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
-        Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
+        final byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
+        final ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
+        final Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
         // Always returns false for now.
         assertFalse("Base64InputStream.markSupported() is false", in.markSupported());
         in.close();
@@ -416,11 +416,11 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testRead0() throws Exception {
-        byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
-        byte[] buf = new byte[1024];
+        final byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
+        final byte[] buf = new byte[1024];
         int bytesRead = 0;
-        ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
-        Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
+        final ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
+        final Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
         bytesRead = in.read(buf, 0, 0);
         assertEquals("Base64InputStream.read(buf, 0, 0) returns 0", 0, bytesRead);
         in.close();
@@ -434,13 +434,13 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testReadNull() throws Exception {
-        byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
-        ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
-        Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
+        final byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
+        final ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
+        final Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
         try {
             in.read(null, 0, 0);
             fail("Base64InputStream.read(null, 0, 0) to throw a NullPointerException");
-        } catch (NullPointerException e) {
+        } catch (final NullPointerException e) {
             // Expected
         }
         in.close();
@@ -453,36 +453,36 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testReadOutOfBounds() throws Exception {
-        byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
-        byte[] buf = new byte[1024];
-        ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
-        Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
+        final byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
+        final byte[] buf = new byte[1024];
+        final ByteArrayInputStream bin = new ByteArrayInputStream(decoded);
+        final Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 });
 
         try {
             in.read(buf, -1, 0);
             fail("Expected Base64InputStream.read(buf, -1, 0) to throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
+        } catch (final IndexOutOfBoundsException e) {
             // Expected
         }
 
         try {
             in.read(buf, 0, -1);
             fail("Expected Base64InputStream.read(buf, 0, -1) to throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
+        } catch (final IndexOutOfBoundsException e) {
             // Expected
         }
 
         try {
             in.read(buf, buf.length + 1, 0);
             fail("Base64InputStream.read(buf, buf.length + 1, 0) throws IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
+        } catch (final IndexOutOfBoundsException e) {
             // Expected
         }
 
         try {
             in.read(buf, buf.length - 1, 2);
             fail("Base64InputStream.read(buf, buf.length - 1, 2) throws IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
+        } catch (final IndexOutOfBoundsException e) {
             // Expected
         }
         in.close();
@@ -495,8 +495,8 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testSkipBig() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
-        Base64InputStream b64stream = new Base64InputStream(ins);
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
+        final Base64InputStream b64stream = new Base64InputStream(ins);
         assertEquals(6, b64stream.skip(Integer.MAX_VALUE));
         // End of stream reached
         assertEquals(-1, b64stream.read());
@@ -511,9 +511,9 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testSkipNone() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
-        Base64InputStream b64stream = new Base64InputStream(ins);
-        byte[] actualBytes = new byte[6];
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
+        final Base64InputStream b64stream = new Base64InputStream(ins);
+        final byte[] actualBytes = new byte[6];
         assertEquals(0, b64stream.skip(0));
         b64stream.read(actualBytes, 0, actualBytes.length);
         assertArrayEquals(actualBytes, new byte[] { 0, 0, 0, (byte) 255, (byte) 255, (byte) 255 });
@@ -529,8 +529,8 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testSkipPastEnd() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
-        Base64InputStream b64stream = new Base64InputStream(ins);
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
+        final Base64InputStream b64stream = new Base64InputStream(ins);
         // due to CODEC-130, skip now skips correctly decoded characters rather than encoded
         assertEquals(6, b64stream.skip(10));
         // End of stream reached
@@ -546,8 +546,8 @@ public class Base64InputStreamTest {
      */
     @Test
     public void testSkipToEnd() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
-        Base64InputStream b64stream = new Base64InputStream(ins);
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
+        final Base64InputStream b64stream = new Base64InputStream(ins);
         // due to CODEC-130, skip now skips correctly decoded characters rather than encoded
         assertEquals(6, b64stream.skip(6));
         // End of stream reached
@@ -563,8 +563,8 @@ public class Base64InputStreamTest {
      */
     @Test(expected=IllegalArgumentException.class)
     public void testSkipWrongArgument() throws Throwable {
-        InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
-        Base64InputStream b64stream = new Base64InputStream(ins);
+        final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64));
+        final Base64InputStream b64stream = new Base64InputStream(ins);
         b64stream.skip(-10);
         b64stream.close();
     }

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java Mon Jan  7 16:08:05 2013
@@ -47,16 +47,16 @@ public class Base64OutputStreamTest {
      */
     @Test
     public void testCodec98NPE() throws Exception {
-        byte[] codec98 = StringUtils.getBytesUtf8(Base64TestData.CODEC_98_NPE);
-        byte[] codec98_1024 = new byte[1024];
+        final byte[] codec98 = StringUtils.getBytesUtf8(Base64TestData.CODEC_98_NPE);
+        final byte[] codec98_1024 = new byte[1024];
         System.arraycopy(codec98, 0, codec98_1024, 0, codec98.length);
-        ByteArrayOutputStream data = new ByteArrayOutputStream(1024);
-        Base64OutputStream stream = new Base64OutputStream(data, false);
+        final ByteArrayOutputStream data = new ByteArrayOutputStream(1024);
+        final Base64OutputStream stream = new Base64OutputStream(data, false);
         stream.write(codec98_1024, 0, 1024);
         stream.close();
 
-        byte[] decodedBytes = data.toByteArray();
-        String decoded = StringUtils.newStringUtf8(decodedBytes);
+        final byte[] decodedBytes = data.toByteArray();
+        final String decoded = StringUtils.newStringUtf8(decodedBytes);
         assertEquals(
             "codec-98 NPE Base64OutputStream", Base64TestData.CODEC_98_NPE_DECODED, decoded
         );
@@ -85,9 +85,9 @@ public class Base64OutputStreamTest {
         testBase64EmptyOutputStream(BaseNCodec.PEM_CHUNK_SIZE);
     }
 
-    private void testBase64EmptyOutputStream(int chunkSize) throws Exception {
-        byte[] emptyEncoded = new byte[0];
-        byte[] emptyDecoded = new byte[0];
+    private void testBase64EmptyOutputStream(final int chunkSize) throws Exception {
+        final byte[] emptyEncoded = new byte[0];
+        final byte[] emptyDecoded = new byte[0];
         testByteByByte(emptyEncoded, emptyDecoded, chunkSize, CRLF);
         testByChunk(emptyEncoded, emptyDecoded, chunkSize, CRLF);
     }
@@ -116,14 +116,14 @@ public class Base64OutputStreamTest {
         testByChunk(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF);
 
         // Single Line test.
-        String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");
+        final String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");
         encoded = StringUtils.getBytesUtf8(singleLine);
         decoded = Base64TestData.DECODED;
         testByChunk(encoded, decoded, 0, LF);
 
         // test random data of sizes 0 thru 150
         for (int i = 0; i <= 150; i++) {
-            byte[][] randomData = Base64TestData.randomData(i, false);
+            final byte[][] randomData = Base64TestData.randomData(i, false);
             encoded = randomData[1];
             decoded = randomData[0];
             testByChunk(encoded, decoded, 0, LF);
@@ -154,14 +154,14 @@ public class Base64OutputStreamTest {
         testByteByByte(encoded, decoded, 64, LF);
 
         // Single Line test.
-        String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");
+        final String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");
         encoded = StringUtils.getBytesUtf8(singleLine);
         decoded = Base64TestData.DECODED;
         testByteByByte(encoded, decoded, 0, LF);
 
         // test random data of sizes 0 thru 150
         for (int i = 0; i <= 150; i++) {
-            byte[][] randomData = Base64TestData.randomData(i, false);
+            final byte[][] randomData = Base64TestData.randomData(i, false);
             encoded = randomData[1];
             decoded = randomData[0];
             testByteByByte(encoded, decoded, 0, LF);
@@ -186,7 +186,7 @@ public class Base64OutputStreamTest {
      * @throws Exception
      *             Usually signifies a bug in the Base64 commons-codec implementation.
      */
-    private void testByChunk(byte[] encoded, byte[] decoded, int chunkSize, byte[] seperator) throws Exception {
+    private void testByChunk(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] seperator) throws Exception {
 
         // Start with encode.
         ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
@@ -236,12 +236,12 @@ public class Base64OutputStreamTest {
      * @throws Exception
      *             Usually signifies a bug in the Base64 commons-codec implementation.
      */
-    private void testByteByByte(byte[] encoded, byte[] decoded, int chunkSize, byte[] seperator) throws Exception {
+    private void testByteByByte(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] seperator) throws Exception {
 
         // Start with encode.
         ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
         OutputStream out = new Base64OutputStream(byteOut, true, chunkSize, seperator);
-        for (byte element : decoded) {
+        for (final byte element : decoded) {
             out.write(element);
         }
         out.close();
@@ -251,7 +251,7 @@ public class Base64OutputStreamTest {
         // Now let's try decode.
         byteOut = new ByteArrayOutputStream();
         out = new Base64OutputStream(byteOut, false);
-        for (byte element : encoded) {
+        for (final byte element : encoded) {
             out.write(element);
         }
         out.close();
@@ -261,7 +261,7 @@ public class Base64OutputStreamTest {
         // Now let's try decode with tonnes of flushes.
         byteOut = new ByteArrayOutputStream();
         out = new Base64OutputStream(byteOut, false);
-        for (byte element : encoded) {
+        for (final byte element : encoded) {
             out.write(element);
             out.flush();
         }
@@ -276,7 +276,7 @@ public class Base64OutputStreamTest {
             out = new Base64OutputStream(out, false);
             out = new Base64OutputStream(out, true, chunkSize, seperator);
         }
-        for (byte element : decoded) {
+        for (final byte element : decoded) {
             out.write(element);
         }
         out.close();
@@ -293,35 +293,35 @@ public class Base64OutputStreamTest {
      */
     @Test
     public void testWriteOutOfBounds() throws Exception {
-        byte[] buf = new byte[1024];
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        Base64OutputStream out = new Base64OutputStream(bout);
+        final byte[] buf = new byte[1024];
+        final ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        final Base64OutputStream out = new Base64OutputStream(bout);
 
         try {
             out.write(buf, -1, 1);
             fail("Expected Base64OutputStream.write(buf, -1, 1) to throw a IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ioobe) {
+        } catch (final IndexOutOfBoundsException ioobe) {
             // Expected
         }
 
         try {
             out.write(buf, 1, -1);
             fail("Expected Base64OutputStream.write(buf, 1, -1) to throw a IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ioobe) {
+        } catch (final IndexOutOfBoundsException ioobe) {
             // Expected
         }
 
         try {
             out.write(buf, buf.length + 1, 0);
             fail("Expected Base64OutputStream.write(buf, buf.length + 1, 0) to throw a IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ioobe) {
+        } catch (final IndexOutOfBoundsException ioobe) {
             // Expected
         }
 
         try {
             out.write(buf, buf.length - 1, 2);
             fail("Expected Base64OutputStream.write(buf, buf.length - 1, 2) to throw a IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ioobe) {
+        } catch (final IndexOutOfBoundsException ioobe) {
             // Expected
         }
         out.close();
@@ -335,12 +335,12 @@ public class Base64OutputStreamTest {
      */
     @Test
     public void testWriteToNullCoverage() throws Exception {
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        Base64OutputStream out = new Base64OutputStream(bout);
+        final ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        final Base64OutputStream out = new Base64OutputStream(bout);
         try {
             out.write(null, 0, 0);
             fail("Expcted Base64OutputStream.write(null) to throw a NullPointerException");
-        } catch (NullPointerException e) {
+        } catch (final NullPointerException e) {
             // Expected
         } finally {
             out.close();

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java Mon Jan  7 16:08:05 2013
@@ -55,15 +55,15 @@ public class Base64Test {
      */
     @Test
     public void testIsStringBase64() {
-        String nullString = null;
-        String emptyString = "";
-        String validString = "abc===defg\n\r123456\r789\r\rABC\n\nDEF==GHI\r\nJKL==============";
-        String invalidString = validString + (char)0; // append null character
+        final String nullString = null;
+        final String emptyString = "";
+        final String validString = "abc===defg\n\r123456\r789\r\rABC\n\nDEF==GHI\r\nJKL==============";
+        final String invalidString = validString + (char)0; // append null character
 
         try {
             Base64.isBase64(nullString);
             fail("Base64.isStringBase64() should not be null-safe.");
-        } catch (NullPointerException npe) {
+        } catch (final NullPointerException npe) {
             assertNotNull("Base64.isStringBase64() should not be null-safe.", npe);
         }
 
@@ -77,7 +77,7 @@ public class Base64Test {
      */
     @Test
     public void testBase64() {
-        String content = "Hello World";
+        final String content = "Hello World";
         String encodedContent;
         byte[] encodedBytes = Base64.encodeBase64(StringUtils.getBytesUtf8(content));
         encodedContent = StringUtils.newStringUtf8(encodedBytes);
@@ -94,8 +94,8 @@ public class Base64Test {
         assertEquals("encoding hello world", "SGVsbG8gV29ybGQ=", encodedContent);
 
         // bogus characters to decode (to skip actually) {e-acute*6}
-        byte[] decode = b64.decode("SGVsbG{\u00e9\u00e9\u00e9\u00e9\u00e9\u00e9}8gV29ybGQ=");
-        String decodeString = StringUtils.newStringUtf8(decode);
+        final byte[] decode = b64.decode("SGVsbG{\u00e9\u00e9\u00e9\u00e9\u00e9\u00e9}8gV29ybGQ=");
+        final String decodeString = StringUtils.newStringUtf8(decode);
         assertEquals("decode hello world", "Hello World", decodeString);
     }
 
@@ -104,11 +104,11 @@ public class Base64Test {
      */
     @Test
     public void testChunkedEncodeMultipleOf76() {
-        byte[] expectedEncode = Base64.encodeBase64(Base64TestData.DECODED, true);
+        final byte[] expectedEncode = Base64.encodeBase64(Base64TestData.DECODED, true);
         // convert to "\r\n" so we're equal to the old openssl encoding test stored
         // in Base64TestData.ENCODED_76_CHARS_PER_LINE:
-        String actualResult = Base64TestData.ENCODED_76_CHARS_PER_LINE.replaceAll("\n", "\r\n");
-        byte[] actualEncode = StringUtils.getBytesUtf8(actualResult);
+        final String actualResult = Base64TestData.ENCODED_76_CHARS_PER_LINE.replaceAll("\n", "\r\n");
+        final byte[] actualEncode = StringUtils.getBytesUtf8(actualResult);
         assertTrue("chunkedEncodeMultipleOf76", Arrays.equals(expectedEncode, actualEncode));
     }
 
@@ -117,14 +117,14 @@ public class Base64Test {
      */
     @Test
     public void testCodec68() {
-        byte[] x = new byte[]{'n', 'A', '=', '=', (byte) 0x9c};
+        final byte[] x = new byte[]{'n', 'A', '=', '=', (byte) 0x9c};
         Base64.decodeBase64(x);
     }
 
     @Test
     public void testCodeInteger1() {
-        String encodedInt1 = "li7dzDacuo67Jg7mtqEm2TRuOMU=";
-        BigInteger bigInt1 = new BigInteger("85739377120809420210425962799" + "0318636601332086981");
+        final String encodedInt1 = "li7dzDacuo67Jg7mtqEm2TRuOMU=";
+        final BigInteger bigInt1 = new BigInteger("85739377120809420210425962799" + "0318636601332086981");
 
         assertEquals(encodedInt1, new String(Base64.encodeInteger(bigInt1)));
         assertEquals(bigInt1, Base64.decodeInteger(encodedInt1.getBytes(Charsets.UTF_8)));
@@ -132,8 +132,8 @@ public class Base64Test {
 
     @Test
     public void testCodeInteger2() {
-        String encodedInt2 = "9B5ypLY9pMOmtxCeTDHgwdNFeGs=";
-        BigInteger bigInt2 = new BigInteger("13936727572861167254666467268" + "91466679477132949611");
+        final String encodedInt2 = "9B5ypLY9pMOmtxCeTDHgwdNFeGs=";
+        final BigInteger bigInt2 = new BigInteger("13936727572861167254666467268" + "91466679477132949611");
 
         assertEquals(encodedInt2, new String(Base64.encodeInteger(bigInt2)));
         assertEquals(bigInt2, Base64.decodeInteger(encodedInt2.getBytes(Charsets.UTF_8)));
@@ -141,8 +141,8 @@ public class Base64Test {
 
     @Test
     public void testCodeInteger3() {
-        String encodedInt3 = "FKIhdgaG5LGKiEtF1vHy4f3y700zaD6QwDS3IrNVGzNp2" + "rY+1LFWTK6D44AyiC1n8uWz1itkYMZF0/aKDK0Yjg==";
-        BigInteger bigInt3 = new BigInteger("10806548154093873461951748545"
+        final String encodedInt3 = "FKIhdgaG5LGKiEtF1vHy4f3y700zaD6QwDS3IrNVGzNp2" + "rY+1LFWTK6D44AyiC1n8uWz1itkYMZF0/aKDK0Yjg==";
+        final BigInteger bigInt3 = new BigInteger("10806548154093873461951748545"
             + "1196989136416448805819079363524309897749044958112417136240557"
             + "4495062430572478766856090958495998158114332651671116876320938126");
 
@@ -152,11 +152,11 @@ public class Base64Test {
 
     @Test
     public void testCodeInteger4() {
-        String encodedInt4 = "ctA8YGxrtngg/zKVvqEOefnwmViFztcnPBYPlJsvh6yKI"
+        final String encodedInt4 = "ctA8YGxrtngg/zKVvqEOefnwmViFztcnPBYPlJsvh6yKI"
             + "4iDm68fnp4Mi3RrJ6bZAygFrUIQLxLjV+OJtgJAEto0xAs+Mehuq1DkSFEpP3o"
             + "DzCTOsrOiS1DwQe4oIb7zVk/9l7aPtJMHW0LVlMdwZNFNNJoqMcT2ZfCPrfvYv"
             + "Q0=";
-        BigInteger bigInt4 = new BigInteger("80624726256040348115552042320"
+        final BigInteger bigInt4 = new BigInteger("80624726256040348115552042320"
             + "6968135001872753709424419772586693950232350200555646471175944"
             + "519297087885987040810778908507262272892702303774422853675597"
             + "748008534040890923814202286633163248086055216976551456088015"
@@ -177,9 +177,9 @@ public class Base64Test {
         try {
             Base64.encodeInteger(null);
             fail("Exception not thrown when passing in null to encodeInteger(BigInteger)");
-        } catch (NullPointerException npe) {
+        } catch (final NullPointerException npe) {
             // expected
-        } catch (Exception e) {
+        } catch (final Exception e) {
             fail("Incorrect Exception caught when passing in null to encodeInteger(BigInteger)");
         }
     }
@@ -194,26 +194,26 @@ public class Base64Test {
         try {
             base64 = new Base64(-1, new byte[]{'A'}); // TODO do we need to check sep if len = -1?
             fail("Should have rejected attempt to use 'A' as a line separator");
-        } catch (IllegalArgumentException ignored) {
+        } catch (final IllegalArgumentException ignored) {
             // Expected
         }
         try {
             base64 = new Base64(64, new byte[]{'A'});
             fail("Should have rejected attempt to use 'A' as a line separator");
-        } catch (IllegalArgumentException ignored) {
+        } catch (final IllegalArgumentException ignored) {
             // Expected
         }
         try {
             base64 = new Base64(64, new byte[]{'='});
             fail("Should have rejected attempt to use '=' as a line separator");
-        } catch (IllegalArgumentException ignored) {
+        } catch (final IllegalArgumentException ignored) {
             // Expected
         }
         base64 = new Base64(64, new byte[]{'$'}); // OK
         try {
             base64 = new Base64(64, new byte[]{'A', '$'});
             fail("Should have rejected attempt to use 'A$' as a line separator");
-        } catch (IllegalArgumentException ignored) {
+        } catch (final IllegalArgumentException ignored) {
             // Expected
         }
         base64 = new Base64(64, new byte[]{' ', '$', '\n', '\r', '\t'}); // OK
@@ -222,25 +222,25 @@ public class Base64Test {
 
     @Test
     public void testConstructor_Int_ByteArray_Boolean() {
-        Base64 base64 = new Base64(65, new byte[]{'\t'}, false);
-        byte[] encoded = base64.encode(Base64TestData.DECODED);
+        final Base64 base64 = new Base64(65, new byte[]{'\t'}, false);
+        final byte[] encoded = base64.encode(Base64TestData.DECODED);
         String expectedResult = Base64TestData.ENCODED_64_CHARS_PER_LINE;
         expectedResult = expectedResult.replace('\n', '\t');
-        String result = StringUtils.newStringUtf8(encoded);
+        final String result = StringUtils.newStringUtf8(encoded);
         assertEquals("new Base64(65, \\t, false)", expectedResult, result);
     }
 
     @Test
     public void testConstructor_Int_ByteArray_Boolean_UrlSafe() {
         // url-safe variation
-        Base64 base64 = new Base64(64, new byte[]{'\t'}, true);
-        byte[] encoded = base64.encode(Base64TestData.DECODED);
+        final Base64 base64 = new Base64(64, new byte[]{'\t'}, true);
+        final byte[] encoded = base64.encode(Base64TestData.DECODED);
         String expectedResult = Base64TestData.ENCODED_64_CHARS_PER_LINE;
         expectedResult = expectedResult.replaceAll("=", ""); // url-safe has no == padding.
         expectedResult = expectedResult.replace('\n', '\t');
         expectedResult = expectedResult.replace('+', '-');
         expectedResult = expectedResult.replace('/', '_');
-        String result = StringUtils.newStringUtf8(encoded);
+        final String result = StringUtils.newStringUtf8(encoded);
         assertEquals("new Base64(64, \\t, true)", result, expectedResult);
     }
 
@@ -286,20 +286,20 @@ public class Base64Test {
     @Test
     public void testDecodeWithWhitespace() throws Exception {
 
-        String orig = "I am a late night coder.";
+        final String orig = "I am a late night coder.";
 
-        byte[] encodedArray = Base64.encodeBase64(orig.getBytes(Charsets.UTF_8));
-        StringBuilder intermediate = new StringBuilder(new String(encodedArray));
+        final byte[] encodedArray = Base64.encodeBase64(orig.getBytes(Charsets.UTF_8));
+        final StringBuilder intermediate = new StringBuilder(new String(encodedArray));
 
         intermediate.insert(2, ' ');
         intermediate.insert(5, '\t');
         intermediate.insert(10, '\r');
         intermediate.insert(15, '\n');
 
-        byte[] encodedWithWS = intermediate.toString().getBytes(Charsets.UTF_8);
-        byte[] decodedWithWS = Base64.decodeBase64(encodedWithWS);
+        final byte[] encodedWithWS = intermediate.toString().getBytes(Charsets.UTF_8);
+        final byte[] decodedWithWS = Base64.decodeBase64(encodedWithWS);
 
-        String dest = new String(decodedWithWS);
+        final String dest = new String(decodedWithWS);
 
         assertEquals("Dest string doesn't equal the original", orig, dest);
     }
@@ -324,11 +324,11 @@ public class Base64Test {
     @Test
     public void testEncodeDecodeRandom() {
         for (int i = 1; i < 5; i++) {
-            byte[] data = new byte[this.getRandom().nextInt(10000) + 1];
+            final byte[] data = new byte[this.getRandom().nextInt(10000) + 1];
             this.getRandom().nextBytes(data);
-            byte[] enc = Base64.encodeBase64(data);
+            final byte[] enc = Base64.encodeBase64(data);
             assertTrue(Base64.isBase64(enc));
-            byte[] data2 = Base64.decodeBase64(enc);
+            final byte[] data2 = Base64.decodeBase64(enc);
             assertTrue(Arrays.equals(data, data2));
         }
     }
@@ -337,11 +337,11 @@ public class Base64Test {
     @Test
     public void testEncodeDecodeSmall() {
         for (int i = 0; i < 12; i++) {
-            byte[] data = new byte[i];
+            final byte[] data = new byte[i];
             this.getRandom().nextBytes(data);
-            byte[] enc = Base64.encodeBase64(data);
+            final byte[] enc = Base64.encodeBase64(data);
             assertTrue("\"" + new String(enc) + "\" is Base64 data.", Base64.isBase64(enc));
-            byte[] data2 = Base64.decodeBase64(enc);
+            final byte[] data2 = Base64.decodeBase64(enc);
             assertTrue(toString(data) + " equals " + toString(data2), Arrays.equals(data, data2));
         }
     }
@@ -356,16 +356,16 @@ public class Base64Test {
 
     @Test
     public void testCodec112() { // size calculation assumes always chunked
-        byte[] in = new byte[] {0};
-        byte[] out=Base64.encodeBase64(in);
+        final byte[] in = new byte[] {0};
+        final byte[] out=Base64.encodeBase64(in);
         Base64.encodeBase64(in, false, false, out.length);
     }
 
-    private void testEncodeOverMaxSize(int maxSize) throws Exception {
+    private void testEncodeOverMaxSize(final int maxSize) throws Exception {
         try {
             Base64.encodeBase64(Base64TestData.DECODED, true, false, maxSize);
             fail("Expected " + IllegalArgumentException.class.getName());
-        } catch (IllegalArgumentException e) {
+        } catch (final IllegalArgumentException e) {
             // Expected
         }
     }
@@ -396,13 +396,13 @@ public class Base64Test {
      */
     @Test
     public void testIsUrlSafe() {
-        Base64 base64Standard = new Base64(false);
-        Base64 base64URLSafe = new Base64(true);
+        final Base64 base64Standard = new Base64(false);
+        final Base64 base64URLSafe = new Base64(true);
 
         assertFalse("Base64.isUrlSafe=false", base64Standard.isUrlSafe());
         assertTrue("Base64.isUrlSafe=true", base64URLSafe.isUrlSafe());
 
-        byte[] whiteSpace = {' ', '\n', '\r', '\t'};
+        final byte[] whiteSpace = {' ', '\n', '\r', '\t'};
         assertTrue("Base64.isBase64(whiteSpace)=true", Base64.isBase64(whiteSpace));
     }
 
@@ -445,18 +445,18 @@ public class Base64Test {
     @Test
     public void testNonBase64Test() throws Exception {
 
-        byte[] bArray = {'%'};
+        final byte[] bArray = {'%'};
 
         assertFalse("Invalid Base64 array was incorrectly validated as " + "an array of Base64 encoded data", Base64
                 .isBase64(bArray));
 
         try {
-            Base64 b64 = new Base64();
-            byte[] result = b64.decode(bArray);
+            final Base64 b64 = new Base64();
+            final byte[] result = b64.decode(bArray);
 
             assertEquals("The result should be empty as the test encoded content did " + "not contain any valid base 64 characters",
                     0, result.length);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             fail("Exception was thrown when trying to decode "
                 + "invalid base64 encoded data - RFC 2045 requires that all "
                 + "non base64 character be discarded, an exception should not"
@@ -466,12 +466,12 @@ public class Base64Test {
 
     @Test
     public void testObjectDecodeWithInvalidParameter() throws Exception {
-        Base64 b64 = new Base64();
+        final Base64 b64 = new Base64();
 
         try {
             b64.decode(Integer.valueOf(5));
             fail("decode(Object) didn't throw an exception when passed an Integer object");
-        } catch (DecoderException e) {
+        } catch (final DecoderException e) {
             // ignored
         }
 
@@ -480,24 +480,24 @@ public class Base64Test {
     @Test
     public void testObjectDecodeWithValidParameter() throws Exception {
 
-        String original = "Hello World!";
-        Object o = Base64.encodeBase64(original.getBytes(Charsets.UTF_8));
+        final String original = "Hello World!";
+        final Object o = Base64.encodeBase64(original.getBytes(Charsets.UTF_8));
 
-        Base64 b64 = new Base64();
-        Object oDecoded = b64.decode(o);
-        byte[] baDecoded = (byte[]) oDecoded;
-        String dest = new String(baDecoded);
+        final Base64 b64 = new Base64();
+        final Object oDecoded = b64.decode(o);
+        final byte[] baDecoded = (byte[]) oDecoded;
+        final String dest = new String(baDecoded);
 
         assertEquals("dest string does not equal original", original, dest);
     }
 
     @Test
     public void testObjectEncodeWithInvalidParameter() throws Exception {
-        Base64 b64 = new Base64();
+        final Base64 b64 = new Base64();
         try {
             b64.encode("Yadayadayada");
             fail("encode(Object) didn't throw an exception when passed a String object");
-        } catch (EncoderException e) {
+        } catch (final EncoderException e) {
             // Expected
         }
     }
@@ -505,20 +505,20 @@ public class Base64Test {
     @Test
     public void testObjectEncodeWithValidParameter() throws Exception {
 
-        String original = "Hello World!";
-        Object origObj = original.getBytes(Charsets.UTF_8);
+        final String original = "Hello World!";
+        final Object origObj = original.getBytes(Charsets.UTF_8);
 
-        Base64 b64 = new Base64();
-        Object oEncoded = b64.encode(origObj);
-        byte[] bArray = Base64.decodeBase64((byte[]) oEncoded);
-        String dest = new String(bArray);
+        final Base64 b64 = new Base64();
+        final Object oEncoded = b64.encode(origObj);
+        final byte[] bArray = Base64.decodeBase64((byte[]) oEncoded);
+        final String dest = new String(bArray);
 
         assertEquals("dest string does not equal original", original, dest);
     }
 
     @Test
     public void testObjectEncode() throws Exception {
-        Base64 b64 = new Base64();
+        final Base64 b64 = new Base64();
         assertEquals("SGVsbG8gV29ybGQ=", new String(b64.encode("Hello World".getBytes(Charsets.UTF_8))));
     }
 
@@ -526,7 +526,7 @@ public class Base64Test {
     public void testPairs() {
         assertEquals("AAA=", new String(Base64.encodeBase64(new byte[]{0, 0})));
         for (int i = -128; i <= 127; i++) {
-            byte test[] = {(byte) i, (byte) i};
+            final byte test[] = {(byte) i, (byte) i};
             assertTrue(Arrays.equals(test, Base64.decodeBase64(Base64.encodeBase64(test))));
         }
     }
@@ -596,7 +596,7 @@ public class Base64Test {
      */
     @Test
     public void testRfc4648Section10DecodeWithCrLf() {
-        String CRLF = StringUtils.newStringUsAscii(Base64.CHUNK_SEPARATOR);
+        final String CRLF = StringUtils.newStringUsAscii(Base64.CHUNK_SEPARATOR);
         assertEquals("", StringUtils.newStringUsAscii(Base64.decodeBase64("" + CRLF)));
         assertEquals("f", StringUtils.newStringUsAscii(Base64.decodeBase64("Zg==" + CRLF)));
         assertEquals("fo", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm8=" + CRLF)));
@@ -656,9 +656,9 @@ public class Base64Test {
         testDecodeEncode("Zm9vYmFy");
     }
 
-    private void testDecodeEncode(String encodedText) {
-        String decodedText = StringUtils.newStringUsAscii(Base64.decodeBase64(encodedText));
-        String encodedText2 = Base64.encodeBase64String(StringUtils.getBytesUtf8(decodedText));
+    private void testDecodeEncode(final String encodedText) {
+        final String decodedText = StringUtils.newStringUsAscii(Base64.decodeBase64(encodedText));
+        final String encodedText2 = Base64.encodeBase64String(StringUtils.getBytesUtf8(decodedText));
         assertEquals(encodedText, encodedText2);
     }
 
@@ -687,9 +687,9 @@ public class Base64Test {
         testEncodeDecode("foobar");
     }
 
-    private void testEncodeDecode(String plainText) {
-        String encodedText = Base64.encodeBase64String(StringUtils.getBytesUtf8(plainText));
-        String decodedText = StringUtils.newStringUsAscii(Base64.decodeBase64(encodedText));
+    private void testEncodeDecode(final String plainText) {
+        final String encodedText = Base64.encodeBase64String(StringUtils.getBytesUtf8(plainText));
+        final String decodedText = StringUtils.newStringUsAscii(Base64.decodeBase64(encodedText));
         assertEquals(plainText, decodedText);
     }
 
@@ -801,7 +801,7 @@ public class Base64Test {
         assertEquals("Zw==", new String(Base64.encodeBase64(new byte[]{(byte) 103})));
         assertEquals("aA==", new String(Base64.encodeBase64(new byte[]{(byte) 104})));
         for (int i = -128; i <= 127; i++) {
-            byte test[] = {(byte) i};
+            final byte test[] = {(byte) i};
             assertTrue(Arrays.equals(test, Base64.decodeBase64(Base64.encodeBase64(test))));
         }
     }
@@ -1058,10 +1058,10 @@ public class Base64Test {
     public void testUrlSafe() {
         // test random data of sizes 0 thru 150
         for (int i = 0; i <= 150; i++) {
-            byte[][] randomData = Base64TestData.randomData(i, true);
-            byte[] encoded = randomData[1];
-            byte[] decoded = randomData[0];
-            byte[] result = Base64.decodeBase64(encoded);
+            final byte[][] randomData = Base64TestData.randomData(i, true);
+            final byte[] encoded = randomData[1];
+            final byte[] decoded = randomData[0];
+            final byte[] result = Base64.decodeBase64(encoded);
             assertTrue("url-safe i=" + i, Arrays.equals(decoded, result));
             assertFalse("url-safe i=" + i + " no '='", Base64TestData.bytesContain(encoded, (byte) '='));
             assertFalse("url-safe i=" + i + " no '\\'", Base64TestData.bytesContain(encoded, (byte) '\\'));
@@ -1081,7 +1081,7 @@ public class Base64Test {
     public void testUUID() throws DecoderException {
         // The 4 UUID's below contains mixtures of + and / to help us test the
         // URL-SAFE encoding mode.
-        byte[][] ids = new byte[4][];
+        final byte[][] ids = new byte[4][];
 
         // ids[0] was chosen so that it encodes with at least one +.
         ids[0] = Hex.decodeHex("94ed8d0319e4493399560fb67404d370".toCharArray());
@@ -1096,27 +1096,27 @@ public class Base64Test {
         // right at the beginning.
         ids[3] = Hex.decodeHex("ff7f8fc01cdb471a8c8b5a9306183fe8".toCharArray());
 
-        byte[][] standard = new byte[4][];
+        final byte[][] standard = new byte[4][];
         standard[0] = StringUtils.getBytesUtf8("lO2NAxnkSTOZVg+2dATTcA==");
         standard[1] = StringUtils.getBytesUtf8("K/fMJwH+Q5e0nr7tWsxwkA==");
         standard[2] = StringUtils.getBytesUtf8("ZL4VS2/6QCWNGgEojnwxyg==");
         standard[3] = StringUtils.getBytesUtf8("/3+PwBzbRxqMi1qTBhg/6A==");
 
-        byte[][] urlSafe1 = new byte[4][];
+        final byte[][] urlSafe1 = new byte[4][];
         // regular padding (two '==' signs).
         urlSafe1[0] = StringUtils.getBytesUtf8("lO2NAxnkSTOZVg-2dATTcA==");
         urlSafe1[1] = StringUtils.getBytesUtf8("K_fMJwH-Q5e0nr7tWsxwkA==");
         urlSafe1[2] = StringUtils.getBytesUtf8("ZL4VS2_6QCWNGgEojnwxyg==");
         urlSafe1[3] = StringUtils.getBytesUtf8("_3-PwBzbRxqMi1qTBhg_6A==");
 
-        byte[][] urlSafe2 = new byte[4][];
+        final byte[][] urlSafe2 = new byte[4][];
         // single padding (only one '=' sign).
         urlSafe2[0] = StringUtils.getBytesUtf8("lO2NAxnkSTOZVg-2dATTcA=");
         urlSafe2[1] = StringUtils.getBytesUtf8("K_fMJwH-Q5e0nr7tWsxwkA=");
         urlSafe2[2] = StringUtils.getBytesUtf8("ZL4VS2_6QCWNGgEojnwxyg=");
         urlSafe2[3] = StringUtils.getBytesUtf8("_3-PwBzbRxqMi1qTBhg_6A=");
 
-        byte[][] urlSafe3 = new byte[4][];
+        final byte[][] urlSafe3 = new byte[4][];
         // no padding (no '=' signs).
         urlSafe3[0] = StringUtils.getBytesUtf8("lO2NAxnkSTOZVg-2dATTcA");
         urlSafe3[1] = StringUtils.getBytesUtf8("K_fMJwH-Q5e0nr7tWsxwkA");
@@ -1124,12 +1124,12 @@ public class Base64Test {
         urlSafe3[3] = StringUtils.getBytesUtf8("_3-PwBzbRxqMi1qTBhg_6A");
 
         for (int i = 0; i < 4; i++) {
-            byte[] encodedStandard = Base64.encodeBase64(ids[i]);
-            byte[] encodedUrlSafe = Base64.encodeBase64URLSafe(ids[i]);
-            byte[] decodedStandard = Base64.decodeBase64(standard[i]);
-            byte[] decodedUrlSafe1 = Base64.decodeBase64(urlSafe1[i]);
-            byte[] decodedUrlSafe2 = Base64.decodeBase64(urlSafe2[i]);
-            byte[] decodedUrlSafe3 = Base64.decodeBase64(urlSafe3[i]);
+            final byte[] encodedStandard = Base64.encodeBase64(ids[i]);
+            final byte[] encodedUrlSafe = Base64.encodeBase64URLSafe(ids[i]);
+            final byte[] decodedStandard = Base64.decodeBase64(standard[i]);
+            final byte[] decodedUrlSafe1 = Base64.decodeBase64(urlSafe1[i]);
+            final byte[] decodedUrlSafe2 = Base64.decodeBase64(urlSafe2[i]);
+            final byte[] decodedUrlSafe3 = Base64.decodeBase64(urlSafe3[i]);
 
             // Very important debugging output should anyone
             // ever need to delve closely into this stuff.
@@ -1168,11 +1168,11 @@ public class Base64Test {
 
     @Test
     public void testByteToStringVariations() throws DecoderException {
-        Base64 base64 = new Base64(0);
-        byte[] b1 = StringUtils.getBytesUtf8("Hello World");
-        byte[] b2 = new byte[0];
-        byte[] b3 = null;
-        byte[] b4 = Hex.decodeHex("2bf7cc2701fe4397b49ebeed5acc7090".toCharArray());  // for url-safe tests
+        final Base64 base64 = new Base64(0);
+        final byte[] b1 = StringUtils.getBytesUtf8("Hello World");
+        final byte[] b2 = new byte[0];
+        final byte[] b3 = null;
+        final byte[] b4 = Hex.decodeHex("2bf7cc2701fe4397b49ebeed5acc7090".toCharArray());  // for url-safe tests
 
         assertEquals("byteToString Hello World", "SGVsbG8gV29ybGQ=", base64.encodeToString(b1));
         assertEquals("byteToString static Hello World", "SGVsbG8gV29ybGQ=", Base64.encodeBase64String(b1));
@@ -1187,13 +1187,13 @@ public class Base64Test {
 
     @Test
     public void testStringToByteVariations() throws DecoderException {
-        Base64 base64 = new Base64();
-        String s1 = "SGVsbG8gV29ybGQ=\r\n";
-        String s2 = "";
-        String s3 = null;
-        String s4a = "K/fMJwH+Q5e0nr7tWsxwkA==\r\n";
-        String s4b = "K_fMJwH-Q5e0nr7tWsxwkA";
-        byte[] b4 = Hex.decodeHex("2bf7cc2701fe4397b49ebeed5acc7090".toCharArray());  // for url-safe tests
+        final Base64 base64 = new Base64();
+        final String s1 = "SGVsbG8gV29ybGQ=\r\n";
+        final String s2 = "";
+        final String s3 = null;
+        final String s4a = "K/fMJwH+Q5e0nr7tWsxwkA==\r\n";
+        final String s4b = "K_fMJwH-Q5e0nr7tWsxwkA";
+        final byte[] b4 = Hex.decodeHex("2bf7cc2701fe4397b49ebeed5acc7090".toCharArray());  // for url-safe tests
 
         assertEquals("StringToByte Hello World", "Hello World", StringUtils.newStringUtf8(base64.decode(s1)));
         assertEquals("StringToByte Hello World", "Hello World", StringUtils.newStringUtf8((byte[])base64.decode((Object)s1)));
@@ -1207,8 +1207,8 @@ public class Base64Test {
         assertTrue("StringToByte static-url-safe UUID", Arrays.equals(b4, Base64.decodeBase64(s4b)));
     }
 
-    private String toString(byte[] data) {
-        StringBuilder buf = new StringBuilder();
+    private String toString(final byte[] data) {
+        final StringBuilder buf = new StringBuilder();
         for (int i = 0; i < data.length; i++) {
             buf.append(data[i]);
             if (i != data.length - 1) {
@@ -1228,10 +1228,10 @@ public class Base64Test {
     public void testHugeLineSeparator() {
         final int BaseNCodec_DEFAULT_BUFFER_SIZE = 8192;
         final int Base64_BYTES_PER_ENCODED_BLOCK = 4;
-        byte[] baLineSeparator = new byte[BaseNCodec_DEFAULT_BUFFER_SIZE * 4 - 3];
-        Base64 b64 = new Base64(Base64_BYTES_PER_ENCODED_BLOCK, baLineSeparator);
-        String strOriginal = "Hello World";
-        String strDecoded = new String(b64.decode(b64.encode(StringUtils.getBytesUtf8(strOriginal))));
+        final byte[] baLineSeparator = new byte[BaseNCodec_DEFAULT_BUFFER_SIZE * 4 - 3];
+        final Base64 b64 = new Base64(Base64_BYTES_PER_ENCODED_BLOCK, baLineSeparator);
+        final String strOriginal = "Hello World";
+        final String strDecoded = new String(b64.decode(b64.encode(StringUtils.getBytesUtf8(strOriginal))));
         assertEquals("testDEFAULT_BUFFER_SIZE", strOriginal, strDecoded);
     }
 



Mime
View raw message