use of com.hotels.styx.common.logging.HttpRequestMessageLogger in project styx by ExpediaGroup.
the class HttpRequestMessageLoggerTest method requestLoggingDoesNotThrowExceptionWhenReceivingNullArguments.
@Test
public void requestLoggingDoesNotThrowExceptionWhenReceivingNullArguments() {
new HttpRequestMessageLogger("com.hotels.styx.http-messages.outbound", false, httpMessageFormatter).logRequest(null, origin, true);
assertThat(log.lastMessage(), is(loggingEvent(WARN, "requestId=N/A, origin=MyApp:h1:hostA:80, request=null")));
}
use of com.hotels.styx.common.logging.HttpRequestMessageLogger 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.common.logging.HttpRequestMessageLogger in project styx by ExpediaGroup.
the class HttpRequestMessageLoggerTest method logsClientSideResponseDetailsShortFormat.
@Test
public void logsClientSideResponseDetailsShortFormat() {
LiveHttpRequest styxRequest = get("http://www.hotels.com/foo/bar/request").build();
LiveHttpResponse styxResponse = response(OK).build();
new HttpRequestMessageLogger("com.hotels.styx.http-messages.outbound", false, httpMessageFormatter).logResponse(styxRequest, styxResponse);
assertThat(log.lastMessage(), is(loggingEvent(INFO, format("requestId=%s, response=\\{version=HTTP/1.1, status=200 OK\\}", styxRequest.id()))));
}
use of com.hotels.styx.common.logging.HttpRequestMessageLogger in project styx by ExpediaGroup.
the class HttpRequestMessageLoggerTest method responseLoggingDoesNotThrowExceptionWhenReceivingNullArguments.
@ParameterizedTest
@MethodSource("responseLogUnexpectedArguments")
public void responseLoggingDoesNotThrowExceptionWhenReceivingNullArguments(LiveHttpRequest request, LiveHttpResponse response, Level expectedLogLevel, String expectedLogMessage) {
new HttpRequestMessageLogger("com.hotels.styx.http-messages.outbound", false, httpMessageFormatter).logResponse(request, response);
assertThat(log.lastMessage(), is(loggingEvent(expectedLogLevel, expectedLogMessage)));
}
use of com.hotels.styx.common.logging.HttpRequestMessageLogger in project styx by ExpediaGroup.
the class HttpRequestMessageLoggerTest method logsClientSideRequestLongFormat.
@Test
public void logsClientSideRequestLongFormat() {
LiveHttpRequest styxRequest = get("http://www.hotels.com/foo/bar/request").build();
new HttpRequestMessageLogger("com.hotels.styx.http-messages.outbound", true, httpMessageFormatter).logRequest(styxRequest, origin, true);
assertThat(log.lastMessage(), is(loggingEvent(INFO, format("requestId=%s, secure=true, origin=%s, request=" + FORMATTED_REQUEST, styxRequest.id(), origin))));
}
Aggregations