commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r153629 - in jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient: HttpClientTestBase.java TestProxy.java params/TestHttpParams.java server/SimpleProxy.java
Date Sun, 13 Feb 2005 14:06:36 GMT
Author: olegk
Date: Sun Feb 13 06:06:34 2005
New Revision: 153629

URL: http://svn.apache.org/viewcvs?view=rev&rev=153629
Log:
Tunnelling proxy test cases restructured

Modified:
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/HttpClientTestBase.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/params/TestHttpParams.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/server/SimpleProxy.java

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/HttpClientTestBase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/HttpClientTestBase.java?view=diff&r1=153628&r2=153629
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/HttpClientTestBase.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/HttpClientTestBase.java
Sun Feb 13 06:06:34 2005
@@ -1,7 +1,7 @@
 /*
  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/test/org/apache/commons/httpclient/HttpClientTestBase.java,v
1.7 2004/11/07 12:31:42 olegk Exp $
  * $Revision: 1.7 $
- * $Date: 2004/11/07 12:31:42 $
+ * $Date$
  * ====================================================================
  *
  *  Copyright 1999-2004 The Apache Software Foundation
@@ -35,8 +35,13 @@
 import junit.framework.TestSuite;
 
 import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
 import org.apache.commons.httpclient.server.SimpleHttpServer;
+import org.apache.commons.httpclient.server.SimplePlainSocketFactory;
 import org.apache.commons.httpclient.server.SimpleProxy;
+import org.apache.commons.httpclient.server.SimpleSocketFactory;
+import org.apache.commons.httpclient.ssl.SimpleSSLSocketFactory;
+import org.apache.commons.httpclient.ssl.SimpleSSLTestProtocolSocketFactory;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -47,7 +52,7 @@
  *
  * @author Oleg Kalnichevski
  * 
- * @version $Id: HttpClientTestBase.java,v 1.7 2004/11/07 12:31:42 olegk Exp $
+ * @version $Id$
  */
 public class HttpClientTestBase extends TestCase {
 
@@ -58,6 +63,7 @@
 
     protected SimpleProxy proxy = null;
     private boolean useProxy = false;
+    private boolean useSSL = false;
     
     // ------------------------------------------------------------ Constructor
     public HttpClientTestBase(final String testName) throws IOException {
@@ -80,18 +86,40 @@
         this.useProxy = useProxy;
     }
     
+    public void setUseSSL(boolean b) {
+        this.useSSL = b;
+    }
+    
+    public boolean isUseSSL() {
+        return this.useSSL;
+    }
+    
     // ------------------------------------------------- TestCase setup/shutdown
 
     public void setUp() throws IOException {
-        this.server = new SimpleHttpServer(); // use arbitrary port
+        // Configure socket factories
+        SimpleSocketFactory serversocketfactory = null; 
+        Protocol testhttp = null;
+        if (this.useSSL) {
+            serversocketfactory = new SimpleSSLSocketFactory(); 
+            testhttp = new Protocol("https", 
+                    (ProtocolSocketFactory)new SimpleSSLTestProtocolSocketFactory(), 443);
+        } else {
+            serversocketfactory = new SimplePlainSocketFactory(); 
+            testhttp = Protocol.getProtocol("http"); 
+        }
+
+        this.server = new SimpleHttpServer(serversocketfactory, 0); // use arbitrary port
         this.server.setTestname(getName());
 
         this.client = new HttpClient();
+
         this.client.getHostConfiguration().setHost(
-            this.server.getLocalAddress(), 
-            this.server.getLocalPort(),
-            Protocol.getProtocol("http"));
-        if (useProxy) {
+                this.server.getLocalAddress(), 
+                this.server.getLocalPort(),
+                testhttp);
+        
+        if (this.useProxy) {
             this.proxy = new SimpleProxy();
             client.getHostConfiguration().setProxy(
                 proxy.getLocalAddress(), 

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java?view=diff&r1=153628&r2=153629
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java
Sun Feb 13 06:06:34 2005
@@ -1,7 +1,7 @@
 /*
  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/test/org/apache/commons/httpclient/TestProxy.java,v
1.11 2004/12/11 22:35:26 olegk Exp $
  * $Revision: 1.11 $
- * $Date: 2004/12/11 22:35:26 $
+ * $Date$
  * ====================================================================
  *
  *  Copyright 1999-2004 The Apache Software Foundation
@@ -27,8 +27,13 @@
  */
 package org.apache.commons.httpclient;
 
+import java.io.IOException;
 import java.util.Enumeration;
 
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.commons.httpclient.auth.AuthScheme;
 import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.auth.CredentialsNotAvailableException;
@@ -36,22 +41,9 @@
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
 import org.apache.commons.httpclient.server.AuthRequestHandler;
 import org.apache.commons.httpclient.server.HttpRequestHandlerChain;
 import org.apache.commons.httpclient.server.HttpServiceHandler;
-import org.apache.commons.httpclient.server.SimpleHttpServer;
-import org.apache.commons.httpclient.server.SimplePlainSocketFactory;
-import org.apache.commons.httpclient.server.SimpleProxy;
-import org.apache.commons.httpclient.server.SimpleSocketFactory;
-import org.apache.commons.httpclient.ssl.SimpleSSLSocketFactory;
-import org.apache.commons.httpclient.ssl.SimpleSSLTestProtocolSocketFactory;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 
 /**
  * Tests for proxied connections.
@@ -59,15 +51,11 @@
  * @author Ortwin Glueck
  * @author Oleg Kalnichevski
  */
-public class TestProxy extends TestCase {
+public class TestProxy extends HttpClientTestBase {
 
-    private SimpleProxy proxy = null;
-    private SimpleHttpServer httpserver = null;
-    private HttpClient httpclient = null;
-    private boolean usessl = false;
-
-    public TestProxy(String testName) {
+    public TestProxy(String testName) throws IOException {
         super(testName);
+        setUseProxy(true);
     }
 
     static class SSLDecorator extends TestSetup {
@@ -105,48 +93,6 @@
         return suite;
     }
 
-    protected void setUp() throws Exception {
-        super.setUp();
-        this.httpclient = new HttpClient();
-        this.proxy = new SimpleProxy();
-        this.httpclient.getHostConfiguration().setProxy(
-                this.proxy.getLocalAddress(), 
-                this.proxy.getLocalPort());
-
-        SimpleSocketFactory serversocketfactory = null; 
-        Protocol testhttp = null;
-        if (this.usessl) {
-            serversocketfactory = new SimpleSSLSocketFactory(); 
-            testhttp = new Protocol("https", 
-                    (ProtocolSocketFactory)new SimpleSSLTestProtocolSocketFactory(), 443);
-        } else {
-            serversocketfactory = new SimplePlainSocketFactory(); 
-            testhttp = Protocol.getProtocol("http"); 
-        }
-        this.httpserver = new SimpleHttpServer(serversocketfactory, 0);
-        this.httpclient.getHostConfiguration().setHost(
-                this.httpserver.getLocalAddress(), 
-                this.httpserver.getLocalPort(),
-                testhttp);
-    }
-
-    protected void tearDown() throws Exception {
-        this.httpclient = null;
-        this.proxy.destroy();
-        this.proxy = null;
-        this.httpserver.destroy();
-        this.httpserver = null;
-        super.tearDown();
-    }
-
-    public void setUseSSL(boolean b) {
-        this.usessl = b;
-    }
-    
-    public boolean isUseSSL() {
-        return this.usessl;
-    }
-    
     class GetItWrongThenGetItRight implements CredentialsProvider {
         
         private int hostcount = 0;
@@ -184,10 +130,10 @@
      * Tests GET via non-authenticating proxy
      */
     public void testSimpleGet() throws Exception {
-        this.httpserver.setHttpService(new FeedbackService());
+        this.server.setHttpService(new FeedbackService());
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_OK, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -202,17 +148,17 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY, creds);
+        this.client.getState().setCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", true));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_OK, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -227,17 +173,17 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY, creds);
+        this.client.getState().setCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", false));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_OK, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -252,20 +198,20 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY, creds);
+        this.client.getState().setCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY,
+        this.client.getState().setCredentials(AuthScope.ANY,
                 new UsernamePasswordCredentials("testuser", "wrongstuff"));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_UNAUTHORIZED, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -280,18 +226,18 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getParams().setParameter(CredentialsProvider.PROVIDER, 
+        this.client.getParams().setParameter(CredentialsProvider.PROVIDER, 
                 new GetItWrongThenGetItRight());
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", true));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_OK, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -306,18 +252,18 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getParams().setParameter(CredentialsProvider.PROVIDER, 
+        this.client.getParams().setParameter(CredentialsProvider.PROVIDER, 
                 new GetItWrongThenGetItRight());
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", false));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_OK, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -332,20 +278,20 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY, creds);
-        this.httpclient.getState().setProxyCredentials(AuthScope.ANY, creds);
+        this.client.getState().setCredentials(AuthScope.ANY, creds);
+        this.client.getState().setProxyCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", true));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         this.proxy.requireAuthentication(creds, "test", true);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_OK, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -359,14 +305,14 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setProxyCredentials(AuthScope.ANY, creds);
-        this.httpserver.setHttpService(new FeedbackService());
+        this.client.getState().setProxyCredentials(AuthScope.ANY, creds);
+        this.server.setHttpService(new FeedbackService());
 
         this.proxy.requireAuthentication(creds, "test", true);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_OK, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -381,20 +327,20 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY, creds);
-        this.httpclient.getState().setProxyCredentials(AuthScope.ANY, creds);
+        this.client.getState().setCredentials(AuthScope.ANY, creds);
+        this.client.getState().setProxyCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", false));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
 
         this.proxy.requireAuthentication(creds, "test", true);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_OK, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -413,17 +359,17 @@
         handlerchain.appendHandler(new AuthRequestHandler(creds));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY,
+        this.client.getState().setCredentials(AuthScope.ANY,
                 new UsernamePasswordCredentials("testuser", "wrongstuff"));
-        this.httpclient.getState().setProxyCredentials(AuthScope.ANY, creds);
+        this.client.getState().setProxyCredentials(AuthScope.ANY, creds);
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         this.proxy.requireAuthentication(creds, "test", true);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_UNAUTHORIZED, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -438,20 +384,20 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getParams().setParameter(CredentialsProvider.PROVIDER, 
+        this.client.getParams().setParameter(CredentialsProvider.PROVIDER, 
                 new GetItWrongThenGetItRight());
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", true));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
 
         this.proxy.requireAuthentication(creds, "test", true);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_OK, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -466,20 +412,20 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getParams().setParameter(CredentialsProvider.PROVIDER, 
+        this.client.getParams().setParameter(CredentialsProvider.PROVIDER, 
                 new GetItWrongThenGetItRight());
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", false));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         this.proxy.requireAuthentication(creds, "test", true);
         
         GetMethod get = new GetMethod("/");
         try {
-            this.httpclient.executeMethod(get);
+            this.client.executeMethod(get);
             assertEquals(HttpStatus.SC_OK, get.getStatusCode());
         } finally {
             get.releaseConnection();
@@ -490,11 +436,11 @@
      * Tests POST via non-authenticating proxy
      */
     public void testSimplePost() throws Exception {
-        this.httpserver.setHttpService(new FeedbackService());
+        this.server.setHttpService(new FeedbackService());
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
             assertNotNull(post.getResponseBodyAsString());
         } finally {
@@ -509,18 +455,18 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY, creds);
+        this.client.getState().setCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", true));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
             assertNotNull(post.getResponseBodyAsString());
         } finally {
@@ -535,18 +481,18 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY, creds);
+        this.client.getState().setCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", false));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
             assertNotNull(post.getResponseBodyAsString());
         } finally {
@@ -562,21 +508,21 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY, creds);
+        this.client.getState().setCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY,
+        this.client.getState().setCredentials(AuthScope.ANY,
                 new UsernamePasswordCredentials("testuser", "wrongstuff"));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_UNAUTHORIZED, post.getStatusCode());
         } finally {
             post.releaseConnection();
@@ -590,19 +536,19 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getParams().setParameter(CredentialsProvider.PROVIDER, 
+        this.client.getParams().setParameter(CredentialsProvider.PROVIDER, 
                 new GetItWrongThenGetItRight());
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", true));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
             assertNotNull(post.getResponseBodyAsString());
         } finally {
@@ -617,19 +563,19 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getParams().setParameter(CredentialsProvider.PROVIDER, 
+        this.client.getParams().setParameter(CredentialsProvider.PROVIDER, 
                 new GetItWrongThenGetItRight());
                 
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", false));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
             assertNotNull(post.getResponseBodyAsString());
         } finally {
@@ -644,15 +590,15 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setProxyCredentials(AuthScope.ANY, creds);
-        this.httpserver.setHttpService(new FeedbackService());
+        this.client.getState().setProxyCredentials(AuthScope.ANY, creds);
+        this.server.setHttpService(new FeedbackService());
 
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
             assertNotNull(post.getResponseBodyAsString());
         } finally {
@@ -667,21 +613,21 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY, creds);
-        this.httpclient.getState().setProxyCredentials(AuthScope.ANY, creds);
+        this.client.getState().setCredentials(AuthScope.ANY, creds);
+        this.client.getState().setProxyCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", true));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
             assertNotNull(post.getResponseBodyAsString());
         } finally {
@@ -696,21 +642,21 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY, creds);
-        this.httpclient.getState().setProxyCredentials(AuthScope.ANY, creds);
+        this.client.getState().setCredentials(AuthScope.ANY, creds);
+        this.client.getState().setProxyCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", false));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
             assertNotNull(post.getResponseBodyAsString());
         } finally {
@@ -726,23 +672,23 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getState().setProxyCredentials(AuthScope.ANY, creds);
+        this.client.getState().setProxyCredentials(AuthScope.ANY, creds);
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpclient.getState().setCredentials(AuthScope.ANY,
+        this.client.getState().setCredentials(AuthScope.ANY,
                 new UsernamePasswordCredentials("testuser", "wrongstuff"));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_UNAUTHORIZED, post.getStatusCode());
         } finally {
             post.releaseConnection();
@@ -756,21 +702,21 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getParams().setParameter(CredentialsProvider.PROVIDER, 
+        this.client.getParams().setParameter(CredentialsProvider.PROVIDER, 
                 new GetItWrongThenGetItRight());
         
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", true));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
             assertNotNull(post.getResponseBodyAsString());
         } finally {
@@ -785,21 +731,21 @@
         UsernamePasswordCredentials creds = 
             new UsernamePasswordCredentials("testuser", "testpass");
         
-        this.httpclient.getParams().setParameter(CredentialsProvider.PROVIDER, 
+        this.client.getParams().setParameter(CredentialsProvider.PROVIDER, 
                 new GetItWrongThenGetItRight());
                 
         HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
         handlerchain.appendHandler(new AuthRequestHandler(creds, "test", false));
         handlerchain.appendHandler(new HttpServiceHandler(new FeedbackService()));
         
-        this.httpserver.setRequestHandler(handlerchain);
+        this.server.setRequestHandler(handlerchain);
         
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
         post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
         try {
-            this.httpclient.executeMethod(post);
+            this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
             assertNotNull(post.getResponseBodyAsString());
         } finally {

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/params/TestHttpParams.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/params/TestHttpParams.java?view=diff&r1=153628&r2=153629
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/params/TestHttpParams.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/params/TestHttpParams.java
Sun Feb 13 06:06:34 2005
@@ -1,7 +1,7 @@
 /*
  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/test/org/apache/commons/httpclient/params/TestHttpParams.java,v
1.4 2004/10/31 14:42:59 olegk Exp $
  * $Revision: 1.4 $
- * $Date: 2004/10/31 14:42:59 $
+ * $Date$
  * ====================================================================
  *
  *  Copyright 1999-2004 The Apache Software Foundation
@@ -23,8 +23,6 @@
  * individuals on behalf of the Apache Software Foundation.  For more
  * information on the Apache Software Foundation, please see
  * <http://www.apache.org/>.
- *
- * [Additional notices, if required by prior licensing conditions]
  *
  */
 

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/server/SimpleProxy.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/server/SimpleProxy.java?view=diff&r1=153628&r2=153629
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/server/SimpleProxy.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/server/SimpleProxy.java
Sun Feb 13 06:06:34 2005
@@ -1,7 +1,7 @@
 /*
  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/test/org/apache/commons/httpclient/server/SimpleProxy.java,v
1.8 2004/12/11 22:35:26 olegk Exp $
  * $Revision: 1.8 $
- * $Date: 2004/12/11 22:35:26 $
+ * $Date$
  *
  * ====================================================================
  *
@@ -44,9 +44,6 @@
     private SimpleConnManager connmanager = null; 
     private HttpRequestHandlerChain stdchain = null;
 
-    /**
-     * @throws IOException
-     */
     public SimpleProxy(int port) throws IOException {
         super(port);
         this.connmanager = new SimpleConnManager(); 
@@ -56,11 +53,6 @@
         setRequestHandler(this.stdchain);
     }
 
-    /**
-     * @param port
-     *                The local TCP port to listen on
-     * @throws IOException
-     */
     public SimpleProxy() throws IOException {
         this(0);
     }
@@ -80,6 +72,10 @@
     public void destroy() {
         super.destroy();
         this.connmanager.shutdown();
+    }
+    
+    public void addHandler(final HttpRequestHandler handler) {
+        this.stdchain.prependHandler(handler);
     }
     
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message