hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1209158 [2/3] - in /httpcomponents/httpcore/trunk/httpcore-nio/src: examples/org/apache/http/examples/nio/ main/java/org/apache/http/impl/nio/ main/java/org/apache/http/nio/ main/java/org/apache/http/nio/protocol/ test/java/org/apache/http...
Date Thu, 01 Dec 2011 17:20:37 GMT
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncServiceHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncServiceHandler.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncServiceHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncServiceHandler.java Thu Dec  1 17:20:25 2011
@@ -49,7 +49,7 @@ import org.apache.http.nio.ContentDecode
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.NHttpConnection;
 import org.apache.http.nio.NHttpServerConnection;
-import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.nio.NHttpServerProtocolHandler;
 import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.params.DefaultedHttpParams;
 import org.apache.http.params.HttpParams;
@@ -62,7 +62,7 @@ import org.apache.http.protocol.HttpProc
  * @since 4.2
  */
 @Immutable // provided injected dependencies are immutable
-public class HttpAsyncServiceHandler implements NHttpServiceHandler {
+public class HttpAsyncServiceHandler implements NHttpServerProtocolHandler {
 
     static final String HTTP_EXCHANGE_STATE = "http.nio.http-exchange-state";
 
@@ -127,196 +127,183 @@ public class HttpAsyncServiceHandler imp
         }
     }
 
