hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1167328 - in /httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src: main/java/org/apache/http/impl/nio/client/ main/java/org/apache/http/nio/client/ main/java/org/apache/http/nio/client/methods/ test/jav...
Date Fri, 09 Sep 2011 18:55:59 GMT
Author: olegk
Date: Fri Sep  9 18:55:59 2011
New Revision: 1167328

URL: http://svn.apache.org/viewvc?rev=1167328&view=rev
Log:
Ported to the latest HttpCore API

Modified:
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ResultCallback.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncExchangeHandler.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncRequestProducer.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncResponseConsumer.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AbstractHttpAsyncResponseConsumer.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BasicHttpAsyncResponseConsumer.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncRequestProducerImpl.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java
    httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java Fri Sep  9 18:55:59 2011
@@ -79,11 +79,11 @@ import org.apache.http.impl.nio.conn.Poo
 import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
 import org.apache.http.impl.nio.reactor.IOReactorConfig;
 import org.apache.http.nio.client.HttpAsyncClient;
-import org.apache.http.nio.client.HttpAsyncExchangeHandler;
-import org.apache.http.nio.client.HttpAsyncRequestProducer;
-import org.apache.http.nio.client.HttpAsyncResponseConsumer;
 import org.apache.http.nio.client.methods.HttpAsyncMethods;
 import org.apache.http.nio.conn.ClientConnectionManager;
+import org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
+import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.IOReactorException;
 import org.apache.http.nio.reactor.IOReactorStatus;
@@ -99,7 +99,7 @@ public abstract class AbstractHttpAsyncC
 
     private final Log log = LogFactory.getLog(getClass());;
     private final ClientConnectionManager connmgr;
-    private final Queue<HttpAsyncExchangeHandler<?>> queue;
+    private final Queue<HttpAsyncClientExchangeHandler<?>> queue;
 
     private Thread reactorThread;
     private BasicHttpProcessor mutableProcessor;
@@ -121,7 +121,7 @@ public abstract class AbstractHttpAsyncC
     protected AbstractHttpAsyncClient(final ClientConnectionManager connmgr) {
         super();
         this.connmgr = connmgr;
-        this.queue = new ConcurrentLinkedQueue<HttpAsyncExchangeHandler<?>>();
+        this.queue = new ConcurrentLinkedQueue<HttpAsyncClientExchangeHandler<?>>();
     }
 
     protected AbstractHttpAsyncClient(final IOReactorConfig config) throws IOReactorException {
@@ -129,7 +129,7 @@ public abstract class AbstractHttpAsyncC
         DefaultConnectingIOReactor defaultioreactor = new DefaultConnectingIOReactor(config);
         defaultioreactor.setExceptionHandler(new InternalIOReactorExceptionHandler(this.log));
         this.connmgr = new PoolingClientConnectionManager(defaultioreactor);
-        this.queue = new ConcurrentLinkedQueue<HttpAsyncExchangeHandler<?>>();
+        this.queue = new ConcurrentLinkedQueue<HttpAsyncClientExchangeHandler<?>>();
     }
 
     protected abstract HttpParams createHttpParams();
@@ -444,8 +444,8 @@ public abstract class AbstractHttpAsyncC
         } finally {
             this.terminated = true;
             while (!this.queue.isEmpty()) {
-                HttpAsyncResponseConsumer<?> responseConsumer = this.queue.remove();
-                responseConsumer.cancel();
+                HttpAsyncClientExchangeHandler<?> exchangeHandler = this.queue.remove();
+                exchangeHandler.cancel();
             }
         }
     }

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java Fri Sep  9 18:55:59 2011
@@ -76,12 +76,12 @@ import org.apache.http.message.BasicHttp
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.IOControl;
-import org.apache.http.nio.client.HttpAsyncExchangeHandler;
-import org.apache.http.nio.client.HttpAsyncRequestProducer;
-import org.apache.http.nio.client.HttpAsyncResponseConsumer;
 import org.apache.http.nio.conn.ClientConnectionManager;
 import org.apache.http.nio.conn.ManagedClientConnection;
 import org.apache.http.nio.conn.scheme.Scheme;
