use of org.apache.http.protocol.HttpRequestHandler in project camel by apache.
the class Http4EndpointTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
localServer = new HttpTestServer(null, null);
localServer.register("/", new HttpRequestHandler() {
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
response.setStatusCode(HttpStatus.SC_OK);
response.setEntity(new StringEntity("OK", Consts.ISO_8859_1));
}
});
localServer.start();
}
use of org.apache.http.protocol.HttpRequestHandler in project camel by apache.
the class Http4MaxConnectionPerHostTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
localServer = new HttpTestServer(null, null);
localServer.register("/", new HttpRequestHandler() {
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
response.setStatusCode(HttpStatus.SC_OK);
response.setEntity(new StringEntity("OK", Consts.ISO_8859_1));
}
});
localServer.start();
}
use of org.apache.http.protocol.HttpRequestHandler in project camel by apache.
the class HttpConcurrentTest method setUp.
@Before
@Override
public void setUp() throws Exception {
localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor()).setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory()).setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("/", new HttpRequestHandler() {
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// ignore
}
response.setStatusCode(HttpStatus.SC_OK);
response.setEntity(new StringEntity("" + counter.incrementAndGet()));
}
}).create();
localServer.start();
super.setUp();
}
use of org.apache.http.protocol.HttpRequestHandler in project camel by apache.
the class HttpProducerTwoHeadersWithSameKeyTest method setUp.
@Before
@Override
public void setUp() throws Exception {
localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor()).setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory()).setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("/myapp", new HttpRequestHandler() {
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
Header[] from = request.getHeaders("from");
assertEquals("me", from[0].getValue());
Header[] to = request.getHeaders("to");
assertEquals("[foo, bar]", to[0].getValue());
response.setHeader("bar", "yes");
response.addHeader("foo", "123");
response.addHeader("foo", "456");
response.setEntity(new StringEntity("OK", "ASCII"));
response.setStatusCode(HttpStatus.SC_OK);
}
}).registerHandler("/myapp", new HttpRequestHandler() {
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
Header[] from = request.getHeaders("from");
assertEquals("me", from[0].getValue());
Header[] to = request.getHeaders("to");
assertEquals("[foo, bar]", to[0].getValue());
response.setHeader("bar", "yes");
response.addHeader("foo", "123");
response.addHeader("foo", "456");
response.setEntity(new StringEntity("OK", "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 HttpProducerTwoParametersWithSameKeyTest method setUp.
@Before
@Override
public void setUp() throws Exception {
localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor()).setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory()).setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("/myapp", new HttpRequestHandler() {
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
String uri = request.getRequestLine().getUri();
assertEquals("/myapp?from=me&to=foo&to=bar", uri);
response.setHeader("bar", "yes");
response.addHeader("foo", "123");
response.addHeader("foo", "456");
response.setEntity(new StringEntity("OK", "ASCII"));
response.setStatusCode(HttpStatus.SC_OK);
}
}).create();
localServer.start();
super.setUp();
}
Aggregations