-    public void exception(final NHttpServerConnection conn, final HttpException httpex) {
+    public void exception(
+            final NHttpServerConnection conn, final Exception cause) {
         State state = ensureNotNull(getState(conn));
         if (state != null) {
-            handleProtocolFailure(conn, state, httpex);
-        } else {
-            shutdownConnection(conn);
-            onException(httpex);
-        }
-    }
-
-    public void exception(final NHttpServerConnection conn, final IOException ex) {
-        State state = getState(conn);
-        if (state != null) {
-            handleFailure(conn, state, ex);
+            closeHandlers(state, cause);
+            if (cause instanceof HttpException) {
+                if (conn.isResponseSubmitted() || state.getResponseState() != MessageState.READY) {
+                    // There is not much that we can do if a response
+                    // has already been submitted
+                    closeConnection(conn);
+                } else {
+                    HttpContext context = state.getContext();
+                    HttpAsyncResponseProducer responseProducer = handleException(cause, context);
+                    state.setResponseProducer(responseProducer);
+                    try {
+                        HttpResponse response = responseProducer.generateResponse();
+                        state.setResponse(response);
+                        commitFinalResponse(conn, state);
+                    } catch (Exception ex) {
+                        shutdownConnection(conn);
+                        closeHandlers(state);
+                        state.reset();
+                        if (ex instanceof RuntimeException) {
+                            throw (RuntimeException) ex;
+                        } else {
+                            log(ex);
+                        }
+                    }
+                }
+            } else {
+                shutdownConnection(conn);
+                state.reset();
+            }
         } else {
             shutdownConnection(conn);
-            onException(ex);
+            log(cause);
         }
     }
 
-    public void requestReceived(final NHttpServerConnection conn) {
+    public void requestReceived(
+            final NHttpServerConnection conn) throws IOException, HttpException {
         State state = ensureNotNull(getState(conn));
-        try {
-            HttpRequest request = conn.getHttpRequest();
-            HttpContext context = state.getContext();
-            request.setParams(new DefaultedHttpParams(request.getParams(), this.params));
-
-            context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
-            context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-            this.httpProcessor.process(request, context);
-
-            state.setRequest(request);
-            HttpAsyncRequestHandler<Object> requestHandler = getRequestHandler(request);
-            state.setRequestHandler(requestHandler);
-            HttpAsyncRequestConsumer<Object> consumer = requestHandler.processRequest(request, context);
-            state.setRequestConsumer(consumer);
-
-            consumer.requestReceived(request);
-
-            if (request instanceof HttpEntityEnclosingRequest) {
-                if (((HttpEntityEnclosingRequest) request).expectContinue()) {
-                    state.setRequestState(MessageState.ACK_EXPECTED);
-                    HttpResponse ack = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_1,
-                            HttpStatus.SC_CONTINUE, context);
-                    if (this.expectationVerifier != null) {
-                        conn.suspendInput();
-                        HttpAsyncServiceExchange httpex = new Exchange(
-                                request, ack, state, conn);
-                        Cancellable asyncProcess = this.expectationVerifier.verify(httpex, context);
-                        state.setAsyncProcess(asyncProcess);
-                    } else {
-                        conn.submitResponse(ack);
-                        state.setRequestState(MessageState.BODY_STREAM);
-                    }
+        HttpRequest request = conn.getHttpRequest();
+        HttpContext context = state.getContext();
+        request.setParams(new DefaultedHttpParams(request.getParams(), this.params));
+
+        context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        this.httpProcessor.process(request, context);
+
+        state.setRequest(request);
+        HttpAsyncRequestHandler<Object> requestHandler = getRequestHandler(request);
+        state.setRequestHandler(requestHandler);
+        HttpAsyncRequestConsumer<Object> consumer = requestHandler.processRequest(request, context);
+        state.setRequestConsumer(consumer);
+
+        consumer.requestReceived(request);
+
+        if (request instanceof HttpEntityEnclosingRequest) {
+            if (((HttpEntityEnclosingRequest) request).expectContinue()) {
+                state.setRequestState(MessageState.ACK_EXPECTED);
+                HttpResponse ack = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_1,
+                        HttpStatus.SC_CONTINUE, context);
+                if (this.expectationVerifier != null) {
+                    conn.suspendInput();
+                    HttpAsyncServiceExchange httpex = new Exchange(
+                            request, ack, state, conn);
+                    Cancellable asyncProcess = this.expectationVerifier.verify(httpex, context);
+                    state.setAsyncProcess(asyncProcess);
                 } else {
+                    conn.submitResponse(ack);
                     state.setRequestState(MessageState.BODY_STREAM);
                 }
             } else {
-                // No request content is expected.
-                // Process request right away
-                conn.suspendInput();
-                processRequest(conn, state);
+                state.setRequestState(MessageState.BODY_STREAM);
             }
-        } catch (HttpException ex) {
-            handleProtocolFailure(conn, state, ex);
-        } catch (IOException ex) {
-            handleFailure(conn, state, ex);
-        } catch (RuntimeException ex) {
-            terminate(conn, state);
-            throw ex;
+        } else {
+            // No request content is expected.
+            // Process request right away
+            conn.suspendInput();
+            processRequest(conn, state);
         }
     }
 
-    public void inputReady(final NHttpServerConnection conn, final ContentDecoder decoder) {
+    public void inputReady(
+            final NHttpServerConnection conn,
+            final ContentDecoder decoder) throws IOException, HttpException {
         State state = ensureNotNull(getState(conn));
-        try {
-            HttpAsyncRequestConsumer<?> consumer = ensureNotNull(state.getRequestConsumer());
-            consumer.consumeContent(decoder, conn);
-            state.setRequestState(MessageState.BODY_STREAM);
-            if (decoder.isCompleted()) {
-                conn.suspendInput();
-                processRequest(conn, state);
-            }
-        } catch (HttpException ex) {
-            handleProtocolFailure(conn, state, ex);
-        } catch (IOException ex) {
-            handleFailure(conn, state, ex);
-        } catch (RuntimeException ex) {
-            terminate(conn, state);
-            throw ex;
+        HttpAsyncRequestConsumer<?> consumer = ensureNotNull(state.getRequestConsumer());
+        consumer.consumeContent(decoder, conn);
+        state.setRequestState(MessageState.BODY_STREAM);
+        if (decoder.isCompleted()) {
+            conn.suspendInput();
+            processRequest(conn, state);
         }
     }
 
-    public void responseReady(final NHttpServerConnection conn) {
+    public void responseReady(
+            final NHttpServerConnection conn) throws IOException, HttpException {
         State state = ensureNotNull(getState(conn));
-        try {
-            if (state.getResponse() != null) {
-                return;
-            }
-            HttpAsyncResponseProducer responseProducer = state.getResponseProducer();
-            if (responseProducer == null) {
-                return;
-            }
-            HttpContext context = state.getContext();
-            HttpResponse response = responseProducer.generateResponse();
-            int status = response.getStatusLine().getStatusCode();
-            if (state.getRequestState() == MessageState.ACK_EXPECTED) {
-                if (status == 100) {
-                    state.setResponseProducer(null);
-                    try {
-                        // Make sure 100 response has no entity
-                        response.setEntity(null);
-                        conn.requestInput();
-                        state.setRequestState(MessageState.BODY_STREAM);
-                        conn.submitResponse(response);
-                        responseProducer.responseCompleted(context);
-                    } finally {
-                        responseProducer.close();
-                    }
-                } else if (status >= 400) {
-                    conn.resetInput();
-                    state.setRequestState(MessageState.COMPLETED);
-                    state.setResponse(response);
-                    commitFinalResponse(conn, state);
-                } else {
-                    throw new HttpException("Invalid response: " + response.getStatusLine());
+        if (state.getResponse() != null) {
+            return;
+        }
+        HttpAsyncResponseProducer responseProducer = state.getResponseProducer();
+        if (responseProducer == null) {
+            return;
+        }
+        HttpContext context = state.getContext();
+        HttpResponse response = responseProducer.generateResponse();
+        int status = response.getStatusLine().getStatusCode();
+        if (state.getRequestState() == MessageState.ACK_EXPECTED) {
+            if (status == 100) {
+                state.setResponseProducer(null);
+                try {
+                    // Make sure 100 response has no entity
+                    response.setEntity(null);
+                    conn.requestInput();
+                    state.setRequestState(MessageState.BODY_STREAM);
+                    conn.submitResponse(response);
+                    responseProducer.responseCompleted(context);
+                } finally {
+                    responseProducer.close();
                 }
+            } else if (status >= 400) {
+                conn.resetInput();
+                state.setRequestState(MessageState.COMPLETED);
+                state.setResponse(response);
+                commitFinalResponse(conn, state);
             } else {
-                if (status >= 200) {
-                    state.setResponse(response);
-                    commitFinalResponse(conn, state);
-                } else {
-                    throw new HttpException("Invalid response: " + response.getStatusLine());
-                }
+                throw new HttpException("Invalid response: " + response.getStatusLine());
+            }
+        } else {
+            if (status >= 200) {
+                state.setResponse(response);
+                commitFinalResponse(conn, state);
+            } else {
+                throw new HttpException("Invalid response: " + response.getStatusLine());
             }
-        } catch (HttpException ex) {
-            handleProtocolFailure(conn, state, ex);
-        } catch (IOException ex) {
-            handleFailure(conn, state, ex);
-        } catch (RuntimeException ex) {
-            terminate(conn, state);
-            throw ex;
         }
     }
 
-    public void outputReady(final NHttpServerConnection conn, final ContentEncoder encoder) {
+    public void outputReady(
+            final NHttpServerConnection conn,
+            final ContentEncoder encoder) throws IOException {
         State state = ensureNotNull(getState(conn));
-        try {
-            HttpAsyncResponseProducer responseProducer = state.getResponseProducer();
-            HttpContext context = state.getContext();
-            HttpResponse response = state.getResponse();
+        HttpAsyncResponseProducer responseProducer = state.getResponseProducer();
+        HttpContext context = state.getContext();
+        HttpResponse response = state.getResponse();
 
-            responseProducer.produceContent(encoder, conn);
-            state.setResponseState(MessageState.BODY_STREAM);
-            if (encoder.isCompleted()) {
-                responseProducer.responseCompleted(context);
-                if (!this.connStrategy.keepAlive(response, context)) {
-                    conn.close();
-                } else {
-                    conn.requestInput();
-                }
-                closeHandlers(state);
-                state.reset();
+        responseProducer.produceContent(encoder, conn);
+        state.setResponseState(MessageState.BODY_STREAM);
+        if (encoder.isCompleted()) {
+            responseProducer.responseCompleted(context);
+            if (!this.connStrategy.keepAlive(response, context)) {
+                conn.close();
+            } else {
+                conn.requestInput();
             }
-        } catch (IOException ex) {
-            handleFailure(conn, state, ex);
-        } catch (RuntimeException ex) {
-            terminate(conn, state);
-            throw ex;
+            closeHandlers(state);
+            state.reset();
         }
     }
 
-    public void timeout(final NHttpServerConnection conn) {
+    public void timeout(final NHttpServerConnection conn) throws IOException {
         State state = getState(conn);
         if (state != null) {
             closeHandlers(state, new SocketTimeoutException());
         }
-        try {
-            if (conn.getStatus() == NHttpConnection.ACTIVE) {
-                conn.close();
-                if (conn.getStatus() == NHttpConnection.CLOSING) {
-                    // Give the connection some grace time to
-                    // close itself nicely
-                    conn.setSocketTimeout(250);
-                }
-            } else {
-                conn.shutdown();
+        if (conn.getStatus() == NHttpConnection.ACTIVE) {
+            conn.close();
+            if (conn.getStatus() == NHttpConnection.CLOSING) {
+                // Give the connection some grace time to
+                // close itself nicely
+                conn.setSocketTimeout(250);
             }
-        } catch (IOException ex) {
-            onException(ex);
+        } else {
+            conn.shutdown();
         }
     }
 
@@ -338,14 +325,14 @@ public class HttpAsyncServiceHandler imp
         return requestConsumer;
     }
 
-    protected void onException(final Exception ex) {
+    protected void log(final Exception ex) {
     }
 
     private void closeConnection(final NHttpConnection conn) {
         try {
             conn.close();
         } catch (IOException ex) {
-            onException(ex);
+            log(ex);
         }
     }
 
@@ -353,7 +340,7 @@ public class HttpAsyncServiceHandler imp
         try {
             conn.shutdown();
         } catch (IOException ex) {
-            onException(ex);
+            log(ex);
         }
     }
 
@@ -366,7 +353,7 @@ public class HttpAsyncServiceHandler imp
                 try {
                     consumer.close();
                 } catch (IOException ioex) {
-                    onException(ioex);
+                    log(ioex);
                 }
             }
         }
@@ -378,7 +365,7 @@ public class HttpAsyncServiceHandler imp
                 try {
                     producer.close();
                 } catch (IOException ioex) {
-                    onException(ioex);
+                    log(ioex);
                 }
             }
         }
@@ -390,7 +377,7 @@ public class HttpAsyncServiceHandler imp
             try {
                 consumer.close();
             } catch (IOException ioex) {
-                onException(ioex);
+                log(ioex);
             }
         }
         HttpAsyncResponseProducer producer = state.getResponseProducer();
@@ -398,7 +385,7 @@ public class HttpAsyncServiceHandler imp
             try {
                 producer.close();
             } catch (IOException ioex) {
-                onException(ioex);
+                log(ioex);
             }
         }
     }
@@ -433,49 +420,6 @@ public class HttpAsyncServiceHandler imp
             && status != HttpStatus.SC_RESET_CONTENT;
     }
 
-    private void terminate(
-            final NHttpServerConnection conn,
-            final State state) {
-        shutdownConnection(conn);
-        closeHandlers(state);
-        state.reset();
-    }
-
-    private void handleFailure(
-            final NHttpServerConnection conn,
-            final State state,
-            final Exception ex) {
-        shutdownConnection(conn);
-        closeHandlers(state, ex);
-        state.reset();
-    }
-
-    private void handleProtocolFailure(
-            final NHttpServerConnection conn,
-            final State state,
-            final HttpException httpex) {
-        closeHandlers(state, httpex);
-        if (conn.isResponseSubmitted() || state.getResponseState() != MessageState.READY) {
-            // There is not much that we can do if a response
-            // has already been submitted
-            closeConnection(conn);
-        } else {
-            HttpContext context = state.getContext();
-            HttpAsyncResponseProducer responseProducer = handleException(httpex, context);
-            state.setResponseProducer(responseProducer);
-            try {
-                HttpResponse response = responseProducer.generateResponse();
-                state.setResponse(response);
-                commitFinalResponse(conn, state);
-            } catch (RuntimeException ex) {
-                handleFailure(conn, state, ex);
-                throw ex;
-            } catch (Exception ex) {
-                handleFailure(conn, state, ex);
-            }
-        }
-    }
-
     private void processRequest(
             final NHttpServerConnection conn,
             final State state) throws HttpException, IOException {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java Thu Dec  1 17:20:25 2011
@@ -28,11 +28,11 @@
 package org.apache.http;
 
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.pool.BasicNIOConnFactory;
 import org.apache.http.impl.nio.pool.BasicNIOConnPool;
-import org.apache.http.nio.NHttpClientIOTarget;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.nio.protocol.HttpAsyncRequestExecutor;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
@@ -68,10 +68,10 @@ public abstract class HttpCoreNIOTestBas
     protected BasicNIOConnPool connpool;
     protected HttpAsyncRequestExecutor executor;
 
-    protected abstract NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+    protected abstract NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
             HttpParams params) throws Exception;
 
-    protected abstract NHttpConnectionFactory<NHttpClientIOTarget> createClientConnectionFactory(
+    protected abstract NHttpConnectionFactory<DefaultNHttpClientConnection> createClientConnectionFactory(
             HttpParams params) throws Exception;
 
     public void initServer() throws Exception {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingClientConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingClientConnectionFactory.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingClientConnectionFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingClientConnectionFactory.java Thu Dec  1 17:20:25 2011
@@ -27,8 +27,8 @@
 package org.apache.http;
 
 import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
 import org.apache.http.impl.nio.DefaultNHttpClientConnectionFactory;
-import org.apache.http.nio.NHttpClientIOTarget;
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.util.ByteBufferAllocator;
 import org.apache.http.nio.util.HeapByteBufferAllocator;
@@ -41,7 +41,7 @@ public class LoggingClientConnectionFact
     }
 
     @Override
-    protected NHttpClientIOTarget createConnection(
+    protected DefaultNHttpClientConnection createConnection(
             final IOSession session,
             final HttpResponseFactory responseFactory,
             final ByteBufferAllocator allocator,

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingNHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingNHttpClientConnection.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingNHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingNHttpClientConnection.java Thu Dec  1 17:20:25 2011
@@ -39,7 +39,7 @@ import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.impl.nio.DefaultNHttpClientConnection;
-import org.apache.http.nio.NHttpClientHandler;
+import org.apache.http.nio.NHttpClientProtocolHandler;
 import org.apache.http.nio.NHttpMessageParser;
 import org.apache.http.nio.NHttpMessageWriter;
 import org.apache.http.nio.reactor.IOSession;
@@ -99,7 +99,7 @@ public class LoggingNHttpClientConnectio
     }
 
     @Override
-    public void consumeInput(final NHttpClientHandler handler) {
+    public void consumeInput(final NHttpClientProtocolHandler handler) {
         if (this.log.isDebugEnabled()) {
             this.log.debug(this.id + ": Consume input");
         }
@@ -107,7 +107,7 @@ public class LoggingNHttpClientConnectio
     }
 
     @Override
-    public void produceOutput(final NHttpClientHandler handler) {
+    public void produceOutput(final NHttpClientProtocolHandler handler) {
         if (this.log.isDebugEnabled()) {
             this.log.debug(this.id + ": Produce output");
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingNHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingNHttpServerConnection.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingNHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingNHttpServerConnection.java Thu Dec  1 17:20:25 2011
@@ -41,7 +41,7 @@ import org.apache.http.HttpResponse;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.nio.NHttpMessageParser;
 import org.apache.http.nio.NHttpMessageWriter;
-import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.nio.NHttpServerProtocolHandler;
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.reactor.SessionInputBuffer;
 import org.apache.http.nio.reactor.SessionOutputBuffer;
@@ -99,7 +99,7 @@ public class LoggingNHttpServerConnectio
     }
 
     @Override
-    public void consumeInput(final NHttpServiceHandler handler) {
+    public void consumeInput(final NHttpServerProtocolHandler handler) {
         if (this.log.isDebugEnabled()) {
             this.log.debug(this.id + ": Consume input");
         }
@@ -107,7 +107,7 @@ public class LoggingNHttpServerConnectio
     }
 
     @Override
-    public void produceOutput(final NHttpServiceHandler handler) {
+    public void produceOutput(final NHttpServerProtocolHandler handler) {
         if (this.log.isDebugEnabled()) {
             this.log.debug(this.id + ": Produce output");
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingSSLClientConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingSSLClientConnectionFactory.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingSSLClientConnectionFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingSSLClientConnectionFactory.java Thu Dec  1 17:20:25 2011
@@ -29,8 +29,8 @@ package org.apache.http;
 import javax.net.ssl.SSLContext;
 
 import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
 import org.apache.http.impl.nio.SSLNHttpClientConnectionFactory;
-import org.apache.http.nio.NHttpClientIOTarget;
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.util.ByteBufferAllocator;
 import org.apache.http.nio.util.HeapByteBufferAllocator;
@@ -45,7 +45,7 @@ public class LoggingSSLClientConnectionF
     }
 
     @Override
-    protected NHttpClientIOTarget createConnection(
+    protected DefaultNHttpClientConnection createConnection(
             final IOSession session,
             final HttpResponseFactory responseFactory,
             final ByteBufferAllocator allocator,

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingSSLServerConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingSSLServerConnectionFactory.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingSSLServerConnectionFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingSSLServerConnectionFactory.java Thu Dec  1 17:20:25 2011
@@ -29,8 +29,8 @@ package org.apache.http;
 import javax.net.ssl.SSLContext;
 
 import org.apache.http.impl.DefaultHttpRequestFactory;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.SSLNHttpServerConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.util.ByteBufferAllocator;
 import org.apache.http.nio.util.HeapByteBufferAllocator;
@@ -45,7 +45,7 @@ public class LoggingSSLServerConnectionF
     }
 
     @Override
-    protected NHttpServerIOTarget createConnection(
+    protected DefaultNHttpServerConnection createConnection(
             final IOSession session,
             final HttpRequestFactory requestFactory,
             final ByteBufferAllocator allocator,

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingServerConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingServerConnectionFactory.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingServerConnectionFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingServerConnectionFactory.java Thu Dec  1 17:20:25 2011
@@ -27,8 +27,8 @@
 package org.apache.http;
 
 import org.apache.http.impl.DefaultHttpRequestFactory;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.util.ByteBufferAllocator;
 import org.apache.http.nio.util.HeapByteBufferAllocator;
@@ -41,7 +41,7 @@ public class LoggingServerConnectionFact
     }
 
     @Override
-    protected NHttpServerIOTarget createConnection(
+    protected DefaultNHttpServerConnection createConnection(
             final IOSession session,
             final HttpRequestFactory requestFactory,
             final ByteBufferAllocator allocator,

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java Thu Dec  1 17:20:25 2011
@@ -48,9 +48,9 @@ import org.apache.http.LoggingSSLServerC
 import org.apache.http.SSLTestContexts;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.nio.NHttpClientIOTarget;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.nio.NHttpServiceHandler;
 import org.apache.http.nio.protocol.BufferingHttpServiceHandler;
 import org.apache.http.nio.protocol.EventListener;
@@ -79,13 +79,13 @@ public class TestBaseIOReactorSSL extend
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingSSLServerConnectionFactory(SSLTestContexts.createServerSSLContext(), params);
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpClientIOTarget> createClientConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpClientConnection> createClientConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingSSLClientConnectionFactory(SSLTestContexts.createClientSSLContext(), params);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java Thu Dec  1 17:20:25 2011
@@ -46,13 +46,13 @@ import org.apache.http.LoggingClientConn
 import org.apache.http.LoggingServerConnectionFactory;
 import org.apache.http.OoopsieRuntimeException;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.pool.BasicNIOPoolEntry;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.nio.NHttpClientConnection;
-import org.apache.http.nio.NHttpClientIOTarget;
 import org.apache.http.nio.NHttpConnectionFactory;
 import org.apache.http.nio.NHttpServerConnection;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
 import org.apache.http.nio.protocol.BasicAsyncResponseConsumer;
 import org.apache.http.nio.protocol.BufferingAsyncRequestHandler;
@@ -91,13 +91,13 @@ public class TestDefaultIOReactors exten
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingServerConnectionFactory(params);
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpClientIOTarget> createClientConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpClientConnection> createClientConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingClientConnectionFactory(params);
     }
@@ -136,7 +136,9 @@ public class TestDefaultIOReactors exten
         HttpAsyncClientProtocolHandler clientHandler = new HttpAsyncClientProtocolHandler() {
 
             @Override
-            public void connected(final NHttpClientConnection conn, final Object attachment) {
+            public void connected(
+                    final NHttpClientConnection conn,
+                    final Object attachment) throws IOException, HttpException {
                 openClientConns.countDown();
                 super.connected(conn, attachment);
             }
@@ -202,7 +204,19 @@ public class TestDefaultIOReactors exten
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 registry,
-                this.serverParams);
+                this.serverParams) {
+
+                    @Override
+                    public void exception(
+                            final NHttpServerConnection conn,
+                            final Exception cause) {
+                        super.exception(conn, cause);
+                        if (cause instanceof RuntimeException) {
+                            throw (RuntimeException) cause;
+                        }
+                    }
+
+        };
         HttpAsyncClientProtocolHandler clientHandler = new HttpAsyncClientProtocolHandler();
         this.server.start(serviceHandler);
         this.client.start(clientHandler);
@@ -273,7 +287,19 @@ public class TestDefaultIOReactors exten
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 registry,
-                this.serverParams);
+                this.serverParams) {
+
+            @Override
+            public void exception(
+                    final NHttpServerConnection conn,
+                    final Exception cause) {
+                super.exception(conn, cause);
+                if (cause instanceof RuntimeException) {
+                    throw (RuntimeException) cause;
+                }
+            }
+
+        };
         HttpAsyncClientProtocolHandler clientHandler = new HttpAsyncClientProtocolHandler();
         this.server.setExceptionHandler(exceptionHandler);
         this.server.start(serviceHandler);
@@ -345,7 +371,19 @@ public class TestDefaultIOReactors exten
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 registry,
-                this.serverParams);
+                this.serverParams) {
+
+            @Override
+            public void exception(
+                    final NHttpServerConnection conn,
+                    final Exception cause) {
+                super.exception(conn, cause);
+                if (cause instanceof RuntimeException) {
+                    throw (RuntimeException) cause;
+                }
+            }
+
+        };
         HttpAsyncClientProtocolHandler clientHandler = new HttpAsyncClientProtocolHandler();
         this.server.setExceptionHandler(exceptionHandler);
         this.server.start(serviceHandler);

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java Thu Dec  1 17:20:25 2011
@@ -30,9 +30,9 @@ package org.apache.http.impl.nio.reactor
 import org.apache.http.LoggingSSLClientConnectionFactory;
 import org.apache.http.LoggingSSLServerConnectionFactory;
 import org.apache.http.SSLTestContexts;
-import org.apache.http.nio.NHttpClientIOTarget;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.params.HttpParams;
 
 /**
@@ -42,13 +42,13 @@ import org.apache.http.params.HttpParams
 public class TestDefaultIOReactorsSSL extends TestDefaultIOReactors {
 
     @Override
-    protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingSSLServerConnectionFactory(SSLTestContexts.createServerSSLContext(), params);
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpClientIOTarget> createClientConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpClientConnection> createClientConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingSSLClientConnectionFactory(SSLTestContexts.createClientSSLContext(), params);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestAsyncNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestAsyncNHttpHandlers.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestAsyncNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestAsyncNHttpHandlers.java Thu Dec  1 17:20:25 2011
@@ -47,11 +47,11 @@ import org.apache.http.LoggingClientConn
 import org.apache.http.LoggingServerConnectionFactory;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
 import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.nio.NHttpClientIOTarget;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.nio.entity.ConsumingNHttpEntity;
 import org.apache.http.nio.entity.NByteArrayEntity;
 import org.apache.http.nio.entity.NStringEntity;
@@ -106,13 +106,13 @@ public class TestAsyncNHttpHandlers exte
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingServerConnectionFactory(params);
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpClientIOTarget> createClientConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpClientConnection> createClientConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingClientConnectionFactory(params);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java Thu Dec  1 17:20:25 2011
@@ -47,12 +47,12 @@ import org.apache.http.concurrent.Cancel
 import org.apache.http.entity.ContentType;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.nio.NHttpClientIOTarget;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.nio.protocol.BasicAsyncRequestConsumer;
 import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
@@ -98,13 +98,13 @@ public class TestHttpAsyncHandlers exten
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingServerConnectionFactory(params);
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpClientIOTarget> createClientConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpClientConnection> createClientConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingClientConnectionFactory(params);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpsAsyncHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpsAsyncHandlers.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpsAsyncHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpsAsyncHandlers.java Thu Dec  1 17:20:25 2011
@@ -30,9 +30,9 @@ package org.apache.http.nio.integration;
 import org.apache.http.LoggingSSLClientConnectionFactory;
 import org.apache.http.LoggingSSLServerConnectionFactory;
 import org.apache.http.SSLTestContexts;
-import org.apache.http.nio.NHttpClientIOTarget;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.params.HttpParams;
 
 /**
@@ -41,13 +41,13 @@ import org.apache.http.params.HttpParams
 public class TestHttpsAsyncHandlers extends TestHttpAsyncHandlers {
 
     @Override
-    protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingSSLServerConnectionFactory(SSLTestContexts.createServerSSLContext(), params);
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpClientIOTarget> createClientConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpClientConnection> createClientConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingSSLClientConnectionFactory(SSLTestContexts.createClientSSLContext(), params);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestThrottlingNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestThrottlingNHttpHandlers.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestThrottlingNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestThrottlingNHttpHandlers.java Thu Dec  1 17:20:25 2011
@@ -54,11 +54,11 @@ import org.apache.http.entity.ContentTyp
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
 import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.nio.NHttpClientIOTarget;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.nio.entity.NByteArrayEntity;
 import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.nio.protocol.HttpRequestExecutionHandler;
@@ -112,13 +112,13 @@ public class TestThrottlingNHttpHandlers
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingServerConnectionFactory(params);
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpClientIOTarget> createClientConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpClientConnection> createClientConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingClientConnectionFactory(params);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java Thu Dec  1 17:20:25 2011
@@ -47,15 +47,15 @@ import org.apache.http.entity.ContentLen
 import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
 import org.apache.http.impl.nio.codecs.AbstractContentEncoder;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.IOControl;
-import org.apache.http.nio.NHttpClientIOTarget;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.nio.entity.ContentInputStream;
 import org.apache.http.nio.protocol.AbstractAsyncResponseConsumer;
 import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
@@ -101,13 +101,13 @@ public class TestTruncatedChunks extends
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpServerIOTarget> createServerConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
             final HttpParams params) throws Exception {
         return new CustomServerConnectionFactory(params);
     }
 
     @Override
-    protected NHttpConnectionFactory<NHttpClientIOTarget> createClientConnectionFactory(
+    protected NHttpConnectionFactory<DefaultNHttpClientConnection> createClientConnectionFactory(
             final HttpParams params) throws Exception {
         return new LoggingClientConnectionFactory(params);
     }
@@ -163,7 +163,7 @@ public class TestTruncatedChunks extends
         }
 
         @Override
-        protected NHttpServerIOTarget createConnection(
+        protected DefaultNHttpServerConnection createConnection(
                 final IOSession session,
                 final HttpRequestFactory requestFactory,
                 final ByteBufferAllocator allocator,

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=1209158&r1=1209157&r2=1209158&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  1 17:20:25 2011
@@ -134,7 +134,7 @@ public class TestHttpAsyncClientProtocol
 
         Mockito.verify(this.exchangeHandler).failed(httpex);
         Mockito.verify(this.exchangeHandler).close();
-        Mockito.verify(this.conn).close();
+        Mockito.verify(this.conn).shutdown();
     }
 
     @Test
@@ -210,37 +210,6 @@ public class TestHttpAsyncClientProtocol
     }
 
     @Test
-    public void testRequestRuntimeException() throws Exception {
-        RuntimeException runtimeex = new RuntimeException();
-        State state = new HttpAsyncClientProtocolHandler.State();
-        state.setHandler(this.exchangeHandler);
-        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
-        Mockito.when(this.exchangeHandler.generateRequest()).thenThrow(runtimeex);
-        try {
-            this.protocolHandler.requestReady(this.conn);
-            Assert.fail("RuntimeException expected");
-        } catch (RuntimeException ex) {
-            Mockito.verify(this.conn).shutdown();
-            Mockito.verify(this.exchangeHandler).close();
-        }
-    }
-
-    @Test
-    public void testRequestHttpException() throws Exception {
-        HttpException httpex = new HttpException();
-        State state = new HttpAsyncClientProtocolHandler.State();
-        state.setHandler(this.exchangeHandler);
-        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
-        Mockito.when(this.exchangeHandler.generateRequest()).thenThrow(httpex);
-
-        this.protocolHandler.requestReady(this.conn);
-
-        Mockito.verify(this.conn).close();
-        Mockito.verify(this.exchangeHandler).failed(httpex);
-        Mockito.verify(this.exchangeHandler).close();
-    }
-
-    @Test
     public void testRequestContentOutput() throws Exception {
         State state = new HttpAsyncClientProtocolHandler.State();
         state.setHandler(this.exchangeHandler);
@@ -282,38 +251,6 @@ public class TestHttpAsyncClientProtocol
     }
 
     @Test
-    public void testRequestContentRuntimeException() throws Exception {
-        RuntimeException runtimeex = new RuntimeException();
-        State state = new HttpAsyncClientProtocolHandler.State();
-        state.setHandler(this.exchangeHandler);
-        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
-        Mockito.doThrow(runtimeex).when(this.exchangeHandler).produceContent(this.encoder, this.conn);
-
-        try {
-            this.protocolHandler.outputReady(this.conn, this.encoder);
-            Assert.fail("RuntimeException expected");
-        } catch (RuntimeException ex) {
-            Mockito.verify(this.conn).shutdown();
-            Mockito.verify(this.exchangeHandler).close();
-        }
-    }
-
-    @Test
-    public void testRequestContentIOException() throws Exception {
-        IOException ioex = new IOException();
-        State state = new HttpAsyncClientProtocolHandler.State();
-        state.setHandler(this.exchangeHandler);
-        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
-        Mockito.doThrow(ioex).when(this.exchangeHandler).produceContent(this.encoder, this.conn);
-
-        this.protocolHandler.outputReady(this.conn, this.encoder);
-
-        Mockito.verify(this.conn).shutdown();
-        Mockito.verify(this.exchangeHandler).failed(ioex);
-        Mockito.verify(this.exchangeHandler).close();
-    }
-
-    @Test
     public void testBasicResponse() throws Exception {
         State state = new HttpAsyncClientProtocolHandler.State();
         HttpRequest request = new BasicHttpRequest("GET", "/");
@@ -370,7 +307,7 @@ public class TestHttpAsyncClientProtocol
         Mockito.verify(this.conn, Mockito.never()).requestOutput();
     }
 
-    @Test
+    @Test(expected=HttpException.class)
     public void testResponseUnsupported1xx() throws Exception {
         State state = new HttpAsyncClientProtocolHandler.State();
         state.setRequestState(MessageState.ACK_EXPECTED);
@@ -384,11 +321,6 @@ public class TestHttpAsyncClientProtocol
         Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
 
         this.protocolHandler.responseReceived(this.conn);
-
-        Assert.assertNull(state.getResponse());
-        Mockito.verify(this.conn).shutdown();
-        Mockito.verify(this.exchangeHandler).failed(Mockito.any(HttpException.class));
-        Mockito.verify(this.exchangeHandler).close();
     }
 
     @Test
@@ -507,45 +439,6 @@ public class TestHttpAsyncClientProtocol
     }
 
     @Test
-    public void testResponseRuntimeException() throws Exception {
-        RuntimeException runtimeex = new RuntimeException();
-        State state = new HttpAsyncClientProtocolHandler.State();
-        HttpRequest request = new BasicHttpRequest("GET", "/");
-        state.setRequest(request);
-        state.setHandler(this.exchangeHandler);
-        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
-        BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
-        Mockito.doThrow(runtimeex).when(this.exchangeHandler).responseReceived(response);
-        try {
-            this.protocolHandler.responseReceived(this.conn);
-            Assert.fail("RuntimeException expected");
-        } catch (RuntimeException ex) {
-            Mockito.verify(this.conn).shutdown();
-            Mockito.verify(this.exchangeHandler).close();
-        }
-    }
-
-    @Test
-    public void testResponseHttpException() throws Exception {
-        HttpException httpex = new HttpException();
-        State state = new HttpAsyncClientProtocolHandler.State();
-        HttpRequest request = new BasicHttpRequest("GET", "/");
-        state.setRequest(request);
-        state.setHandler(this.exchangeHandler);
-        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
-        BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
-        Mockito.doThrow(httpex).when(this.exchangeHandler).responseReceived(response);
-
-        this.protocolHandler.responseReceived(this.conn);
-
-        Mockito.verify(this.conn).close();
-        Mockito.verify(this.exchangeHandler).failed(httpex);
-        Mockito.verify(this.exchangeHandler).close();
-    }
-
-    @Test
     public void testResponseContentInput() throws Exception {
         State state = new HttpAsyncClientProtocolHandler.State();
         state.setHandler(this.exchangeHandler);
@@ -624,38 +517,6 @@ public class TestHttpAsyncClientProtocol
     }
 
     @Test
-    public void testResponseContentRuntimeException() throws Exception {
-        RuntimeException runtimeex = new RuntimeException();
-        State state = new HttpAsyncClientProtocolHandler.State();
-        state.setHandler(this.exchangeHandler);
-        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
-        Mockito.doThrow(runtimeex).when(this.exchangeHandler).consumeContent(this.decoder, this.conn);
-
-        try {
-            this.protocolHandler.inputReady(this.conn, this.decoder);
-            Assert.fail("RuntimeException expected");
-        } catch (RuntimeException ex) {
-            Mockito.verify(this.conn).shutdown();
-            Mockito.verify(this.exchangeHandler).close();
-        }
-    }
-
-    @Test
-    public void testResponseContentIOException() throws Exception {
-        IOException ioex = new IOException();
-        State state = new HttpAsyncClientProtocolHandler.State();
-        state.setHandler(this.exchangeHandler);
-        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);
-        Mockito.doThrow(ioex).when(this.exchangeHandler).consumeContent(this.decoder, this.conn);
-
-        this.protocolHandler.inputReady(this.conn, this.decoder);
-
-        Mockito.verify(this.conn).shutdown();
-        Mockito.verify(this.exchangeHandler).failed(ioex);
-        Mockito.verify(this.exchangeHandler).close();
-    }
-
-    @Test
     public void testTimeoutNoHandler() throws Exception {
         State state = new HttpAsyncClientProtocolHandler.State();
         this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE_STATE, state);

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncServiceHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncServiceHandler.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncServiceHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncServiceHandler.java Thu Dec  1 17:20:25 2011
@@ -182,6 +182,8 @@ public class TestHttpAsyncServiceHandler
 
         Mockito.verify(this.requestConsumer).failed(httpex);
         Mockito.verify(this.requestConsumer).close();
+        Mockito.verify(this.conn, Mockito.never()).shutdown();
+        Mockito.verify(this.conn, Mockito.never()).close();
     }
 
     @Test
@@ -445,46 +447,6 @@ public class TestHttpAsyncServiceHandler
     }
 
     @Test
-    public void testRequestRuntimeException() throws Exception {
-        State state = new HttpAsyncServiceHandler.State();
-        HttpContext exchangeContext = state.getContext();
-        this.connContext.setAttribute(HttpAsyncServiceHandler.HTTP_EXCHANGE_STATE, state);
-
-        BasicHttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
-        Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
-        Mockito.when(this.requestHandler.processRequest(
-                request, exchangeContext)).thenThrow(new RuntimeException());
-        try {
-            this.protocolHandler.requestReceived(this.conn);
-            Assert.fail("RuntimeException expected");
-        } catch (RuntimeException ex) {
-            Mockito.verify(this.conn).shutdown();
-        }
-    }
-
-    @Test
-    public void testRequestHttpException() throws Exception {
-        State state = new HttpAsyncServiceHandler.State();
-        HttpContext exchangeContext = state.getContext();
-        this.connContext.setAttribute(HttpAsyncServiceHandler.HTTP_EXCHANGE_STATE, state);
-
-        BasicHttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
-        Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
-        Mockito.when(this.requestHandler.processRequest(
-                request, exchangeContext)).thenThrow(new HttpException());
-
-        this.protocolHandler.requestReceived(this.conn);
-
-        HttpAsyncResponseProducer responseProducer = state.getResponseProducer();
-        Assert.assertNotNull(responseProducer);
-        HttpResponse response = state.getResponse();
-        Assert.assertNotNull(response);
-        Assert.assertEquals(500, response.getStatusLine().getStatusCode());
-
-        Mockito.verify(this.conn).submitResponse(response);
-    }
-
-    @Test
     public void testRequestExpectationFailed() throws Exception {
         State state = new HttpAsyncServiceHandler.State();
         state.setRequestState(MessageState.ACK_EXPECTED);
@@ -674,58 +636,6 @@ public class TestHttpAsyncServiceHandler
     }
 
     @Test
-    public void testRequestContentRuntimeException() throws Exception {
-        State state = new HttpAsyncServiceHandler.State();
-        HttpContext exchangeContext = state.getContext();
-        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
-                HttpVersion.HTTP_1_1);
-        state.setRequestState(MessageState.BODY_STREAM);
-        state.setRequest(request);
-        state.setRequestConsumer(this.requestConsumer);
-        this.connContext.setAttribute(HttpAsyncServiceHandler.HTTP_EXCHANGE_STATE, state);
-        Mockito.when(this.decoder.isCompleted()).thenReturn(true);
-        RuntimeException runtimeex = new RuntimeException();
-        Mockito.doThrow(runtimeex).when(
-                this.requestConsumer).requestCompleted(exchangeContext);
-        try {
-            this.protocolHandler.inputReady(this.conn, this.decoder);
-            Assert.fail("RuntimeException expected");
-        } catch (RuntimeException ex) {
-            Mockito.verify(this.conn).shutdown();
-            Mockito.verify(this.requestConsumer).close();
-        }
-    }
-
-    @Test
-    public void testRequestContentIOException() throws Exception {
-        State state = new HttpAsyncServiceHandler.State();
-        HttpContext exchangeContext = state.getContext();
-        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
-                HttpVersion.HTTP_1_1);
-        state.setRequestState(MessageState.BODY_STREAM);
-        state.setRequest(request);
-        state.setRequestConsumer(this.requestConsumer);
-        state.setRequestHandler(this.requestHandler);
-        this.connContext.setAttribute(HttpAsyncServiceHandler.HTTP_EXCHANGE_STATE, state);
-        Mockito.when(this.decoder.isCompleted()).thenReturn(true);
-        Mockito.when(this.requestConsumer.getException()).thenReturn(null);
-        Object data = new Object();
-        Mockito.when(this.requestConsumer.getResult()).thenReturn(data);
-        IOException ioex = new IOException();
-        Mockito.doThrow(ioex).when(
-                this.requestHandler).handle(
-                        Mockito.eq(data),
-                        Mockito.any(HttpAsyncServiceExchange.class),
-                        Mockito.eq(exchangeContext));
-
-        this.protocolHandler.inputReady(this.conn, this.decoder);
-
-        Mockito.verify(this.conn).shutdown();
-        Mockito.verify(this.requestConsumer).failed(ioex);
-        Mockito.verify(this.requestConsumer).close();
-    }
-
-    @Test
     public void testBasicResponse() throws Exception {
         State state = new HttpAsyncServiceHandler.State();
         HttpContext exchangeContext = state.getContext();
@@ -914,10 +824,9 @@ public class TestHttpAsyncServiceHandler
         Mockito.verify(this.responseProducer, Mockito.never()).responseCompleted(exchangeContext);
     }
 
-    @Test
+    @Test(expected=HttpException.class)
     public void testInvalidResponseStatus() throws Exception {
         State state = new HttpAsyncServiceHandler.State();
-        HttpContext exchangeContext = state.getContext();
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
                 HttpVersion.HTTP_1_1);
         state.setRequest(request);
@@ -931,25 +840,11 @@ public class TestHttpAsyncServiceHandler
         Mockito.when(this.conn.isResponseSubmitted()).thenReturn(false);
 
         this.protocolHandler.responseReady(this.conn);
-
-        Mockito.verify(this.conn).submitResponse(Mockito.argThat(new ArgumentMatcher<HttpResponse>() {
-
-            @Override
-            public boolean matches(final Object argument) {
-                int status = ((HttpResponse) argument).getStatusLine().getStatusCode();
-                return status == 500;
-            }
-
-        }));
-        Mockito.verify(this.responseProducer, Mockito.never()).responseCompleted(exchangeContext);
-        Mockito.verify(this.responseProducer).failed(Mockito.any(HttpException.class));
-        Mockito.verify(this.responseProducer).close();
     }
 
-    @Test
+    @Test(expected=HttpException.class)
     public void testInvalidResponseStatusToExpection() throws Exception {
         State state = new HttpAsyncServiceHandler.State();
-        HttpContext exchangeContext = state.getContext();
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
                 HttpVersion.HTTP_1_1);
         state.setRequest(request);
@@ -964,19 +859,6 @@ public class TestHttpAsyncServiceHandler
         Mockito.when(this.conn.isResponseSubmitted()).thenReturn(false);
 
         this.protocolHandler.responseReady(this.conn);
-
-        Mockito.verify(this.conn).submitResponse(Mockito.argThat(new ArgumentMatcher<HttpResponse>() {
-
-            @Override
-            public boolean matches(final Object argument) {
-                int status = ((HttpResponse) argument).getStatusLine().getStatusCode();
-                return status == 500;
-            }
-
-        }));
-        Mockito.verify(this.responseProducer, Mockito.never()).responseCompleted(exchangeContext);
-        Mockito.verify(this.responseProducer).failed(Mockito.any(HttpException.class));
-        Mockito.verify(this.responseProducer).close();
     }
 
     @Test
@@ -1021,59 +903,6 @@ public class TestHttpAsyncServiceHandler
     }
 
     @Test
-    public void testResponseRuntimeException() throws Exception {
-        State state = new HttpAsyncServiceHandler.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(HttpAsyncServiceHandler.HTTP_EXCHANGE_STATE, state);
-
-        BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 417, "Expectation failed");
-        response.setEntity(NStringEntity.create("stuff"));
-        Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
-
-        RuntimeException runtimeex = new RuntimeException();
-        Mockito.doThrow(runtimeex).when(
-                this.httpProcessor).process(response, exchangeContext);
-        try {
-            this.protocolHandler.responseReady(this.conn);
-            Assert.fail("RuntimeException expected");
-        } catch (RuntimeException ex) {
-            Mockito.verify(this.conn).shutdown();
-            Mockito.verify(this.responseProducer).close();
-
-        }
-    }
-
-    @Test
-    public void testResponseIOException() throws Exception {
-        State state = new HttpAsyncServiceHandler.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(HttpAsyncServiceHandler.HTTP_EXCHANGE_STATE, state);
-
-        BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 417, "Expectation failed");
-        response.setEntity(NStringEntity.create("stuff"));
-        Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
-        IOException ioex = new IOException();
-        Mockito.doThrow(ioex).when(
-                this.httpProcessor).process(response, exchangeContext);
-
-        this.protocolHandler.responseReady(this.conn);
-
-        Mockito.verify(this.conn).shutdown();
-        Mockito.verify(this.responseProducer).failed(ioex);
-        Mockito.verify(this.responseProducer).close();
-    }
-
-    @Test
     public void testResponseContent() throws Exception {
         State state = new HttpAsyncServiceHandler.State();
         BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
@@ -1146,51 +975,6 @@ public class TestHttpAsyncServiceHandler
     }
 
     @Test
-    public void testResponseContentRuntimeException() throws Exception {
-        State state = new HttpAsyncServiceHandler.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(HttpAsyncServiceHandler.HTTP_EXCHANGE_STATE, state);
-        Mockito.when(this.encoder.isCompleted()).thenReturn(false);
-
-        RuntimeException runtimeex = new RuntimeException();
-        Mockito.doThrow(runtimeex).when(
-                this.responseProducer).produceContent(this.encoder, this.conn);
-        try {
-            this.protocolHandler.outputReady(conn, this.encoder);
-            Assert.fail("RuntimeException expected");
-        } catch (RuntimeException ex) {
-            Mockito.verify(this.conn).shutdown();
-            Mockito.verify(this.responseProducer).close();
-        }
-    }
-
-    @Test
-    public void testResponseContentIOException() throws Exception {
-        State state = new HttpAsyncServiceHandler.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(HttpAsyncServiceHandler.HTTP_EXCHANGE_STATE, state);
-        Mockito.when(this.encoder.isCompleted()).thenReturn(false);
-
-        IOException ioex = new IOException();
-        Mockito.doThrow(ioex).when(
-                this.responseProducer).produceContent(this.encoder, this.conn);
-        this.protocolHandler.outputReady(conn, this.encoder);
-        Mockito.verify(this.conn).shutdown();
-        Mockito.verify(this.responseProducer).failed(ioex);
-        Mockito.verify(this.responseProducer).close();
-    }
-
-    @Test
     public void testTimeoutActiveConnection() throws Exception {
         State state = new HttpAsyncServiceHandler.State();
         this.connContext.setAttribute(HttpAsyncServiceHandler.HTTP_EXCHANGE_STATE, state);

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpClientNio.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpClientNio.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpClientNio.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpClientNio.java Thu Dec  1 17:20:25 2011
@@ -32,10 +32,11 @@ import java.net.InetSocketAddress;
 import java.util.List;
 
 import org.apache.http.impl.nio.DefaultClientIODispatch;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
 import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
 import org.apache.http.impl.nio.reactor.ExceptionEvent;
 import org.apache.http.nio.NHttpClientHandler;
-import org.apache.http.nio.NHttpClientIOTarget;
+import org.apache.http.nio.NHttpClientProtocolHandler;
 import org.apache.http.nio.NHttpConnectionFactory;
 import org.apache.http.nio.reactor.ConnectingIOReactor;
 import org.apache.http.nio.reactor.IOEventDispatch;
@@ -43,15 +44,16 @@ import org.apache.http.nio.reactor.IORea
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.SessionRequest;
 
+@SuppressWarnings("deprecation")
 public class HttpClientNio {
 
     private final DefaultConnectingIOReactor ioReactor;
-    private final NHttpConnectionFactory<NHttpClientIOTarget> connFactory;
+    private final NHttpConnectionFactory<DefaultNHttpClientConnection> connFactory;
 
     private volatile IOReactorThread thread;
 
     public HttpClientNio(
-            final NHttpConnectionFactory<NHttpClientIOTarget> connFactory) throws IOException {
+            final NHttpConnectionFactory<DefaultNHttpClientConnection> connFactory) throws IOException {
         super();
         this.ioReactor = new DefaultConnectingIOReactor();
         this.connFactory = connFactory;
@@ -61,7 +63,7 @@ public class HttpClientNio {
         this.ioReactor.setExceptionHandler(exceptionHandler);
     }
 
-    private void execute(final NHttpClientHandler clientHandler) throws IOException {
+    private void execute(final NHttpClientProtocolHandler clientHandler) throws IOException {
         IOEventDispatch ioEventDispatch = new DefaultClientIODispatch(clientHandler, this.connFactory);
         this.ioReactor.execute(ioEventDispatch);
     }
@@ -70,11 +72,16 @@ public class HttpClientNio {
         return this.ioReactor.connect(address, null, attachment, null);
     }
 
-    public void start(final NHttpClientHandler clientHandler) {
+    public void start(final NHttpClientProtocolHandler clientHandler) {
         this.thread = new IOReactorThread(clientHandler);
         this.thread.start();
     }
 
+    public void start(final NHttpClientHandler handler) {
+        this.thread = new IOReactorThread(new NHttpClientProtocolHandlerAdaptor(handler));
+        this.thread.start();
+    }
+
     public ConnectingIOReactor getIoReactor() {
         return this.ioReactor;
     }
@@ -111,11 +118,11 @@ public class HttpClientNio {
 
     private class IOReactorThread extends Thread {
 
-        private final NHttpClientHandler clientHandler;
+        private final NHttpClientProtocolHandler clientHandler;
 
         private volatile Exception ex;
 
-        public IOReactorThread(final NHttpClientHandler clientHandler) {
+        public IOReactorThread(final NHttpClientProtocolHandler clientHandler) {
             super();
             this.clientHandler = clientHandler;
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpServerNio.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpServerNio.java?rev=1209158&r1=1209157&r2=1209158&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpServerNio.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpServerNio.java Thu Dec  1 17:20:25 2011
@@ -31,11 +31,12 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.List;
 
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultServerIODispatch;
 import org.apache.http.impl.nio.reactor.DefaultListeningIOReactor;
 import org.apache.http.impl.nio.reactor.ExceptionEvent;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.NHttpServerIOTarget;
+import org.apache.http.nio.NHttpServerProtocolHandler;
 import org.apache.http.nio.NHttpServiceHandler;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.IOReactorExceptionHandler;
@@ -43,16 +44,17 @@ import org.apache.http.nio.reactor.IORea
 import org.apache.http.nio.reactor.ListenerEndpoint;
 import org.apache.http.nio.reactor.ListeningIOReactor;
 
+@SuppressWarnings("deprecation")
 public class HttpServerNio {
 
     private final DefaultListeningIOReactor ioReactor;
-    private final NHttpConnectionFactory<NHttpServerIOTarget> connFactory;
+    private final NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory;
 
     private volatile IOReactorThread thread;
     private ListenerEndpoint endpoint;
 
     public HttpServerNio(
-            final NHttpConnectionFactory<NHttpServerIOTarget> connFactory) throws IOException {
+            final NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory) throws IOException {
         super();
         this.ioReactor = new DefaultListeningIOReactor();
         this.connFactory = connFactory;
@@ -62,7 +64,7 @@ public class HttpServerNio {
         this.ioReactor.setExceptionHandler(exceptionHandler);
     }
 
-    private void execute(final NHttpServiceHandler serviceHandler) throws IOException {
+    private void execute(final NHttpServerProtocolHandler serviceHandler) throws IOException {
         IOEventDispatch ioEventDispatch = new DefaultServerIODispatch(serviceHandler, this.connFactory);
         this.ioReactor.execute(ioEventDispatch);
     }
@@ -75,12 +77,18 @@ public class HttpServerNio {
         this.endpoint = endpoint;
     }
 
-    public void start(final NHttpServiceHandler serviceHandler) {
+    public void start(final NHttpServerProtocolHandler serviceHandler) {
         this.endpoint = this.ioReactor.listen(new InetSocketAddress(0));
         this.thread = new IOReactorThread(serviceHandler);
         this.thread.start();
     }
 
+    public void start(final NHttpServiceHandler handler) {
+        this.endpoint = this.ioReactor.listen(new InetSocketAddress(0));
+        this.thread = new IOReactorThread(new NHttpServerProtocolHandlerAdaptor(handler));
+        this.thread.start();
+    }
+
     public ListeningIOReactor getIoReactor() {
         return this.ioReactor;
     }
@@ -117,11 +125,11 @@ public class HttpServerNio {
 
     private class IOReactorThread extends Thread {
 
-        private final NHttpServiceHandler serviceHandler;
+        private final NHttpServerProtocolHandler serviceHandler;
 
         private volatile Exception ex;
 
-        public IOReactorThread(final NHttpServiceHandler serviceHandler) {
+        public IOReactorThread(final NHttpServerProtocolHandler serviceHandler) {
             super();
             this.serviceHandler = serviceHandler;
         }

Added: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientProtocolHandlerAdaptor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientProtocolHandlerAdaptor.java?rev=1209158&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientProtocolHandlerAdaptor.java (added)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientProtocolHandlerAdaptor.java Thu Dec  1 17:20:25 2011
@@ -0,0 +1,97 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.testserver;
+
+import java.io.IOException;
+
+import org.apache.http.HttpException;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.NHttpClientConnection;
+import org.apache.http.nio.NHttpClientHandler;
+import org.apache.http.nio.NHttpClientProtocolHandler;
+
+@Deprecated
+class NHttpClientProtocolHandlerAdaptor implements NHttpClientProtocolHandler {
+
+    private final NHttpClientHandler handler;
+
+    public NHttpClientProtocolHandlerAdaptor(final NHttpClientHandler handler) {
+        super();
+        this.handler = handler;
+    }
+
+    public void connected(final NHttpClientConnection conn, final Object attachment) {
+        this.handler.connected(conn, attachment);
+    }
+
+    public void requestReady(
+            final NHttpClientConnection conn) throws IOException, HttpException {
+        this.handler.requestReady(conn);
+    }
+
+    public void responseReceived(
+            final NHttpClientConnection conn) throws IOException, HttpException {
+        this.handler.responseReceived(conn);
+    }
+
+    public void inputReady(
+            final NHttpClientConnection conn,
+            final ContentDecoder decoder) throws IOException, HttpException {
+        this.handler.inputReady(conn, decoder);
+    }
+
+    public void outputReady(
+            final NHttpClientConnection conn,
+            final ContentEncoder encoder) throws IOException, HttpException {
+        this.handler.outputReady(conn, encoder);
+    }
+
+    public void exception(final NHttpClientConnection conn, final Exception ex) {
+        if (ex instanceof HttpException) {
+            this.handler.exception(conn, (HttpException) ex);
+        } else if (ex instanceof IOException) {
+            this.handler.exception(conn, (IOException) ex);
+        } else {
+            if (ex instanceof RuntimeException) {
+                throw (RuntimeException) ex;
+            } else {
+                throw new Error("Unexpected exception: ", ex);
+            }
+        }
+    }
+
+    public void timeout(final NHttpClientConnection conn) {
+        this.handler.timeout(conn);
+    }
+
+    public void closed(final NHttpClientConnection conn) {
+        this.handler.closed(conn);
+    }
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientProtocolHandlerAdaptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientProtocolHandlerAdaptor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientProtocolHandlerAdaptor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message