use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class StyxProxyTest method startsServerWithBothHttpAndHttpsConnectors.
@Disabled
@Test
public void startsServerWithBothHttpAndHttpsConnectors() throws IOException {
Service server = StyxServers.toGuavaService(newBuilder().setProtocolConnector(connector(0)).build());
server.startAsync().awaitRunning();
assertThat("Server should be running", server.isRunning());
LOGGER.info("server is running: " + server.isRunning());
HttpResponse clearResponse = get("http://localhost:8080/search?q=fanta");
assertThat(clearResponse.bodyAs(UTF_8), containsString("Response from http Connector"));
HttpResponse secureResponse = get("https://localhost:8443/secure");
assertThat(secureResponse.bodyAs(UTF_8), containsString("Response from https 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 StyxHttpClientTest method sendsMessagesInOriginUrlFormat.
/*
* StyxHttpClient
* - Sends a request when HTTP "request-target" is in origin format.
* - Ref: https://tools.ietf.org/html/rfc7230#section-5.3.1
*/
@Test
public void sendsMessagesInOriginUrlFormat() throws ExecutionException, InterruptedException {
HttpResponse response = new StyxHttpClient.Builder().build().send(get("/index.html").header(HOST, hostString(server.port())).build()).get();
assertThat(response.status(), is(OK));
server.verify(getRequestedFor(urlEqualTo("/index.html")).withHeader("Host", equalTo(hostString(server.port()))));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class StyxHttpClientTest method usesDefaultUserAgent.
/*
* StyxHttpClient
* - Uses default user-agent string.
*/
@Test
public void usesDefaultUserAgent() throws ExecutionException, InterruptedException {
StyxHttpClient client = new StyxHttpClient.Builder().userAgent("Simple-Client-Parent-Settings").build();
HttpResponse response = client.send(httpRequest).get();
assertThat(response.status(), is(OK));
server.verify(getRequestedFor(urlEqualTo("/")).withHeader("User-Agent", equalTo("Simple-Client-Parent-Settings")));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class StyxHttpClientTest method usesDefaultTlsSettings.
/*
* StyxHttpClient
* - Applies default TLS settings
*/
@Test
public void usesDefaultTlsSettings() throws ExecutionException, InterruptedException {
StyxHttpClient client = new StyxHttpClient.Builder().tlsSettings(new TlsSettings.Builder().build()).build();
HttpResponse response = client.send(secureRequest).get();
assertThat(response.status(), is(OK));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class AbstractStyxServiceTest method exposesNameAndStatusViaAdminInterface.
@Test
public void exposesNameAndStatusViaAdminInterface() throws ExecutionException, InterruptedException {
DerivedStyxService service = new DerivedStyxService("derived-service", new CompletableFuture<>());
HttpResponse response = Mono.from(service.adminInterfaceHandlers().get("status").handle(get, MOCK_CONTEXT).flatMap(r -> r.aggregate(1024))).block();
assertThat(response.bodyAs(UTF_8), is("{ name: \"derived-service\" status: \"CREATED\" }"));
}
Aggregations