geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r617593 [2/2] - in /geronimo/sandbox/async-http-client-mina2: ./ src/main/java/org/apache/ahc/ src/main/java/org/apache/ahc/auth/ src/main/java/org/apache/ahc/codec/ src/main/java/org/apache/ahc/proxy/ src/main/java/org/apache/ahc/util/ src...
Date Fri, 01 Feb 2008 18:26:44 GMT
Modified: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AsyncHttpClientTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AsyncHttpClientTest.java?rev=617593&r1=617592&r2=617593&view=diff
==============================================================================
--- geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AsyncHttpClientTest.java
(original)
+++ geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AsyncHttpClientTest.java
Fri Feb  1 10:26:11 2008
@@ -36,7 +36,7 @@
         doGetConnection(callback, "http://localhost:8282/", false, true);
 
         HttpResponseMessage msg = callback.getMessage();
-        assertEquals("\nHello World!", msg.getStringContent());
+        assertEquals("Hello World!", msg.getStringContent());
     }
 
     public void testSSLHtmlConnection() throws Exception {
@@ -44,7 +44,7 @@
         doGetConnection(callback, "https://localhost:8383/", false, true);
 
         HttpResponseMessage msg = callback.getMessage();
-        assertEquals("\nHello World!", msg.getStringContent());
+        assertEquals("Hello World!", msg.getStringContent());
     }
 
     public void testRedirect() throws Exception {
@@ -54,7 +54,7 @@
         doGetConnection(callback, "http://localhost:8282/redirect.jsp", false, true);
 
         HttpResponseMessage msg = callback.getMessage();
-        assertEquals("\nHello World!", msg.getStringContent());
+        assertEquals("Hello World!", msg.getStringContent());
 
         //Test that we are not following redirects
         callback = new TestCallback();

Modified: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AsyncHttpClientWithFutureTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AsyncHttpClientWithFutureTest.java?rev=617593&r1=617592&r2=617593&view=diff
==============================================================================
--- geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AsyncHttpClientWithFutureTest.java
(original)
+++ geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AsyncHttpClientWithFutureTest.java
Fri Feb  1 10:26:11 2008
@@ -33,14 +33,14 @@
         Future<HttpResponseMessage> future = submitGetRequest("http://localhost:8282/",
true, null);
 
         HttpResponseMessage msg = future.get();
-        assertEquals("\nHello World!", msg.getStringContent());
+        assertEquals("Hello World!", msg.getStringContent());
     }
 
     public void testSSLHtmlRequest() throws Exception {
         Future<HttpResponseMessage> future = submitGetRequest("https://localhost:8383/",
true, null);
 
         HttpResponseMessage msg = future.get();
-        assertEquals("\nHello World!", msg.getStringContent());
+        assertEquals("Hello World!", msg.getStringContent());
     }
     
     public void testMultipleRequests() throws Exception {
@@ -58,7 +58,7 @@
     		String content = future.get().getStringContent();
     		String url = future.getRequest().getUrl().toString();
     		if (url.equals("http://localhost:8282/")) {
-    			assertEquals("\nHello World!", content);
+    			assertEquals("Hello World!", content);
     		} else {
     			assertEquals("Test One Test Two", content);
     		}
@@ -72,7 +72,7 @@
         Future<HttpResponseMessage> future = submitGetRequest("http://localhost:8282/redirect.jsp",
true, null);
 
         HttpResponseMessage msg = future.get();
-        assertEquals("\nHello World!", msg.getStringContent());
+        assertEquals("Hello World!", msg.getStringContent());
 
         //Test that we are not following redirects
         future = submitGetRequest("http://localhost:8282/redirect.jsp", false, null);

Modified: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AuthTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AuthTest.java?rev=617593&r1=617592&r2=617593&view=diff
==============================================================================
--- geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AuthTest.java (original)
+++ geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/AuthTest.java Fri
Feb  1 10:26:11 2008
@@ -42,7 +42,7 @@
         callback.await(5, TimeUnit.SECONDS);
 
         assertEquals(200, callback.getMessage().getStatusCode());
-        assertEquals("Hello World!\n", callback.getMessage().getStringContent());
+        assertTrue(callback.getMessage().getStringContent().startsWith("Hello World!"));
     }
 
     public void testBasicAuthFailure() throws Exception {
@@ -73,7 +73,7 @@
         callback.await(5, TimeUnit.SECONDS);
 
         assertEquals(200, callback.getMessage().getStatusCode());
-        assertEquals("Hello World!\n", callback.getMessage().getStringContent());
+        assertTrue(callback.getMessage().getStringContent().startsWith("Hello World!"));
     }
 
     protected void setUp() throws Exception {

Modified: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ConnectionReuseTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ConnectionReuseTest.java?rev=617593&r1=617592&r2=617593&view=diff
==============================================================================
--- geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ConnectionReuseTest.java
(original)
+++ geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ConnectionReuseTest.java
Fri Feb  1 10:26:11 2008
@@ -25,11 +25,14 @@
 
 import org.apache.ahc.codec.HttpRequestMessage;
 import org.apache.ahc.codec.HttpResponseMessage;
+import org.apache.ahc.codec.SessionCache;        
 
 public class ConnectionReuseTest extends AbstractTest {
     // variable that keeps count of session close's
     private final AtomicInteger closeCount = new AtomicInteger(0);
     
+    private final SessionCache cache = new SessionCache(); 
+    
     // It is important that this test case contains these methods in this order.
     // It is because to test connection reuse we need to keep the embedded 
     // server running while connections are reused.  However, AbstractTest 
@@ -41,7 +44,7 @@
                 submitRequest("http://localhost:8282/", true, new SessionCloseCounter());
 
         HttpResponseMessage msg = future.get();
-        assertEquals("\nHello World!", msg.getStringContent());
+        assertEquals("Hello World!", msg.getStringContent());
         
         // do another request for the same host
         future = submitRequest("http://localhost:8282/params.jsp", true, 
@@ -62,13 +65,13 @@
                 submitRequest("https://localhost:8383/", true, new SessionCloseCounter());
 
         HttpResponseMessage msg = future.get();
-        assertEquals("\nHello World!", msg.getStringContent());
+        assertEquals("Hello World!", msg.getStringContent());
         
         // do another request for the same host
         future = submitRequest("https://localhost:8383/", true, new SessionCloseCounter());
 
         msg = future.get();
-        assertEquals("\nHello World!", msg.getStringContent());
+        assertEquals("Hello World!", msg.getStringContent());
         
         // check that I got zero close at this point
         assertEquals(0, closeCount.get());
@@ -82,7 +85,7 @@
                 submitRequest("http://localhost:8282/", false, new SessionCloseCounter());
 
         HttpResponseMessage msg = future.get();
-        assertEquals("\nHello World!", msg.getStringContent());
+        assertEquals("Hello World!", msg.getStringContent());
         
         // do another request for the same host
         future = submitRequest("http://localhost:8282/params.jsp", false, 
@@ -107,7 +110,9 @@
         request.setParameter("TEST1", "Test One");
         request.setParameter("TEST2", "Test Two");
         AsyncHttpClient ahc = new AsyncHttpClient();
-        ahc.setReuseConnection(reuseConnection);
+        if (reuseConnection) {
+            ahc.setSessionCache(cache);  
+        }
         ahc.setTcpNoDelay(true);
         return ahc.sendRequest(request);
     }

Added: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/MonitoringTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/MonitoringTest.java?rev=617593&view=auto
==============================================================================
--- geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/MonitoringTest.java
(added)
+++ geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/MonitoringTest.java
Fri Feb  1 10:26:11 2008
@@ -0,0 +1,183 @@
+/*
+ *  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.
+ *
+ */
+package org.apache.ahc;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.ahc.codec.HttpRequestMessage;
+import org.apache.ahc.codec.HttpResponseMessage;
+import org.apache.ahc.util.CountingMonitor;
+import org.apache.ahc.util.MonitoringEvent;
+import org.apache.ahc.util.MonitoringListener; 
+
+public class MonitoringTest extends AbstractTest {
+
+    public void testHtmlConnection() throws Exception {
+        TestCallback callback = new TestCallback();
+        CountingMonitor counter = new CountingMonitor(); 
+        doGetConnection(callback, "http://localhost:8282/", false, true, counter);
+
+        HttpResponseMessage msg = callback.getMessage();
+        assertEquals("Hello World!", msg.getStringContent());
+        
+        // the monitor events are dispatched asynchronously, so give a little time 
+        // for them all to be dispatched. 
+        Thread.sleep(500); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_STARTED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_COMPLETED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_FAILED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_TIMEOUT), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_ATTEMPTED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_RETRIED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_REUSED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_SUCCESSFUL), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_REDIRECTED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_CHALLENGED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_CLOSED_BY_SERVER), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_CLOSED), 0); 
+    }
+
+    public void testSSLHtmlConnection() throws Exception {
+        TestCallback callback = new TestCallback();
+        CountingMonitor counter = new CountingMonitor(); 
+        doGetConnection(callback, "https://localhost:8383/", false, true, counter);
+
+        HttpResponseMessage msg = callback.getMessage();
+        assertEquals("Hello World!", msg.getStringContent());
+        // the monitor events are dispatched asynchronously, so give a little time 
+        // for them all to be dispatched. 
+        Thread.sleep(500); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_STARTED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_COMPLETED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_FAILED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_TIMEOUT), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_ATTEMPTED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_RETRIED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_REUSED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_SUCCESSFUL), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_REDIRECTED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_CHALLENGED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_CLOSED_BY_SERVER), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_CLOSED), 0); 
+    }
+
+    public void testRedirect() throws Exception {
+        TestCallback callback = new TestCallback();
+
+        CountingMonitor counter = new CountingMonitor(); 
+        //Test that we are following redirects
+        doGetConnection(callback, "http://localhost:8282/redirect.jsp", false, true, counter);
+
+        HttpResponseMessage msg = callback.getMessage();
+        assertEquals("Hello World!", msg.getStringContent());
+        // the monitor events are dispatched asynchronously, so give a little time 
+        // for them all to be dispatched. 
+        Thread.sleep(500); 
+        
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_STARTED), 2); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_COMPLETED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_FAILED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_TIMEOUT), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_ATTEMPTED), 2); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_RETRIED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_REUSED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_SUCCESSFUL), 2); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_REDIRECTED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_CHALLENGED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_CLOSED_BY_SERVER), 2); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_CLOSED), 0); 
+        
+        counter.clearCounters(); 
+
+        //Test that we are not following redirects
+        callback = new TestCallback();
+        doGetConnection(callback, "http://localhost:8282/redirect.jsp", false, false, counter);
+
+        msg = callback.getMessage();
+        assertEquals(302, msg.getStatusCode());
+        assertEquals(msg.getLocation(), "http://localhost:8282/index.jsp"); 
+        // the monitor events are dispatched asynchronously, so give a little time 
+        // for them all to be dispatched. 
+        Thread.sleep(500); 
+        
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_STARTED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_COMPLETED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_FAILED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_TIMEOUT), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_ATTEMPTED), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_RETRIED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_REUSED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_SUCCESSFUL), 1); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_REDIRECTED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.REQUEST_CHALLENGED), 0); 
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_CLOSED_BY_SERVER), 1); 
+            
+        assertEquals(counter.getCount(MonitoringEvent.CONNECTION_CLOSED), 0); 
+    }
+
+    private void doGetConnection(TestCallback callback, String url,
+                                 boolean testForException, boolean followRedirects, 
+                                 MonitoringListener listener)  
+        throws Exception {
+        HttpRequestMessage request = new HttpRequestMessage(new URL(url), callback);
+        request.setFollowRedirects(followRedirects);
+
+        request.setParameter("TEST1", "Test One");
+        request.setParameter("TEST2", "Test Two");
+        doConnection(request, false, callback, listener);
+    }
+
+    private void doPostConnection(TestCallback callback, String url, 
+                                  boolean testForException, MonitoringListener listener)
+        throws Exception {
+        HttpRequestMessage request = new HttpRequestMessage(new URL(url), callback);
+        request.setParameter("TEST1", "Test One");
+        request.setParameter("TEST2", "Test Two");
+        request.setRequestMethod(HttpRequestMessage.REQUEST_POST);
+        doConnection(request, false, callback, listener);
+    }
+
+    private void doConnection(HttpRequestMessage request, boolean testForException, 
+                              TestCallback callback, MonitoringListener listener) throws
Exception {
+        AsyncHttpClient ahc = new AsyncHttpClient();
+        ahc.addMonitoringListener(listener); 
+        ahc.setTcpNoDelay(true);
+
+        ahc.sendRequest(request);
+
+        //We are done...Thread would normally end...
+        //So this little wait simulates the thread going back in the pool
+        //5 second timeout due to no response
+        callback.await(5, TimeUnit.SECONDS);
+
+        if (!testForException) {
+            if (((TestCallback)request.getCallback()).isException()) {
+                throw new Exception(((TestCallback)request.getCallback()).getThrowable());
+            }
+        }
+
+    }
+
+}
+

