use of com.hotels.styx.api.HttpRequest in project styx by ExpediaGroup.
the class StyxHttpClientTest method requestWithNoHostOrUrlAuthorityCausesException.
/*
* StyxHttpClient
* - Rejects requests without URL authority or host header
*/
@Test
public void requestWithNoHostOrUrlAuthorityCausesException() {
HttpRequest request = get("/foo.txt").build();
StyxHttpClient client = new StyxHttpClient.Builder().build();
assertThrows(IllegalArgumentException.class, () -> await(client.send(request)));
}
use of com.hotels.styx.api.HttpRequest in project styx by ExpediaGroup.
the class JsonHandlerTest method prettyPrintsOutputWhenPrettyIsSetToTrue.
@Test
public void prettyPrintsOutputWhenPrettyIsSetToTrue() {
HttpRequest request = get("/?pretty=true").build();
Supplier<Convertible> supplier = sequentialSupplier(new Convertible("foo", 456));
JsonHandler<Convertible> handler = new JsonHandler<>(supplier, Optional.empty());
assertThat(responseFor(handler, request), is("{\n" + " \"string\" : \"foo\",\n" + " \"integer\" : 456\n" + "}"));
}
use of com.hotels.styx.api.HttpRequest in project styx by ExpediaGroup.
the class PluginToggleHandlerTest method disablesEnabledPlugin.
@Test
public void disablesEnabledPlugin() {
HttpRequest request = put("/foo/on/enabled").body("false", UTF_8).build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(body(response), is("{\"message\":\"State of 'on' changed to 'disabled'\",\"plugin\":{\"name\":\"on\",\"state\":\"disabled\"}}"));
assertThat(initiallyEnabled.enabled(), is(false));
assertThat(initiallyDisabled.enabled(), is(false));
}
use of com.hotels.styx.api.HttpRequest in project styx by ExpediaGroup.
the class PluginToggleHandlerTest method saysBadRequestWhenNoStateSpecified.
@Test
public void saysBadRequestWhenNoStateSpecified() {
HttpRequest request = put("/foo/on/enabled").build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), is(BAD_REQUEST));
assertThat(body(response), is("No such state: only 'true' and 'false' are valid."));
assertThat(initiallyEnabled.enabled(), is(true));
assertThat(initiallyDisabled.enabled(), is(false));
}
use of com.hotels.styx.api.HttpRequest in project styx by ExpediaGroup.
the class PluginToggleHandlerTest method enablesDisabledPlugin.
@Test
public void enablesDisabledPlugin() {
HttpRequest request = put("/foo/off/enabled").body("true", UTF_8).build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(body(response), is("{\"message\":\"State of 'off' changed to 'enabled'\",\"plugin\":{\"name\":\"off\",\"state\":\"enabled\"}}"));
assertThat(initiallyEnabled.enabled(), is(true));
assertThat(initiallyDisabled.enabled(), is(true));
}
Aggregations