Example usage for org.apache.commons.httpclient.methods TraceMethod releaseConnection

List of usage examples for org.apache.commons.httpclient.methods TraceMethod releaseConnection

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.methods TraceMethod releaseConnection.

Prototype

@Override
public void releaseConnection() 

Source Link

Document

Releases the connection being used by this HTTP method.

Usage

From source file:org.apache.camel.component.jetty.JettyEndpointSetHttpTraceTest.java

@Test
public void testTraceDisabled() throws Exception {
    HttpClient httpclient = new HttpClient();
    TraceMethod trace = new TraceMethod("http://localhost:" + portTraceOff + "/myservice");
    httpclient.executeMethod(trace);//ww  w .  ja  v  a 2s .  c  o m

    // TRACE shouldn't be allowed by default
    assertTrue(trace.getStatusCode() == 405);
    trace.releaseConnection();
}

From source file:org.apache.camel.component.jetty.JettyEndpointSetHttpTraceTest.java

@Test
public void testTraceEnabled() throws Exception {
    HttpClient httpclient = new HttpClient();
    TraceMethod trace = new TraceMethod("http://localhost:" + portTraceOn + "/myservice");
    httpclient.executeMethod(trace);// www .  ja va2  s .com

    // TRACE is now allowed
    assertTrue(trace.getStatusCode() == 200);
    trace.releaseConnection();
}

From source file:org.collectionspace.services.client.test.ServiceLayerTest.java

@Test
public void traceSupported() {
    if (logger.isDebugEnabled()) {
        logger.debug(BaseServiceTest.testBanner("traceSupported", CLASS_NAME));
    }/*  w  ww.  j  a  v  a 2 s .  c  o m*/
    String url = serviceClient.getBaseURL() + "collectionobjects";
    TraceMethod method = new TraceMethod(url);
    try {
        int statusCode = httpClient.executeMethod(method);

        if (logger.isDebugEnabled()) {
            logger.debug("traceSupported url=" + url + " status=" + statusCode);
            logger.debug("traceSupported response=" + new String(method.getResponseBody()));
            for (Header h : method.getResponseHeaders()) {
                logger.debug("traceSupported header name=" + h.getName() + " value=" + h.getValue());
            }
        }
        Assert.assertEquals(statusCode, HttpStatus.SC_METHOD_NOT_ALLOWED,
                "expected " + HttpStatus.SC_METHOD_NOT_ALLOWED);
    } catch (HttpException e) {
        logger.error("Fatal protocol violation: ", e);
    } catch (IOException e) {
        logger.error("Fatal transport error", e);
    } catch (Exception e) {
        logger.error("unknown exception ", e);
    } finally {
        // Release the connection.
        method.releaseConnection();
    }
}