Propchange: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/MonitoringTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/MonitoringTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/MonitoringTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ProxyTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ProxyTest.java?rev=617593&view=auto
==============================================================================
--- geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ProxyTest.java (added)
+++ geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ProxyTest.java Fri
Feb  1 10:26:11 2008
@@ -0,0 +1,117 @@
+package org.apache.ahc;
+
+import java.net.URL;
+import java.util.concurrent.Future;
+
+import org.apache.ahc.codec.HttpRequestMessage;
+import org.apache.ahc.codec.HttpResponseMessage;
+import org.apache.ahc.proxy.ProxyConfiguration;
+
+public class ProxyTest extends AbstractTest {
+    public void testHttpProxy() throws Exception {
+        AsyncHttpClient ahc = new AsyncHttpClient();
+        
+        HttpRequestMessage request = 
+                new HttpRequestMessage(new URL("http://localhost:8282/"), null);
+        ProxyConfiguration config = new ProxyConfiguration("localhost", 8888);
+        request.setProxyConfiguration(config);
+        
+        Future<HttpResponseMessage> future = ahc.sendRequest(request);
+        
+        HttpResponseMessage response = future.get();
+        assertEquals("Hello World!", response.getStringContent());
+    }
+    
+    
+    public void testHttpProxyIP() throws Exception {
+        AsyncHttpClient ahc = new AsyncHttpClient();
+        
+        HttpRequestMessage request = 
+                new HttpRequestMessage(new URL("http://127.0.0.1:8282/"), null);
+        ProxyConfiguration config = new ProxyConfiguration("localhost", 8888);
+        request.setProxyConfiguration(config);
+        
+        Future<HttpResponseMessage> future = ahc.sendRequest(request);
+        
+        HttpResponseMessage response = future.get();
+        assertEquals("Hello World!", response.getStringContent());
+    }
+    
+    public void testHttpsProxySame() throws Exception {
+        AsyncHttpClient ahc = new AsyncHttpClient();
+        
+        HttpRequestMessage request = 
+                new HttpRequestMessage(new URL("https://localhost:8383/"), null);
+        ProxyConfiguration config = new ProxyConfiguration("localhost", 8888);
+        request.setProxyConfiguration(config);
+        
+        Future<HttpResponseMessage> future = ahc.sendRequest(request);
+        
+        HttpResponseMessage response = future.get();
+        assertEquals("Hello World!", response.getStringContent());
+    }
+    
+    
+    public void testHttpsProxyDifferent() throws Exception {
+        AsyncHttpClient ahc = new AsyncHttpClient();
+        
+        HttpRequestMessage request = 
+                new HttpRequestMessage(new URL("https://localhost:8383/"), null);
+        ProxyConfiguration config = new ProxyConfiguration("people.apache.org", 8889, "localhost",
8888);
+        request.setProxyConfiguration(config);
+        
+        Future<HttpResponseMessage> future = ahc.sendRequest(request);
+        
+        HttpResponseMessage response = future.get();
+        assertEquals("Hello World!", response.getStringContent());
+    }
+    
+    public void testHttpExclusion() throws Exception {
+        AsyncHttpClient ahc = new AsyncHttpClient();
+        
+        HttpRequestMessage request = 
+                new HttpRequestMessage(new URL("http://localhost:8282/"), null);
+        // NOTE:  The proxy server config is invalid, so this will fail if the 
+        // exclusion doesn't work. 
+        ProxyConfiguration config = new ProxyConfiguration("localhost", 8889);
+        config.setExclusionList("localhost");
+        request.setProxyConfiguration(config);
+        
+        Future<HttpResponseMessage> future = ahc.sendRequest(request);
+        
+        HttpResponseMessage response = future.get();
+        assertEquals("Hello World!", response.getStringContent());
+    }
+    
+    public void testHttpExclusionIP() throws Exception {
+        AsyncHttpClient ahc = new AsyncHttpClient();
+        
+        HttpRequestMessage request = 
+                new HttpRequestMessage(new URL("http://127.0.0.1:8282/"), null);
+        // NOTE:  The proxy server config is invalid, so this will fail if the 
+        // exclusion doesn't work. 
+        ProxyConfiguration config = new ProxyConfiguration("localhost", 8889);
+        config.setExclusionList("127.0.0.1;*.apache.org");
+        request.setProxyConfiguration(config);
+        
+        Future<HttpResponseMessage> future = ahc.sendRequest(request);
+        
+        HttpResponseMessage response = future.get();
+        assertEquals("Hello World!", response.getStringContent());
+    }
+    
+    public void testHttpsExclusion() throws Exception {
+        AsyncHttpClient ahc = new AsyncHttpClient();
+        
+        HttpRequestMessage request = 
+                new HttpRequestMessage(new URL("https://localhost:8383/"), null);
+        ProxyConfiguration config = new ProxyConfiguration("localhost", 8889);
+        config.setExclusionList("localhost;*.apache.org");
+        request.setProxyConfiguration(config);
+        
+        Future<HttpResponseMessage> future = ahc.sendRequest(request);
+        
+        HttpResponseMessage response = future.get();
+        assertEquals("Hello World!", response.getStringContent());
+    }
+}

