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 TestMethodsNoHost.java
Date Mon, 29 Jul 2002 23:40:02 GMT
jsdever     2002/07/29 16:40:01

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpMethodBase.java
               httpclient/src/test/org/apache/commons/httpclient
                        TestMethodsNoHost.java
  Log:
  Fix for http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6626
  
  Revision  Changes    Path
  1.39      +7 -7      jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
  
  Index: HttpMethodBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- HttpMethodBase.java	28 Jul 2002 18:08:57 -0000	1.38
  +++ HttpMethodBase.java	29 Jul 2002 23:40:01 -0000	1.39
  @@ -111,7 +111,7 @@
    * @author Rodney Waldhoff
    * @author Sean C. Sullivan
    * @author <a href="mailto:dion@apache.org">dIon Gillard</a>
  - * @author <a href="mailto:jsdever@sympatico.ca">Jeff Dever</a>
  + * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
    * @author <a href="mailto:dims@apache.org">Davanum Srinivas</a>
    * @author Ortwin Glück
    * @version $Revision$ $Date$
  @@ -154,10 +154,10 @@
   
       /**
        * Get the path part of my request.
  -     * @return the path to request
  +     * @return the path to request or "/" if the path is blank.
        */
       public String getPath() {
  -        return this.path;
  +        return (path == null || path.equals("")) ? "/" : path;
       }
   
       /**
  
  
  
  1.5       +62 -5     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestMethodsNoHost.java	23 Jul 2002 14:39:14 -0000	1.4
  +++ TestMethodsNoHost.java	29 Jul 2002 23:40:01 -0000	1.5
  @@ -69,8 +69,8 @@
   import org.apache.commons.httpclient.methods.*;
   
   /**
  - * @author <a href="mailto:jsdever@sympatico.ca">Jeffrey Dever</a>
    * @author Rodney Waldhoff
  + * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
    * @version $Revision$ $Date$
    */
   public class TestMethodsNoHost extends TestCase {
  @@ -84,6 +84,23 @@
       static final NameValuePair PAIR1 = new NameValuePair(NAME1, VALUE1);
       static final NameValuePair PAIR2 = new NameValuePair(NAME2, VALUE2);
       
  +    /** Simple method for testing the HttpMethodBase.
  +     */
  +    class HttpSimpleMethod extends HttpMethodBase{
  +
  +       HttpSimpleMethod(){
  +	  super();
  +       }
  +
  +       HttpSimpleMethod(String path){
  +	  super(path);
  +       }
  +
  +       public String getName() {
  +	  return "Simple";
  +       }
  +
  +    }
   
       // ------------------------------------------------------------ Constructor
   
  @@ -218,5 +235,45 @@
               // expected
           }
       }
  +
  +    public void testHttpMethodBasePaths() throws Exception {
  +        HttpMethod simple = new HttpSimpleMethod();
  +	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 HttpSimpleMethod();
  +	assertEquals("/", simple.getPath());
  +
  +	simple.setPath("");
  +	assertEquals("/", simple.getPath());
  +
  +	simple.setPath(null);
  +	assertEquals("/", simple.getPath());
  +    }
  +
  +    public void testHttpMethodBasePathConstructor() throws Exception {
  +        HttpMethod simple = new HttpSimpleMethod(null);
  +	assertEquals("/", simple.getPath());
  +
  +        simple = new HttpSimpleMethod("");
  +	assertEquals("/", simple.getPath());
  +
  +        simple = new HttpSimpleMethod("/some/path/");
  +	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