Author: olegk
Date: Sat Aug 11 16:08:54 2012
New Revision: 1371968
URL: http://svn.apache.org/viewvc?rev=1371968&view=rev
Log:
Decoupled HttpParams and session i/o buffers
Added:
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/CharsetUtils.java (with props)
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java (contents, props changed)
- copied, changed from r1371358, httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionBuffers.java
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSocketInputBuffer.java (with props)
Removed:
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionBuffers.java
Modified:
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java
httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.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/TestIdentityDecoder.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/TestLengthDelimitedDecoder.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/util/TestBuffers.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionInputBuffer.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionOutputBuffer.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SocketInputBuffer.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SocketOutputBuffer.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/SessionOutputBufferMock.java
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntityDeserializer.java
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestMessageParser.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/TestSocketOutputBuffer.java
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java?rev=1371968&r1=1371967&r2=1371968&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java Sat Aug 11 16:08:54 2012
@@ -34,8 +34,11 @@ import java.net.Socket;
import java.net.SocketAddress;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
+import java.nio.charset.Charset;
+import java.nio.charset.CodingErrorAction;
import org.apache.http.ConnectionClosedException;
+import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpConnectionMetrics;
import org.apache.http.HttpEntity;
@@ -71,10 +74,12 @@ import org.apache.http.nio.reactor.Sessi
import org.apache.http.nio.reactor.SocketAccessor;
import org.apache.http.nio.util.ByteBufferAllocator;
import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
+import org.apache.http.util.CharsetUtils;
/**
* This class serves as a base for all {@link NHttpConnection} implementations
@@ -140,8 +145,20 @@ public class NHttpConnectionBase
linebuffersize = 512;
}
- this.inbuf = new SessionInputBufferImpl(buffersize, linebuffersize, allocator, params);
- this.outbuf = new SessionOutputBufferImpl(buffersize, linebuffersize, allocator, params);
+ Charset charset = CharsetUtils.lookup(
+ (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET));
+ if (charset == null) {
+ charset = Consts.ASCII;
+ }
+ CodingErrorAction malformedCharAction = (CodingErrorAction) params.getParameter(
+ CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION);
+ CodingErrorAction unmappableCharAction = (CodingErrorAction) params.getParameter(
+ CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION);
+
+ this.inbuf = new SessionInputBufferImpl(buffersize, linebuffersize,
+ charset, malformedCharAction, unmappableCharAction, allocator);
+ this.outbuf = new SessionOutputBufferImpl(buffersize, linebuffersize,
+ charset, malformedCharAction, unmappableCharAction, allocator);
this.incomingContentStrategy = createIncomingContentStrategy();
this.outgoingContentStrategy = createOutgoingContentStrategy();
@@ -477,7 +494,7 @@ public class NHttpConnectionBase
buffer.append("]");
return buffer.toString();
}
-
+
public Socket getSocket() {
if (this.session instanceof SocketAccessor) {
return ((SocketAccessor) this.session).getSocket();
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java?rev=1371968&r1=1371967&r2=1371968&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java Sat Aug 11 16:08:54 2012
@@ -53,12 +53,6 @@ import org.apache.http.util.CharArrayBuf
/**
* Default implementation of {@link SessionInputBuffer} based on
* the {@link ExpandableBuffer} class.
- * <p>
- * The following parameters can be used to customize the behavior of this
- * class:
- * <ul>
- * <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}</li>
- * </ul>
*
* @since 4.0
*/
@@ -69,6 +63,44 @@ public class SessionInputBufferImpl exte
private Charset charset = null;
private CharsetDecoder chardecoder = null;
+ /**
+ * Creates SessionInputBufferImpl instance.
+ *
+ * @param buffersize input buffer size
+ * @param linebuffersize buffer size for line operations
+ * @param charset charset to be used for decoding HTTP protocol elements.
+ * If <code>null</code> US-ASCII will be used.
+ * @param malformedCharAction action to perform upon receiving a malformed input.
+ * If <code>null</code> {@link CodingErrorAction#REPORT} will be used.
+ * @param unmappableCharAction action to perform upon receiving an unmappable input.
+ * If <code>null</code> {@link CodingErrorAction#REPORT} will be used.
+ * @param allocator memory allocator.
+ * If <code>null</code> {@link HeapByteBufferAllocator#INSTANCE} will be used.
+ *
+ * @since 4.3
+ */
+ public SessionInputBufferImpl(
+ int buffersize,
+ int linebuffersize,
+ final Charset charset,
+ final CodingErrorAction malformedCharAction,
+ final CodingErrorAction unmappableCharAction,
+ final ByteBufferAllocator allocator) {
+ super(buffersize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
+ this.charbuffer = CharBuffer.allocate(linebuffersize);
+ this.charset = charset != null ? charset : Consts.ASCII;
+ this.chardecoder = this.charset.newDecoder();
+ this.chardecoder.onMalformedInput(malformedCharAction != null ? malformedCharAction :
+ CodingErrorAction.REPORT);
+ this.chardecoder.onUnmappableCharacter(unmappableCharAction != null? unmappableCharAction :
+ CodingErrorAction.REPORT);
+ }
+
+ /**
+ * @deprecated (4.3) use
+ * {@link SessionInputBufferImpl#SessionInputBufferImpl(int, int, Charset, CodingErrorAction, CodingErrorAction, ByteBufferAllocator)}
+ */
+ @Deprecated
public SessionInputBufferImpl(
int buffersize,
int linebuffersize,
@@ -87,6 +119,11 @@ public class SessionInputBufferImpl exte
this.chardecoder.onUnmappableCharacter(a2 != null? a2 : CodingErrorAction.REPORT);
}
+ /**
+ * @deprecated (4.3) use
+ * {@link SessionInputBufferImpl#SessionInputBufferImpl(int, int, Charset, CodingErrorAction, CodingErrorAction, ByteBufferAllocator)}
+ */
+ @Deprecated
public SessionInputBufferImpl(
int buffersize,
int linebuffersize,
@@ -94,6 +131,27 @@ public class SessionInputBufferImpl exte
this(buffersize, linebuffersize, HeapByteBufferAllocator.INSTANCE, params);
}
+ /**
+ * @since 4.3
+ */
+ public SessionInputBufferImpl(
+ int buffersize,
+ int linebuffersize) {
+ this(buffersize, linebuffersize, null, null, null, null);
+ }
+
+ /**
+ * @since 4.3
+ */
+ public SessionInputBufferImpl(
+ int buffersize,
+ int linebuffersize,
+ final Charset charset,
+ final CodingErrorAction malformedCharAction,
+ final CodingErrorAction unmappableCharAction) {
+ this(buffersize, linebuffersize, charset, malformedCharAction, unmappableCharAction, null);
+ }
+
public int fill(final ReadableByteChannel channel) throws IOException {
Args.notNull(channel, "Channel");
setInputMode();
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java?rev=1371968&r1=1371967&r2=1371968&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java Sat Aug 11 16:08:54 2012
@@ -53,12 +53,6 @@ import org.apache.http.util.CharArrayBuf
/**
* Default implementation of {@link SessionOutputBuffer} based on
* the {@link ExpandableBuffer} class.
- * <p>
- * The following parameters can be used to customize the behavior of this
- * class:
- * <ul>
- * <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}</li>
- * </ul>
*
* @since 4.0
*/
@@ -71,6 +65,44 @@ public class SessionOutputBufferImpl ext
private Charset charset = null;
private CharsetEncoder charencoder = null;
+ /**
+ * Creates SessionOutputBufferImpl instance.
+ *
+ * @param buffersize input buffer size
+ * @param linebuffersize buffer size for line operations
+ * @param charset charset to be used for decoding HTTP protocol elements.
+ * If <code>null</code> US-ASCII will be used.
+ * @param malformedCharAction action to perform upon receiving a malformed input.
+ * If <code>null</code> {@link CodingErrorAction#REPORT} will be used.
+ * @param unmappableCharAction action to perform upon receiving an unmappable input.
+ * If <code>null</code> {@link CodingErrorAction#REPORT} will be used.
+ * @param allocator memory allocator.
+ * If <code>null</code> {@link HeapByteBufferAllocator#INSTANCE} will be used.
+ *
+ * @since 4.3
+ */
+ public SessionOutputBufferImpl(
+ int buffersize,
+ int linebuffersize,
+ final Charset charset,
+ final CodingErrorAction malformedCharAction,
+ final CodingErrorAction unmappableCharAction,
+ final ByteBufferAllocator allocator) {
+ super(buffersize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
+ this.charbuffer = CharBuffer.allocate(linebuffersize);
+ this.charset = charset != null ? charset : Consts.ASCII;
+ this.charencoder = this.charset.newEncoder();
+ this.charencoder.onMalformedInput(malformedCharAction != null ? malformedCharAction :
+ CodingErrorAction.REPORT);
+ this.charencoder.onUnmappableCharacter(unmappableCharAction != null? unmappableCharAction :
+ CodingErrorAction.REPORT);
+ }
+
+ /**
+ * @deprecated (4.3) use
+ * {@link SessionOutputBufferImpl#SessionOutputBufferImpl(int, int, Charset, CodingErrorAction, CodingErrorAction, ByteBufferAllocator)}
+ */
+ @Deprecated
public SessionOutputBufferImpl(
int buffersize,
int linebuffersize,
@@ -89,6 +121,11 @@ public class SessionOutputBufferImpl ext
this.charencoder.onUnmappableCharacter(a2 != null? a2 : CodingErrorAction.REPORT);
}
+ /**
+ * @deprecated (4.3) use
+ * {@link SessionOutputBufferImpl#SessionOutputBufferImpl(int, int, Charset, CodingErrorAction, CodingErrorAction, ByteBufferAllocator)}
+ */
+ @Deprecated
public SessionOutputBufferImpl(
int buffersize,
int linebuffersize,
@@ -96,6 +133,27 @@ public class SessionOutputBufferImpl ext
this(buffersize, linebuffersize, HeapByteBufferAllocator.INSTANCE, params);
}
+ /**
+ * @since 4.3
+ */
+ public SessionOutputBufferImpl(
+ int buffersize,
+ int linebuffersize) {
+ this(buffersize, linebuffersize, null, null, null, null);
+ }
+
+ /**
+ * @since 4.3
+ */
+ public SessionOutputBufferImpl(
+ int buffersize,
+ int linebuffersize,
+ final Charset charset,
+ final CodingErrorAction malformedCharAction,
+ final CodingErrorAction unmappableCharAction) {
+ this(buffersize, linebuffersize, charset, malformedCharAction, unmappableCharAction, null);
+ }
+
public void reset(final HttpParams params) {
clear();
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java?rev=1371968&r1=1371967&r2=1371968&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java Sat Aug 11 16:08:54 2012
@@ -37,8 +37,6 @@ import org.apache.http.ReadableByteChann
import org.apache.http.impl.io.HttpTransportMetricsImpl;
import org.apache.http.impl.nio.reactor.SessionInputBufferImpl;
import org.apache.http.nio.reactor.SessionInputBuffer;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
import org.junit.Assert;
import org.junit.Test;
@@ -61,9 +59,7 @@ public class TestChunkDecoder {
String s = "5\r\n01234\r\n5\r\n56789\r\n6\r\nabcdef\r\n0\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
-
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -87,9 +83,8 @@ public class TestChunkDecoder {
"5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\nFooter2: fghij\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -125,9 +120,8 @@ public class TestChunkDecoder {
String s2 = "9\r\n6\r\nabcdef\r\n0\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s1, s2}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -170,9 +164,8 @@ public class TestChunkDecoder {
};
ReadableByteChannel channel = new ReadableByteChannelMock(
chunks, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ByteBuffer dst = ByteBuffer.allocate(1024);
@@ -208,9 +201,8 @@ public class TestChunkDecoder {
String s = "5\r\n01234\r\n5zz\r\n56789\r\n6\r\nabcdef\r\n0\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -229,9 +221,8 @@ public class TestChunkDecoder {
String s = "5\r\n01234\r\n5\r\n56789\n\r6\r\nabcdef\r\n0\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -250,9 +241,8 @@ public class TestChunkDecoder {
String s = "3\r\n12";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -272,9 +262,8 @@ public class TestChunkDecoder {
"5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\n \r\n fghij\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -296,9 +285,8 @@ public class TestChunkDecoder {
"5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1 abcde\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -318,9 +306,8 @@ public class TestChunkDecoder {
"5\r\n12345\r\n5\r\n12345";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -346,9 +333,8 @@ public class TestChunkDecoder {
"12345678901234561234567890123456\r\n0\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -379,9 +365,8 @@ public class TestChunkDecoder {
"5\r\n12345\r\n5\r\n12345\r\n0\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -404,9 +389,8 @@ public class TestChunkDecoder {
public void testInvalidConstructor() {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
try {
new ChunkDecoder(null, null, null);
Assert.fail("IllegalArgumentException should have been thrown");
@@ -433,9 +417,8 @@ public class TestChunkDecoder {
"5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1 abcde\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java?rev=1371968&r1=1371967&r2=1371968&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java Sat Aug 11 16:08:54 2012
@@ -37,8 +37,6 @@ import java.nio.channels.WritableByteCha
import org.apache.http.impl.io.HttpTransportMetricsImpl;
import org.apache.http.impl.nio.reactor.SessionOutputBufferImpl;
import org.apache.http.nio.reactor.SessionOutputBuffer;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
import org.apache.http.util.EncodingUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -60,8 +58,7 @@ public class TestChunkEncoder {
public void testBasicCoding() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
@@ -82,8 +79,7 @@ public class TestChunkEncoder {
public void testChunkNoExceed() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
encoder.write(wrap("1234"));
@@ -100,8 +96,7 @@ public class TestChunkEncoder {
@Test
public void testHttpCore239() throws Exception {
FixedByteChannel channel = new FixedByteChannel(16);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
@@ -139,8 +134,7 @@ public class TestChunkEncoder {
public void testChunkExceed() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
@@ -168,8 +162,7 @@ public class TestChunkEncoder {
public void testCodingEmptyBuffer() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
@@ -196,8 +189,7 @@ public class TestChunkEncoder {
public void testCodingCompleted() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
@@ -224,8 +216,7 @@ public class TestChunkEncoder {
public void testInvalidConstructor() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
try {
new ChunkEncoder(null, null, null);
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=1371968&r1=1371967&r2=1371968&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 Sat Aug 11 16:08:54 2012
@@ -68,7 +68,7 @@ public class TestHttpMessageParser {
@Test
public void testSimpleParsing() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.1\r\nSome header: stuff\r\n\r\n"));
@@ -81,7 +81,7 @@ public class TestHttpMessageParser {
@Test
public void testParsingChunkedMessages() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
@@ -103,7 +103,7 @@ public class TestHttpMessageParser {
@Test
public void testParsingFoldedHeaders() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
@@ -134,7 +134,7 @@ public class TestHttpMessageParser {
@Test
public void testParsingBadlyFoldedFirstHeader() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
@@ -162,7 +162,7 @@ public class TestHttpMessageParser {
@Test
public void testParsingEmptyFoldedHeader() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
@@ -193,7 +193,7 @@ public class TestHttpMessageParser {
@Test
public void testParsingIncompleteRequestLine() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
@@ -208,7 +208,7 @@ public class TestHttpMessageParser {
@Test
public void testParsingIncompleteHeader() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
@@ -224,7 +224,7 @@ public class TestHttpMessageParser {
@Test
public void testParsingInvalidRequestLine() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
@@ -241,7 +241,7 @@ public class TestHttpMessageParser {
@Test
public void testParsingInvalidStatusLine() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpResponseFactory responseFactory = DefaultHttpResponseFactory.INSTANCE;
NHttpMessageParser<HttpResponse> responseParser = new DefaultHttpResponseParser(inbuf, null, responseFactory, params);
@@ -258,7 +258,7 @@ public class TestHttpMessageParser {
@Test
public void testParsingInvalidHeader() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpResponseFactory responseFactory = DefaultHttpResponseFactory.INSTANCE;
NHttpMessageParser<HttpResponse> responseParser = new DefaultHttpResponseParser(inbuf, null, responseFactory, params);
@@ -275,7 +275,7 @@ public class TestHttpMessageParser {
@Test
public void testResetParser() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
@@ -299,7 +299,7 @@ public class TestHttpMessageParser {
@Test
public void testInvalidConstructor() {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
try {
new DefaultHttpRequestParser(null, null, null, params);
Assert.fail("IllegalArgumentException should have been thrown");
@@ -329,7 +329,7 @@ public class TestHttpMessageParser {
@Test
public void testLineLimitForStatus() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 0);
@@ -351,7 +351,7 @@ public class TestHttpMessageParser {
@Test
public void testLineLimitForHeader() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 0);
@@ -376,7 +376,7 @@ public class TestHttpMessageParser {
@Test
public void testLineLimitForFoldedHeader() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
params.setIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, 2);
@@ -393,7 +393,7 @@ public class TestHttpMessageParser {
@Test
public void testMaxHeaderCount() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
params.setIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, 2);
@@ -413,7 +413,7 @@ public class TestHttpMessageParser {
@Test
public void testDetectLineLimitEarly() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(2, 128, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(2, 128);
HttpRequestFactory requestFactory = DefaultHttpRequestFactory.INSTANCE;
params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 2);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java?rev=1371968&r1=1371967&r2=1371968&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java Sat Aug 11 16:08:54 2012
@@ -40,8 +40,6 @@ import org.apache.http.ReadableByteChann
import org.apache.http.impl.io.HttpTransportMetricsImpl;
import org.apache.http.impl.nio.reactor.SessionInputBufferImpl;
import org.apache.http.nio.reactor.SessionInputBuffer;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
import org.junit.Assert;
import org.junit.Test;
@@ -79,9 +77,8 @@ public class TestIdentityDecoder {
public void testBasicDecoding() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics);
@@ -117,9 +114,8 @@ public class TestIdentityDecoder {
public void testDecodingFromSessionBuffer() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
inbuf.fill(channel);
@@ -161,9 +157,8 @@ public class TestIdentityDecoder {
public void testBasicDecodingFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
IdentityDecoder decoder = new IdentityDecoder(
channel, inbuf, metrics);
@@ -199,9 +194,8 @@ public class TestIdentityDecoder {
public void testDecodingFileWithBufferedSessionData() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
IdentityDecoder decoder = new IdentityDecoder(
channel, inbuf, metrics);
@@ -235,9 +229,8 @@ public class TestIdentityDecoder {
public void testDecodingFileWithOffsetAndBufferedSessionData() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
IdentityDecoder decoder = new IdentityDecoder(
channel, inbuf, metrics);
@@ -278,9 +271,8 @@ public class TestIdentityDecoder {
public void testWriteBeyondFileSize() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"a"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
IdentityDecoder decoder = new IdentityDecoder(
channel, inbuf, metrics);
@@ -304,9 +296,8 @@ public class TestIdentityDecoder {
public void testInvalidConstructor() {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
try {
new IdentityDecoder(null, null, null);
Assert.fail("IllegalArgumentException should have been thrown");
@@ -332,9 +323,8 @@ public class TestIdentityDecoder {
String s = "stuff";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics);
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=1371968&r1=1371967&r2=1371968&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 Sat Aug 11 16:08:54 2012
@@ -35,8 +35,6 @@ import java.nio.channels.WritableByteCha
import org.apache.http.impl.io.HttpTransportMetricsImpl;
import org.apache.http.impl.nio.reactor.SessionOutputBufferImpl;
import org.apache.http.nio.reactor.SessionOutputBuffer;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
import org.apache.http.util.EncodingUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -58,8 +56,7 @@ public class TestIdentityEncoder {
public void testBasicCoding() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics);
@@ -76,8 +73,7 @@ public class TestIdentityEncoder {
public void testCodingEmptyBuffer() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics);
@@ -100,8 +96,7 @@ public class TestIdentityEncoder {
public void testCodingCompleted() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics);
@@ -120,8 +115,7 @@ public class TestIdentityEncoder {
public void testInvalidConstructor() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
try {
new IdentityEncoder(null, null, null);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java?rev=1371968&r1=1371967&r2=1371968&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java Sat Aug 11 16:08:54 2012
@@ -41,8 +41,6 @@ import org.apache.http.ReadableByteChann
import org.apache.http.impl.io.HttpTransportMetricsImpl;
import org.apache.http.impl.nio.reactor.SessionInputBufferImpl;
import org.apache.http.nio.reactor.SessionInputBuffer;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
@@ -95,9 +93,8 @@ public class TestLengthDelimitedDecoder
public void testBasicDecoding() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 16);
@@ -130,9 +127,8 @@ public class TestLengthDelimitedDecoder
new String[] {
"stuff;",
"more stuff; and a lot more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 16);
@@ -163,9 +159,8 @@ public class TestLengthDelimitedDecoder
public void testBasicDecodingSmallBuffer() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 16);
@@ -217,9 +212,8 @@ public class TestLengthDelimitedDecoder
public void testDecodingFromSessionBuffer1() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
inbuf.fill(channel);
@@ -257,9 +251,8 @@ public class TestLengthDelimitedDecoder
new String[] {
"stuff;",
"more stuff; and a lot more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
inbuf.fill(channel);
@@ -289,9 +282,8 @@ public class TestLengthDelimitedDecoder
public void testBasicDecodingFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 36);
@@ -318,9 +310,8 @@ public class TestLengthDelimitedDecoder
public void testDecodingFileWithBufferedSessionData() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 36);
@@ -350,9 +341,8 @@ public class TestLengthDelimitedDecoder
public void testDecodingFileWithOffsetAndBufferedSessionData() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 36);
@@ -396,9 +386,8 @@ public class TestLengthDelimitedDecoder
public void testWriteBeyondFileSize() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"a"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 1);
@@ -424,9 +413,8 @@ public class TestLengthDelimitedDecoder
new String[] {
"stuff;",
"more stuff; and a lot more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 16);
@@ -459,9 +447,8 @@ public class TestLengthDelimitedDecoder
public void testInvalidConstructor() {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
try {
new LengthDelimitedDecoder(null, null, null, 10);
@@ -494,9 +481,8 @@ public class TestLengthDelimitedDecoder
String s = "stuff";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 3);
@@ -513,9 +499,8 @@ public class TestLengthDelimitedDecoder
public void testZeroLengthDecoding() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 0);
@@ -532,9 +517,8 @@ public class TestLengthDelimitedDecoder
public void testTruncatedContent() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"1234567890"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 20);
@@ -550,9 +534,8 @@ public class TestLengthDelimitedDecoder
public void testTruncatedContentWithFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"1234567890"}, "US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 20);
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=1371968&r1=1371967&r2=1371968&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 Sat Aug 11 16:08:54 2012
@@ -40,8 +40,6 @@ import java.nio.channels.WritableByteCha
import org.apache.http.impl.io.HttpTransportMetricsImpl;
import org.apache.http.impl.nio.reactor.SessionOutputBufferImpl;
import org.apache.http.nio.reactor.SessionOutputBuffer;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
import org.apache.http.util.EncodingUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -63,8 +61,7 @@ public class TestLengthDelimitedEncoder
public void testBasicCoding() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
@@ -82,8 +79,7 @@ public class TestLengthDelimitedEncoder
public void testCodingBeyondContentLimit() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
@@ -101,8 +97,7 @@ public class TestLengthDelimitedEncoder
public void testCodingEmptyBuffer() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
@@ -126,8 +121,7 @@ public class TestLengthDelimitedEncoder
public void testCodingCompleted() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
@@ -147,8 +141,7 @@ public class TestLengthDelimitedEncoder
public void testCodingBeyondContentLimitFromFile() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
@@ -188,8 +181,7 @@ public class TestLengthDelimitedEncoder
public void testCodingEmptyFile() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
@@ -223,8 +215,7 @@ public class TestLengthDelimitedEncoder
public void testCodingCompletedFromFile() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
@@ -256,8 +247,7 @@ public class TestLengthDelimitedEncoder
public void testCodingFromFileSmaller() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
@@ -290,8 +280,7 @@ public class TestLengthDelimitedEncoder
public void testInvalidConstructor() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
try {
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=1371968&r1=1371967&r2=1371968&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 Sat Aug 11 16:08:54 2012
@@ -37,11 +37,9 @@ import java.nio.channels.WritableByteCha
import java.nio.charset.CharacterCodingException;
import java.nio.charset.CodingErrorAction;
+import org.apache.http.Consts;
import org.apache.http.nio.reactor.SessionInputBuffer;
import org.apache.http.nio.reactor.SessionOutputBuffer;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpCoreConfigBuilder;
-import org.apache.http.params.HttpParams;
import org.apache.http.util.CharArrayBuffer;
import org.junit.Assert;
import org.junit.Test;
@@ -71,9 +69,7 @@ public class TestSessionInOutBuffers {
@Test
public void testReadLineChunks() throws Exception {
-
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16);
ReadableByteChannel channel = newChannel("One\r\nTwo\r\nThree");
@@ -111,10 +107,8 @@ public class TestSessionInOutBuffers {
@Test
public void testWriteLineChunks() throws Exception {
-
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16, params);
- SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16);
ReadableByteChannel inChannel = newChannel("One\r\nTwo\r\nThree");
@@ -181,9 +175,7 @@ public class TestSessionInOutBuffers {
teststrs[3] = "";
teststrs[4] = "And goodbye";
- HttpParams params = new BasicHttpParams();
-
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16);
for (int i = 0; i < teststrs.length; i++) {
outbuf.writeLine(teststrs[i]);
}
@@ -197,7 +189,7 @@ public class TestSessionInOutBuffers {
ReadableByteChannel channel = newChannel(outstream.toByteArray());
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16);
inbuf.fill(channel);
for (int i = 0; i < teststrs.length; i++) {
@@ -209,9 +201,7 @@ public class TestSessionInOutBuffers {
@Test
public void testComplexReadWriteLine() throws Exception {
- HttpParams params = new BasicHttpParams();
-
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16);
outbuf.write(ByteBuffer.wrap(new byte[] {'a', '\n'}));
outbuf.write(ByteBuffer.wrap(new byte[] {'\r', '\n'}));
outbuf.write(ByteBuffer.wrap(new byte[] {'\r', '\r', '\n'}));
@@ -249,7 +239,7 @@ public class TestSessionInOutBuffers {
ReadableByteChannel channel = newChannel(outstream.toByteArray());
- SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16);
inbuf.fill(channel);
Assert.assertEquals("a", inbuf.readLine(true));
@@ -272,8 +262,7 @@ public class TestSessionInOutBuffers {
out[i] = (byte)('0' + i);
}
ReadableByteChannel channel = newChannel(out);
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16);
while (inbuf.fill(channel) > 0) {
}
@@ -290,8 +279,7 @@ public class TestSessionInOutBuffers {
public void testReadByteBuffer() throws Exception {
byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
ReadableByteChannel channel = newChannel(pattern);
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024);
while (inbuf.fill(channel) > 0) {
}
ByteBuffer dst = ByteBuffer.allocate(10);
@@ -308,8 +296,7 @@ public class TestSessionInOutBuffers {
public void testReadByteBufferWithMaxLen() throws Exception {
byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
ReadableByteChannel channel = newChannel(pattern);
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024);
while (inbuf.fill(channel) > 0) {
}
ByteBuffer dst = ByteBuffer.allocate(16);
@@ -329,8 +316,7 @@ public class TestSessionInOutBuffers {
public void testReadToChannel() throws Exception {
byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
ReadableByteChannel channel = newChannel(pattern);
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024);
while (inbuf.fill(channel) > 0) {
}
@@ -345,8 +331,7 @@ public class TestSessionInOutBuffers {
public void testReadToChannelWithMaxLen() throws Exception {
byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
ReadableByteChannel channel = newChannel(pattern);
- HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024);
while (inbuf.fill(channel) > 0) {
}
@@ -363,8 +348,7 @@ public class TestSessionInOutBuffers {
public void testWriteByteBuffer() throws Exception {
byte[] pattern = "0123456789ABCDEF0123456789ABCDEF".getBytes("US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(4096, 1024, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(4096, 1024);
ReadableByteChannel src = newChannel(pattern);
outbuf.write(src);
@@ -379,8 +363,7 @@ public class TestSessionInOutBuffers {
public void testWriteFromChannel() throws Exception {
byte[] pattern = "0123456789ABCDEF0123456789ABCDEF".getBytes("US-ASCII");
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(4096, 1024, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(4096, 1024);
outbuf.write(ByteBuffer.wrap(pattern, 0, 16));
outbuf.write(ByteBuffer.wrap(pattern, 16, 10));
outbuf.write(ByteBuffer.wrap(pattern, 26, 6));
@@ -417,11 +400,7 @@ public class TestSessionInOutBuffers {
String s2 = constructString(RUSSIAN_HELLO);
String s3 = "Like hello and stuff";
- HttpParams params = new HttpCoreConfigBuilder()
- .setHttpElementCharset("UTF-8")
- .build();
-
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, Consts.UTF_8, null, null);
for (int i = 0; i < 10; i++) {
outbuf.writeLine(s1);
@@ -436,7 +415,7 @@ public class TestSessionInOutBuffers {
byte[] tmp = outstream.toByteArray();
ReadableByteChannel channel = newChannel(tmp);
- SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, Consts.UTF_8, null, null);
while (inbuf.fill(channel) > 0) {
}
@@ -450,9 +429,8 @@ public class TestSessionInOutBuffers {
@Test
public void testMalformedCharacters() throws Exception {
- HttpParams params = new BasicHttpParams();
String s1 = constructString(SWISS_GERMAN_HELLO);
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16);
try {
outbuf.writeLine(s1);
Assert.fail("Expected CharacterCodingException");
@@ -461,7 +439,7 @@ public class TestSessionInOutBuffers {
byte[] tmp = s1.getBytes("ISO-8859-1");
ReadableByteChannel channel = newChannel(tmp);
- SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16);
while (inbuf.fill(channel) > 0) {
}
@@ -474,90 +452,86 @@ public class TestSessionInOutBuffers {
@Test
public void testInputMatchesBufferLength() throws Exception {
- HttpParams params = new BasicHttpParams();
String s1 = "abcde";
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 5, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 5);
outbuf.writeLine(s1);
}
- @Test
- public void testMalformedInputAction() throws Exception {
- String s1 = constructString(SWISS_GERMAN_HELLO);
- byte[] tmp = s1.getBytes("ISO-8859-1");
+ @Test(expected=CharacterCodingException.class)
+ public void testMalformedInputActionReport() throws Exception {
+ String s = constructString(SWISS_GERMAN_HELLO);
+ byte[] tmp = s.getBytes("ISO-8859-1");
- // Action with report
- HttpParams params = new HttpCoreConfigBuilder()
- .setMalformedInputAction(CodingErrorAction.REPORT)
- .build();
- SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, Consts.ASCII,
+ CodingErrorAction.REPORT, CodingErrorAction.IGNORE);
ReadableByteChannel channel = newChannel(tmp);
while (inbuf.fill(channel) > 0) {
}
- try {
- String s = inbuf.readLine(true);
- Assert.fail("Expected CharacterCodingException, got '" + s + "'");
- } catch (CharacterCodingException expected) {
- }
+ inbuf.readLine(true);
+ }
- // Action with ignore
- params = new HttpCoreConfigBuilder()
- .setMalformedInputAction(CodingErrorAction.IGNORE)
- .build();
- inbuf = new SessionInputBufferImpl(16, 16, params);
- channel = newChannel(tmp);
+ @Test
+ public void testMalformedInputActionIgnore() throws Exception {
+ String s = constructString(SWISS_GERMAN_HELLO);
+ byte[] tmp = s.getBytes("ISO-8859-1");
+
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, Consts.ASCII,
+ CodingErrorAction.IGNORE, CodingErrorAction.IGNORE);
+ ReadableByteChannel channel = newChannel(tmp);
while (inbuf.fill(channel) > 0) {
}
- String s2 = inbuf.readLine(true);
- Assert.assertEquals("Grezi_zm", s2);
+ String result = inbuf.readLine(true);
+ Assert.assertEquals("Grezi_zm", result);
+ }
- // Action with replace
- params = new HttpCoreConfigBuilder()
- .setMalformedInputAction(CodingErrorAction.REPLACE)
- .build();
- inbuf = new SessionInputBufferImpl(16, 16, params);
- channel = newChannel(tmp);
+ @Test
+ public void testMalformedInputActionReplace() throws Exception {
+ String s = constructString(SWISS_GERMAN_HELLO);
+ byte[] tmp = s.getBytes("ISO-8859-1");
+
+ SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, Consts.ASCII,
+ CodingErrorAction.REPLACE, CodingErrorAction.IGNORE);
+ ReadableByteChannel channel = newChannel(tmp);
while (inbuf.fill(channel) > 0) {
}
- String s3 = inbuf.readLine(true);
- Assert.assertEquals("Gr\ufffdezi_z\ufffdm\ufffd", s3);
+ String result = inbuf.readLine(true);
+ Assert.assertEquals("Gr\ufffdezi_z\ufffdm\ufffd", result);
+ }
+
+ @Test(expected=CharacterCodingException.class)
+ public void testUnmappableInputActionReport() throws Exception {
+ String s = constructString(SWISS_GERMAN_HELLO);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, Consts.ASCII,
+ CodingErrorAction.IGNORE, CodingErrorAction.REPORT);
+ outbuf.writeLine(s);
}
@Test
- public void testUnmappableInputAction() throws Exception {
- String s1 = constructString(SWISS_GERMAN_HELLO);
+ public void testUnmappableInputActionIgnore() throws Exception {
+ String s = constructString(SWISS_GERMAN_HELLO);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, Consts.ASCII,
+ CodingErrorAction.IGNORE, CodingErrorAction.IGNORE);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ WritableByteChannel channel = newChannel(baos);
+ outbuf.writeLine(s);
+ outbuf.flush(channel);
- // Action with report
- HttpParams params = new HttpCoreConfigBuilder()
- .setUnmappableInputAction(CodingErrorAction.REPORT)
- .build();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, params);
- try {
- outbuf.writeLine(s1);
- Assert.fail("Expected CharacterCodingException");
- } catch (CharacterCodingException expected) {
- }
+ String result = new String(baos.toByteArray(), "US-ASCII");
+ Assert.assertEquals("Grezi_zm\r\n", result);
+ }
- // Action with ignore
- params = new HttpCoreConfigBuilder()
- .setUnmappableInputAction(CodingErrorAction.IGNORE)
- .build();
- outbuf = new SessionOutputBufferImpl(1024, 16, params);
- try {
- outbuf.writeLine(s1);
- } catch (CharacterCodingException e) {
- Assert.fail("Unexpected CharacterCodingException");
- }
+ @Test
+ public void testUnmappableInputActionReplace() throws Exception {
+ String s = constructString(SWISS_GERMAN_HELLO);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, Consts.ASCII,
+ CodingErrorAction.IGNORE, CodingErrorAction.REPLACE);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ WritableByteChannel channel = newChannel(baos);
+ outbuf.writeLine(s);
+ outbuf.flush(channel);
- // Action with replace
- params = new HttpCoreConfigBuilder()
- .setUnmappableInputAction(CodingErrorAction.REPLACE)
- .build();
- outbuf = new SessionOutputBufferImpl(1024, 16, params);
- try {
- outbuf.writeLine(s1);
- } catch (CharacterCodingException e) {
- Assert.fail("Unexpected CharacterCodingException");
- }
+ String result = new String(baos.toByteArray(), "US-ASCII");
+ Assert.assertEquals("Gr?ezi_z?m?\r\n", result);
}
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java?rev=1371968&r1=1371967&r2=1371968&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java Sat Aug 11 16:08:54 2012
@@ -41,8 +41,6 @@ import org.apache.http.io.BufferInfo;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.ContentEncoder;
import org.apache.http.nio.reactor.SessionOutputBuffer;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
import org.apache.http.util.EncodingUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -90,8 +88,7 @@ public class TestBuffers {
public void testOutputBufferOperations() throws IOException {
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
WritableByteChannel channel = Channels.newChannel(outstream);
- HttpParams params = new BasicHttpParams();
- SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
+ SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ContentEncoder encoder = new ContentEncoderMock(channel, outbuf, metrics);
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java?rev=1371968&r1=1371967&r2=1371968&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java Sat Aug 11 16:08:54 2012
@@ -33,7 +33,10 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketException;
+import java.nio.charset.Charset;
+import java.nio.charset.CodingErrorAction;
+import org.apache.http.Consts;
import org.apache.http.HttpInetConnection;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.impl.io.SocketInputBuffer;
@@ -41,8 +44,10 @@ import org.apache.http.impl.io.SocketOut
import org.apache.http.io.SessionInputBuffer;
import org.apache.http.io.SessionOutputBuffer;
import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.params.HttpParams;
import org.apache.http.util.Args;
+import org.apache.http.util.CharsetUtils;
/**
* Implementation of a client-side HTTP connection that can be bound to an
@@ -105,7 +110,19 @@ public class SocketHttpClientConnection
final Socket socket,
int buffersize,
final HttpParams params) throws IOException {
- return new SocketInputBuffer(socket, buffersize, params);
+ Charset charset = CharsetUtils.get(
+ (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET));
+ if (charset == null) {
+ charset = Consts.ASCII;
+ }
+ int maxLineLen = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1);
+ int minChunkLimit = params.getIntParameter(CoreConnectionPNames.MIN_CHUNK_LIMIT, -1);
+ CodingErrorAction malformedCharAction = (CodingErrorAction) params.getParameter(
+ CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION);
+ CodingErrorAction unmappableCharAction = (CodingErrorAction) params.getParameter(
+ CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION);
+ return SocketInputBuffer.create(socket, buffersize, charset, maxLineLen, minChunkLimit,
+ malformedCharAction, unmappableCharAction);
}
/**
@@ -127,7 +144,18 @@ public class SocketHttpClientConnection
final Socket socket,
int buffersize,
final HttpParams params) throws IOException {
- return new SocketOutputBuffer(socket, buffersize, params);
+ Charset charset = CharsetUtils.get(
+ (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET));
+ if (charset == null) {
+ charset = Consts.ASCII;
+ }
+ int minChunkLimit = params.getIntParameter(CoreConnectionPNames.MIN_CHUNK_LIMIT, -1);
+ CodingErrorAction malformedCharAction = (CodingErrorAction) params.getParameter(
+ CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION);
+ CodingErrorAction unmappableCharAction = (CodingErrorAction) params.getParameter(
+ CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION);
+ return SocketOutputBuffer.create(socket, buffersize, charset, minChunkLimit,
+ malformedCharAction, unmappableCharAction);
}
/**
|