use of com.hotels.styx.api.HttpResponseStatus.OK in project styx by ExpediaGroup.
the class StandardHttpPipelineTest method sendsExceptionUponExtraSubscriptionInsideInterceptor.
@ParameterizedTest
@MethodSource("multipleSubscriptionInterceptors")
public void sendsExceptionUponExtraSubscriptionInsideInterceptor(HttpInterceptor interceptor) throws Exception {
HttpHandler handler = (request, context) -> Eventual.of(response(OK).build());
List<HttpInterceptor> interceptors = singletonList(interceptor);
StandardHttpPipeline pipeline = new StandardHttpPipeline(interceptors, handler, RequestTracker.NO_OP);
Eventual<LiveHttpResponse> responseObservable = pipeline.handle(get("/").build(), requestContext());
assertThrows(IllegalStateException.class, () -> Mono.from(responseObservable).block());
}
use of com.hotels.styx.api.HttpResponseStatus.OK in project styx by ExpediaGroup.
the class StandardHttpPipelineTest method sendsExceptionUponMultipleSubscription.
@Test
public void sendsExceptionUponMultipleSubscription() {
HttpHandler handler = (request, context) -> Eventual.of(response(OK).build());
StandardHttpPipeline pipeline = new StandardHttpPipeline(handler);
Eventual<LiveHttpResponse> responseObservable = pipeline.handle(get("/").build(), requestContext());
LiveHttpResponse response = Mono.from(responseObservable).block();
assertThat(response.status(), is(OK));
assertThrows(IllegalStateException.class, () -> Mono.from(responseObservable).block());
}
use of com.hotels.styx.api.HttpResponseStatus.OK in project styx by ExpediaGroup.
the class InstrumentedPluginTest method metricIsRecordedWhenResponseIsMappedToErrorStatus.
@Test
public void metricIsRecordedWhenResponseIsMappedToErrorStatus() {
Chain chain = request -> aResponse(OK);
String pluginName = "replaceStatus1";
InstrumentedPlugin plugin = instrumentedPlugin(pluginName, (request, aChain) -> aChain.proceed(request).map(response -> responseWithNewStatusCode(response, INTERNAL_SERVER_ERROR)));
LiveHttpResponse response = Mono.from(plugin.intercept(someRequest, chain)).block();
assertThat(response.status(), is(INTERNAL_SERVER_ERROR));
assertThat(getStatusCount(pluginName, "500"), is(1.0));
assertThat(getErrorCount(pluginName), is(1.0));
}
use of com.hotels.styx.api.HttpResponseStatus.OK in project styx by ExpediaGroup.
the class UrlRequestHealthCheckTest method declaresOriginHealthyOnOkResponseCode.
@Test
public void declaresOriginHealthyOnOkResponseCode() {
HttpClient client = request -> respondWith(OK);
new UrlRequestHealthCheck("/version.txt", metrics).check(client, someOrigin, state -> this.originState = state);
assertThat(originState, is(HEALTHY));
assertThat(meters(id -> id.getName().equals("proxy.client.originHealthCheckFailures")).size(), is(0));
}
use of com.hotels.styx.api.HttpResponseStatus.OK in project styx by ExpediaGroup.
the class StyxServerTest method addsEndpointLinksToPluginPage.
@Test
public void addsEndpointLinksToPluginPage() {
setUpStyxAndPluginWithAdminPages(Map.of("adminPage1", (request, ctx) -> Eventual.of(LiveHttpResponse.response().build()), "adminPage2", (request, ctx) -> Eventual.of(LiveHttpResponse.response().build())));
HttpResponse response = doAdminRequest("/admin/plugins/plugin-with-admin-pages");
assertThat(response.status(), is(OK));
assertThat(response.bodyAs(UTF_8), allOf(containsString("/admin/plugins/plugin-with-admin-pages/adminPage1"), containsString("/admin/plugins/plugin-with-admin-pages/adminPage2")));
}
Aggregations