Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve AccessLogSupportTest and fix test with locales other than en_US #998

Merged
merged 1 commit into from
Sep 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ void testHelidonFormat() {
ServerResponse response = mock(ServerResponse.class);
when(response.status()).thenReturn(Http.Status.I_AM_A_TEAPOT);

AccessLogContext accessLogContext = mock(AccessLogContext.class);
when(accessLogContext.requestDateTime()).thenReturn(BEGIN_TIME);
String expectedTimestamp = TimestampLogEntry.create().doApply(accessLogContext);

String logRecord = accessLog.createLogRecord(request,
response,
BEGIN_TIME,
Expand All @@ -77,7 +81,7 @@ void testHelidonFormat() {

//192.168.0.104 - [18/Jun/2019:23:10:44 +0200] "GET /greet/test HTTP/1.1" 200 55 2248

String expected = REMOTE_IP + " - [03/Dec/2007:10:15:30 +0000] \"" + METHOD + " " + PATH + " " + HTTP_VERSION + "\" " +
String expected = REMOTE_IP + " - " + expectedTimestamp + " \"" + METHOD + " " + PATH + " " + HTTP_VERSION + "\" " +
STATUS_CODE + " " + CONTENT_LENGTH + " " + TIME_TAKEN_MICROS;

assertThat(logRecord, is(expected));
Expand All @@ -102,6 +106,10 @@ void testCommonFormat() {
ServerResponse response = mock(ServerResponse.class);
when(response.status()).thenReturn(Http.Status.I_AM_A_TEAPOT);

AccessLogContext accessLogContext = mock(AccessLogContext.class);
when(accessLogContext.requestDateTime()).thenReturn(BEGIN_TIME);
String expectedTimestamp = TimestampLogEntry.create().doApply(accessLogContext);

String logRecord = accessLog.createLogRecord(request,
response,
BEGIN_TIME,
Expand All @@ -111,7 +119,7 @@ void testCommonFormat() {

//192.168.0.104 - [18/Jun/2019:23:10:44 +0200] "GET /greet/test HTTP/1.1" 200 55 2248

String expected = REMOTE_IP + " - - [03/Dec/2007:10:15:30 +0000] \"" + METHOD + " " + PATH + " " + HTTP_VERSION + "\" " +
String expected = REMOTE_IP + " - - " + expectedTimestamp + " \"" + METHOD + " " + PATH + " " + HTTP_VERSION + "\" " +
STATUS_CODE + " " + CONTENT_LENGTH;

assertThat(logRecord, is(expected));
Expand Down Expand Up @@ -151,4 +159,4 @@ void testCustomFormat() {

assertThat(logRecord, is(expected));
}
}
}