commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsde...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient SimpleHttpMethod.java TestAuthenticator.java TestMethodsNoHost.java
Date Tue, 06 Aug 2002 15:15:32 GMT
jsdever     2002/08/06 08:15:32

  Modified:    httpclient/src/test/org/apache/commons/httpclient
                        SimpleHttpMethod.java TestAuthenticator.java
                        TestMethodsNoHost.java
  Log:
  Cleanups using SimpleHttpMethod for testing.
  
  Revision  Changes    Path
  1.2       +21 -3     jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/SimpleHttpMethod.java
  
  Index: SimpleHttpMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/SimpleHttpMethod.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleHttpMethod.java	2 Aug 2002 11:38:12 -0000	1.1
  +++ SimpleHttpMethod.java	6 Aug 2002 15:15:32 -0000	1.2
  @@ -69,6 +69,8 @@
    */
   class SimpleHttpMethod extends HttpMethodBase{
   
  +    Header header = null;
  +
   	SimpleHttpMethod(){
   		super();
   	}
  @@ -77,10 +79,26 @@
   		super(path);
   	}
   
  +	SimpleHttpMethod(Header header){
  +		super();
  +        this.header = header;
  +	}
   
   	public String getName() {
   		return "Simple";
   	}
  +
  +    public Header getResponseHeader(String name) {
  +        try {
  +            if(name.equalsIgnoreCase(header.getName())) {
  +                return header;
  +            } else {
  +                return super.getResponseHeader(name);
  +            }
  +        } catch(NullPointerException e) {
  +            return super.getResponseHeader(name);
  +        }
  +    }
   
   
   	public int execute(HttpState state, HttpConnection conn)
  
  
  
  1.13      +16 -36    jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java
  
  Index: TestAuthenticator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TestAuthenticator.java	26 Jul 2002 00:45:01 -0000	1.12
  +++ TestAuthenticator.java	6 Aug 2002 15:15:32 -0000	1.13
  @@ -95,33 +95,6 @@
           return new TestSuite(TestAuthenticator.class);
       }
   
  -    // ------------------------------------------------------------ Inner Class
  -
  -    // HttpMethodBase.responseHeaders is private,
  -    // so this extension adds a mechanism for setting
  -    // a response header
  -    private class SimpleHttpMethod extends HttpMethodBase {
  -        Header _header = null;
  -        public SimpleHttpMethod(Header header) {
  -            _header = header;
  -        }
  -        public String getName() { return "simple"; }
  -
  -        public Header getResponseHeader(String name) {
  -            try {
  -                if(name.equalsIgnoreCase(_header.getName())) {
  -                    return _header;
  -                } else {
  -                    return super.getResponseHeader(name);
  -                }
  -            } catch(NullPointerException e) {
  -                return super.getResponseHeader(name);
  -            }
  -        }
  -        public String getPath() {
  -        	return "test";
  -        }
  -    }
   
       // ---------------------------------- Test Methods for Basic Authentication
   
  @@ -160,7 +133,7 @@
   
       public void testBasicAuthenticationWithNoChallenge() throws Exception {
           HttpState state = new HttpState();
  -        HttpMethod method = new SimpleHttpMethod(null);
  +        HttpMethod method = new SimpleHttpMethod();
   
           assertEquals(false, Authenticator.authenticate(method,state));
       }
  @@ -240,7 +213,7 @@
   
       public void testPreemptiveAuthorizationDefault() throws Exception {
           HttpState state = new HttpState();
  -        HttpMethod method = new SimpleHttpMethod(null);
  +        HttpMethod method = new SimpleHttpMethod();
           state.setCredentials(null, new UsernamePasswordCredentials("username","password"));
   
           assertTrue(! Authenticator.authenticate(method,state));
  @@ -249,7 +222,7 @@
   
       public void testPreemptiveAuthorizationTrueNoCreds() throws Exception {
           HttpState state = new HttpState();
  -        HttpMethod method = new SimpleHttpMethod(null);
  +        HttpMethod method = new SimpleHttpMethod();
   
           System.getProperties().setProperty(Authenticator.PREEMPTIVE_PROPERTY, "true");
           assertTrue(! Authenticator.authenticate(method,state));
  @@ -258,7 +231,7 @@
   
       public void testPreemptiveAuthorizationTrueWithCreds() throws Exception {
           HttpState state = new HttpState();
  -        HttpMethod method = new SimpleHttpMethod(null);
  +        HttpMethod method = new SimpleHttpMethod();
           state.setCredentials(null, new UsernamePasswordCredentials("username","password"));
   
           System.getProperties().setProperty(Authenticator.PREEMPTIVE_PROPERTY, "true");
  @@ -270,7 +243,7 @@
   
       public void testPreemptiveAuthorizationFalse() throws Exception {
           HttpState state = new HttpState();
  -        HttpMethod method = new SimpleHttpMethod(null);
  +        HttpMethod method = new SimpleHttpMethod();
   
           System.getProperties().setProperty(Authenticator.PREEMPTIVE_PROPERTY, "false");
           state.setCredentials(null, new UsernamePasswordCredentials("username","password"));
  @@ -278,6 +251,13 @@
           assertTrue(null == method.getRequestHeader("Authorization"));
       }
   
  +    public void testMultipleChallenge() throws Exception {
  +        HttpState state = new HttpState();
  +        HttpMethod method = new SimpleHttpMethod();
  +        //set both basic and digest response headers
  +        
  +        assertTrue(! Authenticator.authenticate(method,state));
  +    }
   
   
   
  
  
  
  1.7       +24 -24    jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethodsNoHost.java
  
  Index: TestMethodsNoHost.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethodsNoHost.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestMethodsNoHost.java	2 Aug 2002 11:38:12 -0000	1.6
  +++ TestMethodsNoHost.java	6 Aug 2002 15:15:32 -0000	1.7
  @@ -222,39 +222,39 @@
   
       public void testHttpMethodBasePaths() throws Exception {
           HttpMethod simple = new SimpleHttpMethod();
  -	String[] paths = {
  -	   "/some/absolute/path",
  -	   "../some/relative/path",
  -	   "/",
  -	   "/some/path/with?query=string"
  -	};
  -	
  -	for (int i=0; i<paths.length; i++){
  -	   simple.setPath(paths[i]);
  -	   assertEquals(paths[i], simple.getPath());
  -	}
  +        String[] paths = {
  +           "/some/absolute/path",
  +           "../some/relative/path",
  +           "/",
  +           "/some/path/with?query=string"
  +       };
  +    
  +        for (int i=0; i<paths.length; i++){
  +            simple.setPath(paths[i]);
  +            assertEquals(paths[i], simple.getPath());
  +        }
       }
   
       public void testHttpMethodBaseDefaultPath() throws Exception {
           HttpMethod simple = new SimpleHttpMethod();
  -	assertEquals("/", simple.getPath());
  +        assertEquals("/", simple.getPath());
   
  -	simple.setPath("");
  -	assertEquals("/", simple.getPath());
  +        simple.setPath("");
  +        assertEquals("/", simple.getPath());
   
  -	simple.setPath(null);
  -	assertEquals("/", simple.getPath());
  +        simple.setPath(null);
  +        assertEquals("/", simple.getPath());
       }
   
       public void testHttpMethodBasePathConstructor() throws Exception {
  -        HttpMethod simple = new SimpleHttpMethod(null);
  -	assertEquals("/", simple.getPath());
  +        HttpMethod simple = new SimpleHttpMethod();
  +        assertEquals("/", simple.getPath());
   
           simple = new SimpleHttpMethod("");
  -	assertEquals("/", simple.getPath());
  +        assertEquals("/", simple.getPath());
   
           simple = new SimpleHttpMethod("/some/path/");
  -	assertEquals("/some/path/", simple.getPath());
  +        assertEquals("/some/path/", simple.getPath());
       }
   
   
  
  
  

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


Mime
View raw message