commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1429868 [6/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/net/QuotedPrintableCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/QuotedPrintableCodecTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/QuotedPrintableCodecTest.java
(original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/QuotedPrintableCodecTest.java
Mon Jan  7 16:08:05 2013
@@ -46,10 +46,10 @@ public class QuotedPrintableCodecTest {
         0x432, 0x435, 0x442
     };
 
-    private String constructString(int [] unicodeChars) {
-        StringBuilder buffer = new StringBuilder();
+    private String constructString(final int [] unicodeChars) {
+        final StringBuilder buffer = new StringBuilder();
         if (unicodeChars != null) {
-            for (int unicodeChar : unicodeChars) {
+            for (final int unicodeChar : unicodeChars) {
                 buffer.append((char)unicodeChar);
             }
         }
@@ -59,10 +59,10 @@ public class QuotedPrintableCodecTest {
     @Test
     public void testUTF8RoundTrip() throws Exception {
 
-        String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
-        String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
+        final String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
+        final String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
 
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
 
         assertEquals(
             "=D0=92=D1=81=D0=B5=D0=BC_=D0=BF=D1=80=D0=B8=D0=B2=D0=B5=D1=82",
@@ -76,9 +76,9 @@ public class QuotedPrintableCodecTest {
 
     @Test
     public void testBasicEncodeDecode() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
-        String plain = "= Hello there =\r\n";
-        String encoded = qpcodec.encode(plain);
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final String plain = "= Hello there =\r\n";
+        final String encoded = qpcodec.encode(plain);
         assertEquals("Basic quoted-printable encoding test",
             "=3D Hello there =3D=0D=0A", encoded);
         assertEquals("Basic quoted-printable decoding test",
@@ -87,9 +87,9 @@ public class QuotedPrintableCodecTest {
 
     @Test
     public void testSafeCharEncodeDecode() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
-        String plain = "abc123_-.*~!@#$%^&()+{}\"\\;:`,/[]";
-        String encoded = qpcodec.encode(plain);
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final String plain = "abc123_-.*~!@#$%^&()+{}\"\\;:`,/[]";
+        final String encoded = qpcodec.encode(plain);
         assertEquals("Safe chars quoted-printable encoding test",
             plain, encoded);
         assertEquals("Safe chars quoted-printable decoding test",
@@ -99,9 +99,9 @@ public class QuotedPrintableCodecTest {
 
     @Test
     public void testUnsafeEncodeDecode() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
-        String plain = "=\r\n";
-        String encoded = qpcodec.encode(plain);
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final String plain = "=\r\n";
+        final String encoded = qpcodec.encode(plain);
         assertEquals("Unsafe chars quoted-printable encoding test",
             "=3D=0D=0A", encoded);
         assertEquals("Unsafe chars quoted-printable decoding test",
@@ -110,7 +110,7 @@ public class QuotedPrintableCodecTest {
 
     @Test
     public void testEncodeDecodeNull() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
         assertNull("Null string quoted-printable encoding test",
             qpcodec.encode((String)null));
         assertNull("Null string quoted-printable decoding test",
@@ -120,41 +120,41 @@ public class QuotedPrintableCodecTest {
 
     @Test
     public void testDecodeInvalid() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
         try {
             qpcodec.decode("=");
             fail("DecoderException should have been thrown");
-        } catch (DecoderException e) {
+        } catch (final DecoderException e) {
             // Expected. Move on
         }
         try {
             qpcodec.decode("=A");
             fail("DecoderException should have been thrown");
-        } catch (DecoderException e) {
+        } catch (final DecoderException e) {
             // Expected. Move on
         }
         try {
             qpcodec.decode("=WW");
             fail("DecoderException should have been thrown");
-        } catch (DecoderException e) {
+        } catch (final DecoderException e) {
             // Expected. Move on
         }
     }
 
     @Test
     public void testEncodeNull() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
-        byte[] plain = null;
-        byte[] encoded = qpcodec.encode(plain);
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final byte[] plain = null;
+        final byte[] encoded = qpcodec.encode(plain);
         assertEquals("Encoding a null string should return null",
             null, encoded);
     }
 
     @Test
     public void testEncodeUrlWithNullBitSet() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
-        String plain = "1+1 = 2";
-        String encoded = new String(QuotedPrintableCodec.
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final String plain = "1+1 = 2";
+        final String encoded = new String(QuotedPrintableCodec.
             encodeQuotedPrintable(null, plain.getBytes(Charsets.UTF_8)));
         assertEquals("Basic quoted-printable encoding test",
             "1+1 =3D 2", encoded);
@@ -165,49 +165,49 @@ public class QuotedPrintableCodecTest {
 
     @Test
     public void testDecodeWithNullArray() throws Exception {
-        byte[] plain = null;
-        byte[] result = QuotedPrintableCodec.decodeQuotedPrintable( plain );
+        final byte[] plain = null;
+        final byte[] result = QuotedPrintableCodec.decodeQuotedPrintable( plain );
         assertEquals("Result should be null", null, result);
     }
 
     @Test
     public void testEncodeStringWithNull() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
-        String test = null;
-        String result = qpcodec.encode( test, "charset" );
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final String test = null;
+        final String result = qpcodec.encode( test, "charset" );
         assertEquals("Result should be null", null, result);
     }
 
     @Test
     public void testDecodeStringWithNull() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
-        String test = null;
-        String result = qpcodec.decode( test, "charset" );
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final String test = null;
+        final String result = qpcodec.decode( test, "charset" );
         assertEquals("Result should be null", null, result);
     }
 
     @Test
     public void testEncodeObjects() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
-        String plain = "1+1 = 2";
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final String plain = "1+1 = 2";
         String encoded = (String) qpcodec.encode((Object) plain);
         assertEquals("Basic quoted-printable encoding test",
             "1+1 =3D 2", encoded);
 
-        byte[] plainBA = plain.getBytes(Charsets.UTF_8);
-        byte[] encodedBA = (byte[]) qpcodec.encode((Object) plainBA);
+        final byte[] plainBA = plain.getBytes(Charsets.UTF_8);
+        final byte[] encodedBA = (byte[]) qpcodec.encode((Object) plainBA);
         encoded = new String(encodedBA);
         assertEquals("Basic quoted-printable encoding test",
             "1+1 =3D 2", encoded);
 
-        Object result = qpcodec.encode((Object) null);
+        final Object result = qpcodec.encode((Object) null);
         assertEquals( "Encoding a null Object should return null", null, result);
 
         try {
-            Object dObj = new Double(3.0);
+            final Object dObj = new Double(3.0);
             qpcodec.encode( dObj );
             fail( "Trying to url encode a Double object should cause an exception.");
-        } catch (EncoderException ee) {
+        } catch (final EncoderException ee) {
             // Exception expected, test segment passes.
         }
     }
@@ -219,37 +219,37 @@ public class QuotedPrintableCodecTest {
 
     @Test
     public void testDecodeObjects() throws Exception {
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
-        String plain = "1+1 =3D 2";
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
+        final String plain = "1+1 =3D 2";
         String decoded = (String) qpcodec.decode((Object) plain);
         assertEquals("Basic quoted-printable decoding test",
             "1+1 = 2", decoded);
 
-        byte[] plainBA = plain.getBytes(Charsets.UTF_8);
-        byte[] decodedBA = (byte[]) qpcodec.decode((Object) plainBA);
+        final byte[] plainBA = plain.getBytes(Charsets.UTF_8);
+        final byte[] decodedBA = (byte[]) qpcodec.decode((Object) plainBA);
         decoded = new String(decodedBA);
         assertEquals("Basic quoted-printable decoding test",
             "1+1 = 2", decoded);
 
-        Object result = qpcodec.decode((Object) null);
+        final Object result = qpcodec.decode((Object) null);
         assertEquals( "Decoding a null Object should return null", null, result);
 
         try {
-            Object dObj = new Double(3.0);
+            final Object dObj = new Double(3.0);
             qpcodec.decode( dObj );
             fail( "Trying to url encode a Double object should cause an exception.");
-        } catch (DecoderException ee) {
+        } catch (final DecoderException ee) {
             // Exception expected, test segment passes.
         }
     }
 
     @Test
     public void testDefaultEncoding() throws Exception {
-        String plain = "Hello there!";
-        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec("UnicodeBig");
+        final String plain = "Hello there!";
+        final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec("UnicodeBig");
         qpcodec.encode(plain); // To work around a weird quirk in Java 1.2.2
-        String encoded1 = qpcodec.encode(plain, "UnicodeBig");
-        String encoded2 = qpcodec.encode(plain);
+        final String encoded1 = qpcodec.encode(plain, "UnicodeBig");
+        final String encoded2 = qpcodec.encode(plain);
         assertEquals(encoded1, encoded2);
     }
 
@@ -262,8 +262,8 @@ public class QuotedPrintableCodecTest {
      * @see <a href="https://issues.apache.org/jira/browse/CODEC-121">CODEC-121</a>
      */
     public void testSoftLineBreakDecode() throws Exception {
-        String qpdata = "If you believe that truth=3Dbeauty, then surely=20=\r\nmathematics
is the most beautiful branch of philosophy.";
-        String expected = "If you believe that truth=beauty, then surely mathematics is the
most beautiful branch of philosophy.";
+        final String qpdata = "If you believe that truth=3Dbeauty, then surely=20=\r\nmathematics
is the most beautiful branch of philosophy.";
+        final String expected = "If you believe that truth=beauty, then surely mathematics
is the most beautiful branch of philosophy.";
         assertEquals(expected, new QuotedPrintableCodec().decode(qpdata));
     }
 
@@ -276,8 +276,8 @@ public class QuotedPrintableCodecTest {
      * @see <a href="https://issues.apache.org/jira/browse/CODEC-121">CODEC-121</a>
      */
     public void testSoftLineBreakEncode() throws Exception {
-        String qpdata = "If you believe that truth=3Dbeauty, then surely=20=\r\nmathematics
is the most beautiful branch of philosophy.";
-        String expected = "If you believe that truth=beauty, then surely mathematics is the
most beautiful branch of philosophy.";
+        final String qpdata = "If you believe that truth=3Dbeauty, then surely=20=\r\nmathematics
is the most beautiful branch of philosophy.";
+        final String expected = "If you believe that truth=beauty, then surely mathematics
is the most beautiful branch of philosophy.";
         assertEquals(qpdata, new QuotedPrintableCodec().encode(expected));
     }
 }

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/RFC1522CodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/RFC1522CodecTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/RFC1522CodecTest.java
(original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/RFC1522CodecTest.java
Mon Jan  7 16:08:05 2013
@@ -34,12 +34,12 @@ public class RFC1522CodecTest {
     static class RFC1522TestCodec extends RFC1522Codec {
 
         @Override
-        protected byte[] doDecoding(byte[] bytes) {
+        protected byte[] doDecoding(final byte[] bytes) {
             return bytes;
         }
 
         @Override
-        protected byte[] doEncoding(byte[] bytes) {
+        protected byte[] doEncoding(final byte[] bytes) {
             return bytes;
         }
 
@@ -52,17 +52,17 @@ public class RFC1522CodecTest {
 
     @Test
     public void testNullInput() throws Exception {
-        RFC1522TestCodec testcodec = new RFC1522TestCodec();
+        final RFC1522TestCodec testcodec = new RFC1522TestCodec();
         assertNull(testcodec.decodeText(null));
         assertNull(testcodec.encodeText(null, CharEncoding.UTF_8));
     }
 
-    private void assertExpectedDecoderException(String s) throws Exception {
-        RFC1522TestCodec testcodec = new RFC1522TestCodec();
+    private void assertExpectedDecoderException(final String s) throws Exception {
+        final RFC1522TestCodec testcodec = new RFC1522TestCodec();
         try {
             testcodec.decodeText(s);
             fail("DecoderException should have been thrown");
-        } catch (DecoderException e) {
+        } catch (final DecoderException e) {
             // Expected.
         }
     }

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/URLCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/URLCodecTest.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/URLCodecTest.java
(original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/URLCodecTest.java
Mon Jan  7 16:08:05 2013
@@ -45,14 +45,14 @@ public class URLCodecTest {
         0x432, 0x435, 0x442
     };
 
-    private void validateState(URLCodec urlCodec) {
+    private void validateState(final URLCodec urlCodec) {
         // no tests for now.
     }
 
-    private String constructString(int [] unicodeChars) {
-        StringBuilder buffer = new StringBuilder();
+    private String constructString(final int [] unicodeChars) {
+        final StringBuilder buffer = new StringBuilder();
         if (unicodeChars != null) {
-            for (int unicodeChar : unicodeChars) {
+            for (final int unicodeChar : unicodeChars) {
                 buffer.append((char)unicodeChar);
             }
         }
@@ -62,10 +62,10 @@ public class URLCodecTest {
     @Test
     public void testUTF8RoundTrip() throws Exception {
 
-        String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
-        String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
+        final String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
+        final String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
 
-        URLCodec urlCodec = new URLCodec();
+        final URLCodec urlCodec = new URLCodec();
         this.validateState(urlCodec);
 
         assertEquals(
@@ -81,9 +81,9 @@ public class URLCodecTest {
 
     @Test
     public void testBasicEncodeDecode() throws Exception {
-        URLCodec urlCodec = new URLCodec();
-        String plain = "Hello there!";
-        String encoded = urlCodec.encode(plain);
+        final URLCodec urlCodec = new URLCodec();
+        final String plain = "Hello there!";
+        final String encoded = urlCodec.encode(plain);
         assertEquals("Basic URL encoding test",
             "Hello+there%21", encoded);
         assertEquals("Basic URL decoding test",
@@ -94,9 +94,9 @@ public class URLCodecTest {
 
     @Test
     public void testSafeCharEncodeDecode() throws Exception {
-        URLCodec urlCodec = new URLCodec();
-        String plain = "abc123_-.*";
-        String encoded = urlCodec.encode(plain);
+        final URLCodec urlCodec = new URLCodec();
+        final String plain = "abc123_-.*";
+        final String encoded = urlCodec.encode(plain);
         assertEquals("Safe chars URL encoding test",
             plain, encoded);
         assertEquals("Safe chars URL decoding test",
@@ -107,9 +107,9 @@ public class URLCodecTest {
 
     @Test
     public void testUnsafeEncodeDecode() throws Exception {
-        URLCodec urlCodec = new URLCodec();
-        String plain = "~!@#$%^&()+{}\"\\;:`,/[]";
-        String encoded = urlCodec.encode(plain);
+        final URLCodec urlCodec = new URLCodec();
+        final String plain = "~!@#$%^&()+{}\"\\;:`,/[]";
+        final String encoded = urlCodec.encode(plain);
         assertEquals("Unsafe chars URL encoding test",
             "%7E%21%40%23%24%25%5E%26%28%29%2B%7B%7D%22%5C%3B%3A%60%2C%2F%5B%5D", encoded);
         assertEquals("Unsafe chars URL decoding test",
@@ -120,7 +120,7 @@ public class URLCodecTest {
 
     @Test
     public void testEncodeDecodeNull() throws Exception {
-        URLCodec urlCodec = new URLCodec();
+        final URLCodec urlCodec = new URLCodec();
         assertNull("Null string URL encoding test",
             urlCodec.encode((String)null));
         assertNull("Null string URL decoding test",
@@ -131,31 +131,31 @@ public class URLCodecTest {
 
     @Test
     public void testDecodeInvalid() throws Exception {
-        URLCodec urlCodec = new URLCodec();
+        final URLCodec urlCodec = new URLCodec();
         try {
             urlCodec.decode("%");
             fail("DecoderException should have been thrown");
-        } catch (DecoderException e) {
+        } catch (final DecoderException e) {
             // Expected. Move on
         }
         try {
             urlCodec.decode("%A");
             fail("DecoderException should have been thrown");
-        } catch (DecoderException e) {
+        } catch (final DecoderException e) {
             // Expected. Move on
         }
         try {
             // Bad 1st char after %
             urlCodec.decode("%WW");
             fail("DecoderException should have been thrown");
-        } catch (DecoderException e) {
+        } catch (final DecoderException e) {
             // Expected. Move on
         }
         try {
             // Bad 2nd char after %
             urlCodec.decode("%0W");
             fail("DecoderException should have been thrown");
-        } catch (DecoderException e) {
+        } catch (final DecoderException e) {
             // Expected. Move on
         }
         this.validateState(urlCodec);
@@ -163,10 +163,10 @@ public class URLCodecTest {
 
     @Test
     public void testDecodeInvalidContent() throws UnsupportedEncodingException, DecoderException
{
-        String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
-        URLCodec urlCodec = new URLCodec();
-        byte[] input = ch_msg.getBytes("ISO-8859-1");
-        byte[] output = urlCodec.decode(input);
+        final String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
+        final URLCodec urlCodec = new URLCodec();
+        final byte[] input = ch_msg.getBytes("ISO-8859-1");
+        final byte[] output = urlCodec.decode(input);
         assertEquals(input.length, output.length);
         for (int i = 0; i < input.length; i++) {
             assertEquals(input[i], output[i]);
@@ -176,9 +176,9 @@ public class URLCodecTest {
 
     @Test
     public void testEncodeNull() throws Exception {
-        URLCodec urlCodec = new URLCodec();
-        byte[] plain = null;
-        byte[] encoded = urlCodec.encode(plain);
+        final URLCodec urlCodec = new URLCodec();
+        final byte[] plain = null;
+        final byte[] encoded = urlCodec.encode(plain);
         assertEquals("Encoding a null string should return null",
             null, encoded);
         this.validateState(urlCodec);
@@ -186,9 +186,9 @@ public class URLCodecTest {
 
     @Test
     public void testEncodeUrlWithNullBitSet() throws Exception {
-        URLCodec urlCodec = new URLCodec();
-        String plain = "Hello there!";
-        String encoded = new String( URLCodec.encodeUrl(null, plain.getBytes(Charsets.UTF_8)));
+        final URLCodec urlCodec = new URLCodec();
+        final String plain = "Hello there!";
+        final String encoded = new String( URLCodec.encodeUrl(null, plain.getBytes(Charsets.UTF_8)));
         assertEquals("Basic URL encoding test",
             "Hello+there%21", encoded);
         assertEquals("Basic URL decoding test",
@@ -198,49 +198,49 @@ public class URLCodecTest {
 
     @Test
     public void testDecodeWithNullArray() throws Exception {
-        byte[] plain = null;
-        byte[] result = URLCodec.decodeUrl( plain );
+        final byte[] plain = null;
+        final byte[] result = URLCodec.decodeUrl( plain );
         assertEquals("Result should be null", null, result);
     }
 
     @Test
     public void testEncodeStringWithNull() throws Exception {
-        URLCodec urlCodec = new URLCodec();
-        String test = null;
-        String result = urlCodec.encode( test, "charset" );
+        final URLCodec urlCodec = new URLCodec();
+        final String test = null;
+        final String result = urlCodec.encode( test, "charset" );
         assertEquals("Result should be null", null, result);
     }
 
     @Test
     public void testDecodeStringWithNull() throws Exception {
-        URLCodec urlCodec = new URLCodec();
-        String test = null;
-        String result = urlCodec.decode( test, "charset" );
+        final URLCodec urlCodec = new URLCodec();
+        final String test = null;
+        final String result = urlCodec.decode( test, "charset" );
         assertEquals("Result should be null", null, result);
     }
 
     @Test
     public void testEncodeObjects() throws Exception {
-        URLCodec urlCodec = new URLCodec();
-        String plain = "Hello there!";
+        final URLCodec urlCodec = new URLCodec();
+        final String plain = "Hello there!";
         String encoded = (String) urlCodec.encode((Object) plain);
         assertEquals("Basic URL encoding test",
             "Hello+there%21", encoded);
 
-        byte[] plainBA = plain.getBytes(Charsets.UTF_8);
-        byte[] encodedBA = (byte[]) urlCodec.encode((Object) plainBA);
+        final byte[] plainBA = plain.getBytes(Charsets.UTF_8);
+        final byte[] encodedBA = (byte[]) urlCodec.encode((Object) plainBA);
         encoded = new String(encodedBA);
         assertEquals("Basic URL encoding test",
             "Hello+there%21", encoded);
 
-        Object result = urlCodec.encode((Object) null);
+        final Object result = urlCodec.encode((Object) null);
         assertEquals( "Encoding a null Object should return null", null, result);
 
         try {
-            Object dObj = new Double(3.0);
+            final Object dObj = new Double(3.0);
             urlCodec.encode( dObj );
             fail( "Trying to url encode a Double object should cause an exception.");
-        } catch (EncoderException ee) {
+        } catch (final EncoderException ee) {
             // Exception expected, test segment passes.
         }
         this.validateState(urlCodec);
@@ -248,18 +248,18 @@ public class URLCodecTest {
 
     @Test
     public void testInvalidEncoding() {
-        URLCodec urlCodec = new URLCodec("NONSENSE");
-        String plain = "Hello there!";
+        final URLCodec urlCodec = new URLCodec("NONSENSE");
+        final String plain = "Hello there!";
         try {
             urlCodec.encode(plain);
             fail("We set the encoding to a bogus NONSENSE vlaue, this shouldn't have worked.");
-        } catch (EncoderException ee) {
+        } catch (final EncoderException ee) {
             // Exception expected, test segment passes.
         }
         try {
             urlCodec.decode(plain);
             fail("We set the encoding to a bogus NONSENSE vlaue, this shouldn't have worked.");
-        } catch (DecoderException ee) {
+        } catch (final DecoderException ee) {
             // Exception expected, test segment passes.
         }
         this.validateState(urlCodec);
@@ -267,26 +267,26 @@ public class URLCodecTest {
 
     @Test
     public void testDecodeObjects() throws Exception {
-        URLCodec urlCodec = new URLCodec();
-        String plain = "Hello+there%21";
+        final URLCodec urlCodec = new URLCodec();
+        final String plain = "Hello+there%21";
         String decoded = (String) urlCodec.decode((Object) plain);
         assertEquals("Basic URL decoding test",
             "Hello there!", decoded);
 
-        byte[] plainBA = plain.getBytes(Charsets.UTF_8);
-        byte[] decodedBA = (byte[]) urlCodec.decode((Object) plainBA);
+        final byte[] plainBA = plain.getBytes(Charsets.UTF_8);
+        final byte[] decodedBA = (byte[]) urlCodec.decode((Object) plainBA);
         decoded = new String(decodedBA);
         assertEquals("Basic URL decoding test",
             "Hello there!", decoded);
 
-        Object result = urlCodec.decode((Object) null);
+        final Object result = urlCodec.decode((Object) null);
         assertEquals( "Decoding a null Object should return null", null, result);
 
         try {
-            Object dObj = new Double(3.0);
+            final Object dObj = new Double(3.0);
             urlCodec.decode( dObj );
             fail( "Trying to url encode a Double object should cause an exception.");
-        } catch (DecoderException ee) {
+        } catch (final DecoderException ee) {
             // Exception expected, test segment passes.
         }
         this.validateState(urlCodec);
@@ -294,11 +294,11 @@ public class URLCodecTest {
 
     @Test
     public void testDefaultEncoding() throws Exception {
-        String plain = "Hello there!";
-        URLCodec urlCodec = new URLCodec("UnicodeBig");
+        final String plain = "Hello there!";
+        final URLCodec urlCodec = new URLCodec("UnicodeBig");
         urlCodec.encode(plain); // To work around a weird quirk in Java 1.2.2
-        String encoded1 = urlCodec.encode(plain, "UnicodeBig");
-        String encoded2 = urlCodec.encode(plain);
+        final String encoded1 = urlCodec.encode(plain, "UnicodeBig");
+        final String encoded2 = urlCodec.encode(plain);
         assertEquals(encoded1, encoded2);
         this.validateState(urlCodec);
     }



Mime
View raw message