commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1308111 - in /commons/proper/codec/trunk/src/test/java/org/apache/commons/codec: binary/Base32Test.java binary/Base64Codec13Test.java binary/Base64Test.java binary/BinaryCodecTest.java net/QuotedPrintableCodecTest.java net/URLCodecTest.java
Date Sun, 01 Apr 2012 13:31:47 GMT
Author: ggregory
Date: Sun Apr  1 13:31:46 2012
New Revision: 1308111

URL: http://svn.apache.org/viewvc?rev=1308111&view=rev
Log:
Organize imports.

Modified:
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32Test.java
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/QuotedPrintableCodecTest.java
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/URLCodecTest.java

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=1308111&r1=1308110&r2=1308111&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
Sun Apr  1 13:31:46 2012
@@ -23,6 +23,7 @@ import static org.junit.Assert.fail;
 
 import java.util.Arrays;
 
+import org.apache.commons.codec.Charsets;
 import org.junit.Test;
 
 public class Base32Test {
@@ -62,7 +63,7 @@ public class Base32Test {
     public void testBase32Samples() throws Exception {
         Base32 codec = new Base32();
         for (String[] element : BASE32_TEST_CASES) {
-                assertEquals(element[1], codec.encodeAsString(element[0].getBytes("UTF-8")));
+                assertEquals(element[1], codec.encodeAsString(element[0].getBytes(Charsets.UTF_8)));
         }
     }
 
@@ -70,7 +71,7 @@ public class Base32Test {
     public void testBase32HexSamples() throws Exception {
         Base32 codec = new Base32(true);
         for (String[] element : BASE32HEX_TEST_CASES) {
-                assertEquals(element[1], codec.encodeAsString(element[0].getBytes("UTF-8")));
+                assertEquals(element[1], codec.encodeAsString(element[0].getBytes(Charsets.UTF_8)));
         }
     }
 
@@ -78,7 +79,7 @@ public class Base32Test {
     public void testBase32Chunked () throws Exception {
         Base32 codec = new Base32(20);
         for (String[] element : BASE32_TEST_CASES_CHUNKED) {
-                assertEquals(element[1], codec.encodeAsString(element[0].getBytes("UTF-8")));
+                assertEquals(element[1], codec.encodeAsString(element[0].getBytes(Charsets.UTF_8)));
         }        
     }
 

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=1308111&r1=1308110&r2=1308111&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
Sun Apr  1 13:31:46 2012
@@ -19,11 +19,11 @@ package org.apache.commons.codec.binary;
 
 import static org.junit.Assert.assertTrue;
 
-import java.io.UnsupportedEncodingException;
 import java.util.Arrays;
 
 import org.apache.commons.codec.BinaryDecoder;
 import org.apache.commons.codec.BinaryEncoder;
+import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.Decoder;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.Encoder;
@@ -510,10 +510,6 @@ public class Base64Codec13Test {
         // need this class to be able to run against commons-codec-1.3.jar, hence the
         // duplication here.
         
-        try {
-            return s != null ? s.getBytes("UTF-8") : null;
-        } catch (UnsupportedEncodingException e) {
-            throw new IllegalStateException(e.toString());
-        }
+        return s != null ? s.getBytes(Charsets.UTF_8) : null;
     }
 }

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=1308111&r1=1308110&r2=1308111&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
Sun Apr  1 13:31:46 2012
@@ -28,6 +28,7 @@ import java.math.BigInteger;
 import java.util.Arrays;
 import java.util.Random;
 
+import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.junit.Ignore;
@@ -127,7 +128,7 @@ public class Base64Test {
         BigInteger bigInt1 = new BigInteger("85739377120809420210425962799" + "0318636601332086981");
 
         assertEquals(encodedInt1, new String(Base64.encodeInteger(bigInt1)));
-        assertEquals(bigInt1, Base64.decodeInteger(encodedInt1.getBytes("UTF-8")));
+        assertEquals(bigInt1, Base64.decodeInteger(encodedInt1.getBytes(Charsets.UTF_8)));
     }
 
     @Test
@@ -136,7 +137,7 @@ public class Base64Test {
         BigInteger bigInt2 = new BigInteger("13936727572861167254666467268" + "91466679477132949611");
 
         assertEquals(encodedInt2, new String(Base64.encodeInteger(bigInt2)));
-        assertEquals(bigInt2, Base64.decodeInteger(encodedInt2.getBytes("UTF-8")));
+        assertEquals(bigInt2, Base64.decodeInteger(encodedInt2.getBytes(Charsets.UTF_8)));
     }
 
     @Test
@@ -147,7 +148,7 @@ public class Base64Test {
             + "4495062430572478766856090958495998158114332651671116876320938126");
 
         assertEquals(encodedInt3, new String(Base64.encodeInteger(bigInt3)));
-        assertEquals(bigInt3, Base64.decodeInteger(encodedInt3.getBytes("UTF-8")));
+        assertEquals(bigInt3, Base64.decodeInteger(encodedInt3.getBytes(Charsets.UTF_8)));
     }
 
     @Test
@@ -164,7 +165,7 @@ public class Base64Test {
             + "53542091716518238707344493641683483917");
 
         assertEquals(encodedInt4, new String(Base64.encodeInteger(bigInt4)));
-        assertEquals(bigInt4, Base64.decodeInteger(encodedInt4.getBytes("UTF-8")));
+        assertEquals(bigInt4, Base64.decodeInteger(encodedInt4.getBytes(Charsets.UTF_8)));
     }
 
     @Test
@@ -249,7 +250,7 @@ public class Base64Test {
      */
     @Test
     public void testDecodePadMarkerIndex2() throws UnsupportedEncodingException {
-        assertEquals("A", new String(Base64.decodeBase64("QQ==".getBytes("UTF-8"))));
+        assertEquals("A", new String(Base64.decodeBase64("QQ==".getBytes(Charsets.UTF_8))));
     }
 
     /**
@@ -257,30 +258,30 @@ public class Base64Test {
      */
     @Test
     public void testDecodePadMarkerIndex3() throws UnsupportedEncodingException {
-        assertEquals("AA", new String(Base64.decodeBase64("QUE=".getBytes("UTF-8"))));
-        assertEquals("AAA", new String(Base64.decodeBase64("QUFB".getBytes("UTF-8"))));
+        assertEquals("AA", new String(Base64.decodeBase64("QUE=".getBytes(Charsets.UTF_8))));
+        assertEquals("AAA", new String(Base64.decodeBase64("QUFB".getBytes(Charsets.UTF_8))));
     }
 
     @Test
     public void testDecodePadOnly() throws UnsupportedEncodingException {
-        assertEquals(0, Base64.decodeBase64("====".getBytes("UTF-8")).length);
-        assertEquals("", new String(Base64.decodeBase64("====".getBytes("UTF-8"))));
+        assertEquals(0, Base64.decodeBase64("====".getBytes(Charsets.UTF_8)).length);
+        assertEquals("", new String(Base64.decodeBase64("====".getBytes(Charsets.UTF_8))));
         // Test truncated padding
-        assertEquals(0, Base64.decodeBase64("===".getBytes("UTF-8")).length);
-        assertEquals(0, Base64.decodeBase64("==".getBytes("UTF-8")).length);
-        assertEquals(0, Base64.decodeBase64("=".getBytes("UTF-8")).length);
-        assertEquals(0, Base64.decodeBase64("".getBytes("UTF-8")).length);
+        assertEquals(0, Base64.decodeBase64("===".getBytes(Charsets.UTF_8)).length);
+        assertEquals(0, Base64.decodeBase64("==".getBytes(Charsets.UTF_8)).length);
+        assertEquals(0, Base64.decodeBase64("=".getBytes(Charsets.UTF_8)).length);
+        assertEquals(0, Base64.decodeBase64("".getBytes(Charsets.UTF_8)).length);
     }
 
     @Test
     public void testDecodePadOnlyChunked() throws UnsupportedEncodingException {
-        assertEquals(0, Base64.decodeBase64("====\n".getBytes("UTF-8")).length);
-        assertEquals("", new String(Base64.decodeBase64("====\n".getBytes("UTF-8"))));
+        assertEquals(0, Base64.decodeBase64("====\n".getBytes(Charsets.UTF_8)).length);
+        assertEquals("", new String(Base64.decodeBase64("====\n".getBytes(Charsets.UTF_8))));
         // Test truncated padding
-        assertEquals(0, Base64.decodeBase64("===\n".getBytes("UTF-8")).length);
-        assertEquals(0, Base64.decodeBase64("==\n".getBytes("UTF-8")).length);
-        assertEquals(0, Base64.decodeBase64("=\n".getBytes("UTF-8")).length);
-        assertEquals(0, Base64.decodeBase64("\n".getBytes("UTF-8")).length);
+        assertEquals(0, Base64.decodeBase64("===\n".getBytes(Charsets.UTF_8)).length);
+        assertEquals(0, Base64.decodeBase64("==\n".getBytes(Charsets.UTF_8)).length);
+        assertEquals(0, Base64.decodeBase64("=\n".getBytes(Charsets.UTF_8)).length);
+        assertEquals(0, Base64.decodeBase64("\n".getBytes(Charsets.UTF_8)).length);
     }
 
     @Test
@@ -288,7 +289,7 @@ public class Base64Test {
 
         String orig = "I am a late night coder.";
 
-        byte[] encodedArray = Base64.encodeBase64(orig.getBytes("UTF-8"));
+        byte[] encodedArray = Base64.encodeBase64(orig.getBytes(Charsets.UTF_8));
         StringBuffer intermediate = new StringBuffer(new String(encodedArray));
 
         intermediate.insert(2, ' ');
@@ -296,7 +297,7 @@ public class Base64Test {
         intermediate.insert(10, '\r');
         intermediate.insert(15, '\n');
 
-        byte[] encodedWithWS = intermediate.toString().getBytes("UTF-8");
+        byte[] encodedWithWS = intermediate.toString().getBytes(Charsets.UTF_8);
         byte[] decodedWithWS = Base64.decodeBase64(encodedWithWS);
 
         String dest = new String(decodedWithWS);
@@ -373,7 +374,7 @@ public class Base64Test {
     @Test
     public void testIgnoringNonBase64InDecode() throws Exception {
         assertEquals("The quick brown fox jumped over the lazy dogs.", new String(Base64
-                .decodeBase64("VGhlIH@$#$@%F1aWN@#@#@@rIGJyb3duIGZve\n\r\t%#%#%#%CBqd##$#$W1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==".getBytes("UTF-8"))));
+                .decodeBase64("VGhlIH@$#$@%F1aWN@#@#@@rIGJyb3duIGZve\n\r\t%#%#%#%CBqd##$#$W1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==".getBytes(Charsets.UTF_8))));
     }
 
     @Test
@@ -409,37 +410,37 @@ public class Base64Test {
     @Test
     public void testKnownDecodings() throws UnsupportedEncodingException {
         assertEquals("The quick brown fox jumped over the lazy dogs.", new String(Base64
-                .decodeBase64("VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==".getBytes("UTF-8"))));
+                .decodeBase64("VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==".getBytes(Charsets.UTF_8))));
         assertEquals("It was the best of times, it was the worst of times.", new String(Base64
-                .decodeBase64("SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLg==".getBytes("UTF-8"))));
+                .decodeBase64("SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLg==".getBytes(Charsets.UTF_8))));
         assertEquals("http://jakarta.apache.org/commmons", new String(Base64
-                .decodeBase64("aHR0cDovL2pha2FydGEuYXBhY2hlLm9yZy9jb21tbW9ucw==".getBytes("UTF-8"))));
+                .decodeBase64("aHR0cDovL2pha2FydGEuYXBhY2hlLm9yZy9jb21tbW9ucw==".getBytes(Charsets.UTF_8))));
         assertEquals("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz", new String(Base64
-                .decodeBase64("QWFCYkNjRGRFZUZmR2dIaElpSmpLa0xsTW1Obk9vUHBRcVJyU3NUdFV1VnZXd1h4WXlaeg==".getBytes("UTF-8"))));
+                .decodeBase64("QWFCYkNjRGRFZUZmR2dIaElpSmpLa0xsTW1Obk9vUHBRcVJyU3NUdFV1VnZXd1h4WXlaeg==".getBytes(Charsets.UTF_8))));
         assertEquals("{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }", new String(Base64.decodeBase64("eyAwLCAxLCAyLCAzLCA0LCA1LCA2LCA3LCA4LCA5IH0="
-                .getBytes("UTF-8"))));
-        assertEquals("xyzzy!", new String(Base64.decodeBase64("eHl6enkh".getBytes("UTF-8"))));
+                .getBytes(Charsets.UTF_8))));
+        assertEquals("xyzzy!", new String(Base64.decodeBase64("eHl6enkh".getBytes(Charsets.UTF_8))));
     }
 
     @Test
     public void testKnownEncodings() throws UnsupportedEncodingException {
         assertEquals("VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==",
new String(Base64
-                .encodeBase64("The quick brown fox jumped over the lazy dogs.".getBytes("UTF-8"))));
+                .encodeBase64("The quick brown fox jumped over the lazy dogs.".getBytes(Charsets.UTF_8))));
         assertEquals(
                 "YmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJs\r\nYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFo\r\nIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBi\r\nbGFoIGJsYWg=\r\n",
                 new String(
                         Base64
                                 .encodeBase64Chunked("blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah"
-                                        .getBytes("UTF-8"))));
+                                        .getBytes(Charsets.UTF_8))));
         assertEquals("SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLg==",
new String(Base64
-                .encodeBase64("It was the best of times, it was the worst of times.".getBytes("UTF-8"))));
+                .encodeBase64("It was the best of times, it was the worst of times.".getBytes(Charsets.UTF_8))));
         assertEquals("aHR0cDovL2pha2FydGEuYXBhY2hlLm9yZy9jb21tbW9ucw==", new String(Base64
-                .encodeBase64("http://jakarta.apache.org/commmons".getBytes("UTF-8"))));
+                .encodeBase64("http://jakarta.apache.org/commmons".getBytes(Charsets.UTF_8))));
         assertEquals("QWFCYkNjRGRFZUZmR2dIaElpSmpLa0xsTW1Obk9vUHBRcVJyU3NUdFV1VnZXd1h4WXlaeg==",
new String(Base64
-                .encodeBase64("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz".getBytes("UTF-8"))));
+                .encodeBase64("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz".getBytes(Charsets.UTF_8))));
         assertEquals("eyAwLCAxLCAyLCAzLCA0LCA1LCA2LCA3LCA4LCA5IH0=", new String(Base64.encodeBase64("{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }"
-                .getBytes("UTF-8"))));
-        assertEquals("eHl6enkh", new String(Base64.encodeBase64("xyzzy!".getBytes("UTF-8"))));
+                .getBytes(Charsets.UTF_8))));
+        assertEquals("eHl6enkh", new String(Base64.encodeBase64("xyzzy!".getBytes(Charsets.UTF_8))));
     }
 
     @Test
