You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2007/10/07 11:35:58 UTC

svn commit: r582602 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src: main/java/org/apache/http/cookie/ main/java/org/apache/http/impl/cookie/ test/java/org/apache/http/client/protocol/ test/java/org/apache/http/localserver/

Author: olegk
Date: Sun Oct  7 02:35:48 2007
New Revision: 582602

URL: http://svn.apache.org/viewvc?rev=582602&view=rev
Log:
Ported Cookie2 test cases from the HttpClient 3.x branch

Added:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java
      - copied, changed from r582479, jakarta/httpcomponents/oac.hc3x/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieVersionSupport.java
Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SM.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SM.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SM.java?rev=582602&r1=582601&r2=582602&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SM.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SM.java Sun Oct  7 02:35:48 2007
@@ -41,7 +41,7 @@
 public interface SM {
 
     public static final String COOKIE            = "Cookie";
-    public static final String COOKIE_2          = "Cookie2";
+    public static final String COOKIE2          = "Cookie2";
     public static final String SET_COOKIE        = "Set-Cookie";
     public static final String SET_COOKIE2       = "Set-Cookie2";
        

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java?rev=582602&r1=582601&r2=582602&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java Sun Oct  7 02:35:48 2007
@@ -73,6 +73,23 @@
         registerAttribHandler(ClientCookie.VERSION_ATTR, new RFC2965VersionAttributeHandler());
     }
     