+import org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
+import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
@@ -89,7 +89,7 @@ import org.apache.http.protocol.Executio
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpProcessor;
 
-class DefaultAsyncRequestDirector<T> implements HttpAsyncExchangeHandler<T> {
+class DefaultAsyncRequestDirector<T> implements HttpAsyncClientExchangeHandler<T> {
 
     public static final String HTTP_EXCHANGE_HANDLER = "http.nio.async-exchange-handler";
 
@@ -162,6 +162,10 @@ class DefaultAsyncRequestDirector<T> imp
         this.clientParams = clientParams;
     }
 
+    public synchronized void close() throws IOException {
+        releaseResources();
+    }
+
     public synchronized void start() {
         try {
             HttpHost target = this.requestProducer.getTarget();
@@ -262,6 +266,10 @@ class DefaultAsyncRequestDirector<T> imp
         }
     }
 
+    public void requestCompleted(final HttpContext context) {
+        this.requestProducer.requestCompleted(context);
+    }
+
     public boolean isRepeatable() {
         return this.requestProducer.isRepeatable();
     }
@@ -356,11 +364,7 @@ class DefaultAsyncRequestDirector<T> imp
         }
     }
 
-    public synchronized boolean keepAlive(final HttpResponse response) {
-        return this.reuseStrategy.keepAlive(response, this.localContext);
-    }
-
-    public synchronized void responseCompleted() {
+    public synchronized void responseCompleted(final HttpContext context) {
         this.log.debug("Response fully read");
         try {
             if (this.resultCallback.isDone()) {
@@ -387,7 +391,7 @@ class DefaultAsyncRequestDirector<T> imp
             }
 
             if (this.finalResponse != null) {
-                this.responseConsumer.responseCompleted();
+                this.responseConsumer.responseCompleted(this.localContext);
                 this.log.debug("Response processed");
                 T result = this.responseConsumer.getResult();
                 Exception ex = this.responseConsumer.getException();
@@ -832,4 +836,12 @@ class DefaultAsyncRequestDirector<T> imp
         }
     }
 
+    public HttpContext getContext() {
+        return this.localContext;
+    }
+
+    public ConnectionReuseStrategy getConnectionReuseStrategy() {
+        return this.reuseStrategy;
+    }
+
 }

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java Fri Sep  9 18:55:59 2011
@@ -29,31 +29,31 @@ package org.apache.http.impl.nio.client;
 import java.util.Queue;
 
 import org.apache.http.concurrent.BasicFuture;
-import org.apache.http.nio.client.HttpAsyncExchangeHandler;
+import org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler;
 
 class DefaultResultCallback<T> implements ResultCallback<T> {
 
     private final BasicFuture<T> future;
-    private final Queue<HttpAsyncExchangeHandler<?>> queue;
+    private final Queue<HttpAsyncClientExchangeHandler<?>> queue;
 
     DefaultResultCallback(
-            final BasicFuture<T> future, final Queue<HttpAsyncExchangeHandler<?>> queue) {
+            final BasicFuture<T> future, final Queue<HttpAsyncClientExchangeHandler<?>> queue) {
         super();
         this.future = future;
         this.queue = queue;
     }
 
-    public void completed(final T result, final HttpAsyncExchangeHandler<T> handler) {
+    public void completed(final T result, final HttpAsyncClientExchangeHandler<T> handler) {
         this.future.completed(result);
         this.queue.remove(handler);
     }
 
-    public void failed(final Exception ex, final HttpAsyncExchangeHandler<T> handler) {
+    public void failed(final Exception ex, final HttpAsyncClientExchangeHandler<T> handler) {
         this.future.failed(ex);
         this.queue.remove(handler);
     }
 
-    public void cancelled(final HttpAsyncExchangeHandler<T> handler) {
+    public void cancelled(final HttpAsyncClientExchangeHandler<T> handler) {
         this.future.cancel(true);
         this.queue.remove(handler);
     }

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java Fri Sep  9 18:55:59 2011
@@ -33,6 +33,7 @@ import java.net.SocketTimeoutException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
@@ -43,7 +44,7 @@ import org.apache.http.nio.ContentEncode
 import org.apache.http.nio.NHttpClientConnection;
 import org.apache.http.nio.NHttpClientHandler;
 import org.apache.http.nio.NHttpConnection;
-import org.apache.http.nio.client.HttpAsyncExchangeHandler;
+import org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler;
 import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.protocol.HttpContext;
 
@@ -97,8 +98,7 @@ class NHttpClientProtocolHandler impleme
     }
 
     public void closed(final NHttpClientConnection conn) {
-        HttpContext context = conn.getContext();
-        HttpAsyncExchangeHandler<?> handler = getHandler(context);
+        HttpAsyncClientExchangeHandler<?> handler = getHandler(conn);
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + ": Disconnected");
         }
@@ -108,8 +108,7 @@ class NHttpClientProtocolHandler impleme
     }
 
     public void exception(final NHttpClientConnection conn, final HttpException ex) {
-        HttpContext context = conn.getContext();
-        HttpAsyncExchangeHandler<?> handler = getHandler(context);
+        HttpAsyncClientExchangeHandler<?> handler = getHandler(conn);
         if (this.log.isErrorEnabled()) {
             this.log.error(conn + " HTTP protocol exception: " + ex.getMessage(), ex);
         }
@@ -120,8 +119,7 @@ class NHttpClientProtocolHandler impleme
     }
 
     public void exception(final NHttpClientConnection conn, final IOException ex) {
-        HttpContext context = conn.getContext();
-        HttpAsyncExchangeHandler<?> handler = getHandler(context);
+        HttpAsyncClientExchangeHandler<?> handler = getHandler(conn);
         if (this.log.isErrorEnabled()) {
             this.log.error(conn + " I/O error: " + ex.getMessage(), ex);
         }
@@ -132,9 +130,8 @@ class NHttpClientProtocolHandler impleme
     }
 
     public void requestReady(final NHttpClientConnection conn) {
-        HttpContext context = conn.getContext();
-        HttpExchange httpexchange = getHttpExchange(context);
-        HttpAsyncExchangeHandler<?> handler = getHandler(context);
+        HttpExchange httpexchange = getHttpExchange(conn);
+        HttpAsyncClientExchangeHandler<?> handler = getHandler(conn);
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Request ready");
         }
@@ -148,6 +145,7 @@ class NHttpClientProtocolHandler impleme
             return;
         }
         try {
+            HttpContext context = handler.getContext();
             HttpRequest request = handler.generateRequest();
             httpexchange.setRequest(request);
 
@@ -171,6 +169,7 @@ class NHttpClientProtocolHandler impleme
                 }
             } else {
                 httpexchange.setRequestState(MessageState.COMPLETED);
+                handler.requestCompleted(context);
             }
         } catch (IOException ex) {
             if (this.log.isDebugEnabled()) {
@@ -188,9 +187,8 @@ class NHttpClientProtocolHandler impleme
     }
 
     public void inputReady(final NHttpClientConnection conn, final ContentDecoder decoder) {
-        HttpContext context = conn.getContext();
-        HttpExchange httpexchange = getHttpExchange(context);
-        HttpAsyncExchangeHandler<?> handler = getHandler(context);
+        HttpExchange httpexchange = getHttpExchange(conn);
+        HttpAsyncClientExchangeHandler<?> handler = getHandler(conn);
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Input ready");
         }
@@ -212,13 +210,13 @@ class NHttpClientProtocolHandler impleme
     }
 
     public void outputReady(final NHttpClientConnection conn, final ContentEncoder encoder) {
-        HttpContext context = conn.getContext();
-        HttpExchange httpexchange = getHttpExchange(context);
-        HttpAsyncExchangeHandler<?> handler = getHandler(context);
+        HttpExchange httpexchange = getHttpExchange(conn);
+        HttpAsyncClientExchangeHandler<?> handler = getHandler(conn);
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Output ready");
         }
         try {
+            HttpContext context = handler.getContext();
             if (httpexchange.getRequestState() == MessageState.ACK) {
                 conn.suspendOutput();
                 return;
@@ -229,6 +227,7 @@ class NHttpClientProtocolHandler impleme
             }
             if (encoder.isCompleted()) {
                 httpexchange.setRequestState(MessageState.COMPLETED);
+                handler.requestCompleted(context);
             }
         } catch (IOException ex) {
             if (this.log.isDebugEnabled()) {
@@ -240,9 +239,8 @@ class NHttpClientProtocolHandler impleme
     }
 
     public void responseReceived(final NHttpClientConnection conn) {
-        HttpContext context = conn.getContext();
-        HttpExchange httpexchange = getHttpExchange(context);
-        HttpAsyncExchangeHandler<?> handler = getHandler(context);
+        HttpExchange httpexchange = getHttpExchange(conn);
+        HttpAsyncClientExchangeHandler<?> handler = getHandler(conn);
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Response received");
         }
@@ -301,9 +299,8 @@ class NHttpClientProtocolHandler impleme
     }
 
     public void timeout(final NHttpClientConnection conn) {
-        HttpContext context = conn.getContext();
-        HttpExchange httpexchange = getHttpExchange(context);
-        HttpAsyncExchangeHandler<?> handler = getHandler(context);
+        HttpExchange httpexchange = getHttpExchange(conn);
+        HttpAsyncClientExchangeHandler<?> handler = getHandler(conn);
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Timeout");
         }
