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 2018/08/21 15:01:27 UTC
[16/32] httpcomponents-core git commit: Use camel-case for ivars and
param names; don't nest with else clauses unnecessarily;
comment intention of empty blocks;
use "readLen" name for local var instead of "i" or other cryptic name to hold
read length of
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/EntityUtils.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/EntityUtils.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/EntityUtils.java
index feae3d7..1873af8 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/EntityUtils.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/EntityUtils.java
@@ -88,9 +88,9 @@ public final class EntityUtils {
return;
}
if (entity.isStreaming()) {
- final InputStream instream = entity.getContent();
- if (instream != null) {
- instream.close();
+ final InputStream inStream = entity.getContent();
+ if (inStream != null) {
+ inStream.close();
}
}
}
@@ -196,8 +196,8 @@ public final class EntityUtils {
*/
public static byte[] toByteArray(final HttpEntity entity) throws IOException {
Args.notNull(entity, "Entity");
- final InputStream instream = entity.getContent();
- if (instream == null) {
+ final InputStream inStream = entity.getContent();
+ if (inStream == null) {
return null;
}
try {
@@ -208,20 +208,20 @@ public final class EntityUtils {
final ByteArrayBuffer buffer = new ByteArrayBuffer(i);
final byte[] tmp = new byte[4096];
int l;
- while((l = instream.read(tmp)) != -1) {
+ while((l = inStream.read(tmp)) != -1) {
buffer.append(tmp, 0, l);
}
return buffer.toByteArray();
} finally {
- instream.close();
+ inStream.close();
}
}
private static String toString(
final HttpEntity entity,
final ContentType contentType) throws IOException {
- final InputStream instream = entity.getContent();
- if (instream == null) {
+ final InputStream inStream = entity.getContent();
+ if (inStream == null) {
return null;
}
try {
@@ -240,7 +240,7 @@ public final class EntityUtils {
if (charset == null) {
charset = StandardCharsets.ISO_8859_1;
}
- final Reader reader = new InputStreamReader(instream, charset);
+ final Reader reader = new InputStreamReader(inStream, charset);
final CharArrayBuffer buffer = new CharArrayBuffer(contentLength);
final char[] tmp = new char[1024];
int chReadCount;
@@ -249,7 +249,7 @@ public final class EntityUtils {
}
return buffer.toString();
} finally {
- instream.close();
+ inStream.close();
}
}
@@ -349,14 +349,14 @@ public final class EntityUtils {
final long len = entity.getContentLength();
Args.checkRange(len, 0, Integer.MAX_VALUE, "HTTP entity is too large");
final Charset charset = contentType.getCharset() != null ? contentType.getCharset() : StandardCharsets.ISO_8859_1;
- final InputStream instream = entity.getContent();
- if (instream == null) {
+ final InputStream inStream = entity.getContent();
+ if (inStream == null) {
return Collections.emptyList();
}
final CharArrayBuffer buf;
try {
buf = new CharArrayBuffer(len > 0 ? (int) len : 1024);
- final Reader reader = new InputStreamReader(instream, charset);
+ final Reader reader = new InputStreamReader(inStream, charset);
final char[] tmp = new char[1024];
int l;
while((l = reader.read(tmp)) != -1) {
@@ -364,7 +364,7 @@ public final class EntityUtils {
}
} finally {
- instream.close();
+ inStream.close();
}
if (buf.isEmpty()) {
return Collections.emptyList();
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpContentProducer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpContentProducer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpContentProducer.java
index 27db0c3..742426b 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpContentProducer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpContentProducer.java
@@ -39,6 +39,6 @@ import java.io.OutputStream;
*/
public interface HttpContentProducer {
- void writeTo(OutputStream outstream) throws IOException;
+ void writeTo(OutputStream outStream) throws IOException;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpEntityWithTrailers.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpEntityWithTrailers.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpEntityWithTrailers.java
index bd7599a..a676cfc 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpEntityWithTrailers.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpEntityWithTrailers.java
@@ -91,9 +91,9 @@ public class HttpEntityWithTrailers implements HttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream)
+ public void writeTo(final OutputStream outStream)
throws IOException {
- wrappedEntity.writeTo(outstream);
+ wrappedEntity.writeTo(outStream);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpEntityWrapper.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpEntityWrapper.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpEntityWrapper.java
index 135fad0..f162859 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpEntityWrapper.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/HttpEntityWrapper.java
@@ -92,9 +92,9 @@ public class HttpEntityWrapper implements HttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream)
+ public void writeTo(final OutputStream outStream)
throws IOException {
- wrappedEntity.writeTo(outstream);
+ wrappedEntity.writeTo(outStream);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/InputStreamEntity.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/InputStreamEntity.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/InputStreamEntity.java
index 74027f4..9f2e68e 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/InputStreamEntity.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/InputStreamEntity.java
@@ -47,50 +47,50 @@ public class InputStreamEntity extends AbstractHttpEntity {
/**
* Creates an entity with an unknown length.
- * Equivalent to {@code new InputStreamEntity(instream, -1)}.
+ * Equivalent to {@code new InputStreamEntity(inStream, -1)}.
*
- * @param instream input stream
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @param inStream input stream
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
* @since 4.3
*/
- public InputStreamEntity(final InputStream instream) {
- this(instream, -1);
+ public InputStreamEntity(final InputStream inStream) {
+ this(inStream, -1);
}
/**
* Creates an entity with a specified content length.
*
- * @param instream input stream
+ * @param inStream input stream
* @param length of the input stream, {@code -1} if unknown
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
*/
- public InputStreamEntity(final InputStream instream, final long length) {
- this(instream, length, null);
+ public InputStreamEntity(final InputStream inStream, final long length) {
+ this(inStream, length, null);
}
/**
* Creates an entity with a content type and unknown length.
- * Equivalent to {@code new InputStreamEntity(instream, -1, contentType)}.
+ * Equivalent to {@code new InputStreamEntity(inStream, -1, contentType)}.
*
- * @param instream input stream
+ * @param inStream input stream
* @param contentType content type
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
* @since 4.3
*/
- public InputStreamEntity(final InputStream instream, final ContentType contentType) {
- this(instream, -1, contentType);
+ public InputStreamEntity(final InputStream inStream, final ContentType contentType) {
+ this(inStream, -1, contentType);
}
/**
- * @param instream input stream
+ * @param inStream input stream
* @param length of the input stream, {@code -1} if unknown
* @param contentType for specifying the {@code Content-Type} header, may be {@code null}
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
* @since 4.2
*/
- public InputStreamEntity(final InputStream instream, final long length, final ContentType contentType) {
+ public InputStreamEntity(final InputStream inStream, final long length, final ContentType contentType) {
super();
- this.content = Args.notNull(instream, "Source input stream");
+ this.content = Args.notNull(inStream, "Source input stream");
this.length = length;
if (contentType != null) {
setContentType(contentType.toString());
@@ -123,31 +123,31 @@ public class InputStreamEntity extends AbstractHttpEntity {
*
*/
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = this.content;
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = this.content;
try {
final byte[] buffer = new byte[OUTPUT_BUFFER_SIZE];
- int l;
+ int readLen;
if (this.length < 0) {
// consume until EOF
- while ((l = instream.read(buffer)) != -1) {
- outstream.write(buffer, 0, l);
+ while ((readLen = inStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, readLen);
}
} else {
// consume no more than length
long remaining = this.length;
while (remaining > 0) {
- l = instream.read(buffer, 0, (int)Math.min(OUTPUT_BUFFER_SIZE, remaining));
- if (l == -1) {
+ readLen = inStream.read(buffer, 0, (int)Math.min(OUTPUT_BUFFER_SIZE, remaining));
+ if (readLen == -1) {
break;
}
- outstream.write(buffer, 0, l);
- remaining -= l;
+ outStream.write(buffer, 0, readLen);
+ remaining -= readLen;
}
}
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/SerializableEntity.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/SerializableEntity.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/SerializableEntity.java
index b54237e..c1b5163 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/SerializableEntity.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/SerializableEntity.java
@@ -113,15 +113,15 @@ public class SerializableEntity extends AbstractHttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
if (this.objSer == null) {
- final ObjectOutputStream out = new ObjectOutputStream(outstream);
+ final ObjectOutputStream out = new ObjectOutputStream(outStream);
out.writeObject(this.objRef);
out.flush();
} else {
- outstream.write(this.objSer);
- outstream.flush();
+ outStream.write(this.objSer);
+ outStream.flush();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/StringEntity.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/StringEntity.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/StringEntity.java
index 6f2879a..4608dbb 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/StringEntity.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/StringEntity.java
@@ -115,10 +115,10 @@ public class StringEntity extends AbstractHttpEntity implements Cloneable {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.content);
- outstream.flush();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ outStream.write(this.content);
+ outStream.flush();
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/SharedInputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/SharedInputBuffer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/SharedInputBuffer.java
index 7303f70..24abeda 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/SharedInputBuffer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/SharedInputBuffer.java
@@ -47,8 +47,8 @@ public final class SharedInputBuffer extends AbstractSharedBuffer implements Con
super(lock, initialBufferSize);
}
- public SharedInputBuffer(final int buffersize) {
- super(new ReentrantLock(), buffersize);
+ public SharedInputBuffer(final int bufferSize) {
+ super(new ReentrantLock(), bufferSize);
}
public int fill(final ByteBuffer src) throws IOException {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/SharedOutputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/SharedOutputBuffer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/SharedOutputBuffer.java
index f5da5f7..701ad87 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/SharedOutputBuffer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/SharedOutputBuffer.java
@@ -49,8 +49,8 @@ public final class SharedOutputBuffer extends AbstractSharedBuffer implements Co
this.hasCapacity = false;
}
- public SharedOutputBuffer(final int buffersize) {
- this(new ReentrantLock(), buffersize);
+ public SharedOutputBuffer(final int bufferSize) {
+ this(new ReentrantLock(), bufferSize);
}
public void flush(final DataStreamChannel channel) throws IOException {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
index c29a7c3..89ecac2 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/ssl/SSLContextBuilder.java
@@ -228,8 +228,8 @@ public class SSLContextBuilder {
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
Args.notNull(file, "Truststore file");
final KeyStore trustStore = KeyStore.getInstance(keyStoreType);
- try (final FileInputStream instream = new FileInputStream(file)) {
- trustStore.load(instream, storePassword);
+ try (final FileInputStream inStream = new FileInputStream(file)) {
+ trustStore.load(inStream, storePassword);
}
return loadTrustMaterial(trustStore, trustStrategy);
}
@@ -251,8 +251,8 @@ public class SSLContextBuilder {
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
Args.notNull(url, "Truststore URL");
final KeyStore trustStore = KeyStore.getInstance(keyStoreType);
- try (final InputStream instream = url.openStream()) {
- trustStore.load(instream, storePassword);
+ try (final InputStream inStream = url.openStream()) {
+ trustStore.load(inStream, storePassword);
}
return loadTrustMaterial(trustStore, trustStrategy);
}
@@ -302,8 +302,8 @@ public class SSLContextBuilder {
final PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException {
Args.notNull(file, "Keystore file");
final KeyStore identityStore = KeyStore.getInstance(keyStoreType);
- try (final FileInputStream instream = new FileInputStream(file)) {
- identityStore.load(instream, storePassword);
+ try (final FileInputStream inStream = new FileInputStream(file)) {
+ identityStore.load(inStream, storePassword);
}
return loadKeyMaterial(identityStore, keyPassword, aliasStrategy);
}
@@ -322,8 +322,8 @@ public class SSLContextBuilder {
final PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException {
Args.notNull(url, "Keystore URL");
final KeyStore identityStore = KeyStore.getInstance(keyStoreType);
- try (final InputStream instream = url.openStream()) {
- identityStore.load(instream, storePassword);
+ try (final InputStream inStream = url.openStream()) {
+ identityStore.load(inStream, storePassword);
}
return loadKeyMaterial(identityStore, keyPassword, aliasStrategy);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
index 2cb0e6b..970da95 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
@@ -185,13 +185,13 @@ public class TestHttpHost {
public void testSerialization() throws Exception {
final HttpHost orig = new HttpHost("somehost", 8080, "https");
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final HttpHost clone = (HttpHost) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final HttpHost clone = (HttpHost) inStream.readObject();
Assert.assertEquals(orig, clone);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpVersion.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpVersion.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpVersion.java
index c957dc8..85cc485 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpVersion.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpVersion.java
@@ -108,13 +108,13 @@ public class TestHttpVersion {
public void testSerialization() throws Exception {
final HttpVersion orig = HttpVersion.HTTP_1_1;
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final HttpVersion clone = (HttpVersion) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final HttpVersion clone = (HttpVersion) inStream.readObject();
Assert.assertEquals(orig, clone);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
index e667001..3fecc9d 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
@@ -97,15 +97,15 @@ public class TestBHttpConnectionBase {
@Test
public void testConnectionClose() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- final OutputStream outstream = Mockito.mock(OutputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ final OutputStream outStream = Mockito.mock(OutputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
conn.ensureOpen();
- conn.outbuffer.write(0, outstream);
+ conn.outbuffer.write(0, outStream);
Assert.assertTrue(conn.isOpen());
@@ -113,7 +113,7 @@ public class TestBHttpConnectionBase {
Assert.assertFalse(conn.isOpen());
- Mockito.verify(outstream, Mockito.times(1)).write(
+ Mockito.verify(outStream, Mockito.times(1)).write(
ArgumentMatchers.<byte[]>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
Mockito.verify(socket, Mockito.times(1)).shutdownInput();
Mockito.verify(socket, Mockito.times(1)).shutdownOutput();
@@ -121,20 +121,20 @@ public class TestBHttpConnectionBase {
conn.close();
Mockito.verify(socket, Mockito.times(1)).close();
- Mockito.verify(outstream, Mockito.times(1)).write(
+ Mockito.verify(outStream, Mockito.times(1)).write(
ArgumentMatchers.<byte[]>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
}
@Test
public void testConnectionShutdown() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- final OutputStream outstream = Mockito.mock(OutputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ final OutputStream outStream = Mockito.mock(OutputStream.class);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
conn.ensureOpen();
- conn.outbuffer.write(0, outstream);
+ conn.outbuffer.write(0, outStream);
Assert.assertTrue(conn.isOpen());
@@ -142,7 +142,7 @@ public class TestBHttpConnectionBase {
Assert.assertFalse(conn.isOpen());
- Mockito.verify(outstream, Mockito.never()).write(
+ Mockito.verify(outStream, Mockito.never()).write(
ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
Mockito.verify(socket, Mockito.never()).shutdownInput();
Mockito.verify(socket, Mockito.never()).shutdownOutput();
@@ -157,12 +157,12 @@ public class TestBHttpConnectionBase {
@Test
public void testCreateEntityLengthDelimited() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
final ClassicHttpResponse message = new BasicClassicHttpResponse(200, "OK");
message.addHeader("Content-Length", "10");
message.addHeader("Content-Type", "stuff");
message.addHeader("Content-Encoding", "chunked");
- final HttpEntity entity = conn.createIncomingEntity(message, conn.inbuffer, instream, 10);
+ final HttpEntity entity = conn.createIncomingEntity(message, conn.inBuffer, inStream, 10);
Assert.assertNotNull(entity);
Assert.assertFalse(entity.isChunked());
Assert.assertEquals(10, entity.getContentLength());
@@ -175,9 +175,9 @@ public class TestBHttpConnectionBase {
@Test
public void testCreateEntityInputChunked() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
final ClassicHttpResponse message = new BasicClassicHttpResponse(200, "OK");
- final HttpEntity entity = conn.createIncomingEntity(message, conn.inbuffer, instream, ContentLengthStrategy.CHUNKED);
+ final HttpEntity entity = conn.createIncomingEntity(message, conn.inBuffer, inStream, ContentLengthStrategy.CHUNKED);
Assert.assertNotNull(entity);
Assert.assertTrue(entity.isChunked());
Assert.assertEquals(-1, entity.getContentLength());
@@ -188,9 +188,9 @@ public class TestBHttpConnectionBase {
@Test
public void testCreateEntityInputUndefined() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
final ClassicHttpResponse message = new BasicClassicHttpResponse(200, "OK");
- final HttpEntity entity = conn.createIncomingEntity(message, conn.inbuffer, instream, ContentLengthStrategy.UNDEFINED);
+ final HttpEntity entity = conn.createIncomingEntity(message, conn.inBuffer, inStream, ContentLengthStrategy.UNDEFINED);
Assert.assertNotNull(entity);
Assert.assertFalse(entity.isChunked());
Assert.assertEquals(-1, entity.getContentLength());
@@ -241,26 +241,26 @@ public class TestBHttpConnectionBase {
@Test
public void testAwaitInputInBuffer() throws Exception {
- final ByteArrayInputStream instream = Mockito.spy(new ByteArrayInputStream(
+ final ByteArrayInputStream inStream = Mockito.spy(new ByteArrayInputStream(
new byte[] {1, 2, 3, 4, 5}));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
conn.ensureOpen();
- conn.inbuffer.read(instream);
+ conn.inBuffer.read(inStream);
Assert.assertTrue(conn.awaitInput(432));
Mockito.verify(socket, Mockito.never()).setSoTimeout(ArgumentMatchers.anyInt());
- Mockito.verify(instream, Mockito.times(1)).read(
+ Mockito.verify(inStream, Mockito.times(1)).read(
ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
}
@Test
public void testAwaitInputInSocket() throws Exception {
- final ByteArrayInputStream instream = Mockito.spy(new ByteArrayInputStream(
+ final ByteArrayInputStream inStream = Mockito.spy(new ByteArrayInputStream(
new byte[] {1, 2, 3, 4, 5}));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
Mockito.when(socket.getSoTimeout()).thenReturn(345);
conn.bind(socket);
@@ -270,15 +270,15 @@ public class TestBHttpConnectionBase {
Mockito.verify(socket, Mockito.times(1)).setSoTimeout(432);
Mockito.verify(socket, Mockito.times(1)).setSoTimeout(345);
- Mockito.verify(instream, Mockito.times(1)).read(
+ Mockito.verify(inStream, Mockito.times(1)).read(
ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
}
@Test
public void testAwaitInputNoData() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(inStream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
.thenReturn(-1);
conn.bind(socket);
@@ -289,9 +289,9 @@ public class TestBHttpConnectionBase {
@Test
public void testStaleWhenClosed() throws Exception {
- final OutputStream outstream = Mockito.mock(OutputStream.class);
+ final OutputStream outStream = Mockito.mock(OutputStream.class);
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
conn.ensureOpen();
@@ -301,9 +301,9 @@ public class TestBHttpConnectionBase {
@Test
public void testNotStaleWhenHasData() throws Exception {
- final ByteArrayInputStream instream = Mockito.spy(new ByteArrayInputStream(
+ final ByteArrayInputStream inStream = Mockito.spy(new ByteArrayInputStream(
new byte[] {1, 2, 3, 4, 5}));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
conn.ensureOpen();
@@ -313,9 +313,9 @@ public class TestBHttpConnectionBase {
@Test
public void testStaleWhenEndOfStream() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(inStream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
.thenReturn(-1);
conn.bind(socket);
@@ -326,9 +326,9 @@ public class TestBHttpConnectionBase {
@Test
public void testNotStaleWhenTimeout() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(inStream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
.thenThrow(new SocketTimeoutException());
conn.bind(socket);
@@ -339,9 +339,9 @@ public class TestBHttpConnectionBase {
@Test
public void testStaleWhenIOError() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(inStream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
.thenThrow(new SocketException());
conn.bind(socket);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
index 04e007f..e3aab55 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
@@ -58,9 +58,9 @@ public class TestChunkCoding {
@Test
public void testChunkedInputStreamLargeBuffer() throws IOException {
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(CHUNKED_INPUT.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] buffer = new byte[300];
final ByteArrayOutputStream out = new ByteArrayOutputStream();
int len;
@@ -87,9 +87,9 @@ public class TestChunkCoding {
//Test for when buffer is smaller than chunk size.
@Test
public void testChunkedInputStreamSmallBuffer() throws IOException {
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(CHUNKED_INPUT.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] buffer = new byte[7];
final ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -115,9 +115,9 @@ public class TestChunkCoding {
@Test
public void testChunkedInputStreamOneByteRead() throws IOException {
final String s = "5\r\n01234\r\n5\r\n56789\r\n0\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
int ch;
int i = '0';
while ((ch = in.read()) != -1) {
@@ -133,9 +133,9 @@ public class TestChunkCoding {
@Test
public void testAvailable() throws IOException {
final String s = "5\r\n12345\r\n0\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
Assert.assertEquals(0, in.available());
in.read();
Assert.assertEquals(4, in.available());
@@ -145,9 +145,9 @@ public class TestChunkCoding {
@Test
public void testChunkedInputStreamClose() throws IOException {
final String s = "5\r\n01234\r\n5\r\n56789\r\n0\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
in.close();
in.close();
try {
@@ -172,9 +172,9 @@ public class TestChunkCoding {
@Test(expected=ConnectionClosedException.class)
public void testChunkedInputStreamNoClosingChunk() throws IOException {
final String s = "5\r\n01234\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] tmp = new byte[5];
Assert.assertEquals(5, in.read(tmp));
in.read();
@@ -185,9 +185,9 @@ public class TestChunkCoding {
@Test(expected=MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamTruncatedCRLF() throws IOException {
final String s = "5\r\n01234";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] tmp = new byte[5];
Assert.assertEquals(5, in.read(tmp));
in.read();
@@ -198,9 +198,9 @@ public class TestChunkCoding {
@Test(expected=MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamMissingCRLF() throws IOException {
final String s = "5\r\n012345\r\n56789\r\n0\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] buffer = new byte[300];
final ByteArrayOutputStream out = new ByteArrayOutputStream();
int len;
@@ -214,9 +214,9 @@ public class TestChunkCoding {
@Test(expected=MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamMissingLF() throws IOException {
final String s = "5\r01234\r\n5\r\n56789\r\n0\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
in.read();
in.close();
}
@@ -225,9 +225,9 @@ public class TestChunkCoding {
@Test(expected = MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamInvalidSize() throws IOException {
final String s = "whatever\r\n01234\r\n5\r\n56789\r\n0\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
in.read();
in.close();
}
@@ -236,9 +236,9 @@ public class TestChunkCoding {
@Test(expected = MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamNegativeSize() throws IOException {
final String s = "-5\r\n01234\r\n5\r\n56789\r\n0\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
in.read();
in.close();
}
@@ -247,9 +247,9 @@ public class TestChunkCoding {
@Test(expected = TruncatedChunkException.class)
public void testCorruptChunkedInputStreamTruncatedChunk() throws IOException {
final String s = "3\r\n12";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] buffer = new byte[300];
Assert.assertEquals(2, in.read(buffer));
in.read(buffer);
@@ -260,9 +260,9 @@ public class TestChunkCoding {
@Test(expected = MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamInvalidFooter() throws IOException {
final String s = "1\r\n0\r\n0\r\nstuff\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
in.read();
in.read();
in.close();
@@ -271,9 +271,9 @@ public class TestChunkCoding {
@Test
public void testCorruptChunkedInputStreamClose() throws IOException {
final String s = "whatever\r\n01234\r\n5\r\n56789\r\n0\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
try {
in.read();
Assert.fail("MalformedChunkCodingException expected");
@@ -285,9 +285,9 @@ public class TestChunkCoding {
@Test
public void testEmptyChunkedInputStream() throws IOException {
final String s = "0\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] buffer = new byte[300];
final ByteArrayOutputStream out = new ByteArrayOutputStream();
int len;
@@ -301,16 +301,16 @@ public class TestChunkCoding {
@Test
public void testTooLongChunkHeader() throws IOException {
final String s = "5; and some very looooong commend\r\n12345\r\n0\r\n";
- final SessionInputBuffer inbuffer1 = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer1 = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream1 = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in1 = new ChunkedInputStream(inbuffer1, inputStream1);
+ final ChunkedInputStream in1 = new ChunkedInputStream(inBuffer1, inputStream1);
final byte[] buffer = new byte[300];
Assert.assertEquals(5, in1.read(buffer));
in1.close();
- final SessionInputBuffer inbuffer2 = new SessionInputBufferImpl(16, 10);
+ final SessionInputBuffer inBuffer2 = new SessionInputBufferImpl(16, 10);
final ByteArrayInputStream inputStream2 = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in2 = new ChunkedInputStream(inbuffer2, inputStream2);
+ final ChunkedInputStream in2 = new ChunkedInputStream(inBuffer2, inputStream2);
try {
in2.read(buffer);
Assert.fail("MessageConstraintException expected");
@@ -354,9 +354,9 @@ public class TestChunkCoding {
out.flush();
out.close();
out.close();
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] d = new byte[10];
final ByteArrayOutputStream result = new ByteArrayOutputStream();
@@ -436,9 +436,9 @@ public class TestChunkCoding {
@Test
public void testResumeOnSocketTimeoutInData() throws IOException {
final String s = "5\r\n01234\r\n5\r\n5\0006789\r\na\r\n0123\000456789\r\n0\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final TimeoutByteArrayInputStream inputStream = new TimeoutByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] tmp = new byte[3];
@@ -464,9 +464,9 @@ public class TestChunkCoding {
@Test
public void testResumeOnSocketTimeoutInChunk() throws IOException {
final String s = "5\000\r\000\n\00001234\r\n\0005\r\n56789\r\na\r\n0123456789\r\n\0000\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final TimeoutByteArrayInputStream inputStream = new TimeoutByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] tmp = new byte[3];
@@ -493,10 +493,10 @@ public class TestChunkCoding {
@Test
public void testHugeChunk() throws IOException {
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream("1234567890abcdef\r\n01234567".getBytes(
StandardCharsets.ISO_8859_1));
- final ChunkedInputStream in = new ChunkedInputStream(inbuffer, inputStream);
+ final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
for (int i = 0; i < 8; ++i) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java
index f54155e..199baf4 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java
@@ -45,8 +45,8 @@ public class TestContentLengthInputStream {
public void testBasics() throws IOException {
final String s = "1234567890123456";
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
- final InputStream in = new ContentLengthInputStream(inbuffer, inputStream, 10L);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
+ final InputStream in = new ContentLengthInputStream(inBuffer, inputStream, 10L);
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final byte[] buffer = new byte[50];
@@ -63,23 +63,23 @@ public class TestContentLengthInputStream {
@Test
public void testSkip() throws IOException {
final ByteArrayInputStream inputStream1 = new ByteArrayInputStream(new byte[20]);
- final SessionInputBuffer inbuffer1 = new SessionInputBufferImpl(16);
- final InputStream in1 = new ContentLengthInputStream(inbuffer1, inputStream1, 10L);
+ final SessionInputBuffer inBuffer1 = new SessionInputBufferImpl(16);
+ final InputStream in1 = new ContentLengthInputStream(inBuffer1, inputStream1, 10L);
Assert.assertEquals(10, in1.skip(10));
Assert.assertTrue(in1.read() == -1);
in1.close();
final ByteArrayInputStream inputStream2 = new ByteArrayInputStream(new byte[20]);
- final SessionInputBuffer inbuffer2 = new SessionInputBufferImpl(16);
- final InputStream in2 = new ContentLengthInputStream(inbuffer2, inputStream2, 10L);
+ final SessionInputBuffer inBuffer2 = new SessionInputBufferImpl(16);
+ final InputStream in2 = new ContentLengthInputStream(inBuffer2, inputStream2, 10L);
in2.read();
Assert.assertEquals(9, in2.skip(10));
Assert.assertTrue(in2.read() == -1);
in2.close();
final ByteArrayInputStream inputStream3 = new ByteArrayInputStream(new byte[20]);
- final SessionInputBuffer inbuffer3 = new SessionInputBufferImpl(16);
- final InputStream in3 = new ContentLengthInputStream(inbuffer3, inputStream3, 2L);
+ final SessionInputBuffer inBuffer3 = new SessionInputBufferImpl(16);
+ final InputStream in3 = new ContentLengthInputStream(inBuffer3, inputStream3, 2L);
in3.read();
in3.read();
Assert.assertTrue(in3.skip(10) <= 0);
@@ -88,8 +88,8 @@ public class TestContentLengthInputStream {
in3.close();
final ByteArrayInputStream inputStream4 = new ByteArrayInputStream(new byte[20]);
- final SessionInputBuffer inbuffer4 = new SessionInputBufferImpl(16);
- final InputStream in4 = new ContentLengthInputStream(inbuffer4, inputStream4, 10L);
+ final SessionInputBuffer inBuffer4 = new SessionInputBufferImpl(16);
+ final InputStream in4 = new ContentLengthInputStream(inBuffer4, inputStream4, 10L);
Assert.assertEquals(5,in4.skip(5));
Assert.assertEquals(5, in4.read(new byte[20]));
in4.close();
@@ -98,8 +98,8 @@ public class TestContentLengthInputStream {
@Test
public void testAvailable() throws IOException {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[] {1, 2, 3});
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
- final InputStream in = new ContentLengthInputStream(inbuffer, inputStream, 3L);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
+ final InputStream in = new ContentLengthInputStream(inBuffer, inputStream, 3L);
Assert.assertEquals(0, in.available());
in.read();
Assert.assertEquals(2, in.available());
@@ -110,8 +110,8 @@ public class TestContentLengthInputStream {
public void testClose() throws IOException {
final String s = "1234567890123456-";
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
- final InputStream in = new ContentLengthInputStream(inbuffer, inputStream, 16L);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
+ final InputStream in = new ContentLengthInputStream(inBuffer, inputStream, 16L);
in.close();
in.close();
@@ -131,15 +131,15 @@ public class TestContentLengthInputStream {
Assert.fail("StreamClosedException expected");
} catch (final StreamClosedException expected) {
}
- Assert.assertEquals('-', inbuffer.read(inputStream));
+ Assert.assertEquals('-', inBuffer.read(inputStream));
}
@Test
public void testTruncatedContent() throws IOException {
final String s = "1234567890123456";
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
- final InputStream in = new ContentLengthInputStream(inbuffer, inputStream, 32L);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
+ final InputStream in = new ContentLengthInputStream(inBuffer, inputStream, 32L);
final byte[] tmp = new byte[32];
final int byteRead = in.read(tmp);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java
index 277ea19..f584353 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java
@@ -77,8 +77,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testReadResponseHead() throws Exception {
final String s = "HTTP/1.1 200 OK\r\nUser-Agent: test\r\n\r\n";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -94,8 +94,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testReadResponseEntityWithContentLength() throws Exception {
final String s = "HTTP/1.1 200 OK\r\nServer: test\r\nContent-Length: 3\r\n\r\n123";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -123,8 +123,8 @@ public class TestDefaultBHttpClientConnection {
public void testReadResponseEntityChunkCoded() throws Exception {
final String s = "HTTP/1.1 200 OK\r\nServer: test\r\nTransfer-Encoding: " +
"chunked\r\n\r\n3\r\n123\r\n0\r\n\r\n";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -152,8 +152,8 @@ public class TestDefaultBHttpClientConnection {
@Test(expected = NotImplementedException.class)
public void testReadResponseEntityIdentity() throws Exception {
final String s = "HTTP/1.1 200 OK\r\nServer: test\r\nTransfer-Encoding: identity\r\n\r\n123";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -172,8 +172,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testReadResponseNoEntity() throws Exception {
final String s = "HTTP/1.1 200 OK\r\nServer: test\r\n\r\n";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -194,8 +194,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testWriteRequestHead() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -208,14 +208,14 @@ public class TestDefaultBHttpClientConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("GET /stuff HTTP/1.1\r\nUser-Agent: test\r\n\r\n", s);
}
@Test
public void testWriteRequestEntityWithContentLength() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -231,14 +231,14 @@ public class TestDefaultBHttpClientConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123", s);
}
@Test
public void testWriteRequestEntityChunkCoded() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -254,15 +254,15 @@ public class TestDefaultBHttpClientConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nTransfer-Encoding: " +
"chunked\r\n\r\n3\r\n123\r\n0\r\n\r\n", s);
}
@Test(expected = LengthRequiredException.class)
public void testWriteRequestEntityNoContentLength() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -278,8 +278,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testWriteRequestNoEntity() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -293,14 +293,14 @@ public class TestDefaultBHttpClientConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\n\r\n", s);
}
@Test
public void testTerminateRequestChunkedEntity() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -318,7 +318,7 @@ public class TestDefaultBHttpClientConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nTransfer-Encoding: " +
"chunked\r\n\r\n0\r\n\r\n", s);
Assert.assertTrue(conn.isConsistent());
@@ -326,8 +326,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testTerminateRequestContentLengthShort() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -345,7 +345,7 @@ public class TestDefaultBHttpClientConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: " +
"3\r\n\r\n123", s);
Assert.assertTrue(conn.isConsistent());
@@ -353,8 +353,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testTerminateRequestContentLengthLong() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -372,7 +372,7 @@ public class TestDefaultBHttpClientConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: " +
"3000\r\n\r\n", s);
Assert.assertFalse(conn.isConsistent());
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
index 9898218..7ddce42 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
@@ -76,8 +76,8 @@ public class TestDefaultBHttpServerConnection {
@Test
public void testReadRequestHead() throws Exception {
final String s = "GET / HTTP/1.1\r\nUser-Agent: test\r\n\r\n";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -94,8 +94,8 @@ public class TestDefaultBHttpServerConnection {
@Test
public void testReadRequestEntityWithContentLength() throws Exception {
final String s = "POST / HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -125,8 +125,8 @@ public class TestDefaultBHttpServerConnection {
public void testReadRequestEntityChunckCoded() throws Exception {
final String s = "POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nTransfer-Encoding: " +
"chunked\r\n\r\n3\r\n123\r\n0\r\n\r\n";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -157,8 +157,8 @@ public class TestDefaultBHttpServerConnection {
public void testReadRequestEntityIdentity() throws Exception {
final String s = "POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nTransfer-Encoding: " +
"identity\r\n\r\n123";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -179,8 +179,8 @@ public class TestDefaultBHttpServerConnection {
@Test
public void testReadRequestNoEntity() throws Exception {
final String s = "POST /stuff HTTP/1.1\r\nUser-Agent: test\r\n\r\n";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -203,8 +203,8 @@ public class TestDefaultBHttpServerConnection {
@Test
public void testWriteResponseHead() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -217,14 +217,14 @@ public class TestDefaultBHttpServerConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("HTTP/1.1 200 OK\r\nUser-Agent: test\r\n\r\n", s);
}
@Test
public void testWriteResponse100Head() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -236,14 +236,14 @@ public class TestDefaultBHttpServerConnection {
conn.flush();
Assert.assertEquals(0, conn.getEndpointDetails().getResponseCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("HTTP/1.1 100 Go on\r\n\r\n", s);
}
@Test
public void testWriteResponseEntityWithContentLength() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -259,14 +259,14 @@ public class TestDefaultBHttpServerConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("HTTP/1.1 200 OK\r\nServer: test\r\nContent-Length: 3\r\n\r\n123", s);
}
@Test
public void testWriteResponseEntityChunkCoded() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -282,15 +282,15 @@ public class TestDefaultBHttpServerConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("HTTP/1.1 200 OK\r\nServer: test\r\nTransfer-Encoding: " +
"chunked\r\n\r\n3\r\n123\r\n0\r\n\r\n", s);
}
@Test(expected = NotImplementedException.class)
public void testWriteResponseEntityIdentity() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -308,8 +308,8 @@ public class TestDefaultBHttpServerConnection {
@Test
public void testWriteResponseNoEntity() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -323,7 +323,7 @@ public class TestDefaultBHttpServerConnection {
conn.flush();
Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("HTTP/1.1 200 OK\r\nServer: test\r\n\r\n", s);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.java
index 1dcd472..b73feef 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.java
@@ -133,8 +133,8 @@ public class TestHttpService {
public void testExecutionEntityEnclosingRequest() throws Exception {
final HttpCoreContext context = HttpCoreContext.create();
final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/");
- final InputStream instream = Mockito.mock(InputStream.class);
- final InputStreamEntity entity = new InputStreamEntity(instream, -1);
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ final InputStreamEntity entity = new InputStreamEntity(inStream, -1);
request.setEntity(entity);
Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
@@ -159,7 +159,7 @@ public class TestHttpService {
Assert.assertSame(request, context.getRequest());
Mockito.verify(httprocessor).process(request, request.getEntity(), context);
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
Mockito.verify(httprocessor).process(response, response.getEntity(), context);
Mockito.verify(conn).sendResponseHeader(response);
Mockito.verify(conn).sendResponseEntity(response);
@@ -173,8 +173,8 @@ public class TestHttpService {
final HttpCoreContext context = HttpCoreContext.create();
final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/");
request.addHeader(HttpHeaders.EXPECT, HeaderElements.CONTINUE);
- final InputStream instream = Mockito.mock(InputStream.class);
- final InputStreamEntity entity = new InputStreamEntity(instream, -1);
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ final InputStreamEntity entity = new InputStreamEntity(inStream, -1);
request.setEntity(entity);
Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
@@ -203,7 +203,7 @@ public class TestHttpService {
Assert.assertSame(request, context.getRequest());
Mockito.verify(httprocessor).process(request, request.getEntity(), context);
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
Mockito.verify(httprocessor).process(response, response.getEntity(), context);
Mockito.verify(conn).sendResponseHeader(response);
Mockito.verify(conn).sendResponseEntity(response);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3267db4f/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityInputStream.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityInputStream.java
index b15a7bf..a00f1f3 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityInputStream.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityInputStream.java
@@ -44,8 +44,8 @@ public class TestIdentityInputStream {
public void testBasicRead() throws Exception {
final byte[] input = new byte[] {'a', 'b', 'c'};
final ByteArrayInputStream inputStream = new ByteArrayInputStream(input);
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
- final IdentityInputStream in = new IdentityInputStream(inbuffer, inputStream);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
+ final IdentityInputStream in = new IdentityInputStream(inBuffer, inputStream);
final byte[] tmp = new byte[2];
Assert.assertEquals(2, in.read(tmp, 0, tmp.length));
Assert.assertEquals('a', tmp[0]);
@@ -62,8 +62,8 @@ public class TestIdentityInputStream {
public void testClosedCondition() throws Exception {
final byte[] input = new byte[] {'a', 'b', 'c'};
final ByteArrayInputStream inputStream = new ByteArrayInputStream(input);
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16);
- final IdentityInputStream in = new IdentityInputStream(inbuffer, inputStream);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
+ final IdentityInputStream in = new IdentityInputStream(inBuffer, inputStream);
in.close();
in.close();
@@ -86,8 +86,8 @@ public class TestIdentityInputStream {
public void testAvailable() throws Exception {
final byte[] input = new byte[] {'a', 'b', 'c'};
final ByteArrayInputStream inputStream = new ByteArrayInputStream(input);
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(new BasicHttpTransportMetrics(), 16, 16, 1024, null);
- final IdentityInputStream in = new IdentityInputStream(inbuffer, inputStream);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(new BasicHttpTransportMetrics(), 16, 16, 1024, null);
+ final IdentityInputStream in = new IdentityInputStream(inBuffer, inputStream);
in.read();
Assert.assertEquals(2, in.available());
in.close();
@@ -97,8 +97,8 @@ public class TestIdentityInputStream {
public void testAvailableInStream() throws Exception {
final byte[] input = new byte[] {'a', 'b', 'c', 'd', 'e', 'f'};
final ByteArrayInputStream inputStream = new ByteArrayInputStream(input);
- final SessionInputBuffer inbuffer = new SessionInputBufferImpl(new BasicHttpTransportMetrics(), 16, 0, 1024, null);
- final IdentityInputStream in = new IdentityInputStream(inbuffer, inputStream);
+ final SessionInputBuffer inBuffer = new SessionInputBufferImpl(new BasicHttpTransportMetrics(), 16, 0, 1024, null);
+ final IdentityInputStream in = new IdentityInputStream(inBuffer, inputStream);
final byte[] tmp = new byte[3];
Assert.assertEquals(3, in.read(tmp));
Assert.assertEquals(3, in.available());