hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1393136 [3/3] - in /httpcomponents/httpcore/trunk: ./ httpcore-ab/src/main/java/org/apache/http/benchmark/ httpcore-ab/src/test/java/org/apache/http/benchmark/ httpcore-nio/src/main/java/org/apache/http/impl/nio/ httpcore-nio/src/main/java...
Date Tue, 02 Oct 2012 19:44:37 GMT
Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java?rev=1393136&r1=1393135&r2=1393136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
Tue Oct  2 19:44:35 2012
@@ -35,10 +35,8 @@ import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
 import org.apache.http.NoHttpResponseException;
 import org.apache.http.StatusLine;
-import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.SessionInputBufferMock;
 import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.message.BasicLineParser;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -47,18 +45,9 @@ import org.junit.Test;
  */
 public class TestResponseParser {
 
-    @Test
+    @Test(expected=IllegalArgumentException.class)
     public void testInvalidConstructorInput() throws Exception {
-        try {
-            new DefaultHttpResponseParser(
-                    null,
-                    -1, -1,
-                    BasicLineParser.INSTANCE,
-                    DefaultHttpResponseFactory.INSTANCE);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            // expected
-        }
+        new DefaultHttpResponseParser(null);
     }
 
     @Test
@@ -71,12 +60,7 @@ public class TestResponseParser {
             "\r\n";
         SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
 
-        DefaultHttpResponseParser parser = new DefaultHttpResponseParser(
-                inbuffer,
-                -1, -1,
-                BasicLineParser.INSTANCE,
-                DefaultHttpResponseFactory.INSTANCE);
-
+        DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inbuffer);
         HttpResponse httpresponse = parser.parse();
 
         StatusLine statusline = httpresponse.getStatusLine();
@@ -92,11 +76,7 @@ public class TestResponseParser {
     public void testConnectionClosedException() throws Exception {
         SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {});
 
-        DefaultHttpResponseParser parser = new DefaultHttpResponseParser(
-                inbuffer,
-                -1, -1,
-                BasicLineParser.INSTANCE,
-                DefaultHttpResponseFactory.INSTANCE);
+        DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inbuffer);
         try {
             parser.parse();
             Assert.fail("NoHttpResponseException should have been thrown");
@@ -115,11 +95,7 @@ public class TestResponseParser {
         SessionInputBuffer inbuffer = new SessionInputBufferMock(
                 new TimeoutByteArrayInputStream(s.getBytes("US-ASCII")), 16);
 
-        DefaultHttpResponseParser parser = new DefaultHttpResponseParser(
-                inbuffer,
-                -1, -1,
-                BasicLineParser.INSTANCE,
-                DefaultHttpResponseFactory.INSTANCE);
+        DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inbuffer);
 
         int timeoutCount = 0;
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java?rev=1393136&r1=1393135&r2=1393136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
Tue Oct  2 19:44:35 2012
@@ -34,6 +34,7 @@ import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CodingErrorAction;
 
 import org.apache.http.Consts;
+import org.apache.http.impl.MessageConstraints;
 import org.apache.http.impl.SessionInputBufferMock;
 import org.apache.http.impl.SessionOutputBufferMock;
 import org.apache.http.io.HttpTransportMetrics;
@@ -331,13 +332,15 @@ public class TestSessionInOutBuffers {
         String s = "a very looooooooooooooooooooooooooooooooooooooong line\r\n     ";
         byte[] tmp = s.getBytes("US-ASCII");
         // no limit
-        SessionInputBufferMock inbuffer1 = new SessionInputBufferMock(tmp, 5, 0);
+        SessionInputBufferMock inbuffer1 = new SessionInputBufferMock(tmp, 5, 
+                MessageConstraints.UNLIMITED);
         Assert.assertNotNull(inbuffer1.readLine());
         long bytesRead = inbuffer1.getMetrics().getBytesTransferred();
         Assert.assertEquals(60, bytesRead);
 
         // 15 char limit
-        SessionInputBufferMock inbuffer2 = new SessionInputBufferMock(tmp, 5, 15);
+        SessionInputBufferMock inbuffer2 = new SessionInputBufferMock(tmp, 5, 
+                MessageConstraints.lineLen(15));
         try {
             inbuffer2.readLine();
             Assert.fail("IOException should have been thrown");

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java?rev=1393136&r1=1393135&r2=1393136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java
Tue Oct  2 19:44:35 2012
@@ -90,7 +90,7 @@ public class HttpClient {
     }
 
     public DefaultBHttpClientConnection createConnection() {
-        return new LoggingBHttpClientConnection(this.params);
+        return new LoggingBHttpClientConnection(8 * 1024);
     }
 
     public HttpResponse execute(

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java?rev=1393136&r1=1393135&r2=1393136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java
Tue Oct  2 19:44:35 2012
@@ -74,7 +74,6 @@ public class HttpServer {
         super();
         this.params = new HttpCoreConfigBuilder()
             .setSocketTimeout(5000)
-            .setSocketBufferSize(8 * 1024)
             .setTcpNoDelay(true)
             .setOriginServer("TEST-SERVER/1.1").build();
         this.httpproc = new ImmutableHttpProcessor(
@@ -102,7 +101,7 @@ public class HttpServer {
 
     private HttpServerConnection acceptConnection() throws IOException {
         Socket socket = this.serversocket.accept();
-        LoggingBHttpServerConnection conn = new LoggingBHttpServerConnection(this.params);
+        LoggingBHttpServerConnection conn = new LoggingBHttpServerConnection(8 * 1024);
         conn.bind(socket);
         return conn;
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java?rev=1393136&r1=1393135&r2=1393136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
Tue Oct  2 19:44:35 2012
@@ -31,6 +31,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.commons.logging.Log;
@@ -38,8 +40,11 @@ import org.apache.commons.logging.LogFac
 import org.apache.http.Header;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
+import org.apache.http.entity.ContentLengthStrategy;
 import org.apache.http.impl.DefaultBHttpClientConnection;
-import org.apache.http.params.HttpParams;
+import org.apache.http.impl.MessageConstraints;
+import org.apache.http.io.HttpMessageParserFactory;
+import org.apache.http.io.HttpMessageWriterFactory;
 
 public class LoggingBHttpClientConnection extends DefaultBHttpClientConnection {
 
@@ -50,14 +55,28 @@ public class LoggingBHttpClientConnectio
     private final Log headerlog;
     private final Wire wire;
 
-    public LoggingBHttpClientConnection(final HttpParams params) {
-        super(params);
+    public LoggingBHttpClientConnection(
+            int buffersize,
+            final CharsetDecoder chardecoder,
+            final CharsetEncoder charencoder,
+            final MessageConstraints constraints,
+            final ContentLengthStrategy incomingContentStrategy,
+            final ContentLengthStrategy outgoingContentStrategy,
+            final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
+            final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
+        super(buffersize, chardecoder, charencoder, 
+                constraints, incomingContentStrategy, outgoingContentStrategy, 
+                requestWriterFactory, responseParserFactory);
         this.id = "http-outgoing-" + COUNT.incrementAndGet();
         this.log = LogFactory.getLog(getClass());
         this.headerlog = LogFactory.getLog("org.apache.http.headers");
         this.wire = new Wire(LogFactory.getLog("org.apache.http.wire"), this.id);
     }
 
+    public LoggingBHttpClientConnection(int buffersize) {
+        this(buffersize, null, null, null, null, null, null, null);
+    }
+
     @Override
     public void close() throws IOException {
         if (this.log.isDebugEnabled()) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java?rev=1393136&r1=1393135&r2=1393136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
Tue Oct  2 19:44:35 2012
@@ -31,6 +31,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.commons.logging.Log;
@@ -38,8 +40,11 @@ import org.apache.commons.logging.LogFac
 import org.apache.http.Header;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
+import org.apache.http.entity.ContentLengthStrategy;
 import org.apache.http.impl.DefaultBHttpServerConnection;
-import org.apache.http.params.HttpParams;
+import org.apache.http.impl.MessageConstraints;
+import org.apache.http.io.HttpMessageParserFactory;
+import org.apache.http.io.HttpMessageWriterFactory;
 
 public class LoggingBHttpServerConnection extends DefaultBHttpServerConnection {
 
@@ -50,14 +55,28 @@ public class LoggingBHttpServerConnectio
     private final Log headerlog;
     private final Wire wire;
 
-    public LoggingBHttpServerConnection(final HttpParams params) {
-        super(params);
+    public LoggingBHttpServerConnection(
+            int buffersize,
+            final CharsetDecoder chardecoder,
+            final CharsetEncoder charencoder,
+            final MessageConstraints constraints,
+            final ContentLengthStrategy incomingContentStrategy,
+            final ContentLengthStrategy outgoingContentStrategy,
+            final HttpMessageParserFactory<HttpRequest> requestParserFactory,
+            final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
+        super(buffersize, chardecoder, charencoder, constraints, 
+                incomingContentStrategy, outgoingContentStrategy, 
+                requestParserFactory, responseWriterFactory);
         this.id = "http-incoming-" + COUNT.incrementAndGet();
         this.log = LogFactory.getLog(getClass());
         this.headerlog = LogFactory.getLog("org.apache.http.headers");
         this.wire = new Wire(LogFactory.getLog("org.apache.http.wire"), this.id);
     }
 
+    public LoggingBHttpServerConnection(int buffersize) {
+        this(buffersize, null, null, null, null, null, null, null);
+    }
+
     @Override
     public void close() throws IOException {
         if (this.log.isDebugEnabled()) {



Mime
View raw message