hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1558078 - in /httpcomponents/httpcore/trunk: httpcore-ab/src/main/java/org/apache/http/benchmark/ httpcore-nio/src/main/java/org/apache/http/nio/entity/ httpcore-nio/src/test/java/org/apache/http/ httpcore-nio/src/test/java/org/apache/http...
Date Tue, 14 Jan 2014 15:23:08 GMT
Author: olegk
Date: Tue Jan 14 15:23:07 2014
New Revision: 1558078

URL: http://svn.apache.org/r1558078
Log:
Use String methods and constructors that require Charset instead of String

Modified:
    httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/ReadableByteChannelMock.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncPrematureTermination.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/SessionInputBufferMock.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEntityUtils.java

Modified: httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java Tue Jan 14 15:23:07 2014
@@ -176,7 +176,7 @@ class BenchmarkWorker implements Runnabl
                     while ((l = instream.read(this.buffer)) != -1) {
                         contentlen += l;
                         if (config.getVerbosity() >= 4) {
-                            final String s = new String(this.buffer, 0, l, charset.name());
+                            final String s = new String(this.buffer, 0, l, charset);
                             System.out.print(s);
                         }
                     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java Tue Jan 14 15:23:07 2014
@@ -34,7 +34,6 @@ import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
-import java.nio.charset.UnsupportedCharsetException;
 
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.entity.AbstractHttpEntity;
@@ -86,12 +85,7 @@ public class NStringEntity extends Abstr
         if (charset == null) {
             charset = HTTP.DEF_CONTENT_CHARSET;
         }
-        try {
-            this.b = s.getBytes(charset.name());
-        } catch (final UnsupportedEncodingException ex) {
-            // should never happen
-            throw new UnsupportedCharsetException(charset.name());
-        }
+        this.b = s.getBytes(charset);
         this.buf = ByteBuffer.wrap(this.b);
         this.content = b;
         this.buffer = this.buf;
@@ -109,7 +103,7 @@ public class NStringEntity extends Abstr
      *   is {@link HTTP#DEF_CONTENT_CHARSET} is assumed
      *
      * @throws IllegalArgumentException if the string parameter is null
-     * @throws UnsupportedCharsetException Thrown when the named charset is not available in
+     * @throws UnsupportedEncodingException Thrown when the named charset is not available in
      * this instance of the Java virtual machine
      */
     public NStringEntity(final String s, final String charset)

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/ReadableByteChannelMock.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/ReadableByteChannelMock.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/ReadableByteChannelMock.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/ReadableByteChannelMock.java Tue Jan 14 15:23:07 2014
@@ -33,8 +33,6 @@ import java.nio.channels.ClosedChannelEx
 import java.nio.channels.ReadableByteChannel;
 import java.nio.charset.Charset;
 
-import org.apache.http.util.EncodingUtils;
-
 public class ReadableByteChannelMock implements ReadableByteChannel {
 
     private final String[] chunks;
@@ -57,7 +55,7 @@ public class ReadableByteChannelMock imp
             if (this.chunkCount < this.chunks.length) {
                 final String s = this.chunks[this.chunkCount];
                 this.chunkCount++;
-                this.currentChunk = ByteBuffer.wrap(EncodingUtils.getBytes(s, this.charset.name()));
+                this.currentChunk = ByteBuffer.wrap(s.getBytes(this.charset));
             } else {
                 this.eof = true;
             }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java Tue Jan 14 15:23:07 2014
@@ -28,7 +28,6 @@
 package org.apache.http;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.WritableByteChannel;
@@ -89,11 +88,7 @@ public class WritableByteChannelMock imp
 
         private static String toString(
             final byte[] b, final int off, final int len, final Charset charset) {
-            try {
-                return new String(b, off, len, charset.name());
-            } catch (final UnsupportedEncodingException e) {
-                return new String(b, off, len);
-            }
+            return new String(b, off, len, charset);
         }
 
         public String dump(final Charset charset) {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java Tue Jan 14 15:23:07 2014
@@ -32,6 +32,7 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.Charset;
 
 import org.apache.http.Consts;
 import org.apache.http.HttpException;
@@ -50,14 +51,14 @@ import org.junit.Test;
  */
 public class TestHttpMessageParser {
 
-    private static ReadableByteChannel newChannel(final String s, final String charset)
+    private static ReadableByteChannel newChannel(final String s, final Charset charset)
             throws UnsupportedEncodingException {
         return Channels.newChannel(new ByteArrayInputStream(s.getBytes(charset)));
     }
 
     private static ReadableByteChannel newChannel(final String s)
             throws UnsupportedEncodingException {
-        return newChannel(s, "US-ASCII");
+        return newChannel(s, Consts.ASCII);
     }
 
     @Test

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java Tue Jan 14 15:23:07 2014
@@ -158,8 +158,8 @@ public class TestIdentityEncoder {
         createTempFile();
         RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
         try {
-            testfile.write("stuff;".getBytes("US-ASCII"));
-            testfile.write("more stuff".getBytes("US-ASCII"));
+            testfile.write("stuff;".getBytes(Consts.ASCII));
+            testfile.write("more stuff".getBytes(Consts.ASCII));
         } finally {
             testfile.close();
         }
@@ -218,8 +218,8 @@ public class TestIdentityEncoder {
         createTempFile();
         RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
         try {
-            testfile.write("stuff;".getBytes("US-ASCII"));
-            testfile.write("more stuff".getBytes("US-ASCII"));
+            testfile.write("stuff;".getBytes(Consts.ASCII));
+            testfile.write("more stuff".getBytes(Consts.ASCII));
         } finally {
             testfile.close();
         }
@@ -250,8 +250,8 @@ public class TestIdentityEncoder {
         createTempFile();
         RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
         try {
-            testfile.write("stuff;".getBytes("US-ASCII"));
-            testfile.write("more stuff".getBytes("US-ASCII"));
+            testfile.write("stuff;".getBytes(Consts.ASCII));
+            testfile.write("more stuff".getBytes(Consts.ASCII));
         } finally {
             testfile.close();
         }
@@ -282,7 +282,7 @@ public class TestIdentityEncoder {
         createTempFile();
         RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
         try {
-            testfile.write("stuff".getBytes("US-ASCII"));
+            testfile.write("stuff".getBytes(Consts.ASCII));
         } finally {
             testfile.close();
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java Tue Jan 14 15:23:07 2014
@@ -182,8 +182,8 @@ public class TestLengthDelimitedEncoder 
         createTempFile();
         RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
         try {
-            testfile.write("stuff;".getBytes("US-ASCII"));
-            testfile.write("more stuff; and a lot more stuff".getBytes("US-ASCII"));
+            testfile.write("stuff;".getBytes(Consts.ASCII));
+            testfile.write("more stuff; and a lot more stuff".getBytes(Consts.ASCII));
         } finally {
             testfile.close();
         }
@@ -245,7 +245,7 @@ public class TestLengthDelimitedEncoder 
         createTempFile();
         RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
         try {
-            testfile.write("more stuff".getBytes("US-ASCII"));
+            testfile.write("more stuff".getBytes(Consts.ASCII));
         } finally {
             testfile.close();
         }
@@ -274,8 +274,8 @@ public class TestLengthDelimitedEncoder 
         createTempFile();
         RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
         try {
-            testfile.write("stuff;".getBytes("US-ASCII"));
-            testfile.write("more stuff".getBytes("US-ASCII"));
+            testfile.write("stuff;".getBytes(Consts.ASCII));
+            testfile.write("more stuff".getBytes(Consts.ASCII));
         } finally {
             testfile.close();
         }
@@ -307,8 +307,8 @@ public class TestLengthDelimitedEncoder 
         createTempFile();
         RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
         try {
-            testfile.write("stuff;".getBytes("US-ASCII"));
-            testfile.write("more stuff".getBytes("US-ASCII"));
+            testfile.write("stuff;".getBytes(Consts.ASCII));
+            testfile.write("more stuff".getBytes(Consts.ASCII));
         } finally {
             testfile.close();
         }
@@ -340,7 +340,7 @@ public class TestLengthDelimitedEncoder 
         createTempFile();
         RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
         try {
-            testfile.write("stuff".getBytes("US-ASCII"));
+            testfile.write("stuff".getBytes(Consts.ASCII));
         } finally {
             testfile.close();
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java Tue Jan 14 15:23:07 2014
@@ -35,6 +35,7 @@ import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.WritableByteChannel;
 import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CodingErrorAction;
@@ -83,14 +84,14 @@ public class TestSessionInOutBuffers {
         return Channels.newChannel(new ByteArrayInputStream(bytes));
     }
 
-    private static ReadableByteChannel newChannel(final String s, final String charset)
+    private static ReadableByteChannel newChannel(final String s, final Charset charset)
             throws UnsupportedEncodingException {
         return Channels.newChannel(new ByteArrayInputStream(s.getBytes(charset)));
     }
 
     private static ReadableByteChannel newChannel(final String s)
             throws UnsupportedEncodingException {
-        return newChannel(s, "US-ASCII");
+        return newChannel(s, Consts.ASCII);
     }
 
     @Test
@@ -239,7 +240,7 @@ public class TestSessionInOutBuffers {
         }
         final String s1 = buffer.toString();
         buffer.append("\r\n");
-        outbuf.write(ByteBuffer.wrap(buffer.toString().getBytes("US-ASCII")));
+        outbuf.write(ByteBuffer.wrap(buffer.toString().getBytes(Consts.ASCII)));
 
         buffer.setLength(0);
         for (int i = 0; i < 15; i++) {
@@ -247,7 +248,7 @@ public class TestSessionInOutBuffers {
         }
         final String s2 = buffer.toString();
         buffer.append("\r\n");
-        outbuf.write(ByteBuffer.wrap(buffer.toString().getBytes("US-ASCII")));
+        outbuf.write(ByteBuffer.wrap(buffer.toString().getBytes(Consts.ASCII)));
 
         buffer.setLength(0);
         for (int i = 0; i < 16; i++) {
@@ -255,7 +256,7 @@ public class TestSessionInOutBuffers {
         }
         final String s3 = buffer.toString();
         buffer.append("\r\n");
-        outbuf.write(ByteBuffer.wrap(buffer.toString().getBytes("US-ASCII")));
+        outbuf.write(ByteBuffer.wrap(buffer.toString().getBytes(Consts.ASCII)));
 
         outbuf.write(ByteBuffer.wrap(new byte[] {'a'}));
 
@@ -303,7 +304,7 @@ public class TestSessionInOutBuffers {
 
     @Test
     public void testReadByteBuffer() throws Exception {
-        final byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
+        final byte[] pattern = "0123456789ABCDEF".getBytes(Consts.ASCII);
         final ReadableByteChannel channel = newChannel(pattern);
         final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null, this.allocator);
         while (inbuf.fill(channel) > 0) {
@@ -320,7 +321,7 @@ public class TestSessionInOutBuffers {
 
     @Test
     public void testReadByteBufferWithMaxLen() throws Exception {
-        final byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
+        final byte[] pattern = "0123456789ABCDEF".getBytes(Consts.ASCII);
         final ReadableByteChannel channel = newChannel(pattern);
         final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null, this.allocator);
         while (inbuf.fill(channel) > 0) {
@@ -340,7 +341,7 @@ public class TestSessionInOutBuffers {
 
     @Test
     public void testReadToChannel() throws Exception {
-        final byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
+        final byte[] pattern = "0123456789ABCDEF".getBytes(Consts.ASCII);
         final ReadableByteChannel channel = newChannel(pattern);
         final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null, this.allocator);
         while (inbuf.fill(channel) > 0) {
@@ -355,7 +356,7 @@ public class TestSessionInOutBuffers {
 
     @Test
     public void testReadToChannelWithMaxLen() throws Exception {
-        final byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
+        final byte[] pattern = "0123456789ABCDEF".getBytes(Consts.ASCII);
         final ReadableByteChannel channel = newChannel(pattern);
         final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null, this.allocator);
         while (inbuf.fill(channel) > 0) {
@@ -372,7 +373,7 @@ public class TestSessionInOutBuffers {
 
     @Test
     public void testWriteByteBuffer() throws Exception {
-        final byte[] pattern = "0123456789ABCDEF0123456789ABCDEF".getBytes("US-ASCII");
+        final byte[] pattern = "0123456789ABCDEF0123456789ABCDEF".getBytes(Consts.ASCII);
 
         final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(4096, 1024, null, this.allocator);
         final ReadableByteChannel src = newChannel(pattern);
@@ -387,7 +388,7 @@ public class TestSessionInOutBuffers {
 
     @Test
     public void testWriteFromChannel() throws Exception {
-        final byte[] pattern = "0123456789ABCDEF0123456789ABCDEF".getBytes("US-ASCII");
+        final byte[] pattern = "0123456789ABCDEF0123456789ABCDEF".getBytes(Consts.ASCII);
 
         final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(4096, 1024, null, this.allocator);
         outbuf.write(ByteBuffer.wrap(pattern, 0, 16));
@@ -465,7 +466,7 @@ public class TestSessionInOutBuffers {
     @Test(expected=CharacterCodingException.class)
     public void testMalformedInputActionReport() throws Exception {
         final String s = constructString(SWISS_GERMAN_HELLO);
-        final byte[] tmp = s.getBytes("ISO-8859-1");
+        final byte[] tmp = s.getBytes(Consts.ISO_8859_1);
 
         final CharsetDecoder decoder = Consts.UTF_8.newDecoder();
         decoder.onMalformedInput(CodingErrorAction.REPORT);
@@ -480,7 +481,7 @@ public class TestSessionInOutBuffers {
     @Test
     public void testMalformedInputActionIgnore() throws Exception {
         final String s = constructString(SWISS_GERMAN_HELLO);
-        final byte[] tmp = s.getBytes("ISO-8859-1");
+        final byte[] tmp = s.getBytes(Consts.ISO_8859_1);
 
         final CharsetDecoder decoder = Consts.UTF_8.newDecoder();
         decoder.onMalformedInput(CodingErrorAction.IGNORE);
@@ -496,7 +497,7 @@ public class TestSessionInOutBuffers {
     @Test
     public void testMalformedInputActionReplace() throws Exception {
         final String s = constructString(SWISS_GERMAN_HELLO);
-        final byte[] tmp = s.getBytes("ISO-8859-1");
+        final byte[] tmp = s.getBytes(Consts.ISO_8859_1);
 
         final CharsetDecoder decoder = Consts.UTF_8.newDecoder();
         decoder.onMalformedInput(CodingErrorAction.REPLACE);

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncPrematureTermination.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncPrematureTermination.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncPrematureTermination.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncPrematureTermination.java Tue Jan 14 15:23:07 2014
@@ -169,7 +169,7 @@ public class TestHttpAsyncPrematureTermi
         final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         final CountDownLatch responseStreamClosed = new CountDownLatch(1);
         final InputStream testInputStream = new ByteArrayInputStream(
-                "all is well".getBytes(Consts.ASCII.name())) {
+                "all is well".getBytes(Consts.ASCII)) {
             @Override
             public void close() throws IOException {
                 responseStreamClosed.countDown();

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java Tue Jan 14 15:23:07 2014
@@ -82,12 +82,12 @@ public class ElementalHttpPost {
                             "This is the first test request",
                             ContentType.create("text/plain", Consts.UTF_8)),
                     new ByteArrayEntity(
-                            "This is the second test request".getBytes("UTF-8"),
+                            "This is the second test request".getBytes(Consts.UTF_8),
                             ContentType.APPLICATION_OCTET_STREAM),
                     new InputStreamEntity(
                             new ByteArrayInputStream(
                                     "This is the third test request (will be chunked)"
-                                    .getBytes("UTF-8")),
+                                    .getBytes(Consts.UTF_8)),
                             ContentType.APPLICATION_OCTET_STREAM)
             };
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java Tue Jan 14 15:23:07 2014
@@ -69,12 +69,7 @@ public class StringEntity extends Abstra
         if (charset == null) {
             charset = HTTP.DEF_CONTENT_CHARSET;
         }
-        try {
-            this.content = string.getBytes(charset.name());
-        } catch (final UnsupportedEncodingException ex) {
-            // should never happen
-            throw new UnsupportedCharsetException(charset.name());
-        }
+        this.content = string.getBytes(charset);
         if (contentType != null) {
             setContentType(contentType.toString());
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java Tue Jan 14 15:23:07 2014
@@ -104,11 +104,7 @@ public final class EncodingUtils {
      */
     public static byte[] getAsciiBytes(final String data) {
         Args.notNull(data, "Input");
-        try {
-            return data.getBytes(Consts.ASCII.name());
-        } catch (final UnsupportedEncodingException e) {
-            throw new Error("ASCII not supported");
-        }
+        return data.getBytes(Consts.ASCII);
     }
 
     /**
@@ -123,11 +119,7 @@ public final class EncodingUtils {
      */
     public static String getAsciiString(final byte[] data, final int offset, final int length) {
         Args.notNull(data, "Input");
-        try {
-            return new String(data, offset, length, Consts.ASCII.name());
-        } catch (final UnsupportedEncodingException e) {
-            throw new Error("ASCII not supported");
-        }
+        return new String(data, offset, length, Consts.ASCII);
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java Tue Jan 14 15:23:07 2014
@@ -44,7 +44,7 @@ public class TestBasicHttpEntity {
     @Test
     public void testBasics() throws Exception {
 
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final InputStream content = new ByteArrayInputStream(bytes);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(content);
@@ -57,7 +57,7 @@ public class TestBasicHttpEntity {
 
     @Test
     public void testContent() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final InputStream content = new ByteArrayInputStream(bytes);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         try {
@@ -80,7 +80,7 @@ public class TestBasicHttpEntity {
 
     @Test
     public void testWriteTo() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final InputStream content = new ByteArrayInputStream(bytes);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(content);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java Tue Jan 14 15:23:07 2014
@@ -42,7 +42,7 @@ public class TestBufferedHttpEntity {
 
     @Test
     public void testBufferingEntity() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final InputStreamEntity httpentity = new InputStreamEntity(new ByteArrayInputStream(bytes), -1);
         final BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity);
         Assert.assertEquals(bytes.length, bufentity.getContentLength());
@@ -57,7 +57,7 @@ public class TestBufferedHttpEntity {
 
     @Test
     public void testWrappingEntity() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final ByteArrayEntity httpentity = new ByteArrayEntity(bytes);
         httpentity.setChunked(true);
         final BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity);
@@ -83,7 +83,7 @@ public class TestBufferedHttpEntity {
 
     @Test
     public void testWriteToBuffered() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final InputStreamEntity httpentity = new InputStreamEntity(new ByteArrayInputStream(bytes), -1);
         final BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity);
 
@@ -115,7 +115,7 @@ public class TestBufferedHttpEntity {
 
     @Test
     public void testWriteToWrapped() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final ByteArrayEntity httpentity = new ByteArrayEntity(bytes);
         final BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity);
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java Tue Jan 14 15:23:07 2014
@@ -41,7 +41,7 @@ public class TestByteArrayEntity {
 
     @Test
     public void testBasics() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final ByteArrayEntity httpentity = new ByteArrayEntity(bytes);
 
         Assert.assertEquals(bytes.length, httpentity.getContentLength());
@@ -52,7 +52,7 @@ public class TestByteArrayEntity {
 
     @Test
     public void testBasicOffLen() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final ByteArrayEntity httpentity = new ByteArrayEntity(bytes, 8, 7);
 
         Assert.assertEquals(7, httpentity.getContentLength());
@@ -68,25 +68,25 @@ public class TestByteArrayEntity {
 
     @Test(expected=IndexOutOfBoundsException.class)
     public void testIllegalConstructorBadLen() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         new ByteArrayEntity(bytes, 0, bytes.length + 1);
     }
 
     @Test(expected=IndexOutOfBoundsException.class)
     public void testIllegalConstructorBadOff1() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         new ByteArrayEntity(bytes, -1, bytes.length);
     }
 
     @Test(expected=IndexOutOfBoundsException.class)
     public void testIllegalConstructorBadOff2() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         new ByteArrayEntity(bytes, bytes.length + 1, bytes.length);
     }
 
     @Test
     public void testWriteTo() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final ByteArrayEntity httpentity = new ByteArrayEntity(bytes);
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -117,7 +117,7 @@ public class TestByteArrayEntity {
 
     @Test
     public void testWriteToOffLen() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ASCII);
         final int off = 8;
         final int len = 7;
         final ByteArrayEntity httpentity = new ByteArrayEntity(bytes, off, len);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java Tue Jan 14 15:23:07 2014
@@ -70,7 +70,7 @@ public class TestHttpEntityWrapper {
     @Test
     public void testWriteTo() throws Exception {
         final String s = "Message content";
-        final byte[] bytes = s.getBytes(Consts.ISO_8859_1.name());
+        final byte[] bytes = s.getBytes(Consts.ISO_8859_1);
         final StringEntity httpentity = new StringEntity(s);
         final HttpEntityWrapper wrapped = new HttpEntityWrapper(httpentity);
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java Tue Jan 14 15:23:07 2014
@@ -43,7 +43,7 @@ public class TestInputStreamEntity {
 
     @Test
     public void testBasics() throws Exception {
-        final byte[] bytes = "Message content".getBytes(Consts.ISO_8859_1.name());
+        final byte[] bytes = "Message content".getBytes(Consts.ISO_8859_1);
         final InputStream instream = new ByteArrayInputStream(bytes);
         final InputStreamEntity httpentity = new InputStreamEntity(instream, bytes.length);
 
@@ -69,7 +69,7 @@ public class TestInputStreamEntity {
     @Test
     public void testWriteTo() throws Exception {
         final String message = "Message content";
-        final byte[] bytes = message.getBytes(Consts.ISO_8859_1.name());
+        final byte[] bytes = message.getBytes(Consts.ISO_8859_1);
         final InputStream instream = new ByteArrayInputStream(bytes);
         final InputStreamEntity httpentity = new InputStreamEntity(instream, bytes.length);
 
@@ -86,7 +86,7 @@ public class TestInputStreamEntity {
     @Test
     public void testWriteToPartialContent() throws Exception {
         final String message = "Message content";
-        final byte[] bytes = message.getBytes(Consts.ISO_8859_1.name());
+        final byte[] bytes = message.getBytes(Consts.ISO_8859_1);
         final InputStream instream = new ByteArrayInputStream(bytes);
         final int contentLength = 7;
         final InputStreamEntity httpentity = new InputStreamEntity(instream, contentLength);
@@ -104,7 +104,7 @@ public class TestInputStreamEntity {
     @Test
     public void testWriteToUnknownLength() throws Exception {
         final String message = "Message content";
-        final byte[] bytes = message.getBytes(Consts.ISO_8859_1.name());
+        final byte[] bytes = message.getBytes(Consts.ISO_8859_1);
         final InputStream instream = new ByteArrayInputStream(bytes);
         final InputStreamEntity httpentity = new InputStreamEntity(instream);
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java Tue Jan 14 15:23:07 2014
@@ -45,7 +45,7 @@ public class TestStringEntity {
         final String s = "Message content";
         final StringEntity httpentity = new StringEntity(s, ContentType.TEXT_PLAIN);
 
-        final byte[] bytes = s.getBytes(Consts.ISO_8859_1.name());
+        final byte[] bytes = s.getBytes(Consts.ISO_8859_1);
         Assert.assertEquals(bytes.length, httpentity.getContentLength());
         Assert.assertNotNull(httpentity.getContent());
         Assert.assertTrue(httpentity.isRepeatable());
@@ -113,7 +113,7 @@ public class TestStringEntity {
     @Test
     public void testWriteTo() throws Exception {
         final String s = "Message content";
-        final byte[] bytes = s.getBytes(Consts.ISO_8859_1.name());
+        final byte[] bytes = s.getBytes(Consts.ISO_8859_1);
         final StringEntity httpentity = new StringEntity(s);
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/SessionInputBufferMock.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/SessionInputBufferMock.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/SessionInputBufferMock.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/SessionInputBufferMock.java Tue Jan 14 15:23:07 2014
@@ -30,7 +30,6 @@ package org.apache.http.impl;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetDecoder;
 
@@ -99,8 +98,8 @@ public class SessionInputBufferMock exte
 
     public SessionInputBufferMock(
             final String s,
-            final Charset charset) throws UnsupportedEncodingException {
-        this(s.getBytes(charset.name()), charset);
+            final Charset charset) {
+        this(s.getBytes(charset), charset);
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java Tue Jan 14 15:23:07 2014
@@ -30,8 +30,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.net.Socket;
 
-import junit.framework.Assert;
-
+import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpRequest;
@@ -52,6 +51,8 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 
+import junit.framework.Assert;
+
 public class TestDefaultBHttpClientConnection {
 
     @Mock
@@ -80,7 +81,7 @@ public class TestDefaultBHttpClientConne
     @Test
     public void testReadRequestHead() throws Exception {
         final String s = "HTTP/1.1 200 OK\r\nUser-Agent: test\r\n\r\n";
-        final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes("ASCII"));
+        final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
         Mockito.when(socket.getInputStream()).thenReturn(instream);
 
         conn.bind(socket);
@@ -98,7 +99,7 @@ public class TestDefaultBHttpClientConne
     @Test
     public void testReadRequestEntity() throws Exception {
         final String s = "HTTP/1.1 200 OK\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123";
-        final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes("ASCII"));
+        final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
         Mockito.when(socket.getInputStream()).thenReturn(instream);
 
         conn.bind(socket);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java Tue Jan 14 15:23:07 2014
@@ -30,8 +30,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.net.Socket;
 
-import junit.framework.Assert;
-
+import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpRequest;
@@ -51,6 +50,8 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 
+import junit.framework.Assert;
+
 public class TestDefaultBHttpServerConnection {
 
     @Mock
@@ -79,7 +80,7 @@ public class TestDefaultBHttpServerConne
     @Test
     public void testReadRequestHead() throws Exception {
         final String s = "GET / HTTP/1.1\r\nUser-Agent: test\r\n\r\n";
-        final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes("ASCII"));
+        final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
         Mockito.when(socket.getInputStream()).thenReturn(instream);
 
         conn.bind(socket);
@@ -98,7 +99,7 @@ public class TestDefaultBHttpServerConne
     @Test
     public void testReadRequestEntity() throws Exception {
         final String s = "POST / HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123";
-        final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes("ASCII"));
+        final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
         Mockito.when(socket.getInputStream()).thenReturn(instream);
 
         conn.bind(socket);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java Tue Jan 14 15:23:07 2014
@@ -33,20 +33,18 @@ import java.io.InputStream;
 import java.io.InterruptedIOException;
 import java.io.OutputStream;
 
+import org.apache.http.Consts;
 import org.apache.http.Header;
 import org.apache.http.MalformedChunkCodingException;
 import org.apache.http.TruncatedChunkException;
 import org.apache.http.impl.SessionInputBufferMock;
 import org.apache.http.impl.SessionOutputBufferMock;
 import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.util.EncodingUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class TestChunkCoding {
 
-    private static final String CONTENT_CHARSET = "ISO-8859-1";
-
     @Test
     public void testConstructors() throws Exception {
         try {
@@ -69,8 +67,7 @@ public class TestChunkCoding {
     @Test
     public void testChunkedInputStreamLargeBuffer() throws IOException {
         final ChunkedInputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(CHUNKED_INPUT, CONTENT_CHARSET)));
+                new SessionInputBufferMock(CHUNKED_INPUT, Consts.ISO_8859_1));
         final byte[] buffer = new byte[300];
         final ByteArrayOutputStream out = new ByteArrayOutputStream();
         int len;
@@ -82,7 +79,7 @@ public class TestChunkCoding {
 
         in.close();
 
-        final String result = EncodingUtils.getString(out.toByteArray(), CONTENT_CHARSET);
+        final String result = new String(out.toByteArray(), Consts.ISO_8859_1);
         Assert.assertEquals(result, CHUNKED_RESULT);
 
         final Header[] footers = in.getFooters();
@@ -98,8 +95,7 @@ public class TestChunkCoding {
     @Test
     public void testChunkedInputStreamSmallBuffer() throws IOException {
         final ChunkedInputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                            EncodingUtils.getBytes(CHUNKED_INPUT, CONTENT_CHARSET)));
+                new SessionInputBufferMock(CHUNKED_INPUT, Consts.ISO_8859_1));
 
         final byte[] buffer = new byte[7];
         final ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -112,7 +108,6 @@ public class TestChunkCoding {
 
         in.close();
 
-        EncodingUtils.getString(out.toByteArray(), CONTENT_CHARSET);
         final Header[] footers = in.getFooters();
         Assert.assertNotNull(footers);
         Assert.assertEquals(2, footers.length);
@@ -127,8 +122,7 @@ public class TestChunkCoding {
     public void testChunkedInputStreamOneByteRead() throws IOException {
         final String s = "5\r\n01234\r\n5\r\n56789\r\n0\r\n";
         final ChunkedInputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
+                new SessionInputBufferMock(s, Consts.ISO_8859_1));
         int ch;
         int i = '0';
         while ((ch = in.read()) != -1) {
@@ -145,8 +139,7 @@ public class TestChunkCoding {
     public void testAvailable() throws IOException {
         final String s = "5\r\n12345\r\n0\r\n";
         final ChunkedInputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
+                new SessionInputBufferMock(s, Consts.ISO_8859_1));
         Assert.assertEquals(0, in.available());
         in.read();
         Assert.assertEquals(4, in.available());
@@ -157,8 +150,7 @@ public class TestChunkCoding {
     public void testChunkedInputStreamClose() throws IOException {
         final String s = "5\r\n01234\r\n5\r\n56789\r\n0\r\n";
         final ChunkedInputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
+                new SessionInputBufferMock(s, Consts.ISO_8859_1));
         in.close();
         in.close();
         try {
@@ -207,8 +199,7 @@ public class TestChunkCoding {
     public void testChunkedInputStreamNoClosingChunk() throws IOException {
         final String s = "5\r\n01234\r\n";
         final ChunkedInputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
+                new SessionInputBufferMock(s, Consts.ISO_8859_1));
         final byte[] tmp = new byte[5];
         Assert.assertEquals(5, in.read(tmp));
         Assert.assertEquals(-1, in.read());
@@ -220,8 +211,7 @@ public class TestChunkCoding {
     public void testCorruptChunkedInputStreamMissingCRLF() throws IOException {
         final String s = "5\r\n012345\r\n56789\r\n0\r\n";
         final InputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
+                new SessionInputBufferMock(s, Consts.ISO_8859_1));
         final byte[] buffer = new byte[300];
         final ByteArrayOutputStream out = new ByteArrayOutputStream();
         int len;
@@ -240,8 +230,7 @@ public class TestChunkCoding {
     public void testCorruptChunkedInputStreamMissingLF() throws IOException {
         final String s = "5\r01234\r\n5\r\n56789\r\n0\r\n";
         final InputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
+                new SessionInputBufferMock(s, Consts.ISO_8859_1));
         try {
             in.read();
             Assert.fail("MalformedChunkCodingException should have been thrown");
@@ -256,8 +245,7 @@ public class TestChunkCoding {
     public void testCorruptChunkedInputStreamInvalidSize() throws IOException {
         final String s = "whatever\r\n01234\r\n5\r\n56789\r\n0\r\n";
         final InputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
+                new SessionInputBufferMock(s, Consts.ISO_8859_1));
         try {
             in.read();
             Assert.fail("MalformedChunkCodingException should have been thrown");
@@ -275,8 +263,7 @@ public class TestChunkCoding {
     public void testCorruptChunkedInputStreamNegativeSize() throws IOException {
         final String s = "-5\r\n01234\r\n5\r\n56789\r\n0\r\n";
         final InputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
+                new SessionInputBufferMock(s, Consts.ISO_8859_1));
         try {
             in.read();
             Assert.fail("MalformedChunkCodingException should have been thrown");
@@ -294,8 +281,7 @@ public class TestChunkCoding {
     public void testCorruptChunkedInputStreamTruncatedChunk() throws IOException {
         final String s = "3\r\n12";
         final InputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
+                new SessionInputBufferMock(s, Consts.ISO_8859_1));
         final byte[] buffer = new byte[300];
         Assert.assertEquals(2, in.read(buffer));
         try {
@@ -312,8 +298,7 @@ public class TestChunkCoding {
     public void testCorruptChunkedInputStreamInvalidFooter() throws IOException {
         final String s = "1\r\n0\r\n0\r\nstuff\r\n";
         final InputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
+                new SessionInputBufferMock(s, Consts.ISO_8859_1));
         try {
             in.read();
             in.read();
@@ -328,8 +313,7 @@ public class TestChunkCoding {
     public void testEmptyChunkedInputStream() throws IOException {
         final String input = "0\r\n";
         final InputStream in = new ChunkedInputStream(
-                new SessionInputBufferMock(
-                        EncodingUtils.getBytes(input, CONTENT_CHARSET)));
+                new SessionInputBufferMock(input, Consts.ISO_8859_1));
         final byte[] buffer = new byte[300];
         final ByteArrayOutputStream out = new ByteArrayOutputStream();
         int len;
@@ -345,7 +329,7 @@ public class TestChunkCoding {
         final String input = "76126;27823abcd;:q38a-\nkjc\rk%1ad\tkh/asdui\r\njkh+?\\suweb";
         final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
         final OutputStream out = new ChunkedOutputStream(2048, new SessionOutputBufferMock(buffer));
-        out.write(EncodingUtils.getBytes(input, CONTENT_CHARSET));
+        out.write(input.getBytes(Consts.ISO_8859_1));
         out.flush();
         out.close();
         out.close();
@@ -361,7 +345,7 @@ public class TestChunkCoding {
             result.write(d, 0, len);
         }
 
-        final String output = EncodingUtils.getString(result.toByteArray(), CONTENT_CHARSET);
+        final String output = new String(result.toByteArray(), Consts.ISO_8859_1);
         Assert.assertEquals(input, output);
         in.close();
 }
@@ -456,7 +440,7 @@ public class TestChunkCoding {
     public void testResumeOnSocketTimeoutInData() throws IOException {
         final String s = "5\r\n01234\r\n5\r\n5\0006789\r\na\r\n0123\000456789\r\n0\r\n";
         final SessionInputBuffer sessbuf = new SessionInputBufferMock(
-                new TimeoutByteArrayInputStream(s.getBytes("ISO-8859-1")), 16);
+                new TimeoutByteArrayInputStream(s.getBytes(Consts.ISO_8859_1)), 16);
         final InputStream in = new ChunkedInputStream(sessbuf);
 
         final byte[] tmp = new byte[3];
@@ -484,7 +468,7 @@ public class TestChunkCoding {
     public void testResumeOnSocketTimeoutInChunk() throws IOException {
         final String s = "5\000\r\000\n\00001234\r\n\0005\r\n56789\r\na\r\n0123456789\r\n\0000\r\n";
         final SessionInputBuffer sessbuf = new SessionInputBufferMock(
-                new TimeoutByteArrayInputStream(s.getBytes("ISO-8859-1")), 16);
+                new TimeoutByteArrayInputStream(s.getBytes(Consts.ISO_8859_1)), 16);
         final InputStream in = new ChunkedInputStream(sessbuf);
 
         final byte[] tmp = new byte[3];

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java Tue Jan 14 15:23:07 2014
@@ -32,16 +32,14 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.http.ConnectionClosedException;
+import org.apache.http.Consts;
 import org.apache.http.impl.SessionInputBufferMock;
 import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.util.EncodingUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class TestContentLengthInputStream {
 
-    private static final String CONTENT_CHARSET = "ISO-8859-1";
-
     @Test
     public void testConstructors() throws Exception {
         final ContentLengthInputStream in = new ContentLengthInputStream(
@@ -64,8 +62,8 @@ public class TestContentLengthInputStrea
     @Test
     public void testBasics() throws IOException {
         final String correct = "1234567890123456";
-        final InputStream in = new ContentLengthInputStream(new SessionInputBufferMock(
-            EncodingUtils.getBytes(correct, CONTENT_CHARSET)), 10L);
+        final InputStream in = new ContentLengthInputStream(
+                new SessionInputBufferMock(correct, Consts.ISO_8859_1), 10L);
         final ByteArrayOutputStream out = new ByteArrayOutputStream();
 
         final byte[] buffer = new byte[50];
@@ -74,7 +72,7 @@ public class TestContentLengthInputStrea
         len = in.read(buffer);
         out.write(buffer, 0, len);
 
-        final String result = EncodingUtils.getString(out.toByteArray(), CONTENT_CHARSET);
+        final String result = new String(out.toByteArray(), Consts.ISO_8859_1);
         Assert.assertEquals(result, "1234567890");
         in.close();
     }
@@ -118,8 +116,7 @@ public class TestContentLengthInputStrea
     @Test
     public void testClose() throws IOException {
         final String correct = "1234567890123456-";
-        final SessionInputBuffer inbuffer = new SessionInputBufferMock(EncodingUtils.getBytes(
-                correct, CONTENT_CHARSET));
+        final SessionInputBuffer inbuffer = new SessionInputBufferMock(correct, Consts.ISO_8859_1);
         final InputStream in = new ContentLengthInputStream(inbuffer, 16L);
         in.close();
         in.close();
@@ -148,8 +145,7 @@ public class TestContentLengthInputStrea
     @Test
     public void testTruncatedContent() throws IOException {
         final String correct = "1234567890123456";
-        final SessionInputBuffer inbuffer = new SessionInputBufferMock(EncodingUtils.getBytes(
-                correct, CONTENT_CHARSET));
+        final SessionInputBuffer inbuffer = new SessionInputBufferMock(correct, Consts.ISO_8859_1);
         final InputStream in = new ContentLengthInputStream(inbuffer, 32L);
         final byte[] tmp = new byte[32];
         final int byteRead = in.read(tmp);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java Tue Jan 14 15:23:07 2014
@@ -92,7 +92,7 @@ public class TestRequestParser {
             "Coo\000kie: c1=stuff\r\n" +
             "\000\r\n";
         final SessionInputBuffer inbuffer = new SessionInputBufferMock(
-                new TimeoutByteArrayInputStream(s.getBytes("US-ASCII")), 16);
+                new TimeoutByteArrayInputStream(s.getBytes(Consts.ASCII)), 16);
 
         final DefaultHttpRequestParser parser = new DefaultHttpRequestParser(inbuffer);
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java Tue Jan 14 15:23:07 2014
@@ -93,7 +93,7 @@ public class TestResponseParser {
             "Set-Coo\000kie: c1=stuff\r\n" +
             "\000\r\n";
         final SessionInputBuffer inbuffer = new SessionInputBufferMock(
-                new TimeoutByteArrayInputStream(s.getBytes("US-ASCII")), 16);
+                new TimeoutByteArrayInputStream(s.getBytes(Consts.ASCII)), 16);
 
         final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inbuffer);
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java Tue Jan 14 15:23:07 2014
@@ -137,7 +137,7 @@ public class TestSessionInOutBuffers {
         }
         final String s1 = buffer.toString();
         buffer.append("\r\n");
-        outbuffer.write(buffer.toString().getBytes("US-ASCII"));
+        outbuffer.write(buffer.toString().getBytes(Consts.ASCII));
         outbuffer.flush();
         bytesWritten = outbuffer.getMetrics().getBytesTransferred();
         Assert.assertEquals(8 + 14 +2, bytesWritten);
@@ -148,7 +148,7 @@ public class TestSessionInOutBuffers {
         }
         final String s2 = buffer.toString();
         buffer.append("\r\n");
-        outbuffer.write(buffer.toString().getBytes("US-ASCII"));
+        outbuffer.write(buffer.toString().getBytes(Consts.ASCII));
         outbuffer.flush();
         bytesWritten = outbuffer.getMetrics().getBytesTransferred();
         Assert.assertEquals(8 + 14 + 2 + 15 + 2 , bytesWritten);
@@ -159,7 +159,7 @@ public class TestSessionInOutBuffers {
         }
         final String s3 = buffer.toString();
         buffer.append("\r\n");
-        outbuffer.write(buffer.toString().getBytes("US-ASCII"));
+        outbuffer.write(buffer.toString().getBytes(Consts.ASCII));
         outbuffer.flush();
         bytesWritten = outbuffer.getMetrics().getBytesTransferred();
         Assert.assertEquals(8 + 14 + 2 + 15 + 2 + 16 + 2, bytesWritten);
@@ -359,7 +359,7 @@ public class TestSessionInOutBuffers {
     @Test
     public void testLineLimit() throws Exception {
         final String s = "a very looooooooooooooooooooooooooooooooooooooong line\r\n     ";
-        final byte[] tmp = s.getBytes("US-ASCII");
+        final byte[] tmp = s.getBytes(Consts.ASCII);
         // no limit
         final SessionInputBufferMock inbuffer1 = new SessionInputBufferMock(tmp, 5,
                 MessageConstraints.DEFAULT);
@@ -383,7 +383,7 @@ public class TestSessionInOutBuffers {
     @Test
     public void testReadLineFringeCase1() throws Exception {
         final String s = "abc\r\n";
-        final byte[] tmp = s.getBytes("US-ASCII");
+        final byte[] tmp = s.getBytes(Consts.ASCII);
         final SessionInputBufferMock inbuffer1 = new SessionInputBufferMock(tmp, 128);
         Assert.assertEquals('a', inbuffer1.read());
         Assert.assertEquals('b', inbuffer1.read());
@@ -433,9 +433,9 @@ public class TestSessionInOutBuffers {
         }
         outbuffer.flush();
         final long bytesWritten = outbuffer.getMetrics().getBytesTransferred();
-        final long expected = ((s1.getBytes("UTF-8").length + 2)+
-                (s2.getBytes("UTF-8").length + 2) +
-                (s3.getBytes("UTF-8").length + 2)) * 10;
+        final long expected = ((s1.getBytes(Consts.UTF_8).length + 2)+
+                (s2.getBytes(Consts.UTF_8).length + 2) +
+                (s3.getBytes(Consts.UTF_8).length + 2)) * 10;
         Assert.assertEquals(expected, bytesWritten);
 
         final SessionInputBufferMock inbuffer = new SessionInputBufferMock(
@@ -495,7 +495,7 @@ public class TestSessionInOutBuffers {
         outbuffer.writeLine(chbuffer);
         outbuffer.flush();
         final long bytesWritten = outbuffer.getMetrics().getBytesTransferred();
-        final long expected = ((s1.toString().getBytes(Consts.ISO_8859_1.name()).length + 2)) * 10 + 2;
+        final long expected = ((s1.toString().getBytes(Consts.ISO_8859_1).length + 2)) * 10 + 2;
         Assert.assertEquals(expected, bytesWritten);
 
         final SessionInputBufferMock inbuffer = new SessionInputBufferMock(
@@ -554,7 +554,7 @@ public class TestSessionInOutBuffers {
 
     @Test(expected=CharacterCodingException.class)
     public void testMalformedInputActionReport() throws Exception {
-        final byte[] tmp = constructString(SWISS_GERMAN_HELLO).getBytes(Consts.ISO_8859_1.name());
+        final byte[] tmp = constructString(SWISS_GERMAN_HELLO).getBytes(Consts.ISO_8859_1);
         final CharsetDecoder decoder = Consts.UTF_8.newDecoder();
         decoder.onMalformedInput(CodingErrorAction.REPORT);
         decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
@@ -564,7 +564,7 @@ public class TestSessionInOutBuffers {
 
     @Test
     public void testMalformedInputActionReplace() throws Exception {
-        final byte[] tmp = constructString(SWISS_GERMAN_HELLO).getBytes(Consts.ISO_8859_1.name());
+        final byte[] tmp = constructString(SWISS_GERMAN_HELLO).getBytes(Consts.ISO_8859_1);
         final CharsetDecoder decoder = Consts.UTF_8.newDecoder();
         decoder.onMalformedInput(CodingErrorAction.REPLACE);
         decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
@@ -575,7 +575,7 @@ public class TestSessionInOutBuffers {
 
     @Test
     public void testMalformedInputActionIgnore() throws Exception {
-        final byte[] tmp = constructString(SWISS_GERMAN_HELLO).getBytes(Consts.ISO_8859_1.name());
+        final byte[] tmp = constructString(SWISS_GERMAN_HELLO).getBytes(Consts.ISO_8859_1);
         final CharsetDecoder decoder = Consts.UTF_8.newDecoder();
         decoder.onMalformedInput(CodingErrorAction.IGNORE);
         decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java Tue Jan 14 15:23:07 2014
@@ -32,7 +32,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
@@ -614,14 +613,7 @@ public class TestSyncHttp {
             super();
             final Charset cs = charset != null ? charset : Charset.forName("US-ASCII");
             byte[] b;
-            // Java 6 only:
-            // b = content.getBytes(charset);
-            // Java 5 OK:
-            try {
-                b = content.getBytes(cs.name());
-            } catch (final UnsupportedEncodingException ex) {
-                b = content.getBytes();
-            }
+            b = content.getBytes(cs);
             this.raw = b;
             this.n = n;
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java Tue Jan 14 15:23:07 2014
@@ -32,6 +32,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import org.apache.http.Consts;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -199,7 +200,7 @@ public class TestByteArrayBuffer {
     public void testIndexOf() throws Exception {
         final byte COLON = (byte) ':';
         final byte COMMA = (byte) ',';
-        final byte[] bytes = "name1: value1; name2: value2".getBytes("US-ASCII");
+        final byte[] bytes = "name1: value1; name2: value2".getBytes(Consts.ASCII);
         final int index1 = 5;
         final int index2 = 20;
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java Tue Jan 14 15:23:07 2014
@@ -32,6 +32,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import org.apache.http.Consts;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -296,8 +297,8 @@ public class TestCharArrayBuffer {
     public void testAppendAsciiByteArray() throws Exception {
         final String s1 = "stuff";
         final String s2 = " and more stuff";
-        final byte[] b1 = s1.getBytes("US-ASCII");
-        final byte[] b2 = s2.getBytes("US-ASCII");
+        final byte[] b1 = s1.getBytes(Consts.ASCII);
+        final byte[] b2 = s2.getBytes(Consts.ASCII);
 
         final CharArrayBuffer buffer = new CharArrayBuffer(8);
         buffer.append(b1, 0, b1.length);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEntityUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEntityUtils.java?rev=1558078&r1=1558077&r2=1558078&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEntityUtils.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEntityUtils.java Tue Jan 14 15:23:07 2014
@@ -29,7 +29,9 @@ package org.apache.http.util;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
+import java.nio.charset.Charset;
 
+import org.apache.http.Consts;
 import org.apache.http.entity.BasicHttpEntity;
 import org.apache.http.message.BasicHeader;
 import org.junit.Assert;
@@ -60,7 +62,7 @@ public class TestEntityUtils {
 
     @Test
     public void testMaxIntContentToByteArray() throws Exception {
-        final byte[] content = "Message content".getBytes("ISO-8859-1");
+        final byte[] content = "Message content".getBytes(Consts.ISO_8859_1);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(content));
         httpentity.setContentLength(Integer.MAX_VALUE + 100L);
@@ -74,7 +76,7 @@ public class TestEntityUtils {
 
     @Test
     public void testUnknownLengthContentToByteArray() throws Exception {
-        final byte[] bytes = "Message content".getBytes("ISO-8859-1");
+        final byte[] bytes = "Message content".getBytes(Consts.ISO_8859_1);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(bytes));
         httpentity.setContentLength(-1L);
@@ -88,7 +90,7 @@ public class TestEntityUtils {
 
     @Test
     public void testKnownLengthContentToByteArray() throws Exception {
-        final byte[] bytes = "Message content".getBytes("ISO-8859-1");
+        final byte[] bytes = "Message content".getBytes(Consts.ISO_8859_1);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(bytes));
         httpentity.setContentLength(bytes.length);
@@ -119,7 +121,7 @@ public class TestEntityUtils {
 
     @Test
     public void testMaxIntContentToString() throws Exception {
-        final byte[] content = "Message content".getBytes("ISO-8859-1");
+        final byte[] content = "Message content".getBytes(Consts.ISO_8859_1);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(content));
         httpentity.setContentLength(Integer.MAX_VALUE + 100L);
@@ -133,7 +135,7 @@ public class TestEntityUtils {
 
     @Test
     public void testUnknownLengthContentToString() throws Exception {
-        final byte[] bytes = "Message content".getBytes("ISO-8859-1");
+        final byte[] bytes = "Message content".getBytes(Consts.ISO_8859_1);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(bytes));
         httpentity.setContentLength(-1L);
@@ -143,7 +145,7 @@ public class TestEntityUtils {
 
     @Test
     public void testKnownLengthContentToString() throws Exception {
-        final byte[] bytes = "Message content".getBytes("ISO-8859-1");
+        final byte[] bytes = "Message content".getBytes(Consts.ISO_8859_1);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(bytes));
         httpentity.setContentLength(bytes.length);
@@ -173,7 +175,7 @@ public class TestEntityUtils {
     @Test
     public void testNoCharsetContentToString() throws Exception {
         final String content = constructString(SWISS_GERMAN_HELLO);
-        final byte[] bytes = content.getBytes("ISO-8859-1");
+        final byte[] bytes = content.getBytes(Consts.ISO_8859_1);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(bytes));
         httpentity.setContentType(new BasicHeader("Content-Type", "text/plain"));
@@ -184,7 +186,7 @@ public class TestEntityUtils {
     @Test
     public void testDefaultCharsetContentToString() throws Exception {
         final String content = constructString(RUSSIAN_HELLO);
-        final byte[] bytes = content.getBytes("KOI8-R");
+        final byte[] bytes = content.getBytes(Charset.forName("KOI8-R"));
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(bytes));
         httpentity.setContentType(new BasicHeader("Content-Type", "text/plain"));
@@ -195,7 +197,7 @@ public class TestEntityUtils {
     @Test
     public void testContentWithContentTypeToString() throws Exception {
         final String content = constructString(RUSSIAN_HELLO);
-        final byte[] bytes = content.getBytes("UTF-8");
+        final byte[] bytes = content.getBytes(Consts.UTF_8);
         final BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(bytes));
         httpentity.setContentType(new BasicHeader("Content-Type", "text/plain; charset=UTF-8"));



Mime
View raw message