Propchange: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ProxyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ProxyTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/ProxyTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/RetryTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/RetryTest.java?rev=617593&r1=617592&r2=617593&view=diff
==============================================================================
--- geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/RetryTest.java (original)
+++ geronimo/sandbox/async-http-client-mina2/src/test/java/org/apache/ahc/RetryTest.java Fri
Feb  1 10:26:11 2008
@@ -19,47 +19,49 @@
  */
 package org.apache.ahc;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.net.URL;
-import java.util.Arrays;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.ahc.codec.HttpRequestMessage;
-import org.apache.ahc.codec.HttpResponseMessage;
+import org.apache.ahc.util.CountingMonitor;
+import org.apache.ahc.util.MonitoringEvent;
 
 public class RetryTest extends AbstractTest {
 
 
     public void testHtmlConnection() throws Exception {
         TestCallback callback = new TestCallback();
-        doGetConnection(callback, "http://localhost:8284/");
+        CountingMonitor counter = doGetConnection(callback, "http://localhost:8284/");
         Thread.sleep(5000); 
         assertTrue(callback.isException());
+        assertTrue(counter.getCount(MonitoringEvent.CONNECTION_RETRIED) == 3); 
     }
 
     public void testSSLHtmlConnection() throws Exception {
         TestCallback callback = new TestCallback();
-        doGetConnection(callback, "https://localhost:8385/");
+        CountingMonitor counter = doGetConnection(callback, "https://localhost:8385/");
         
         Thread.sleep(5000); 
         assertTrue(callback.isException());
+        assertTrue(counter.getCount(MonitoringEvent.CONNECTION_RETRIED) == 3); 
     }
 
-    private void doGetConnection(TestCallback callback, String url)
+    private CountingMonitor doGetConnection(TestCallback callback, String url)
         throws Exception {
         HttpRequestMessage request = new HttpRequestMessage(new URL(url), callback);
 
         request.setParameter("TEST1", "Test One");
         request.setParameter("TEST2", "Test Two");
-        doConnection(request, callback);
-    }
+        return doConnection(request, callback);
+    }          
 
-    private void doConnection(HttpRequestMessage request,
+    private CountingMonitor doConnection(HttpRequestMessage request,
                               TestCallback callback) throws Exception {
         AsyncHttpClient ahc = new AsyncHttpClient();
         ahc.setTcpNoDelay(true);
         ahc.setConnectionRetries(3); 
+        CountingMonitor counter = new CountingMonitor(); 
+        ahc.addMonitoringListener(counter); 
         // set a short timeout 
         request.setTimeOut(200); 
 
@@ -69,6 +71,8 @@
         //So this little wait simulates the thread going back in the pool
         //5 second timeout due to no response
         callback.await(5, TimeUnit.SECONDS);
+        // and return our monitor 
+        return counter; 
     }
 }
 



Mime
View raw message