commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sul...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestTraceMethodLocal.java
Date Tue, 03 Sep 2002 03:03:11 GMT
sullis      2002/09/02 20:03:10

  Modified:    httpclient/src/test/org/apache/commons/httpclient
                        TestTraceMethodLocal.java
  Log:
  added more assertions
  
  Revision  Changes    Path
  1.2       +35 -5     jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestTraceMethodLocal.java
  
  Index: TestTraceMethodLocal.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestTraceMethodLocal.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestTraceMethodLocal.java	3 Sep 2002 01:23:38 -0000	1.1
  +++ TestTraceMethodLocal.java	3 Sep 2002 03:03:10 -0000	1.2
  @@ -69,7 +69,7 @@
   /**
    * 
    * Simple tests of {@link TraceMethod} hitting
  - * a local webserver.
  + * a local HTTP server.
    * <p>
    * This test suite assumes a webserver is running on
    * port 8080 on the 127.0.0.1 (localhost) host.  It
  @@ -131,9 +131,39 @@
           client.startSession(host, port);
   
           TraceMethod method = new TraceMethod("/");
  -        
  +
  +		final String strTestHeaderName = "MyTestHeader";
  +		
  +		final String strTestHeaderValue = "This-is-a-test-value.";
  +		
  +		method.setRequestHeader(
  +					strTestHeaderName, 
  +					strTestHeaderValue);
  +		
           try {
               client.executeMethod(method);
  +
  +			final int iResponseStatusCode = method.getStatusCode();
  +			assertEquals(200, iResponseStatusCode);
  +			
  +            Header[] requestHeaders = method.getRequestHeaders();
  +            assertTrue( requestHeaders.length > 0);
  +
  +            Header[] responseHeaders = method.getResponseHeaders();
  +            assertNotNull(responseHeaders);
  +            
  +            //
  +            // note:  the reason that we convert the String's to lowercase is
  +            //        because some HTTP servers send a response body that contains 
  +            //        lower request headers
  +            //
  +            final String strResponseBody_lowercase = method.getResponseBodyAsString().toLowerCase();
  +            assertNotNull(strResponseBody_lowercase);
  +            assertTrue( strResponseBody_lowercase.length() > 0);
  +            
  +            assertTrue( strResponseBody_lowercase.indexOf(strTestHeaderName.toLowerCase())
!= -1);
  +            assertTrue( strResponseBody_lowercase.indexOf(strTestHeaderValue.toLowerCase())
!= -1);
  +            
           } catch (Throwable t) {
               t.printStackTrace();
               fail("Unable to execute method : " + t.toString());
  
  
  

--
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