morgand     01/05/01 11:24:07

  Modified:    httpclient/src/test/org/apache/commons/httpclient
                        TestMethods.java
  Log:
  added test to insure that bad urls throw the correct exception
  
  Revision  Changes    Path
  1.3       +28 -4     
jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethods.java
  
  Index: TestMethods.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethods.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestMethods.java  2001/04/30 19:56:44     1.2
  +++ TestMethods.java  2001/05/01 18:24:07     1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethods.java,v
 1.2 2001/04/30 19:56:44 morgand Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/04/30 19:56:44 $
  + * $Header: 
/home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethods.java,v
 1.3 2001/05/01 18:24:07 morgand Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/05/01 18:24:07 $
    *
    * ====================================================================
    *
  @@ -61,6 +61,7 @@
   
   package org.apache.commons.httpclient;
   
  +import java.io.IOException;
   import java.util.Enumeration;
   import junit.framework.*;
   import org.apache.commons.httpclient.methods.*;
  @@ -70,7 +71,7 @@
    * configuration of Tomcat 4 is used as the server.
    * 
    * @author Remy Maucherat
  - * @version $Id: TestMethods.java,v 1.2 2001/04/30 19:56:44 morgand Exp $
  + * @version $Id: TestMethods.java,v 1.3 2001/05/01 18:24:07 morgand Exp $
    */
   public class TestMethods extends TestCase {
   
  @@ -246,6 +247,29 @@
   
           assert("Method failed : " + method.getStatusCode(), 
                  (method.getStatusCode() == 200));
  +
  +    }
  +
  +    /**
  +     * This test proves that bad urls throw an IOException,
  +     * and not some other throwable like a NullPointerException.
  +     */
  +    public void testIOException() {
  +
  +        HttpClient client = new HttpClient();
  +        client.startSession("http://whaturl.com.org";, externalPort);
  +
  +        GetMethod method = new GetMethod("");
  +
  +        try {
  +            client.executeMethod(method);
  +        } catch (IOException e) {
  +          return; // good
  +        } catch (HttpException e) {
  +          return; // also good
  +        } 
  +
  +        fail("Should have thrown an exception");
   
       }
   
  
  
  

Reply via email to