You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2016/11/03 19:36:26 UTC
svn commit: r1767957 - in /httpcomponents/httpcore/trunk:
httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/
httpcore5/src/examples/org/apache/hc/core5/http/examples/
httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ httpco...
Author: olegk
Date: Thu Nov 3 19:36:26 2016
New Revision: 1767957
URL: http://svn.apache.org/viewvc?rev=1767957&view=rev
Log:
Removed obsolete util classes
Removed:
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/ByteBufferAllocator.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/CharsetUtils.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/DirectByteBufferAllocator.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/HeapByteBufferAllocator.java
Modified:
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/FrameworkTest.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFrameworkRequestHandler.java
httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ExpandableBuffer.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/entity/AbstractSharedBuffer.java
httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkDecoder.java
httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityDecoder.java
httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedDecoder.java
httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/FrameworkTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/FrameworkTest.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/FrameworkTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/FrameworkTest.java Thu Nov 3 19:36:26 2016
@@ -46,9 +46,12 @@ import java.util.List;
import java.util.Map;
import org.apache.hc.core5.http.NameValuePair;
-import org.apache.hc.core5.util.URLEncodedUtils; public class FrameworkTest {
- private Map<String, Object> request = new HashMap<String, Object>();
- private Map<String, Object> response = new HashMap<String, Object>();
+import org.apache.hc.core5.net.URLEncodedUtils;
+
+public class FrameworkTest {
+
+ private Map<String, Object> request = new HashMap<>();
+ private Map<String, Object> response = new HashMap<>();
/**
* Constructs a test with default values.
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFrameworkRequestHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFrameworkRequestHandler.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFrameworkRequestHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFrameworkRequestHandler.java Thu Nov 3 19:36:26 2016
@@ -55,7 +55,9 @@ import org.apache.hc.core5.http.io.entit
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.protocol.HttpContext;
-import org.apache.hc.core5.util.URLEncodedUtils; public class TestingFrameworkRequestHandler implements HttpRequestHandler {
+import org.apache.hc.core5.net.URLEncodedUtils;
+
+public class TestingFrameworkRequestHandler implements HttpRequestHandler {
protected Throwable thrown;
protected Map<String, Object> requestExpectations;
protected Map<String, Object> desiredResponse;
Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java Thu Nov 3 19:36:26 2016
@@ -84,7 +84,6 @@ import org.apache.hc.core5.pool.PoolStat
import org.apache.hc.core5.reactor.ConnectionInitiator;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.reactor.IOSession;
-import org.apache.hc.core5.util.HeapByteBufferAllocator;
/**
* Example of asynchronous embedded HTTP/1.1 reverse proxy with full content streaming.
@@ -218,7 +217,7 @@ public class AsyncReverseProxyExample {
private static class ProxyBuffer extends ExpandableBuffer {
ProxyBuffer(int buffersize) {
- super(buffersize, HeapByteBufferAllocator.INSTANCE);
+ super(buffersize);
}
void put(final ByteBuffer src) {
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java Thu Nov 3 19:36:26 2016
@@ -46,6 +46,7 @@ import org.apache.hc.core5.http.HttpMess
import org.apache.hc.core5.http.Message;
import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
import org.apache.hc.core5.http.impl.ConnSupport;
@@ -64,7 +65,6 @@ import org.apache.hc.core5.reactor.Comma
import org.apache.hc.core5.reactor.EventMask;
import org.apache.hc.core5.reactor.IOSession;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.HeapByteBufferAllocator;
abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage, OutgoingMessage extends HttpMessage>
implements ResourceHolder, HttpConnection {
@@ -97,13 +97,11 @@ abstract class AbstractHttp1StreamDuplex
this.ioSession = Args.notNull(ioSession, "I/O session");
final int bufferSize = connectionConfig.getBufferSize();
this.inbuf = new SessionInputBufferImpl(bufferSize,
- bufferSize < 512 ? bufferSize : 512,
- ConnSupport.createDecoder(connectionConfig),
- HeapByteBufferAllocator.INSTANCE);
+ bufferSize < 512 ? bufferSize : 512, H1Config.DEFAULT,
+ ConnSupport.createDecoder(connectionConfig));
this.outbuf = new SessionOutputBufferImpl(bufferSize,
bufferSize < 512 ? bufferSize : 512,
- ConnSupport.createEncoder(connectionConfig),
- HeapByteBufferAllocator.INSTANCE);
+ ConnSupport.createEncoder(connectionConfig));
this.inTransportMetrics = new BasicHttpTransportMetrics();
this.outTransportMetrics = new BasicHttpTransportMetrics();
this.connMetrics = new BasicHttpConnectionMetrics(inTransportMetrics, outTransportMetrics);
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ExpandableBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ExpandableBuffer.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ExpandableBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ExpandableBuffer.java Thu Nov 3 19:36:26 2016
@@ -29,13 +29,9 @@ package org.apache.hc.core5.http.impl.ni
import java.nio.ByteBuffer;
-import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.ByteBufferAllocator;
-
/**
- * A buffer that expand its capacity on demand using {@link ByteBufferAllocator}
- * interface. Internally, this class is backed by an instance of
- * {@link ByteBuffer}.
+ * A buffer that expand its capacity on demand. Internally, this class is backed
+ * by an instance of {@link ByteBuffer}.
* <p>
* This class is not thread safe.
*
@@ -46,8 +42,6 @@ public class ExpandableBuffer {
public final static int INPUT_MODE = 0;
public final static int OUTPUT_MODE = 1;
- private final ByteBufferAllocator allocator;
-
private int mode;
private ByteBuffer buffer;
@@ -55,13 +49,10 @@ public class ExpandableBuffer {
* Allocates buffer of the given size using the given allocator.
*
* @param buffersize the buffer size.
- * @param allocator allocator to be used to allocate {@link ByteBuffer}s.
*/
- protected ExpandableBuffer(final int buffersize, final ByteBufferAllocator allocator) {
+ protected ExpandableBuffer(final int buffersize) {
super();
- Args.notNull(allocator, "ByteBuffer allocator");
- this.allocator = allocator;
- this.buffer = allocator.allocate(buffersize);
+ this.buffer = ByteBuffer.allocate(buffersize);
this.mode = INPUT_MODE;
}
@@ -108,7 +99,7 @@ public class ExpandableBuffer {
private void expandCapacity(final int capacity) {
final ByteBuffer oldbuffer = this.buffer;
- this.buffer = allocator.allocate(capacity);
+ this.buffer = ByteBuffer.allocate(capacity);
oldbuffer.flip();
this.buffer.put(oldbuffer);
}
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java Thu Nov 3 19:36:26 2016
@@ -41,9 +41,7 @@ import org.apache.hc.core5.http.MessageC
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.nio.SessionInputBuffer;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.ByteBufferAllocator;
import org.apache.hc.core5.util.CharArrayBuffer;
-import org.apache.hc.core5.util.HeapByteBufferAllocator;
/**
* Default implementation of {@link SessionInputBuffer} based on
@@ -54,7 +52,7 @@ import org.apache.hc.core5.util.HeapByte
public class SessionInputBufferImpl extends ExpandableBuffer implements SessionInputBuffer {
private final CharsetDecoder chardecoder;
- private final H1Config constraints;
+ private final H1Config h1Config;
private final int lineBuffersize;
private CharBuffer charbuffer;
@@ -67,55 +65,31 @@ public class SessionInputBufferImpl exte
* {@code chardecoder} is not {@code null}.
* @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param constraints Message constraints. If {@code null}
+ * @param h1Config Message h1Config. If {@code null}
* {@link H1Config#DEFAULT} will be used.
- * @param allocator memory allocator.
- * If {@code null} {@link HeapByteBufferAllocator#INSTANCE} will be used.
*
* @since 4.4
*/
public SessionInputBufferImpl(
final int buffersize,
final int lineBuffersize,
- final H1Config constraints,
- final CharsetDecoder chardecoder,
- final ByteBufferAllocator allocator) {
- super(buffersize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
+ final H1Config h1Config,
+ final CharsetDecoder chardecoder) {
+ super(buffersize);
this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
- this.constraints = constraints != null ? constraints : H1Config.DEFAULT;
+ this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
this.chardecoder = chardecoder;
}
/**
- * Creates SessionInputBufferImpl instance.
- *
- * @param buffersize input buffer size
- * @param lineBuffersize buffer size for line operations. Has effect only if
- * {@code chardecoder} is not {@code null}.
- * @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
- * If {@code null} simple type cast will be used for byte to char conversion.
- * @param allocator memory allocator.
- * If {@code null} {@link HeapByteBufferAllocator#INSTANCE} will be used.
- *
- * @since 4.3
- */
- public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
- final CharsetDecoder chardecoder,
- final ByteBufferAllocator allocator) {
- this(buffersize, lineBuffersize, null, chardecoder, allocator);
- }
-
- /**
* @since 4.3
*/
public SessionInputBufferImpl(
final int buffersize,
final int lineBuffersize,
+ final H1Config h1Config,
final Charset charset) {
- this(buffersize, lineBuffersize, null,
- charset != null ? charset.newDecoder() : null, HeapByteBufferAllocator.INSTANCE);
+ this(buffersize, lineBuffersize, h1Config, charset != null ? charset.newDecoder() : null);
}
/**
@@ -124,10 +98,8 @@ public class SessionInputBufferImpl exte
public SessionInputBufferImpl(
final int buffersize,
final int lineBuffersize,
- final H1Config constraints,
- final Charset charset) {
- this(buffersize, lineBuffersize, constraints,
- charset != null ? charset.newDecoder() : null, HeapByteBufferAllocator.INSTANCE);
+ final H1Config h1Config) {
+ this(buffersize, lineBuffersize, h1Config, (CharsetDecoder) null);
}
/**
@@ -136,14 +108,14 @@ public class SessionInputBufferImpl exte
public SessionInputBufferImpl(
final int buffersize,
final int lineBuffersize) {
- this(buffersize, lineBuffersize, null, null, HeapByteBufferAllocator.INSTANCE);
+ this(buffersize, lineBuffersize, null, (CharsetDecoder) null);
}
/**
* @since 4.3
*/
public SessionInputBufferImpl(final int buffersize) {
- this(buffersize, 256, null, null, HeapByteBufferAllocator.INSTANCE);
+ this(buffersize, 256);
}
@Override
@@ -234,7 +206,7 @@ public class SessionInputBufferImpl exte
}
}
- final int maxLineLen = this.constraints.getMaxLineLength();
+ final int maxLineLen = this.h1Config.getMaxLineLength();
if (maxLineLen > 0) {
final int currentLen = (pos > 0 ? pos : buffer().limit()) - buffer().position();
if (currentLen >= maxLineLen) {
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java Thu Nov 3 19:36:26 2016
@@ -40,9 +40,7 @@ import java.nio.charset.CoderResult;
import org.apache.hc.core5.http.Chars;
import org.apache.hc.core5.http.nio.SessionOutputBuffer;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.ByteBufferAllocator;
import org.apache.hc.core5.util.CharArrayBuffer;
-import org.apache.hc.core5.util.HeapByteBufferAllocator;
/**
* Default implementation of {@link SessionOutputBuffer} based on
@@ -67,17 +65,14 @@ public class SessionOutputBufferImpl ext
* {@code charencoder} is not {@code null}.
* @param charencoder charencoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
- * @param allocator memory allocator.
- * If {@code null} {@link HeapByteBufferAllocator#INSTANCE} will be used.
*
* @since 4.3
*/
public SessionOutputBufferImpl(
final int buffersize,
final int lineBuffersize,
- final CharsetEncoder charencoder,
- final ByteBufferAllocator allocator) {
- super(buffersize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
+ final CharsetEncoder charencoder) {
+ super(buffersize);
this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
this.charencoder = charencoder;
}
@@ -85,19 +80,11 @@ public class SessionOutputBufferImpl ext
/**
* @since 4.3
*/
- public SessionOutputBufferImpl(final int buffersize) {
- this(buffersize, 256, null, HeapByteBufferAllocator.INSTANCE);
- }
-
- /**
- * @since 4.3
- */
public SessionOutputBufferImpl(
final int buffersize,
final int linebuffersize,
final Charset charset) {
- this(buffersize, linebuffersize,
- charset != null ? charset.newEncoder() : null, HeapByteBufferAllocator.INSTANCE);
+ this(buffersize, linebuffersize, charset != null ? charset.newEncoder() : null);
}
/**
@@ -106,7 +93,14 @@ public class SessionOutputBufferImpl ext
public SessionOutputBufferImpl(
final int buffersize,
final int linebuffersize) {
- this(buffersize, linebuffersize, null, HeapByteBufferAllocator.INSTANCE);
+ this(buffersize, linebuffersize, (CharsetEncoder) null);
+ }
+
+ /**
+ * @since 4.3
+ */
+ public SessionOutputBufferImpl(final int buffersize) {
+ this(buffersize, 256);
}
@Override
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/entity/AbstractSharedBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/entity/AbstractSharedBuffer.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/entity/AbstractSharedBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/entity/AbstractSharedBuffer.java Thu Nov 3 19:36:26 2016
@@ -33,7 +33,6 @@ import org.apache.hc.core5.annotation.Co
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.impl.nio.ExpandableBuffer;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.HeapByteBufferAllocator;
/**
* @since 5.0
@@ -48,7 +47,7 @@ abstract class AbstractSharedBuffer exte
volatile boolean aborted;
public AbstractSharedBuffer(final ReentrantLock lock, final int initialBufferSize) {
- super(initialBufferSize, HeapByteBufferAllocator.INSTANCE);
+ super(initialBufferSize);
this.lock = Args.notNull(lock, "Lock");
this.condition = lock.newCondition();
}
Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkDecoder.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkDecoder.java Thu Nov 3 19:36:26 2016
@@ -54,7 +54,7 @@ public class TestChunkDecoder {
final String s = "5\r\n01234\r\n5\r\n56789\r\n6\r\nabcdef\r\n0\r\n\r\n";
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -80,7 +80,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -117,7 +117,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s1, s2}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -153,7 +153,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(32, 32, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(32, 32, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -183,7 +183,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
chunks, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ByteBuffer dst = ByteBuffer.allocate(1024);
@@ -220,7 +220,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -234,7 +234,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -248,7 +248,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -264,7 +264,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -287,7 +287,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -302,7 +302,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -320,7 +320,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -350,7 +350,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -382,7 +382,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
@@ -407,9 +407,8 @@ public class TestChunkDecoder {
final ReadableByteChannel channel1 = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf1 = new SessionInputBufferImpl(1024, 256,
- H1Config.DEFAULT, null, null);
final BasicHttpTransportMetrics metrics1 = new BasicHttpTransportMetrics();
+ final SessionInputBuffer inbuf1 = new SessionInputBufferImpl(1024, 256);
final ChunkDecoder decoder1 = new ChunkDecoder(channel1, inbuf1, metrics1);
final ByteBuffer dst = ByteBuffer.allocate(1024);
@@ -424,7 +423,7 @@ public class TestChunkDecoder {
new String[] {s}, StandardCharsets.US_ASCII);
final SessionInputBuffer inbuf2 = new SessionInputBufferImpl(1024, 256,
- H1Config.custom().setMaxLineLength(10).build(), null, null);
+ H1Config.custom().setMaxLineLength(10).build());
final BasicHttpTransportMetrics metrics2 = new BasicHttpTransportMetrics();
final ChunkDecoder decoder2 = new ChunkDecoder(channel2, inbuf2, metrics2);
@@ -553,7 +552,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
try {
new ChunkDecoder(null, null, null);
Assert.fail("IllegalArgumentException should have been thrown");
@@ -581,7 +580,7 @@ public class TestChunkDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
decoder.read(null);
@@ -591,7 +590,7 @@ public class TestChunkDecoder {
public void testHugeChunk() throws Exception {
final String s = "1234567890abcdef\r\n0123456789abcdef";
final ReadableByteChannel channel = new ReadableByteChannelMock(new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityDecoder.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityDecoder.java Thu Nov 3 19:36:26 2016
@@ -36,6 +36,7 @@ import java.nio.channels.ReadableByteCha
import java.nio.charset.StandardCharsets;
import org.apache.hc.core5.http.ReadableByteChannelMock;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
import org.apache.hc.core5.http.nio.SessionInputBuffer;
import org.junit.After;
@@ -66,7 +67,7 @@ public class TestIdentityDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics);
@@ -105,7 +106,7 @@ public class TestIdentityDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
inbuf.fill(channel);
@@ -148,7 +149,7 @@ public class TestIdentityDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final IdentityDecoder decoder = new IdentityDecoder(
channel, inbuf, metrics);
@@ -178,7 +179,7 @@ public class TestIdentityDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final IdentityDecoder decoder = new IdentityDecoder(
channel, inbuf, metrics);
@@ -212,7 +213,7 @@ public class TestIdentityDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final IdentityDecoder decoder = new IdentityDecoder(
channel, inbuf, metrics);
@@ -259,7 +260,7 @@ public class TestIdentityDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"a"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final IdentityDecoder decoder = new IdentityDecoder(
channel, inbuf, metrics);
@@ -283,7 +284,7 @@ public class TestIdentityDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
try {
new IdentityDecoder(null, null, null);
Assert.fail("IllegalArgumentException should have been thrown");
@@ -310,7 +311,7 @@ public class TestIdentityDecoder {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics);
Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedDecoder.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedDecoder.java Thu Nov 3 19:36:26 2016
@@ -37,6 +37,7 @@ import java.nio.charset.StandardCharsets
import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.http.ReadableByteChannelMock;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
import org.apache.hc.core5.http.nio.SessionInputBuffer;
import org.junit.After;
@@ -67,7 +68,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 16);
@@ -103,7 +104,7 @@ public class TestLengthDelimitedDecoder
"stuff;",
"more stuff; and a lot more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 16);
@@ -135,7 +136,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 16);
@@ -188,7 +189,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
inbuf.fill(channel);
@@ -227,7 +228,7 @@ public class TestLengthDelimitedDecoder
"stuff;",
"more stuff; and a lot more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
inbuf.fill(channel);
@@ -259,7 +260,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 36);
@@ -288,7 +289,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 36);
@@ -320,7 +321,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 36);
@@ -367,7 +368,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"a"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 1);
@@ -394,7 +395,7 @@ public class TestLengthDelimitedDecoder
"stuff;",
"more stuff; and a lot more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 16);
@@ -428,7 +429,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
try {
new LengthDelimitedDecoder(null, null, null, 10);
@@ -462,7 +463,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 3);
@@ -480,7 +481,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 0);
@@ -498,7 +499,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"1234567890"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 20);
@@ -515,7 +516,7 @@ public class TestLengthDelimitedDecoder
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"1234567890"}, StandardCharsets.US_ASCII);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, StandardCharsets.US_ASCII);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, H1Config.DEFAULT, StandardCharsets.US_ASCII);
final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
channel, inbuf, metrics, 20);
Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java?rev=1767957&r1=1767956&r2=1767957&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java Thu Nov 3 19:36:26 2016
@@ -40,44 +40,20 @@ import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Collection;
import org.apache.hc.core5.http.MessageConstraintException;
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.nio.SessionInputBuffer;
import org.apache.hc.core5.http.nio.SessionOutputBuffer;
-import org.apache.hc.core5.util.ByteBufferAllocator;
import org.apache.hc.core5.util.CharArrayBuffer;
-import org.apache.hc.core5.util.DirectByteBufferAllocator;
-import org.apache.hc.core5.util.HeapByteBufferAllocator;
import org.junit.Assert;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
/**
* Simple tests for {@link SessionInputBuffer} and {@link SessionOutputBuffer}.
*/
-@RunWith(Parameterized.class)
public class TestSessionInOutBuffers {
- private final ByteBufferAllocator allocator;
-
- public TestSessionInOutBuffers(final ByteBufferAllocator allocator) {
- super();
- this.allocator = allocator;
- }
-
- @Parameters
- public static Collection<Object[]> getParameters() {
-
- return Arrays.asList(
- new Object[] { HeapByteBufferAllocator.INSTANCE },
- new Object[] { DirectByteBufferAllocator.INSTANCE });
- }
-
private static WritableByteChannel newChannel(final ByteArrayOutputStream outstream) {
return Channels.newChannel(outstream);
}
@@ -98,7 +74,7 @@ public class TestSessionInOutBuffers {
@Test
public void testReadLineChunks() throws Exception {
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, null, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16);
ReadableByteChannel channel = newChannel("One\r\nTwo\r\nThree");
@@ -138,8 +114,7 @@ public class TestSessionInOutBuffers {
public void testLineLimit() throws Exception {
final String s = "LoooooooooooooooooooooooooOOOOOOOOOOOOOOOOOOoooooooooooooooooooooong line\r\n";
final CharArrayBuffer line = new CharArrayBuffer(64);
- final SessionInputBuffer inbuf1 = new SessionInputBufferImpl(128, 128,
- H1Config.DEFAULT, null, this.allocator);
+ final SessionInputBuffer inbuf1 = new SessionInputBufferImpl(128, 128);
final ReadableByteChannel channel1 = newChannel(s);
inbuf1.fill(channel1);
@@ -147,7 +122,7 @@ public class TestSessionInOutBuffers {
line.clear();
final SessionInputBuffer inbuf2 = new SessionInputBufferImpl(128, 128,
- H1Config.custom().setMaxLineLength(10).build(), null, this.allocator);
+ H1Config.custom().setMaxLineLength(10).build());
final ReadableByteChannel channel2 = newChannel(s);
inbuf2.fill(channel2);
try {
@@ -161,8 +136,7 @@ public class TestSessionInOutBuffers {
public void testLineLimitBufferFull() throws Exception {
final String s = "LoooooooooooooooooooooooooOOOOOOOOOOOOOOOOOOoooooooooooooooooooooong line\r\n";
final CharArrayBuffer line = new CharArrayBuffer(64);
- final SessionInputBuffer inbuf1 = new SessionInputBufferImpl(32, 32,
- H1Config.DEFAULT, null, this.allocator);
+ final SessionInputBuffer inbuf1 = new SessionInputBufferImpl(32, 32);
final ReadableByteChannel channel1 = newChannel(s);
inbuf1.fill(channel1);
@@ -170,7 +144,7 @@ public class TestSessionInOutBuffers {
line.clear();
final SessionInputBuffer inbuf2 = new SessionInputBufferImpl(32, 32,
- H1Config.custom().setMaxLineLength(10).build(), null, this.allocator);
+ H1Config.custom().setMaxLineLength(10).build());
final ReadableByteChannel channel2 = newChannel(s);
inbuf2.fill(channel2);
try {
@@ -182,8 +156,8 @@ public class TestSessionInOutBuffers {
@Test
public void testWriteLineChunks() throws Exception {
- final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16, null, this.allocator);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, null, this.allocator);
+ final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, null);
ReadableByteChannel inChannel = newChannel("One\r\nTwo\r\nThree");
@@ -251,7 +225,7 @@ public class TestSessionInOutBuffers {
teststrs[4] = "And goodbye";
final CharArrayBuffer chbuffer = new CharArrayBuffer(32);
- final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, null, this.allocator);
+ final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16);
for (final String teststr : teststrs) {
chbuffer.clear();
chbuffer.append(teststr);
@@ -266,7 +240,7 @@ public class TestSessionInOutBuffers {
final ReadableByteChannel channel = newChannel(outstream.toByteArray());
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, null, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, null);
inbuf.fill(channel);
for (final String teststr : teststrs) {
@@ -282,7 +256,7 @@ public class TestSessionInOutBuffers {
@Test
public void testComplexReadWriteLine() throws Exception {
- final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, null, this.allocator);
+ final 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'}));
@@ -320,7 +294,7 @@ public class TestSessionInOutBuffers {
final ReadableByteChannel channel = newChannel(outstream.toByteArray());
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, null, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, null);
inbuf.fill(channel);
final CharArrayBuffer chbuffer = new CharArrayBuffer(32);
@@ -364,7 +338,7 @@ public class TestSessionInOutBuffers {
out[i] = (byte)('0' + i);
}
final ReadableByteChannel channel = newChannel(out);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, null, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, null);
while (inbuf.fill(channel) > 0) {
}
@@ -381,7 +355,7 @@ public class TestSessionInOutBuffers {
public void testReadByteBuffer() throws Exception {
final byte[] pattern = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
final ReadableByteChannel channel = newChannel(pattern);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null);
while (inbuf.fill(channel) > 0) {
}
final ByteBuffer dst = ByteBuffer.allocate(10);
@@ -398,7 +372,7 @@ public class TestSessionInOutBuffers {
public void testReadByteBufferWithMaxLen() throws Exception {
final byte[] pattern = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
final ReadableByteChannel channel = newChannel(pattern);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null);
while (inbuf.fill(channel) > 0) {
}
final ByteBuffer dst = ByteBuffer.allocate(16);
@@ -418,7 +392,7 @@ public class TestSessionInOutBuffers {
public void testReadToChannel() throws Exception {
final byte[] pattern = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
final ReadableByteChannel channel = newChannel(pattern);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null);
while (inbuf.fill(channel) > 0) {
}
@@ -433,7 +407,7 @@ public class TestSessionInOutBuffers {
public void testReadToChannelWithMaxLen() throws Exception {
final byte[] pattern = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
final ReadableByteChannel channel = newChannel(pattern);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null);
while (inbuf.fill(channel) > 0) {
}
@@ -450,7 +424,7 @@ public class TestSessionInOutBuffers {
public void testWriteByteBuffer() throws Exception {
final byte[] pattern = "0123456789ABCDEF0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
- final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(4096, 1024, null, this.allocator);
+ final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(4096, 1024);
final ReadableByteChannel src = newChannel(pattern);
outbuf.write(src);
@@ -465,7 +439,7 @@ public class TestSessionInOutBuffers {
public void testWriteFromChannel() throws Exception {
final byte[] pattern = "0123456789ABCDEF0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
- final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(4096, 1024, null, this.allocator);
+ final 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));
@@ -503,7 +477,7 @@ public class TestSessionInOutBuffers {
final String s3 = "Like hello and stuff";
final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16,
- StandardCharsets.UTF_8.newEncoder(), this.allocator);
+ StandardCharsets.UTF_8.newEncoder());
final CharArrayBuffer chbuffer = new CharArrayBuffer(32);
for (int i = 0; i < 10; i++) {
@@ -525,8 +499,8 @@ public class TestSessionInOutBuffers {
final byte[] tmp = outstream.toByteArray();
final ReadableByteChannel channel = newChannel(tmp);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16,
- StandardCharsets.UTF_8.newDecoder(), this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, H1Config.DEFAULT,
+ StandardCharsets.UTF_8.newDecoder());
while (inbuf.fill(channel) > 0) {
}
@@ -547,7 +521,7 @@ public class TestSessionInOutBuffers {
@Test
public void testInputMatchesBufferLength() throws Exception {
final String s1 = "abcde";
- final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 5, null, this.allocator);
+ final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 5);
final CharArrayBuffer chbuffer = new CharArrayBuffer(16);
chbuffer.append(s1);
outbuf.writeLine(chbuffer);
@@ -561,7 +535,7 @@ public class TestSessionInOutBuffers {
final CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder();
decoder.onMalformedInput(CodingErrorAction.REPORT);
decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, decoder, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, H1Config.DEFAULT, decoder);
final ReadableByteChannel channel = newChannel(tmp);
while (inbuf.fill(channel) > 0) {
}
@@ -577,7 +551,7 @@ public class TestSessionInOutBuffers {
final CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder();
decoder.onMalformedInput(CodingErrorAction.IGNORE);
decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, decoder, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, H1Config.DEFAULT, decoder);
final ReadableByteChannel channel = newChannel(tmp);
while (inbuf.fill(channel) > 0) {
}
@@ -594,7 +568,7 @@ public class TestSessionInOutBuffers {
final CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder();
decoder.onMalformedInput(CodingErrorAction.REPLACE);
decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
- final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, decoder, this.allocator);
+ final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, H1Config.DEFAULT, decoder);
final ReadableByteChannel channel = newChannel(tmp);
while (inbuf.fill(channel) > 0) {
}
@@ -609,7 +583,7 @@ public class TestSessionInOutBuffers {
final CharsetEncoder encoder = StandardCharsets.ISO_8859_1.newEncoder();
encoder.onMalformedInput(CodingErrorAction.IGNORE);
encoder.onUnmappableCharacter(CodingErrorAction.REPORT);
- final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, encoder, this.allocator);
+ final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, encoder);
final CharArrayBuffer chbuffer = new CharArrayBuffer(16);
chbuffer.append(s);
outbuf.writeLine(chbuffer);
@@ -621,7 +595,7 @@ public class TestSessionInOutBuffers {
final CharsetEncoder encoder = StandardCharsets.ISO_8859_1.newEncoder();
encoder.onMalformedInput(CodingErrorAction.IGNORE);
encoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
- final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, encoder, this.allocator);
+ final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, encoder);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final WritableByteChannel channel = newChannel(baos);
final CharArrayBuffer chbuffer = new CharArrayBuffer(16);
@@ -639,7 +613,7 @@ public class TestSessionInOutBuffers {
final CharsetEncoder encoder = StandardCharsets.ISO_8859_1.newEncoder();
encoder.onMalformedInput(CodingErrorAction.IGNORE);
encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
- final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, encoder, this.allocator);
+ final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, encoder);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final WritableByteChannel channel = newChannel(baos);
final CharArrayBuffer chbuffer = new CharArrayBuffer(16);