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