use of org.apache.http.protocol.HttpRequestHandler in project camel by apache.
the class HttpProducerContentTypeTest method setUp.
@Before
@Override
public void setUp() throws Exception {
localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor()).setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory()).setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("/content", new HttpRequestHandler() {
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
String contentType = request.getFirstHeader(Exchange.CONTENT_TYPE).getValue();
assertEquals(CONTENT_TYPE, contentType);
response.setEntity(new StringEntity(contentType, "ASCII"));
response.setStatusCode(HttpStatus.SC_OK);
}
}).create();
localServer.start();
super.setUp();
}
use of org.apache.http.protocol.HttpRequestHandler in project camel by apache.
the class HttpNoCamelHeaderTest method setUp.
@Before
@Override
public void setUp() throws Exception {
localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor()).setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory()).setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("/hello", new HttpRequestHandler() {
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
response.setStatusCode(HttpStatus.SC_OK);
Object header = request.getFirstHeader(Exchange.FILE_NAME);
assertNull("There should be no Camel header", header);
for (Header h : request.getAllHeaders()) {
if (h.getName().startsWith("Camel") || h.getName().startsWith("org.apache.camel")) {
assertNull("There should be no Camel header", h);
}
}
// set ar regular and Camel header
response.setHeader("MyApp", "dude");
response.setHeader(Exchange.TO_ENDPOINT, "foo");
}
}).create();
localServer.start();
super.setUp();
}
Aggregations