use of com.hotels.styx.routing.handlers.HttpInterceptorPipeline in project styx by ExpediaGroup.
the class StyxProxyTest method startsServerWithHttpConnector.
@Test
public void startsServerWithHttpConnector() {
HttpInterceptor echoInterceptor = (request, chain) -> textResponse("Response from http connector");
StandardHttpRouter handler = new StandardHttpRouter();
InetServer styxServer = newBuilder().setProtocolConnector(connector(0)).bossExecutor(NettyExecutor.create("Test-Server-Boss", 1)).workerExecutor(NettyExecutor.create("Test-Server-Worker", 0)).handler(new HttpInterceptorPipeline(List.of(echoInterceptor), (request, context) -> new HttpAggregator(new StandardHttpRouter()).handle(request, context), false)).build();
Service server = StyxServers.toGuavaService(styxServer);
server.startAsync().awaitRunning();
assertThat("Server should be running", server.isRunning());
HttpResponse secureResponse = get("http://localhost:" + styxServer.inetAddress().getPort());
assertThat(secureResponse.bodyAs(UTF_8), containsString("Response from http connector"));
server.stopAsync().awaitTerminated();
assertThat("Server should not be running", !server.isRunning());
}
Aggregations