+    private BasicClientCookie createCookie(
+            final String name, final String value, final CookieOrigin origin) {
+        BasicClientCookie cookie = new BasicClientCookie(name, value);
+        cookie.setPath(getDefaultPath(origin));
+        cookie.setDomain(getDefaultDomain(origin));
+        return cookie;
+    }
+    
+    private BasicClientCookie createCookie2(
+            final String name, final String value, final CookieOrigin origin) {
+        BasicClientCookie2 cookie = new BasicClientCookie2(name, value);
+        cookie.setPath(getDefaultPath(origin));
+        cookie.setDomain(getDefaultDomain(origin));
+        cookie.setPorts(new int [] { origin.getPort() });
+        return cookie;
+    }
+    
     public Cookie[] parse(
             final Header header, 
             CookieOrigin origin) throws MalformedCookieException {
@@ -96,11 +113,13 @@
             if (name == null || name.equals("")) {
                 throw new MalformedCookieException("Cookie name may not be empty");
             }
-            
-            BasicClientCookie2 cookie = new BasicClientCookie2(name, value);
-            cookie.setPath(getDefaultPath(origin));
-            cookie.setDomain(getDefaultDomain(origin));
-            cookie.setPorts(new int [] { origin.getPort() });
+
+            BasicClientCookie cookie;
+            if (header.getName().equals(SM.SET_COOKIE2)) {
+                cookie = createCookie2(name, value, origin);
+            } else {
+                cookie = createCookie(name, value, origin);
+            }
             
             // cycle through the parameters
             NameValuePair[] attribs = headerelement.getParameters();
@@ -212,7 +231,7 @@
 
     public Header getVersionHeader() {
         CharArrayBuffer buffer = new CharArrayBuffer(40);
-        buffer.append(SM.COOKIE_2);
+        buffer.append(SM.COOKIE2);
         buffer.append(": ");
         buffer.append("$Version=");
         buffer.append(Integer.toString(getVersion()));

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java?rev=582602&r1=582601&r2=582602&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java Sun Oct  7 02:35:48 2007
@@ -6,6 +6,7 @@
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.cookie.SetCookie2;
 
 /**
  * <tt>"Version"</tt> cookie attribute handler for RFC 2965 cookie spec.
@@ -48,7 +49,7 @@
         if (cookie == null) {
             throw new IllegalArgumentException("Cookie may not be null");
         }
-        if (cookie instanceof ClientCookie) {
+        if (cookie instanceof SetCookie2) {
             if (cookie instanceof ClientCookie 
                     && !((ClientCookie) cookie).containsAttribute(ClientCookie.VERSION_ATTR)) {
                 throw new MalformedCookieException(

Copied: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java (from r582479, jakarta/httpcomponents/oac.hc3x/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieVersionSupport.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java?p2=jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java&p1=jakarta/httpcomponents/oac.hc3x/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieVersionSupport.java&r1=582479&r2=582602&rev=582602&view=diff
==============================================================================
--- jakarta/httpcomponents/oac.hc3x/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieVersionSupport.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java Sun Oct  7 02:35:48 2007
@@ -26,210 +26,259 @@
  * <http://www.apache.org/>.
  */
 
-package org.apache.commons.httpclient.cookie;
+package org.apache.http.client.protocol;
 
 import java.io.IOException;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.commons.httpclient.Cookie;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClientTestBase;
-import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.HttpVersion;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.server.HttpService;
-import org.apache.commons.httpclient.server.SimpleRequest;
-import org.apache.commons.httpclient.server.SimpleResponse;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.ProtocolVersion;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.RoutedRequest;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.params.ClientPNames;
+import org.apache.http.client.params.CookiePolicy;
+import org.apache.http.cookie.Cookie;
+import org.apache.http.cookie.SM;
+import org.apache.http.cookie.SetCookie2;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.localserver.ServerTestBase;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
 
 /**
- * Cookie version support tests.
+ * Cookie2 support tests.
  *
  * @author Oleg Kalnichevski
  * 
  * @version $Revision$
  */
-public class TestCookieVersionSupport extends HttpClientTestBase {
+public class TestCookie2Support extends ServerTestBase {
 
     // ------------------------------------------------------------ Constructor
-    public TestCookieVersionSupport(final String testName) throws IOException {
+    public TestCookie2Support(final String testName) throws IOException {
         super(testName);
     }
 
     // ------------------------------------------------------------------- Main
     public static void main(String args[]) {
-        String[] testCaseName = { TestCookieVersionSupport.class.getName() };
+        String[] testCaseName = { TestCookie2Support.class.getName() };
         junit.textui.TestRunner.main(testCaseName);
     }
 
     // ------------------------------------------------------- TestCase Methods
 
     public static Test suite() {
-        return new TestSuite(TestCookieVersionSupport.class);
+        return new TestSuite(TestCookie2Support.class);
     }
 
-    private static class CookieVer0Service implements HttpService {
+    private static class CookieVer0Service implements HttpRequestHandler {
 
-        public CookieVer0Service() {
-            super();
-        }
-
-        public boolean process(final SimpleRequest request, final SimpleResponse response)
-            throws IOException
-        {
-            HttpVersion httpversion = request.getRequestLine().getHttpVersion();
+        public void handle(
+                final HttpRequest request, 
+                final HttpResponse response, 
+                final HttpContext context) throws HttpException, IOException {
+            ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
             response.setStatusLine(httpversion, HttpStatus.SC_OK);
-            response.addHeader(new Header("Set-Cookie", "name1=value1; path=/test"));
-            response.setBodyString("whatever");
-            return true;
+            response.addHeader(new BasicHeader("Set-Cookie", "name1=value1; path=/test"));
+            StringEntity entity = new StringEntity("whatever");
+            response.setEntity(entity);
         }
+
     }
     
-    
-    public void testCookieVersionSupportHeader1() throws IOException {
-        this.server.setHttpService(new CookieVer0Service());
-        this.client.getParams().setCookiePolicy(CookiePolicy.RFC_2965);
-        GetMethod httpget1 = new GetMethod("/test/");
-        try {
-            this.client.executeMethod(httpget1);
-        } finally {
-            httpget1.releaseConnection();
-        }
-        GetMethod httpget2 = new GetMethod("/test/");
-        try {
-            this.client.executeMethod(httpget2);
-        } finally {
-            httpget2.releaseConnection();
+    public void testCookieVersionSupportHeader1() throws Exception {
+        this.localServer.register("*", new CookieVer0Service());
+        
+        DefaultHttpClient client = new DefaultHttpClient(); 
+        client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.RFC_2965);
+
+        CookieStore cookieStore = new BasicCookieStore();
+        HttpContext context = client.getDefaultContext();
+        context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
+        
+        HttpGet httpget = new HttpGet("/test/");
+        
+        RoutedRequest request1 = new RoutedRequest.Impl(httpget, getDefaultRoute()); 
+        HttpResponse response1 = client.execute(request1, context);
+        HttpEntity e1 = response1.getEntity();
+        if (e1 != null) {
+            e1.consumeContent();
         }
-        Header cookiesupport = httpget2.getRequestHeader("Cookie2");
+        
+        Cookie[] cookies = cookieStore.getCookies();
+        assertNotNull(cookies);
+        assertEquals(1, cookies.length);
+
+        RoutedRequest request2 = new RoutedRequest.Impl(httpget, getDefaultRoute()); 
+        HttpResponse response2 = client.execute(request2, context);
+        HttpEntity e2 = response2.getEntity();
+        if (e2 != null) {
+            e2.consumeContent();
+        }
+        
+        HttpRequest reqWrapper = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
+        
+        Header cookiesupport = reqWrapper.getFirstHeader("Cookie2");
         assertNotNull(cookiesupport);
-        assertEquals("$Version=\"1\"", cookiesupport.getValue());
+        assertEquals("$Version=1", cookiesupport.getValue());
     }
     
-    private static class CookieVer1Service implements HttpService {
-
-        public CookieVer1Service() {
-            super();
-        }
+    private static class CookieVer1Service implements HttpRequestHandler {
 
-        public boolean process(final SimpleRequest request, final SimpleResponse response)
-            throws IOException
-        {
-            HttpVersion httpversion = request.getRequestLine().getHttpVersion();
+        public void handle(
+                final HttpRequest request, 
+                final HttpResponse response, 
+                final HttpContext context) throws HttpException, IOException {
+            ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
             response.setStatusLine(httpversion, HttpStatus.SC_OK);
-            response.addHeader(new Header("Set-Cookie", "name1=value1; Path=\"/test\"; Version=\"1\""));
-            response.addHeader(new Header("Set-Cookie2", "name2=value2; Path=\"/test\"; Version=\"1\""));
-            response.setBodyString("whatever");
-            return true;
+            response.addHeader(new BasicHeader("Set-Cookie", "name1=value1; Path=\"/test\"; Version=1"));
+            response.addHeader(new BasicHeader("Set-Cookie2", "name2=value2; Path=\"/test\"; Version=1"));
+            StringEntity entity = new StringEntity("whatever");
+            response.setEntity(entity);
         }
+
     }
     
-    
-    public void testCookieVersionSupportHeader2() throws IOException {
-        this.server.setHttpService(new CookieVer1Service());
-        this.client.getParams().setCookiePolicy(CookiePolicy.RFC_2965);
-        GetMethod httpget1 = new GetMethod("/test/");
-        try {
-            this.client.executeMethod(httpget1);
-        } finally {
-            httpget1.releaseConnection();
-        }
-        GetMethod httpget2 = new GetMethod("/test/");
-        try {
-            this.client.executeMethod(httpget2);
-        } finally {
-            httpget2.releaseConnection();
+    public void testCookieVersionSupportHeader2() throws Exception {
+        this.localServer.register("*", new CookieVer1Service());
+        
+        DefaultHttpClient client = new DefaultHttpClient(); 
+        client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.RFC_2965);
+
+        CookieStore cookieStore = new BasicCookieStore();
+        HttpContext context = client.getDefaultContext();
+        context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
+        
+        HttpGet httpget = new HttpGet("/test/");
+        
+        RoutedRequest request1 = new RoutedRequest.Impl(httpget, getDefaultRoute()); 
+        HttpResponse response1 = client.execute(request1, context);
+        HttpEntity e1 = response1.getEntity();
+        if (e1 != null) {
+            e1.consumeContent();
         }
-        Header cookiesupport = httpget2.getRequestHeader("Cookie2");
+        
+        Cookie[] cookies = cookieStore.getCookies();
+        assertNotNull(cookies);
+        assertEquals(2, cookies.length);
+
+        RoutedRequest request2 = new RoutedRequest.Impl(httpget, getDefaultRoute()); 
+        HttpResponse response2 = client.execute(request2, context);
+        HttpEntity e2 = response2.getEntity();
+        if (e2 != null) {
+            e2.consumeContent();
+        }
+        
+        HttpRequest reqWrapper = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
+        
+        Header cookiesupport = reqWrapper.getFirstHeader(SM.COOKIE2);
         assertNull(cookiesupport);
     }
 
-    private static class CookieVer2Service implements HttpService {
-
-        public CookieVer2Service() {
-            super();
-        }
+    private static class CookieVer2Service implements HttpRequestHandler {
 
-        public boolean process(final SimpleRequest request, final SimpleResponse response)
-            throws IOException
-        {
-            HttpVersion httpversion = request.getRequestLine().getHttpVersion();
+        public void handle(
+                final HttpRequest request, 
+                final HttpResponse response, 
+                final HttpContext context) throws HttpException, IOException {
+            ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
             response.setStatusLine(httpversion, HttpStatus.SC_OK);
-            response.addHeader(new Header("Set-Cookie2", "name2=value2; Path=\"/test\"; Version=\"2\""));
-            response.setBodyString("whatever");
-            return true;
+            response.addHeader(new BasicHeader("Set-Cookie2", "name2=value2; Path=\"/test\"; Version=2"));
+            StringEntity entity = new StringEntity("whatever");
+            response.setEntity(entity);
         }
+
     }
     
-    
-    public void testCookieVersionSupportHeader3() throws IOException {
-        this.server.setHttpService(new CookieVer2Service());
-        this.client.getParams().setCookiePolicy(CookiePolicy.RFC_2965);
-        GetMethod httpget1 = new GetMethod("/test/");
-        try {
-            this.client.executeMethod(httpget1);
-        } finally {
-            httpget1.releaseConnection();
-        }
-        GetMethod httpget2 = new GetMethod("/test/");
-        try {
-            this.client.executeMethod(httpget2);
-        } finally {
-            httpget2.releaseConnection();
+    public void testCookieVersionSupportHeader3() throws Exception {
+        this.localServer.register("*", new CookieVer2Service());
+        
+        DefaultHttpClient client = new DefaultHttpClient(); 
+        client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.RFC_2965);
+
+        CookieStore cookieStore = new BasicCookieStore();
+        HttpContext context = client.getDefaultContext();
+        context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
+        
+        HttpGet httpget = new HttpGet("/test/");
+        
+        RoutedRequest request1 = new RoutedRequest.Impl(httpget, getDefaultRoute()); 
+        HttpResponse response1 = client.execute(request1, context);
+        HttpEntity e1 = response1.getEntity();
+        if (e1 != null) {
+            e1.consumeContent();
+        }
+        
+        Cookie[] cookies = cookieStore.getCookies();
+        assertNotNull(cookies);
+        assertEquals(1, cookies.length);
+
+        RoutedRequest request2 = new RoutedRequest.Impl(httpget, getDefaultRoute()); 
+        HttpResponse response2 = client.execute(request2, context);
+        HttpEntity e2 = response2.getEntity();
+        if (e2 != null) {
+            e2.consumeContent();
         }
-        Header cookiesupport = httpget2.getRequestHeader("Cookie2");
+        
+        HttpRequest reqWrapper = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
+        
+        Header cookiesupport = reqWrapper.getFirstHeader("Cookie2");
         assertNotNull(cookiesupport);
-        assertEquals("$Version=\"1\"", cookiesupport.getValue());
+        assertEquals("$Version=1", cookiesupport.getValue());
     }
 
-    private static class SetCookieVersionMixService implements HttpService {
-
-        public SetCookieVersionMixService() {
-            super();
-        }
+    private static class SetCookieVersionMixService implements HttpRequestHandler {
 
-        public boolean process(final SimpleRequest request, final SimpleResponse response)
-            throws IOException
-        {
-            HttpVersion httpversion = request.getRequestLine().getHttpVersion();
+        public void handle(
+                final HttpRequest request, 
+                final HttpResponse response, 
+                final HttpContext context) throws HttpException, IOException {
+            ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
             response.setStatusLine(httpversion, HttpStatus.SC_OK);
-            response.addHeader(new Header("Set-Cookie", "name=wrong; Path=/test"));
-            response.addHeader(new Header("Set-Cookie2", "name=right; Path=\"/test\"; Version=\"1\""));
-            response.setBodyString("whatever");
-            return true;
+            response.addHeader(new BasicHeader("Set-Cookie", "name=wrong; Path=/test"));
+            response.addHeader(new BasicHeader("Set-Cookie2", "name=right; Path=\"/test\"; Version=1"));
+            StringEntity entity = new StringEntity("whatever");
+            response.setEntity(entity);
         }
+
     }
     
-    public static class TestHttpState extends HttpState {
+    public void testSetCookieVersionMix() throws Exception {
+        this.localServer.register("*", new SetCookieVersionMixService());
         
-        public synchronized void addCookie(Cookie cookie) {
-            if (cookie != null) {
-                if ("localhost.local".equals(cookie.getDomain())) {
-                    cookie.setDomain("localhost");
-                }
-                super.addCookie(cookie);
-            }
-        }
-    }
-    
-    public void testSetCookieVersionMix() throws IOException {
-        this.server.setHttpService(new SetCookieVersionMixService());
-        this.client.setState(new TestHttpState());
-        this.client.getParams().setCookiePolicy(CookiePolicy.RFC_2965);
-        GetMethod httpget1 = new GetMethod("/test/");
-        try {
-            this.client.executeMethod(httpget1);
-        } finally {
-            httpget1.releaseConnection();
+        DefaultHttpClient client = new DefaultHttpClient(); 
+        client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.RFC_2965);
+
+        CookieStore cookieStore = new BasicCookieStore();
+        HttpContext context = client.getDefaultContext();
+        context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
+        
+        HttpGet httpget = new HttpGet("/test/");
+        
+        RoutedRequest request1 = new RoutedRequest.Impl(httpget, getDefaultRoute()); 
+        HttpResponse response1 = client.execute(request1, context);
+        HttpEntity e1 = response1.getEntity();
+        if (e1 != null) {
+            e1.consumeContent();
         }
-        Cookie[] cookies = this.client.getState().getCookies();
+        
+        Cookie[] cookies = cookieStore.getCookies();
         assertNotNull(cookies);
         assertEquals(1, cookies.length);
         assertEquals("right", cookies[0].getValue());
-        assertTrue(cookies[0] instanceof Cookie2);
+        assertTrue(cookies[0] instanceof SetCookie2);
     }
 
-    
 }

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java?rev=582602&r1=582601&r2=582602&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java Sun Oct  7 02:35:48 2007
@@ -36,6 +36,7 @@
 
 import org.apache.http.HttpHost;
 import org.apache.http.HttpVersion;
+import org.apache.http.conn.HttpRoute;
 import org.apache.http.conn.PlainSocketFactory;
 import org.apache.http.conn.Scheme;
 import org.apache.http.conn.SchemeRegistry;
@@ -175,6 +176,15 @@
                             "http");
     }
 
+    /**
+     * Obtains the default route to the local test server.
+     *
+     * @return the default route to the local test server
+     */
+    protected HttpRoute getDefaultRoute() {
+        return new HttpRoute(new HttpHost("localhost", localServer.getServicePort())); 
+    }
+    
 
     /**
      * Opens a connection to the given target using