@@ -481,7 +482,7 @@ public class Base64Test {
     public void testObjectDecodeWithValidParameter() throws Exception {
 
         String original = "Hello World!";
-        Object o = Base64.encodeBase64(original.getBytes("UTF-8"));
+        Object o = Base64.encodeBase64(original.getBytes(Charsets.UTF_8));
 
         Base64 b64 = new Base64();
         Object oDecoded = b64.decode(o);
@@ -506,7 +507,7 @@ public class Base64Test {
     public void testObjectEncodeWithValidParameter() throws Exception {
 
         String original = "Hello World!";
-        Object origObj = original.getBytes("UTF-8");
+        Object origObj = original.getBytes(Charsets.UTF_8);
 
         Base64 b64 = new Base64();
         Object oEncoded = b64.encode(origObj);
@@ -519,7 +520,7 @@ public class Base64Test {
     @Test
     public void testObjectEncode() throws Exception {
         Base64 b64 = new Base64();
-        assertEquals("SGVsbG8gV29ybGQ=", new String(b64.encode("Hello World".getBytes("UTF-8"))));
+        assertEquals("SGVsbG8gV29ybGQ=", new String(b64.encode("Hello World".getBytes(Charsets.UTF_8))));
     }
 
     @Test

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java?rev=1308111&r1=1308110&r2=1308111&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java
(original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java
Sun Apr  1 13:31:46 2012
@@ -22,6 +22,7 @@ import static org.junit.Assert.fail;
 
 import java.io.UnsupportedEncodingException;
 
+import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.junit.After;
@@ -182,7 +183,7 @@ public class BinaryCodecTest {
         if (encodeMe == null) {
             decoded = instance.decode((byte[]) null);
         } else {
-            decoded = (byte[]) instance.decode((Object) encodeMe.getBytes("UTF-8"));
+            decoded = (byte[]) instance.decode((Object) encodeMe.getBytes(Charsets.UTF_8));
         }
         assertEquals(new String(bits), new String(decoded));
         if (encodeMe == null) {
@@ -200,84 +201,84 @@ public class BinaryCodecTest {
     public void testDecodeByteArray() throws UnsupportedEncodingException {
         // With a single raw binary
         byte[] bits = new byte[1];
-        byte[] decoded = instance.decode("00000000".getBytes("UTF-8"));
+        byte[] decoded = instance.decode("00000000".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0;
-        decoded = instance.decode("00000001".getBytes("UTF-8"));
+        decoded = instance.decode("00000001".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1;
-        decoded = instance.decode("00000011".getBytes("UTF-8"));
+        decoded = instance.decode("00000011".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1 | BIT_2;
-        decoded = instance.decode("00000111".getBytes("UTF-8"));
+        decoded = instance.decode("00000111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
-        decoded = instance.decode("00001111".getBytes("UTF-8"));
+        decoded = instance.decode("00001111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
-        decoded = instance.decode("00011111".getBytes("UTF-8"));
+        decoded = instance.decode("00011111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
-        decoded = instance.decode("00111111".getBytes("UTF-8"));
+        decoded = instance.decode("00111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
-        decoded = instance.decode("01111111".getBytes("UTF-8"));
+        decoded = instance.decode("01111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = instance.decode("11111111".getBytes("UTF-8"));
+        decoded = instance.decode("11111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         // With a two raw binaries
         bits = new byte[2];
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = instance.decode("0000000011111111".getBytes("UTF-8"));
+        decoded = instance.decode("0000000011111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = instance.decode("0000000111111111".getBytes("UTF-8"));
+        decoded = instance.decode("0000000111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = instance.decode("0000001111111111".getBytes("UTF-8"));
+        decoded = instance.decode("0000001111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1 | BIT_2;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = instance.decode("0000011111111111".getBytes("UTF-8"));
+        decoded = instance.decode("0000011111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = instance.decode("0000111111111111".getBytes("UTF-8"));
+        decoded = instance.decode("0000111111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = instance.decode("0001111111111111".getBytes("UTF-8"));
+        decoded = instance.decode("0001111111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = instance.decode("0011111111111111".getBytes("UTF-8"));
+        decoded = instance.decode("0011111111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = instance.decode("0111111111111111".getBytes("UTF-8"));
+        decoded = instance.decode("0111111111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = instance.decode("1111111111111111".getBytes("UTF-8"));
+        decoded = instance.decode("1111111111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
     }
 
@@ -485,84 +486,84 @@ public class BinaryCodecTest {
         assertEquals(0, BinaryCodec.fromAscii(new byte[0]).length);
         // With a single raw binary
         byte[] bits = new byte[1];
-        byte[] decoded = BinaryCodec.fromAscii("00000000".getBytes("UTF-8"));
+        byte[] decoded = BinaryCodec.fromAscii("00000000".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0;
-        decoded = BinaryCodec.fromAscii("00000001".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("00000001".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1;
-        decoded = BinaryCodec.fromAscii("00000011".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("00000011".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1 | BIT_2;
-        decoded = BinaryCodec.fromAscii("00000111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("00000111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
-        decoded = BinaryCodec.fromAscii("00001111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("00001111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
-        decoded = BinaryCodec.fromAscii("00011111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("00011111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
-        decoded = BinaryCodec.fromAscii("00111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("00111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
-        decoded = BinaryCodec.fromAscii("01111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("01111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[1];
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = BinaryCodec.fromAscii("11111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("11111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         // With a two raw binaries
         bits = new byte[2];
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = BinaryCodec.fromAscii("0000000011111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("0000000011111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = BinaryCodec.fromAscii("0000000111111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("0000000111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = BinaryCodec.fromAscii("0000001111111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("0000001111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1 | BIT_2;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = BinaryCodec.fromAscii("0000011111111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("0000011111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = BinaryCodec.fromAscii("0000111111111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("0000111111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = BinaryCodec.fromAscii("0001111111111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("0001111111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = BinaryCodec.fromAscii("0011111111111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("0011111111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = BinaryCodec.fromAscii("0111111111111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("0111111111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         bits = new byte[2];
         bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
         bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
-        decoded = BinaryCodec.fromAscii("1111111111111111".getBytes("UTF-8"));
+        decoded = BinaryCodec.fromAscii("1111111111111111".getBytes(Charsets.UTF_8));
         assertEquals(new String(bits), new String(decoded));
         assertEquals(0, BinaryCodec.fromAscii((byte[]) null).length);
     }

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=1308111&r1=1308110&r2=1308111&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
Sun Apr  1 13:31:46 2012
@@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
 import java.nio.charset.UnsupportedCharsetException;
 
 import org.apache.commons.codec.CharEncoding;
+import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.junit.Ignore;
@@ -154,7 +155,7 @@ public class QuotedPrintableCodecTest {
         QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
         String plain = "1+1 = 2";
         String encoded = new String(QuotedPrintableCodec.
-            encodeQuotedPrintable(null, plain.getBytes("UTF-8")));
+            encodeQuotedPrintable(null, plain.getBytes(Charsets.UTF_8)));
         assertEquals("Basic quoted-printable encoding test", 
             "1+1 =3D 2", encoded);
         assertEquals("Basic quoted-printable decoding test", 
@@ -193,7 +194,7 @@ public class QuotedPrintableCodecTest {
         assertEquals("Basic quoted-printable encoding test", 
             "1+1 =3D 2", encoded);
 
-        byte[] plainBA = plain.getBytes("UTF-8");
+        byte[] plainBA = plain.getBytes(Charsets.UTF_8);
         byte[] encodedBA = (byte[]) qpcodec.encode((Object) plainBA);
         encoded = new String(encodedBA);
         assertEquals("Basic quoted-printable encoding test", 
@@ -224,7 +225,7 @@ public class QuotedPrintableCodecTest {
         assertEquals("Basic quoted-printable decoding test", 
             "1+1 = 2", decoded);
 
-        byte[] plainBA = plain.getBytes("UTF-8");
+        byte[] plainBA = plain.getBytes(Charsets.UTF_8);
         byte[] decodedBA = (byte[]) qpcodec.decode((Object) plainBA);
         decoded = new String(decodedBA);
         assertEquals("Basic quoted-printable decoding test", 

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=1308111&r1=1308110&r2=1308111&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
Sun Apr  1 13:31:46 2012
@@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
 import java.io.UnsupportedEncodingException;
 
 import org.apache.commons.codec.CharEncoding;
+import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.junit.Test;
@@ -187,7 +188,7 @@ public class URLCodecTest {
     public void testEncodeUrlWithNullBitSet() throws Exception {
         URLCodec urlCodec = new URLCodec();
         String plain = "Hello there!";
-        String encoded = new String( URLCodec.encodeUrl(null, plain.getBytes("UTF-8")));
+        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", 
@@ -226,7 +227,7 @@ public class URLCodecTest {
         assertEquals("Basic URL encoding test", 
             "Hello+there%21", encoded);
 
-        byte[] plainBA = plain.getBytes("UTF-8");
+        byte[] plainBA = plain.getBytes(Charsets.UTF_8);
         byte[] encodedBA = (byte[]) urlCodec.encode((Object) plainBA);
         encoded = new String(encodedBA);
         assertEquals("Basic URL encoding test", 
@@ -272,7 +273,7 @@ public class URLCodecTest {
         assertEquals("Basic URL decoding test", 
             "Hello there!", decoded);
 
-        byte[] plainBA = plain.getBytes("UTF-8");
+        byte[] plainBA = plain.getBytes(Charsets.UTF_8);
         byte[] decodedBA = (byte[]) urlCodec.decode((Object) plainBA);
         decoded = new String(decodedBA);
         assertEquals("Basic URL decoding test", 



Mime
View raw message