use of com.hotels.styx.api.LiveHttpResponse in project styx by ExpediaGroup.
the class StyxToNettyResponseTranslatorTest method shouldCreateNettyResponseWithoutHeaders.
@Test
public void shouldCreateNettyResponseWithoutHeaders() throws Exception {
LiveHttpResponse styxResponse = new LiveHttpResponse.Builder(OK).version(HTTP_1_1).build();
io.netty.handler.codec.http.HttpResponse nettyResponse = translator.toNettyResponse(styxResponse);
assertThat(nettyResponse.status(), equalTo(io.netty.handler.codec.http.HttpResponseStatus.OK));
assertThat(nettyResponse.protocolVersion(), equalTo(io.netty.handler.codec.http.HttpVersion.HTTP_1_1));
}
use of com.hotels.styx.api.LiveHttpResponse in project styx by ExpediaGroup.
the class StyxToNettyResponseTranslatorTest method shouldCreateNettyResponseWithHostHeader.
@Test
public void shouldCreateNettyResponseWithHostHeader() {
LiveHttpResponse styxResponse = new LiveHttpResponse.Builder(OK).header("Host", "localhost").build();
io.netty.handler.codec.http.HttpResponse nettyResponse = translator.toNettyResponse(styxResponse);
assertTrue(nettyResponse.headers().containsValue("Host", "localhost", false));
}
use of com.hotels.styx.api.LiveHttpResponse in project styx by ExpediaGroup.
the class StaticFileHandlerTest method setsTheContentTypeBasedOnFileExtension.
@ParameterizedTest
@MethodSource("fileTypesProvider")
public void setsTheContentTypeBasedOnFileExtension(String path, CharSequence mediaType) throws Exception {
writeFile(path, mediaType.toString());
handler = new StaticFileHandler(dir);
LiveHttpResponse response = handle(get("/" + path).build());
assertThat(response, hasStatus(OK));
assertThat(response.contentType(), isValue(mediaType.toString()));
}
use of com.hotels.styx.api.LiveHttpResponse in project styx by ExpediaGroup.
the class HttpRequestMessageLoggerTest method logsClientSideResponseDetailsLongFormat.
@Test
public void logsClientSideResponseDetailsLongFormat() {
LiveHttpRequest styxRequest = get("http://www.hotels.com/foo/bar/request").build();
LiveHttpResponse styxResponse = response(OK).build();
new HttpRequestMessageLogger("com.hotels.styx.http-messages.outbound", true, httpMessageFormatter).logResponse(styxRequest, styxResponse);
assertThat(log.lastMessage(), is(loggingEvent(INFO, format("requestId=%s, response=" + FORMATTED_RESPONSE, styxRequest.id()))));
}
use of com.hotels.styx.api.LiveHttpResponse in project styx by ExpediaGroup.
the class HttpRequestMessageLoggerTest method responseLogUnexpectedArguments.
private static Stream<Arguments> responseLogUnexpectedArguments() {
LiveHttpRequest normalRequest = get("http://www.hotels.com/foo/bar/request").build();
LiveHttpResponse normalResponse = response(OK).build();
return Stream.of(Arguments.of(normalRequest, null, WARN, "requestId=.*, response=null"), Arguments.of(null, normalResponse, INFO, "requestId=null, response=\\{version=HTTP/1.1, status=200 OK\\}"), Arguments.of(null, null, WARN, "requestId=null, response=null"));
}
Aggregations