Search in sources :

Example 16 with HttpResponse

use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.

the class VersionTextHandlerTest method canProvideASingleVersionTextFile.

@Test
public void canProvideASingleVersionTextFile() {
    VersionTextHandler handler = new VersionTextHandler(resources("classpath:/versions/version1.txt"));
    HttpResponse response = Mono.from(handler.handle(get("/version.txt").build(), requestContext())).block();
    assertThat(response.bodyAs(UTF_8), is("foo\n"));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) Test(org.junit.jupiter.api.Test)

Example 17 with HttpResponse

use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.

the class CurrentRequestsHandlerTest method testWithoutStackTrace.

@Test
public void testWithoutStackTrace() {
    tracker.trackRequest(req1);
    HttpResponse response = Mono.from(handler.handle(adminRequest, requestContext())).block();
    String body = response.bodyAs(UTF_8);
    assertFalse(body.contains(format("id=%d state", Thread.currentThread().getId())), format("This is received response body: ```%s```", body));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) Test(org.junit.jupiter.api.Test)

Example 18 with HttpResponse

use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.

the class CurrentRequestsHandlerTest method testStackTrace.

@Test
public void testStackTrace() {
    Thread.currentThread().setName("Test-Thread");
    tracker.trackRequest(req1);
    HttpResponse response = Mono.from(handler.handle(adminRequest, requestContext())).block();
    assertThat(response.bodyAs(UTF_8).contains("Test-Thread"), is(true));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) Test(org.junit.jupiter.api.Test)

Example 19 with HttpResponse

use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.

the class JVMMetricsHandlerTest method doesNotExposeIrrelevantMetrics.

@Test
public void doesNotExposeIrrelevantMetrics() {
    HttpResponse response = call(get("/jvm").build());
    assertThat(response.bodyAs(UTF_8), is(not(containsString("irrelevant"))));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) Test(org.junit.jupiter.api.Test)

Example 20 with HttpResponse

use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.

the class LoggingConfigurationHandlerTest method showsLogConfigContent.

@Test
public void showsLogConfigContent() throws IOException {
    StartupConfig startupConfig = newStartupConfigBuilder().logbackConfigLocation(fixturesHome() + "/conf/environment/styx-config-test.yml").build();
    LoggingConfigurationHandler handler = new LoggingConfigurationHandler(startupConfig.logConfigLocation());
    HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
    String expected = Resources.load(new ClasspathResource("conf/environment/styx-config-test.yml", LoggingConfigurationHandlerTest.class));
    assertThat(response.status(), is(OK));
    assertThat(response.bodyAs(UTF_8), is(expected));
}
Also used : ClasspathResource(com.hotels.styx.common.io.ClasspathResource) HttpResponse(com.hotels.styx.api.HttpResponse) StartupConfig(com.hotels.styx.StartupConfig) Test(org.junit.jupiter.api.Test)

Aggregations

HttpResponse (com.hotels.styx.api.HttpResponse)107 Test (org.junit.jupiter.api.Test)99 LiveHttpResponse (com.hotels.styx.api.LiveHttpResponse)30 HttpRequest (com.hotels.styx.api.HttpRequest)18 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 Eventual (com.hotels.styx.api.Eventual)10 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)9 StyxHttpClient (com.hotels.styx.client.StyxHttpClient)8 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)8 TlsSettings (com.hotels.styx.api.extension.service.TlsSettings)7 StyxObjectRecord (com.hotels.styx.StyxObjectRecord)6 HttpHandler (com.hotels.styx.api.HttpHandler)6 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)6 OK (com.hotels.styx.api.HttpResponseStatus.OK)5 HttpClient (com.hotels.styx.client.HttpClient)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 HttpInterceptor (com.hotels.styx.api.HttpInterceptor)4 Plugin (com.hotels.styx.api.plugins.spi.Plugin)4 PluginFactory (com.hotels.styx.api.plugins.spi.PluginFactory)4 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)3