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 2011/12/29 13:03:34 UTC
svn commit: r1225503 [2/2] - in /httpcomponents/httpcore/trunk:
httpcore-nio/src/examples/org/apache/http/examples/nio/
httpcore-nio/src/main/java/org/apache/http/nio/protocol/
httpcore-nio/src/test/java/org/apache/http/
httpcore-nio/src/test/java/org/...
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncClientProtocolHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncClientProtocolHandler.java?rev=1225503&r1=1225502&r2=1225503&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncClientProtocolHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncClientProtocolHandler.java Thu Dec 29 12:03:33 2011
@@ -45,7 +45,7 @@ import org.apache.http.nio.ContentEncode
import org.apache.http.nio.NHttpClientConnection;
import org.apache.http.nio.NHttpConnection;
import org.apache.http.nio.entity.NStringEntity;
-import org.apache.http.nio.protocol.HttpAsyncClientProtocolHandler.State;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutor.State;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
@@ -56,7 +56,7 @@ import org.mockito.Mockito;
public class TestHttpAsyncClientProtocolHandler {
- private HttpAsyncClientProtocolHandler protocolHandler;
+ private HttpAsyncRequestExecutor protocolHandler;
private HttpContext connContext;
private NHttpClientConnection conn;
private HttpAsyncRequestExecutionHandler<?> exchangeHandler;
@@ -67,7 +67,7 @@ public class TestHttpAsyncClientProtocol
@Before
public void setUp() throws Exception {
- this.protocolHandler = new HttpAsyncClientProtocolHandler();
+ this.protocolHandler = new HttpAsyncRequestExecutor();
this.connContext = new BasicHttpContext();
this.conn = Mockito.mock(NHttpClientConnection.class);
this.exchangeHandler = Mockito.mock(HttpAsyncRequestExecutionHandler.class);
@@ -88,12 +88,12 @@ public class TestHttpAsyncClientProtocol
public void testConnected() throws Exception {
HttpRequest request = new BasicHttpRequest("GET", "/");
Mockito.when(this.exchangeHandler.generateRequest()).thenReturn(request);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_HANDLER, this.exchangeHandler);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this.exchangeHandler);
this.protocolHandler.connected(this.conn, null);
State state = (State) this.connContext.getAttribute(
- HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE);
+ HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE);
Assert.assertNotNull(state);
Assert.assertSame(this.exchangeHandler, state.getHandler());
Mockito.verify(this.exchangeHandler).generateRequest();
@@ -107,11 +107,11 @@ public class TestHttpAsyncClientProtocol
@Test
public void testClosed() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.COMPLETED);
state.setResponseState(MessageState.COMPLETED);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
this.protocolHandler.closed(this.conn);
@@ -123,11 +123,11 @@ public class TestHttpAsyncClientProtocol
@Test
public void testHttpExceptionHandling() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.COMPLETED);
state.setResponseState(MessageState.COMPLETED);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
HttpException httpex = new HttpException();
this.protocolHandler.exception(this.conn, httpex);
@@ -139,11 +139,11 @@ public class TestHttpAsyncClientProtocol
@Test
public void testIOExceptionHandling() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.COMPLETED);
state.setResponseState(MessageState.COMPLETED);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
IOException ioex = new IOException();
this.protocolHandler.exception(this.conn, ioex);
@@ -155,9 +155,9 @@ public class TestHttpAsyncClientProtocol
@Test
public void testBasicRequest() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
HttpRequest request = new BasicHttpRequest("GET", "/");
Mockito.when(this.exchangeHandler.generateRequest()).thenReturn(request);
@@ -172,9 +172,9 @@ public class TestHttpAsyncClientProtocol
@Test
public void testEntityEnclosingRequestWithoutExpectContinue() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.setEntity(NStringEntity.create("stuff"));
Mockito.when(this.exchangeHandler.generateRequest()).thenReturn(request);
@@ -190,9 +190,9 @@ public class TestHttpAsyncClientProtocol
@Test
public void testEntityEnclosingRequestWithExpectContinue() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.setHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
Mockito.when(this.exchangeHandler.generateRequest()).thenReturn(request);
@@ -211,9 +211,9 @@ public class TestHttpAsyncClientProtocol
@Test
public void testRequestContentOutput() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.encoder.isCompleted()).thenReturn(false);
this.protocolHandler.outputReady(this.conn, this.encoder);
@@ -224,9 +224,9 @@ public class TestHttpAsyncClientProtocol
@Test
public void testRequestContentOutputCompleted() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.encoder.isCompleted()).thenReturn(true);
this.protocolHandler.outputReady(this.conn, this.encoder);
@@ -238,10 +238,10 @@ public class TestHttpAsyncClientProtocol
@Test
public void testRequestContentContinueExpected() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.ACK_EXPECTED);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
this.protocolHandler.outputReady(this.conn, this.encoder);
@@ -252,11 +252,11 @@ public class TestHttpAsyncClientProtocol
@Test
public void testBasicResponse() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
HttpRequest request = new BasicHttpRequest("GET", "/");
state.setRequest(request);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
@@ -268,14 +268,14 @@ public class TestHttpAsyncClientProtocol
@Test
public void testResponseContinue() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.ACK_EXPECTED);
state.setTimeout(1000);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.setEntity(NStringEntity.create("stuff"));
state.setRequest(request);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
@@ -290,13 +290,13 @@ public class TestHttpAsyncClientProtocol
@Test
public void testResponseContinueOutOfSequence() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.COMPLETED);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.setEntity(NStringEntity.create("stuff"));
state.setRequest(request);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
@@ -309,14 +309,14 @@ public class TestHttpAsyncClientProtocol
@Test(expected=HttpException.class)
public void testResponseUnsupported1xx() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.ACK_EXPECTED);
state.setTimeout(1000);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.setEntity(NStringEntity.create("stuff"));
state.setRequest(request);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 111, "WTF?");
Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
@@ -325,14 +325,14 @@ public class TestHttpAsyncClientProtocol
@Test
public void testResponseExpectationFailed() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.ACK_EXPECTED);
state.setTimeout(1000);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.setEntity(NStringEntity.create("stuff"));
state.setRequest(request);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 403, "Unauthorized");
Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
@@ -347,14 +347,14 @@ public class TestHttpAsyncClientProtocol
@Test
public void testEarlyResponse() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.BODY_STREAM);
state.setTimeout(1000);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.setEntity(NStringEntity.create("stuff"));
state.setRequest(request);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 403, "Unauthorized");
Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
@@ -370,11 +370,11 @@ public class TestHttpAsyncClientProtocol
@Test
public void testResponseToHead() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
HttpRequest request = new BasicHttpRequest("HEAD", "/");
state.setRequest(request);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
Mockito.when(this.reuseStrategy.keepAlive(response, this.exchangeContext)).thenReturn(true);
@@ -393,11 +393,11 @@ public class TestHttpAsyncClientProtocol
@Test
public void testResponseToConnect() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
HttpRequest request = new BasicHttpRequest("Connect", "/");
state.setRequest(request);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
Mockito.when(this.reuseStrategy.keepAlive(response, this.exchangeContext)).thenReturn(true);
@@ -416,11 +416,11 @@ public class TestHttpAsyncClientProtocol
@Test
public void testResponseNotModified() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
HttpRequest request = new BasicHttpRequest("Connect", "/");
state.setRequest(request);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
HttpStatus.SC_NOT_MODIFIED, "Not modified");
Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
@@ -440,9 +440,9 @@ public class TestHttpAsyncClientProtocol
@Test
public void testResponseContentInput() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.decoder.isCompleted()).thenReturn(false);
this.protocolHandler.inputReady(this.conn, this.decoder);
@@ -453,13 +453,13 @@ public class TestHttpAsyncClientProtocol
@Test
public void testResponseContentOutputCompleted() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
HttpRequest request = new BasicHttpRequest("GET", "/");
state.setRequest(request);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
state.setResponse(response);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.reuseStrategy.keepAlive(response, this.exchangeContext)).thenReturn(true);
Mockito.when(this.exchangeHandler.getConnectionReuseStrategy()).thenReturn(this.reuseStrategy);
Mockito.when(this.decoder.isCompleted()).thenReturn(true);
@@ -475,14 +475,14 @@ public class TestHttpAsyncClientProtocol
@Test
public void testResponseInvalidState() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
HttpRequest request = new BasicHttpRequest("GET", "/");
state.setRequest(request);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
state.setResponse(response);
state.invalidate();
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.decoder.isCompleted()).thenReturn(true);
this.protocolHandler.inputReady(this.conn, this.decoder);
@@ -496,13 +496,13 @@ public class TestHttpAsyncClientProtocol
@Test
public void testResponseNoKeepAlive() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
HttpRequest request = new BasicHttpRequest("GET", "/");
state.setRequest(request);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
state.setResponse(response);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.reuseStrategy.keepAlive(response, this.exchangeContext)).thenReturn(false);
Mockito.when(this.exchangeHandler.getConnectionReuseStrategy()).thenReturn(this.reuseStrategy);
Mockito.when(this.decoder.isCompleted()).thenReturn(true);
@@ -518,8 +518,8 @@ public class TestHttpAsyncClientProtocol
@Test
public void testTimeoutNoHandler() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ State state = new HttpAsyncRequestExecutor.State();
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.conn.getStatus()).thenReturn(
NHttpConnection.ACTIVE, NHttpConnection.CLOSING);
@@ -532,11 +532,11 @@ public class TestHttpAsyncClientProtocol
@Test
public void testExpectContinueTimeout() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.ACK_EXPECTED);
state.setTimeout(1000);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
this.protocolHandler.timeout(this.conn);
@@ -547,10 +547,10 @@ public class TestHttpAsyncClientProtocol
@Test
public void testTimeoutActiveConnection() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.BODY_STREAM);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.conn.getStatus()).thenReturn(NHttpConnection.ACTIVE, NHttpConnection.CLOSED);
this.protocolHandler.timeout(this.conn);
@@ -564,10 +564,10 @@ public class TestHttpAsyncClientProtocol
@Test
public void testTimeoutActiveConnectionBufferedData() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.BODY_STREAM);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.conn.getStatus()).thenReturn(NHttpConnection.ACTIVE, NHttpConnection.CLOSING);
this.protocolHandler.timeout(this.conn);
@@ -581,10 +581,10 @@ public class TestHttpAsyncClientProtocol
@Test
public void testTimeoutClosingConnection() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
state.setRequestState(MessageState.BODY_STREAM);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.conn.getStatus()).thenReturn(NHttpConnection.CLOSING, NHttpConnection.CLOSED);
this.protocolHandler.timeout(this.conn);
@@ -597,13 +597,13 @@ public class TestHttpAsyncClientProtocol
@Test
public void testExchangeDone() throws Exception {
- State state = new HttpAsyncClientProtocolHandler.State();
+ State state = new HttpAsyncRequestExecutor.State();
HttpRequest request = new BasicHttpRequest("GET", "/");
state.setRequest(request);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
state.setResponse(response);
state.setHandler(this.exchangeHandler);
- this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.exchangeHandler.isDone()).thenReturn(true);
Assert.assertEquals("request state: READY; request: GET / HTTP/1.1; " +
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java?rev=1225503&r1=1225502&r2=1225503&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java Thu Dec 29 12:03:33 2011
@@ -36,7 +36,7 @@ import org.apache.http.HttpHost;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.impl.nio.pool.BasicNIOPoolEntry;
import org.apache.http.nio.NHttpClientConnection;
-import org.apache.http.nio.protocol.HttpAsyncRequestExecutor.ConnRequestCallback;
+import org.apache.http.nio.protocol.HttpAsyncRequester.ConnRequestCallback;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.pool.ConnPool;
@@ -55,7 +55,7 @@ public class TestHttpAsyncRequestExecuto
private HttpProcessor httpProcessor;
private ConnectionReuseStrategy reuseStrategy;
private HttpParams params;
- private HttpAsyncRequestExecutor requestExecutor;
+ private HttpAsyncRequester requestExecutor;
private HttpContext exchangeContext;
private HttpContext connContext;
private HttpAsyncRequestProducer requestProducer;
@@ -70,7 +70,7 @@ public class TestHttpAsyncRequestExecuto
this.httpProcessor = Mockito.mock(HttpProcessor.class);
this.reuseStrategy = Mockito.mock(ConnectionReuseStrategy.class);
this.params = new BasicHttpParams();
- this.requestExecutor = new HttpAsyncRequestExecutor(
+ this.requestExecutor = new HttpAsyncRequester(
this.httpProcessor, this.reuseStrategy, this.params);
this.exchangeContext = new BasicHttpContext();
this.requestProducer = Mockito.mock(HttpAsyncRequestProducer.class);
@@ -165,7 +165,7 @@ public class TestHttpAsyncRequestExecuto
this.responseConsumer,
this.conn, this.exchangeContext, null);
Assert.assertNotNull(future);
- Assert.assertNotNull(this.connContext.getAttribute(HttpAsyncClientProtocolHandler.HTTP_HANDLER));
+ Assert.assertNotNull(this.connContext.getAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER));
Mockito.verify(this.conn).requestOutput();
}
@@ -259,7 +259,7 @@ public class TestHttpAsyncRequestExecuto
BasicNIOPoolEntry entry = new BasicNIOPoolEntry("id", host, this.conn);
connRequestCallback.completed(entry);
BasicAsyncRequestExecutionHandler exchangeHandler = (BasicAsyncRequestExecutionHandler) this.connContext.getAttribute(
- HttpAsyncClientProtocolHandler.HTTP_HANDLER);
+ HttpAsyncRequestExecutor.HTTP_HANDLER);
Assert.assertNotNull(exchangeHandler);
Mockito.verify(this.conn).requestOutput();
@@ -291,7 +291,7 @@ public class TestHttpAsyncRequestExecuto
BasicNIOPoolEntry entry = new BasicNIOPoolEntry("id", host, this.conn);
connRequestCallback.completed(entry);
BasicAsyncRequestExecutionHandler exchangeHandler = (BasicAsyncRequestExecutionHandler) this.connContext.getAttribute(
- HttpAsyncClientProtocolHandler.HTTP_HANDLER);
+ HttpAsyncRequestExecutor.HTTP_HANDLER);
Assert.assertNotNull(exchangeHandler);
Mockito.verify(this.conn).requestOutput();
@@ -323,7 +323,7 @@ public class TestHttpAsyncRequestExecuto
BasicNIOPoolEntry entry = new BasicNIOPoolEntry("id", host, this.conn);
connRequestCallback.completed(entry);
BasicAsyncRequestExecutionHandler exchangeHandler = (BasicAsyncRequestExecutionHandler) this.connContext.getAttribute(
- HttpAsyncClientProtocolHandler.HTTP_HANDLER);
+ HttpAsyncRequestExecutor.HTTP_HANDLER);
Assert.assertNotNull(exchangeHandler);
Mockito.verify(this.conn).requestOutput();
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncServerProtocolHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncServerProtocolHandler.java?rev=1225503&r1=1225502&r2=1225503&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncServerProtocolHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncServerProtocolHandler.java Thu Dec 29 12:03:33 2011
@@ -49,7 +49,7 @@ import org.apache.http.nio.ContentEncode
import org.apache.http.nio.NHttpClientConnection;
import org.apache.http.nio.NHttpServerConnection;
import org.apache.http.nio.entity.NStringEntity;
-import org.apache.http.nio.protocol.HttpAsyncServerProtocolHandler.State;
+import org.apache.http.nio.protocol.HttpAsyncService.State;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
@@ -66,7 +66,7 @@ import org.mockito.Mockito;
public class TestHttpAsyncServerProtocolHandler {
private HttpAsyncRequestHandlerRegistry handlerResolver;
- private HttpAsyncServerProtocolHandler protocolHandler;
+ private HttpAsyncService protocolHandler;
private HttpProcessor httpProcessor;
private ConnectionReuseStrategy reuseStrategy;
private HttpResponseFactory responseFactory;
@@ -92,7 +92,7 @@ public class TestHttpAsyncServerProtocol
this.reuseStrategy = Mockito.mock(ConnectionReuseStrategy.class);
this.responseFactory = new DefaultHttpResponseFactory();
this.params = new BasicHttpParams();
- this.protocolHandler = new HttpAsyncServerProtocolHandler(
+ this.protocolHandler = new HttpAsyncService(
this.httpProcessor, this.reuseStrategy, this.handlerResolver, this.params);
this.connContext = new BasicHttpContext();
this.conn = Mockito.mock(NHttpServerConnection.class);
@@ -110,22 +110,22 @@ public class TestHttpAsyncServerProtocol
@Test
public void testInvalidConstruction() throws Exception {
try {
- new HttpAsyncServerProtocolHandler(null, this.reuseStrategy, this.responseFactory, null, null, this.params);
+ new HttpAsyncService(null, this.reuseStrategy, this.responseFactory, null, null, this.params);
Assert.fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
}
try {
- new HttpAsyncServerProtocolHandler(this.httpProcessor, null, this.responseFactory, null, null, this.params);
+ new HttpAsyncService(this.httpProcessor, null, this.responseFactory, null, null, this.params);
Assert.fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
}
try {
- new HttpAsyncServerProtocolHandler(this.httpProcessor, this.reuseStrategy, null, null, null, this.params);
+ new HttpAsyncService(this.httpProcessor, this.reuseStrategy, null, null, null, this.params);
Assert.fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
}
try {
- new HttpAsyncServerProtocolHandler(this.httpProcessor, this.reuseStrategy, this.responseFactory, null, null, null);
+ new HttpAsyncService(this.httpProcessor, this.reuseStrategy, this.responseFactory, null, null, null);
Assert.fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
}
@@ -136,7 +136,7 @@ public class TestHttpAsyncServerProtocol
this.protocolHandler.connected(this.conn);
State state = (State) this.connContext.getAttribute(
- HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE);
+ HttpAsyncService.HTTP_EXCHANGE_STATE);
Assert.assertNotNull(state);
Assert.assertEquals(MessageState.READY, state.getRequestState());
Assert.assertEquals(MessageState.READY, state.getResponseState());
@@ -146,13 +146,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testClosed() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
state.setRequestState(MessageState.COMPLETED);
state.setResponseState(MessageState.COMPLETED);
state.setRequestConsumer(this.requestConsumer);
state.setResponseProducer(this.responseProducer);
state.setCancellable(this.cancellable);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
this.protocolHandler.closed(this.conn);
@@ -165,11 +165,11 @@ public class TestHttpAsyncServerProtocol
@Test
public void testHttpExceptionHandling() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
state.setRequestState(MessageState.READY);
state.setResponseState(MessageState.READY);
state.setRequestConsumer(this.requestConsumer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
HttpException httpex = new HttpException();
this.protocolHandler.exception(this.conn, httpex);
@@ -188,13 +188,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testHttpExceptionHandlingRuntimeException() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
state.setRequestState(MessageState.READY);
state.setResponseState(MessageState.READY);
state.setRequestConsumer(this.requestConsumer);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.doThrow(new RuntimeException()).when(this.httpProcessor).process(
Mockito.any(HttpResponse.class), Mockito.eq(exchangeContext));
@@ -213,13 +213,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testHttpExceptionHandlingIOException() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
state.setRequestState(MessageState.READY);
state.setResponseState(MessageState.READY);
state.setRequestConsumer(this.requestConsumer);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.doThrow(new IOException()).when(this.httpProcessor).process(
Mockito.any(HttpResponse.class), Mockito.eq(exchangeContext));
@@ -236,12 +236,12 @@ public class TestHttpAsyncServerProtocol
@Test
public void testHttpExceptionHandlingResponseSubmitted() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
state.setRequestState(MessageState.READY);
state.setResponseState(MessageState.READY);
state.setRequestConsumer(this.requestConsumer);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.conn.isResponseSubmitted()).thenReturn(true);
HttpException httpex = new HttpException();
@@ -258,12 +258,12 @@ public class TestHttpAsyncServerProtocol
@Test
public void testIOExceptionHandling() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
state.setRequestState(MessageState.READY);
state.setResponseState(MessageState.READY);
state.setRequestConsumer(this.requestConsumer);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
IOException httpex = new IOException();
this.protocolHandler.exception(this.conn, httpex);
@@ -279,9 +279,9 @@ public class TestHttpAsyncServerProtocol
@Test
public void testBasicRequest() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
@@ -314,9 +314,9 @@ public class TestHttpAsyncServerProtocol
@Test
public void testRequestNoMatchingHandler() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST",
"/stuff", HttpVersion.HTTP_1_1);
@@ -336,9 +336,9 @@ public class TestHttpAsyncServerProtocol
@Test
public void testEntityEnclosingRequest() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
@@ -364,9 +364,9 @@ public class TestHttpAsyncServerProtocol
@Test
public void testEntityEnclosingRequestContinueWithoutVerification() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
@@ -403,13 +403,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testEntityEnclosingRequestExpectationVerification() throws Exception {
HttpAsyncExpectationVerifier expectationVerifier = Mockito.mock(HttpAsyncExpectationVerifier.class);
- this.protocolHandler = new HttpAsyncServerProtocolHandler(
+ this.protocolHandler = new HttpAsyncService(
this.httpProcessor, this.reuseStrategy, this.responseFactory,
this.handlerResolver, expectationVerifier, this.params);
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
@@ -439,11 +439,11 @@ public class TestHttpAsyncServerProtocol
@Test
public void testRequestExpectationFailed() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
state.setRequestState(MessageState.ACK_EXPECTED);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
- HttpAsyncExchange httpexchanage = new HttpAsyncServerProtocolHandler.Exchange(
+ HttpAsyncExchange httpexchanage = new HttpAsyncService.Exchange(
new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1),
new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"),
state, this.conn);
@@ -466,11 +466,11 @@ public class TestHttpAsyncServerProtocol
@Test(expected=IllegalArgumentException.class)
public void testRequestExpectationFailedInvalidResponseProducer() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
state.setRequestState(MessageState.ACK_EXPECTED);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
- HttpAsyncExchange httpexchanage = new HttpAsyncServerProtocolHandler.Exchange(
+ HttpAsyncExchange httpexchanage = new HttpAsyncService.Exchange(
new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1),
new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"),
state, this.conn);
@@ -479,11 +479,11 @@ public class TestHttpAsyncServerProtocol
@Test
public void testRequestContinue() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
state.setRequestState(MessageState.ACK_EXPECTED);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
- HttpAsyncExchange httpexchanage = new HttpAsyncServerProtocolHandler.Exchange(
+ HttpAsyncExchange httpexchanage = new HttpAsyncService.Exchange(
new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1),
new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue"),
state, this.conn);
@@ -509,13 +509,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testRequestContent() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
state.setRequestState(MessageState.BODY_STREAM);
state.setRequest(request);
state.setRequestConsumer(this.requestConsumer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.decoder.isCompleted()).thenReturn(false);
this.protocolHandler.inputReady(conn, this.decoder);
@@ -529,7 +529,7 @@ public class TestHttpAsyncServerProtocol
@Test
public void testRequestContentCompleted() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
@@ -537,7 +537,7 @@ public class TestHttpAsyncServerProtocol
state.setRequest(request);
state.setRequestConsumer(this.requestConsumer);
state.setRequestHandler(this.requestHandler);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.decoder.isCompleted()).thenReturn(true);
Mockito.when(this.requestConsumer.getException()).thenReturn(null);
Object data = new Object();
@@ -559,7 +559,7 @@ public class TestHttpAsyncServerProtocol
@Test
public void testRequestCompletedWithException() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
@@ -567,7 +567,7 @@ public class TestHttpAsyncServerProtocol
state.setRequest(request);
state.setRequestConsumer(this.requestConsumer);
state.setRequestHandler(this.requestHandler);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.decoder.isCompleted()).thenReturn(true);
Mockito.when(this.requestConsumer.getException()).thenReturn(new HttpException());
Mockito.when(this.requestConsumer.getResult()).thenReturn(null);
@@ -590,7 +590,7 @@ public class TestHttpAsyncServerProtocol
@Test
public void testRequestHandlingHttpException() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
@@ -598,7 +598,7 @@ public class TestHttpAsyncServerProtocol
state.setRequest(request);
state.setRequestConsumer(this.requestConsumer);
state.setRequestHandler(this.requestHandler);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.decoder.isCompleted()).thenReturn(true);
Mockito.when(this.requestConsumer.getException()).thenReturn(null);
Object data = new Object();
@@ -623,13 +623,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testBasicResponse() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
state.setRequest(request);
state.setRequestState(MessageState.COMPLETED);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
@@ -649,13 +649,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testBasicResponseNoKeepAlive() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
state.setRequest(request);
state.setRequestState(MessageState.COMPLETED);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
@@ -674,13 +674,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testEntityEnclosingResponse() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
state.setRequest(request);
state.setRequestState(MessageState.COMPLETED);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.setEntity(NStringEntity.create("stuff"));
@@ -700,13 +700,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testResponseToHead() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpRequest request = new BasicHttpRequest("HEAD", "/", HttpVersion.HTTP_1_1);
state.setRequest(request);
state.setRequestState(MessageState.COMPLETED);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.setEntity(NStringEntity.create("stuff"));
@@ -727,13 +727,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testResponseNotModified() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpRequest request = new BasicHttpRequest("HEAD", "/", HttpVersion.HTTP_1_1);
state.setRequest(request);
state.setRequestState(MessageState.COMPLETED);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
HttpStatus.SC_NOT_MODIFIED, "Not modified");
@@ -755,13 +755,13 @@ public class TestHttpAsyncServerProtocol
@Test
public void testResponseContinue() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
state.setRequest(request);
state.setRequestState(MessageState.ACK_EXPECTED);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
HttpStatus.SC_CONTINUE, "Continue");
@@ -786,14 +786,14 @@ public class TestHttpAsyncServerProtocol
@Test
public void testResponseFailedExpectation() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
state.setRequest(request);
state.setRequestState(MessageState.ACK_EXPECTED);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 417, "Expectation failed");
response.setEntity(NStringEntity.create("stuff"));
@@ -812,14 +812,14 @@ public class TestHttpAsyncServerProtocol
@Test(expected=HttpException.class)
public void testInvalidResponseStatus() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
state.setRequest(request);
state.setRequestState(MessageState.COMPLETED);
state.setResponseState(MessageState.READY);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 112, "Something stupid");
Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
@@ -830,14 +830,14 @@ public class TestHttpAsyncServerProtocol
@Test(expected=HttpException.class)
public void testInvalidResponseStatusToExpection() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
state.setRequest(request);
state.setRequestState(MessageState.ACK_EXPECTED);
state.setResponseState(MessageState.READY);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.setEntity(NStringEntity.create("stuff"));
@@ -849,12 +849,12 @@ public class TestHttpAsyncServerProtocol
@Test
public void testResponseTrigger() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
state.setRequestState(MessageState.COMPLETED);
state.setResponseState(MessageState.READY);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
- HttpAsyncExchange httpexchanage = new HttpAsyncServerProtocolHandler.Exchange(
+ HttpAsyncExchange httpexchanage = new HttpAsyncService.Exchange(
new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1),
new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"),
state, this.conn);
@@ -877,11 +877,11 @@ public class TestHttpAsyncServerProtocol
@Test(expected=IllegalArgumentException.class)
public void testResponseTriggerInvalidResponseProducer() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
state.setRequestState(MessageState.ACK_EXPECTED);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
- HttpAsyncExchange httpexchanage = new HttpAsyncServerProtocolHandler.Exchange(
+ HttpAsyncExchange httpexchanage = new HttpAsyncService.Exchange(
new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1),
new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"),
state, this.conn);
@@ -890,14 +890,14 @@ public class TestHttpAsyncServerProtocol
@Test
public void testResponseContent() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.setEntity(NStringEntity.create("stuff"));
state.setRequestState(MessageState.COMPLETED);
state.setResponseState(MessageState.BODY_STREAM);
state.setResponse(response);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.encoder.isCompleted()).thenReturn(false);
this.protocolHandler.outputReady(conn, this.encoder);
@@ -912,7 +912,7 @@ public class TestHttpAsyncServerProtocol
@Test
public void testResponseContentCompleted() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.setEntity(NStringEntity.create("stuff"));
@@ -920,7 +920,7 @@ public class TestHttpAsyncServerProtocol
state.setResponseState(MessageState.BODY_STREAM);
state.setResponse(response);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.encoder.isCompleted()).thenReturn(true);
Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(true);
@@ -937,7 +937,7 @@ public class TestHttpAsyncServerProtocol
@Test
public void testResponseContentCompletedNoKeepAlive() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.setEntity(NStringEntity.create("stuff"));
@@ -945,7 +945,7 @@ public class TestHttpAsyncServerProtocol
state.setResponseState(MessageState.BODY_STREAM);
state.setResponse(response);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.encoder.isCompleted()).thenReturn(true);
Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(false);
@@ -962,8 +962,8 @@ public class TestHttpAsyncServerProtocol
@Test
public void testTimeoutActiveConnection() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ State state = new HttpAsyncService.State();
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.conn.getStatus()).thenReturn(NHttpClientConnection.ACTIVE, NHttpClientConnection.CLOSED);
this.protocolHandler.timeout(this.conn);
@@ -974,8 +974,8 @@ public class TestHttpAsyncServerProtocol
@Test
public void testTimeoutActiveConnectionBufferedData() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ State state = new HttpAsyncService.State();
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.conn.getStatus()).thenReturn(NHttpClientConnection.ACTIVE, NHttpClientConnection.CLOSING);
this.protocolHandler.timeout(this.conn);
@@ -986,10 +986,10 @@ public class TestHttpAsyncServerProtocol
@Test
public void testTimeoutClosingConnection() throws Exception {
- State state = new HttpAsyncServerProtocolHandler.State();
+ State state = new HttpAsyncService.State();
state.setRequestConsumer(this.requestConsumer);
state.setResponseProducer(this.responseProducer);
- this.connContext.setAttribute(HttpAsyncServerProtocolHandler.HTTP_EXCHANGE_STATE, state);
+ this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
Mockito.when(this.conn.getStatus()).thenReturn(NHttpClientConnection.CLOSING);
this.protocolHandler.timeout(this.conn);
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpConnection.java?rev=1225503&r1=1225502&r2=1225503&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpConnection.java Thu Dec 29 12:03:33 2011
@@ -27,6 +27,7 @@
package org.apache.http;
+import java.io.Closeable;
import java.io.IOException;
/**
@@ -34,7 +35,7 @@ import java.io.IOException;
*
* @since 4.0
*/
-public interface HttpConnection {
+public interface HttpConnection extends Closeable {
/**
* Closes this connection gracefully.
@@ -43,13 +44,13 @@ public interface HttpConnection {
* This method MUST NOT be called from a different thread to force
* shutdown of the connection. Use {@link #shutdown shutdown} instead.
*/
- public void close() throws IOException;
+ void close() throws IOException;
/**
* Checks if this connection is open.
* @return true if it is open, false if it is closed.
*/
- public boolean isOpen();
+ boolean isOpen();
/**
* Checks whether this connection has gone down.
@@ -66,7 +67,7 @@ public interface HttpConnection {
* likely to succeed, or <code>false</code> if they are likely
* to fail and this connection should be closed
*/
- public boolean isStale();
+ boolean isStale();
/**
* Sets the socket timeout value.
@@ -91,7 +92,7 @@ public interface HttpConnection {
* This method will not attempt to flush the transmitter's
* internal buffer prior to closing the underlying socket.
*/
- public void shutdown() throws IOException;
+ void shutdown() throws IOException;
/**
* Returns a collection of connection metrics.
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java?rev=1225503&r1=1225502&r2=1225503&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java Thu Dec 29 12:03:33 2011
@@ -43,16 +43,16 @@ import org.apache.http.annotation.Immuta
import org.apache.http.params.CoreProtocolPNames;
/**
- * HttpRequestExecutor is a client side HTTP protocol handler based on the
- * blocking I/O model that implements the essential requirements of the HTTP
- * protocol for the client side message processing, as described by RFC 2616.
- * <br>
- * HttpRequestExecutor relies on {@link HttpProcessor} to generate mandatory
- * protocol headers for all outgoing messages and apply common, cross-cutting
- * message transformations to all incoming and outgoing messages. Application
- * specific processing can be implemented outside HttpRequestExecutor once the
- * request has been executed and a response has been received.
- * <p>
+ * <tt>HttpRequestExecutor</tt> is a client side HTTP protocol handler based
+ * on the blocking (classic) I/O model.
+ * <p/>
+ * <tt>HttpRequestExecutor</tt> relies on {@link HttpProcessor} to generate
+ * mandatory protocol headers for all outgoing messages and apply common,
+ * cross-cutting message transformations to all incoming and outgoing messages.
+ * Application specific processing can be implemented outside
+ * <tt>HttpRequestExecutor</tt> once the request has been executed and
+ * a response has been received.
+ * <p/>
* The following parameters can be used to customize the behavior of this
* class:
* <ul>
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java?rev=1225503&r1=1225502&r2=1225503&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java Thu Dec 29 12:03:33 2011
@@ -50,21 +50,21 @@ import org.apache.http.util.EncodingUtil
import org.apache.http.util.EntityUtils;
/**
- * HttpService is a server side HTTP protocol handler based in the blocking
- * I/O model that implements the essential requirements of the HTTP protocol
- * for the server side message processing as described by RFC 2616.
- * <br>
- * HttpService relies on {@link HttpProcessor} to generate mandatory protocol
- * headers for all outgoing messages and apply common, cross-cutting message
- * transformations to all incoming and outgoing messages, whereas individual
- * {@link HttpRequestHandler}s are expected to take care of application specific
- * content generation and processing.
- * <br>
- * HttpService relies on {@link HttpRequestHandler} to resolve matching request
- * handler for a particular request URI of an incoming HTTP request.
- * <br>
- * HttpService can use optional {@link HttpExpectationVerifier} to ensure that
- * incoming requests meet server's expectations.
+ * <tt>HttpService</tt> is a server side HTTP protocol handler based on
+ * the classic (blocking) I/O model.
+ * <p/>
+ * <tt>HttpService</tt> relies on {@link HttpProcessor} to generate mandatory
+ * protocol headers for all outgoing messages and apply common, cross-cutting
+ * message transformations to all incoming and outgoing messages, whereas
+ * individual {@link HttpRequestHandler}s are expected to implement
+ * application specific content generation and processing.
+ * <p/>
+ * <tt>HttpService</tt> uses {@link HttpRequestHandlerResolver} to resolve
+ * matching request handler for a particular request URI of an incoming HTTP
+ * request.
+ * <p/>
+ * <tt>HttpService</tt> can use optional {@link HttpExpectationVerifier}
+ * to ensure that incoming requests meet server's expectations.
*
* @since 4.0
*/