use of com.hotels.styx.api.HttpResponse 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());
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class CurrentRequestsHandlerTest method testStackTraceForSentRequest.
@Test
public void testStackTraceForSentRequest() {
Thread.currentThread().setName("Test-Thread-1");
tracker.trackRequest(req1);
tracker.markRequestAsSent(req1);
HttpResponse response = Mono.from(handler.handle(adminRequest, requestContext())).block();
assertThat(response.bodyAs(UTF_8).contains("Request state: Waiting response from origin."), is(true));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class CurrentRequestsHandlerTest method testWithStackTrace.
@Test
public void testWithStackTrace() {
Thread.currentThread().setName("Test-Thread");
tracker.trackRequest(req1);
HttpResponse response = Mono.from(handler.handle(HttpRequest.get("/req?withStackTrace=true").build(), requestContext())).block();
assertTrue(response.bodyAs(UTF_8).contains("Thread Info:"));
assertTrue(response.bodyAs(UTF_8).contains("id=" + Thread.currentThread().getId() + " state"));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class IndexHandlerTest method printsTheRegisteredPaths.
@Test
public void printsTheRegisteredPaths() {
HttpResponse response = Mono.from(handler.handle(get("/admin").build(), requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(response.contentType().map(String::toLowerCase).get(), is("text/html; charset=utf-8"));
assertThat(response.bodyAs(UTF_8), is("<html><body><ol style='list-style-type: none; padding-left: 0px; margin-left: 0px;'>" + "<li><a href='/admin/foo'>Abc</a></li>" + "<li><a href='/admin/bar'>Xyz</a></li>" + "</ol></body></html>"));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class JVMMetricsHandlerTest method exposesAllMetricsStartingWithJvm.
@Test
public void exposesAllMetricsStartingWithJvm() {
HttpResponse response = call(get("/jvm").build());
assertThat(response.bodyAs(UTF_8), containsStrings("jvm.foo.gauge", "jvm.bar.counter", "jvm.baz.meter", "jvm.hello.timer", "jvm.world.histogram"));
}
Aggregations