use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class JVMMetricsHandlerTest method respondsToRequestWithJsonResponse.
@Test
public void respondsToRequestWithJsonResponse() {
HttpResponse response = call(get("/jvm").build());
assertThat(response.status(), is(OK));
assertThat(response.contentType().get(), is(APPLICATION_JSON.toString()));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class LoggingConfigurationHandlerTest method showsErrorMessageInContentIfLogConfigFileDoesNotExist.
@Test
public void showsErrorMessageInContentIfLogConfigFileDoesNotExist() {
StartupConfig startupConfig = newStartupConfigBuilder().logbackConfigLocation("/foo/bar").build();
LoggingConfigurationHandler handler = new LoggingConfigurationHandler(startupConfig.logConfigLocation());
HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(response.bodyAs(UTF_8), matchesRegex("Could not load resource=.*foo[\\\\/]bar'"));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class MetricsHandlerTest method canRequestMetricsBeginningWithPrefix.
@Test
public void canRequestMetricsBeginningWithPrefix() {
metricRegistry.counter("foo.bar").inc(1);
metricRegistry.counter("foo.bar.baz").inc(1);
// should not be included
metricRegistry.counter("foo.barx").inc(1);
HttpResponse response = Mono.from(handler.handle(get("/admin/metrics/foo.bar").build(), requestContext())).block();
assertThat(response.bodyAs(UTF_8), is("{\"foo.bar\":{\"count\":1},\"foo.bar.baz\":{\"count\":1}}"));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class MetricsHandlerTest method searchReturnsEmptyJsonObjectWhenThereAreNoResults.
@Test
public void searchReturnsEmptyJsonObjectWhenThereAreNoResults() {
metricRegistry.counter("foo.bar.a").inc(1);
metricRegistry.counter("foo.bar.b").inc(1);
HttpResponse response = Mono.from(handler.handle(get("/admin/metrics/?filter=notpresent").build(), requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(response.bodyAs(UTF_8), is("{}"));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class MetricsHandlerTest method canSearchForTermWithinMetricName.
@Test
public void canSearchForTermWithinMetricName() {
metricRegistry.counter("foo.bar.a").inc(1);
metricRegistry.counter("foo.bar.b").inc(1);
metricRegistry.counter("baz.bar.foo").inc(1);
metricRegistry.counter("foo.baz.a").inc(1);
HttpResponse response = Mono.from(handler.handle(get("/admin/metrics/?filter=bar").build(), requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(response.bodyAs(UTF_8), is("{" + "\"baz.bar.foo\":{\"count\":1}," + "\"foo.bar.a\":{\"count\":1}," + "\"foo.bar.b\":{\"count\":1}" + "}"));
}
Aggregations