Examples of TraceMethod


Examples of org.apache.commons.httpclient.methods.TraceMethod

    public void testExecute() {
     
        HttpClient client = createHttpClient();

        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);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.