@@ -335,22 +332,23 @@ class NHttpClientProtocolHandler impleme
         }
     }
 
-    private HttpExchange getHttpExchange(final HttpContext context) {
-        return (HttpExchange) context.getAttribute(HTTP_EXCHNAGE);
+    private HttpExchange getHttpExchange(final NHttpClientConnection conn) {
+        return (HttpExchange) conn.getContext().getAttribute(HTTP_EXCHNAGE);
     }
 
-    private HttpAsyncExchangeHandler<?> getHandler(final HttpContext context) {
-        return (HttpAsyncExchangeHandler<?>) context.getAttribute(
+    private HttpAsyncClientExchangeHandler<?> getHandler(final NHttpClientConnection conn) {
+        return (HttpAsyncClientExchangeHandler<?>) conn.getContext().getAttribute(
                 DefaultAsyncRequestDirector.HTTP_EXCHANGE_HANDLER);
     }
 
     private void processResponse(
             final NHttpClientConnection conn,
             final HttpExchange httpexchange,
-            final HttpAsyncExchangeHandler<?> handler) throws IOException {
+            final HttpAsyncClientExchangeHandler<?> handler) throws IOException {
         if (!httpexchange.isValid()) {
             conn.close();
         }
+        HttpContext context = handler.getContext();
         HttpRequest request = httpexchange.getRequest();
         HttpResponse response = httpexchange.getResponse();
 
@@ -360,7 +358,8 @@ class NHttpClientProtocolHandler impleme
             this.log.debug("CONNECT method succeeded");
             conn.resetInput();
         } else {
-            if (!handler.keepAlive(response)) {
+            ConnectionReuseStrategy reuseStrategy = handler.getConnectionReuseStrategy();
+            if (!reuseStrategy.keepAlive(response, context)) {
                 this.log.debug("Connection cannot be kept alive");
                 conn.close();
             }
@@ -368,7 +367,7 @@ class NHttpClientProtocolHandler impleme
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Response processed");
         }
-        handler.responseCompleted();
+        handler.responseCompleted(context);
         httpexchange.reset();
     }
 

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ResultCallback.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ResultCallback.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ResultCallback.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ResultCallback.java Fri Sep  9 18:55:59 2011
@@ -26,15 +26,15 @@
  */
 package org.apache.http.impl.nio.client;
 
-import org.apache.http.nio.client.HttpAsyncExchangeHandler;
+import org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler;
 
 interface ResultCallback<T> {
 
-    void completed(T result, HttpAsyncExchangeHandler<T> handler);
+    void completed(T result, HttpAsyncClientExchangeHandler<T> handler);
 
-    void failed(Exception ex, HttpAsyncExchangeHandler<T> handler);
+    void failed(Exception ex, HttpAsyncClientExchangeHandler<T> handler);
 
-    void cancelled(HttpAsyncExchangeHandler<T> handler);
+    void cancelled(HttpAsyncClientExchangeHandler<T> handler);
 
     boolean isDone();
 

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java Fri Sep  9 18:55:59 2011
@@ -34,6 +34,8 @@ import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.concurrent.FutureCallback;
 import org.apache.http.nio.conn.ClientConnectionManager;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
+import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpContext;

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java Fri Sep  9 18:55:59 2011
@@ -31,8 +31,9 @@ import java.nio.ByteBuffer;
 
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.IOControl;
+import org.apache.http.nio.protocol.AbstractAsyncResponseConsumer;
 
-public abstract class AsyncByteConsumer<T> extends AbstractHttpAsyncResponseConsumer<T> {
+public abstract class AsyncByteConsumer<T> extends AbstractAsyncResponseConsumer<T> {
 
     private final int bufSize;
     private ByteBuffer bbuf;
@@ -67,9 +68,8 @@ public abstract class AsyncByteConsumer<
     }
 
     @Override
-    void releaseResources() {
+    protected void releaseResources() {
         this.bbuf = null;
-        super.releaseResources();
     }
 
 }

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java Fri Sep  9 18:55:59 2011
@@ -41,9 +41,10 @@ import org.apache.http.HttpResponse;
 import org.apache.http.entity.ContentType;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.IOControl;
+import org.apache.http.nio.protocol.AbstractAsyncResponseConsumer;
 import org.apache.http.protocol.HTTP;
 
-public abstract class AsyncCharConsumer<T> extends AbstractHttpAsyncResponseConsumer<T> {
+public abstract class AsyncCharConsumer<T> extends AbstractAsyncResponseConsumer<T> {
 
     private final int bufSize;
     private ContentType contentType;
@@ -119,12 +120,11 @@ public abstract class AsyncCharConsumer<
     }
 
     @Override
-    void releaseResources() {
+    protected void releaseResources() {
         this.charset = null;
         this.chardecoder = null;
         this.bbuf = null;
         this.cbuf = null;
-        super.releaseResources();
     }
 
 }

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncEntityRequestProducer.java Fri Sep  9 18:55:59 2011
@@ -26,7 +26,6 @@
  */
 package org.apache.http.nio.client.methods;
 
-import java.io.Closeable;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
@@ -39,14 +38,15 @@ import org.apache.http.HttpRequest;
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.IOControl;
-import org.apache.http.nio.client.HttpAsyncRequestProducer;
 import org.apache.http.nio.entity.NByteArrayEntity;
 import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.nio.entity.ProducingNHttpEntity;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
 
 @Deprecated
-abstract class BaseHttpAsyncEntityRequestProducer implements HttpAsyncRequestProducer, Closeable {
+abstract class BaseHttpAsyncEntityRequestProducer implements HttpAsyncRequestProducer {
 
     private final URI requestURI;
     private final ProducingNHttpEntity producer;
@@ -103,6 +103,9 @@ abstract class BaseHttpAsyncEntityReques
         }
     }
 
+    public void requestCompleted(final HttpContext context) {
+    }
+
     public synchronized boolean isRepeatable() {
         return this.producer.isRepeatable();
     }

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseHttpAsyncRequestProducer.java Fri Sep  9 18:55:59 2011
@@ -35,7 +35,8 @@ import org.apache.http.HttpRequest;
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.IOControl;
-import org.apache.http.nio.client.HttpAsyncRequestProducer;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
+import org.apache.http.protocol.HttpContext;
 
 @Deprecated
 abstract class BaseHttpAsyncRequestProducer implements HttpAsyncRequestProducer {
@@ -64,6 +65,9 @@ abstract class BaseHttpAsyncRequestProdu
             final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
     }
 
+    public void requestCompleted(final HttpContext context) {
+    }
+
     public boolean isRepeatable() {
         return true;
     }
@@ -71,4 +75,7 @@ abstract class BaseHttpAsyncRequestProdu
     public void resetRequest() {
     }
 
+    public void close() throws IOException {
+    }
+
 }

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java Fri Sep  9 18:55:59 2011
@@ -26,7 +26,6 @@
  */
 package org.apache.http.nio.client.methods;
 
-import java.io.Closeable;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -45,9 +44,10 @@ import org.apache.http.nio.ContentEncode
 import org.apache.http.nio.ContentEncoderChannel;
 import org.apache.http.nio.FileContentEncoder;
 import org.apache.http.nio.IOControl;
-import org.apache.http.nio.client.HttpAsyncRequestProducer;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
+import org.apache.http.protocol.HttpContext;
 
-abstract class BaseZeroCopyRequestProducer implements HttpAsyncRequestProducer, Closeable {
+abstract class BaseZeroCopyRequestProducer implements HttpAsyncRequestProducer {
 
     private final URI requestURI;
     private final File file;
@@ -112,6 +112,9 @@ abstract class BaseZeroCopyRequestProduc
         }
     }
 
+    public void requestCompleted(final HttpContext context) {
+    }
+
     public synchronized boolean isRepeatable() {
         return true;
     }

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java Fri Sep  9 18:55:59 2011
@@ -30,6 +30,7 @@ import java.io.File;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
 
+import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
@@ -42,10 +43,13 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.entity.ContentType;
-import org.apache.http.nio.client.HttpAsyncRequestProducer;
-import org.apache.http.nio.client.HttpAsyncResponseConsumer;
 import org.apache.http.nio.entity.NByteArrayEntity;
 import org.apache.http.nio.entity.NStringEntity;
+import org.apache.http.nio.entity.ProducingNHttpEntity;
+import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
+import org.apache.http.nio.protocol.BasicAsyncResponseConsumer;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
+import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
 
 public final class HttpAsyncMethods {
 
@@ -56,7 +60,7 @@ public final class HttpAsyncMethods {
         if (request == null) {
             throw new IllegalArgumentException("HTTP request may not be null");
         }
-        return new HttpAsyncRequestProducerImpl(target, request);
+        return new RequestProducerImpl(target, request);
     }
 
     public static HttpAsyncRequestProducer create(final HttpUriRequest request) {
@@ -64,7 +68,7 @@ public final class HttpAsyncMethods {
             throw new IllegalArgumentException("HTTP request may not be null");
         }
         HttpHost target = URIUtils.extractHost(request.getURI());
-        return new HttpAsyncRequestProducerImpl(target, request);
+        return new RequestProducerImpl(target, request);
     }
 
     public static HttpAsyncRequestProducer createGet(final URI requestURI) {
@@ -115,7 +119,7 @@ public final class HttpAsyncMethods {
         NStringEntity entity = new NStringEntity(content, contentType);
         httppost.setEntity(entity);
         HttpHost target = URIUtils.extractHost(requestURI);
-        return new HttpAsyncRequestProducerImpl(target, httppost, entity);
+        return new RequestProducerImpl(target, httppost, entity);
     }
 
     public static HttpAsyncRequestProducer createPost(
@@ -132,7 +136,7 @@ public final class HttpAsyncMethods {
         HttpPost httppost = new HttpPost(requestURI);
         NByteArrayEntity entity = new NByteArrayEntity(content, contentType);
         HttpHost target = URIUtils.extractHost(requestURI);
-        return new HttpAsyncRequestProducerImpl(target, httppost, entity);
+        return new RequestProducerImpl(target, httppost, entity);
     }
 
     public static HttpAsyncRequestProducer createPost(
@@ -150,7 +154,7 @@ public final class HttpAsyncMethods {
         NStringEntity entity = new NStringEntity(content, contentType);
         httpput.setEntity(entity);
         HttpHost target = URIUtils.extractHost(requestURI);
-        return new HttpAsyncRequestProducerImpl(target, httpput, entity);
+        return new RequestProducerImpl(target, httpput, entity);
     }
 
     public static HttpAsyncRequestProducer createPut(
@@ -167,7 +171,7 @@ public final class HttpAsyncMethods {
         HttpPut httpput = new HttpPut(requestURI);
         NByteArrayEntity entity = new NByteArrayEntity(content, contentType);
         HttpHost target = URIUtils.extractHost(requestURI);
-        return new HttpAsyncRequestProducerImpl(target, httpput, entity);
+        return new RequestProducerImpl(target, httpput, entity);
     }
 
     public static HttpAsyncRequestProducer createPut(
@@ -206,7 +210,7 @@ public final class HttpAsyncMethods {
     }
 
     public static HttpAsyncResponseConsumer<HttpResponse> createConsumer() {
-        return new BasicHttpAsyncResponseConsumer();
+        return new BasicAsyncResponseConsumer();
     }
 
     public static HttpAsyncResponseConsumer<HttpResponse> createZeroCopyConsumer(final File file) {
@@ -220,4 +224,19 @@ public final class HttpAsyncMethods {
         };
     }
 
+    static class RequestProducerImpl extends BasicAsyncRequestProducer {
+
+        protected RequestProducerImpl(
+                final HttpHost target,
+                final HttpEntityEnclosingRequest request,
+                final ProducingNHttpEntity producer) {
+            super(target, request, producer);
+        }
+
+        public RequestProducerImpl(final HttpHost target, final HttpRequest request) {
+            super(target, request);
+        }
+
+    }
+
 }

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java Fri Sep  9 18:55:59 2011
@@ -37,9 +37,10 @@ import org.apache.http.nio.ContentDecode
 import org.apache.http.nio.ContentDecoderChannel;
 import org.apache.http.nio.FileContentDecoder;
 import org.apache.http.nio.IOControl;
+import org.apache.http.nio.protocol.AbstractAsyncResponseConsumer;
 import org.apache.http.protocol.HTTP;
 
-public abstract class ZeroCopyConsumer<T> extends AbstractHttpAsyncResponseConsumer<T> {
+public abstract class ZeroCopyConsumer<T> extends AbstractAsyncResponseConsumer<T> {
 
     private final File file;
 
@@ -96,7 +97,7 @@ public abstract class ZeroCopyConsumer<T
     }
 
     @Override
-    protected void onCleanup() {
+    protected void releaseResources() {
         if (this.fileChannel != null) {
             try {
                 this.fileChannel.close();

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java Fri Sep  9 18:55:59 2011
@@ -40,10 +40,10 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.localserver.AsyncHttpTestBase;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.IOControl;
-import org.apache.http.nio.client.HttpAsyncRequestProducer;
-import org.apache.http.nio.client.methods.BasicHttpAsyncResponseConsumer;
 import org.apache.http.nio.client.methods.HttpAsyncMethods;
 import org.apache.http.nio.entity.NByteArrayEntity;
+import org.apache.http.nio.protocol.BasicAsyncResponseConsumer;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
 import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
 import org.junit.Test;
@@ -144,7 +144,7 @@ public class TestHttpAsync extends Async
     public void testRequestFailure() throws Exception {
         HttpGet httpget = new HttpGet("/random/2048");
         HttpAsyncRequestProducer requestProducer = HttpAsyncMethods.create(this.target, httpget) ;
-        BasicHttpAsyncResponseConsumer responseConsumer = new BasicHttpAsyncResponseConsumer() {
+        BasicAsyncResponseConsumer responseConsumer = new BasicAsyncResponseConsumer() {
 
             @Override
             public void consumeContent(final ContentDecoder decoder, final IOControl ioctrl)

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java Fri Sep  9 18:55:59 2011
@@ -52,13 +52,13 @@ import org.apache.http.localserver.Async
 import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.IOControl;
-import org.apache.http.nio.client.HttpAsyncRequestProducer;
-import org.apache.http.nio.client.methods.BasicHttpAsyncResponseConsumer;
 import org.apache.http.nio.client.methods.HttpAsyncMethods;
 import org.apache.http.nio.conn.scheme.Scheme;
 import org.apache.http.nio.conn.scheme.SchemeRegistry;
 import org.apache.http.nio.conn.ssl.SSLLayeringStrategy;
 import org.apache.http.nio.entity.NByteArrayEntity;
+import org.apache.http.nio.protocol.BasicAsyncResponseConsumer;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
 import org.apache.http.nio.reactor.ConnectingIOReactor;
 import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
@@ -231,7 +231,7 @@ public class TestHttpsAsync extends Asyn
     public void testRequestFailure() throws Exception {
         HttpGet httpget = new HttpGet("/random/2048");
         HttpAsyncRequestProducer requestProducer = HttpAsyncMethods.create(this.target, httpget) ;
-        BasicHttpAsyncResponseConsumer responseConsumer = new BasicHttpAsyncResponseConsumer() {
+        BasicAsyncResponseConsumer responseConsumer = new BasicAsyncResponseConsumer() {
 
             @Override
             public void consumeContent(final ContentDecoder decoder, final IOControl ioctrl)

Modified: httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java?rev=1167328&r1=1167327&r2=1167328&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java (original)
+++ httpcomponents/httpasyncclient/branches/protocol-handler-refactoring/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java Fri Sep  9 18:55:59 2011
@@ -39,8 +39,9 @@ import org.apache.http.entity.ContentTyp
 import org.apache.http.localserver.AsyncHttpTestBase;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.IOControl;
-import org.apache.http.nio.client.HttpAsyncRequestProducer;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -69,10 +70,6 @@ public class TestAsyncConsumers extends 
         }
 
         @Override
-        protected void onCleanup() {
-        }
-
-        @Override
         protected Long buildResult() throws Exception {
             return count.get();
         }
@@ -125,7 +122,8 @@ public class TestAsyncConsumers extends 
         }
 
         @Override
-        protected void onCleanup() {
+        protected void releaseResources() {
+            super.releaseResources();
             this.sb.setLength(0);
         }
 
@@ -188,14 +186,13 @@ public class TestAsyncConsumers extends 
         HttpAsyncRequestProducer httppost = HttpAsyncMethods.createPost(
                 this.target.toURI() + "/echo/stuff", s,
                 ContentType.create("text/plain", HTTP.ASCII));
-        AsyncCharConsumer<String> consumer = Mockito.spy(new BufferingCharConsumer());
+        BufferingCharConsumer consumer = Mockito.spy(new BufferingCharConsumer());
         Future<String> future = this.httpclient.execute(httppost, consumer, null);
         String result = future.get();
         Assert.assertEquals(s, result);
-        Mockito.verify(consumer).responseCompleted();
+        Mockito.verify(consumer).responseCompleted(Mockito.any(HttpContext.class));
         Mockito.verify(consumer).buildResult();
         Mockito.verify(consumer).releaseResources();
-        Mockito.verify(consumer).onCleanup();
     }
 
     @Test
@@ -219,7 +216,6 @@ public class TestAsyncConsumers extends 
         }
         Mockito.verify(consumer).failed(Mockito.any(IOException.class));
         Mockito.verify(consumer).releaseResources();
-        Mockito.verify(consumer).onCleanup();
     }
 
     @Test
@@ -227,7 +223,7 @@ public class TestAsyncConsumers extends 
         HttpAsyncRequestProducer httppost = HttpAsyncMethods.createPost(
                 this.target.toURI() + "/echo/stuff", "stuff",
                 ContentType.create("text/plain", HTTP.ASCII));
-        AsyncCharConsumer<String> consumer = Mockito.spy(new BufferingCharConsumer());
+        BufferingCharConsumer consumer = Mockito.spy(new BufferingCharConsumer());
         Mockito.doThrow(new HttpException("Kaboom")).when(consumer).buildResult();
 
         Future<String> future = this.httpclient.execute(httppost, consumer, null);
@@ -240,9 +236,8 @@ public class TestAsyncConsumers extends 
             Assert.assertTrue(t instanceof HttpException);
             Assert.assertEquals("Kaboom", t.getMessage());
         }
-        Mockito.verify(consumer).responseCompleted();
+        Mockito.verify(consumer).responseCompleted(Mockito.any(HttpContext.class));
         Mockito.verify(consumer).releaseResources();
-        Mockito.verify(consumer).onCleanup();
     }
 
 }



Mime
View raw message