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

[UNDERTOW-1574] Failing access log tests due to different new-line ch… #792

Merged
merged 1 commit into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
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 @@ -109,7 +109,7 @@ private void verifySingleLogMessageToFile(Path logFileName, DefaultAccessLogRece
Assert.assertEquals("Hello", HttpClientUtils.readResponse(result));
latchHandler.await();
logReceiver.awaitWrittenForTest();
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header single-val - [d, d]\n", new String(Files.readAllBytes(logFileName)));
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header single-val - [d, d]" + System.lineSeparator(), new String(Files.readAllBytes(logFileName)));
} finally {
client.getConnectionManager().shutdown();
}
Expand Down Expand Up @@ -188,12 +188,12 @@ public void testForcedLogRotation() throws IOException, InterruptedException {
latchHandler.await();
latchHandler.reset();
logReceiver.awaitWrittenForTest();
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header v1\n", new String(Files.readAllBytes(logFileName)));
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header v1" + System.lineSeparator(), new String(Files.readAllBytes(logFileName)));
logReceiver.rotate();
logReceiver.awaitWrittenForTest();
Assert.assertFalse(Files.exists(logFileName));
Path firstLogRotate = logDirectory.resolve("server." + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".log");
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header v1\n", new String(Files.readAllBytes(firstLogRotate)));
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header v1" + System.lineSeparator(), new String(Files.readAllBytes(firstLogRotate)));

get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path");
get.addHeader("test-header", "v2");
Expand All @@ -203,12 +203,12 @@ public void testForcedLogRotation() throws IOException, InterruptedException {
latchHandler.await();
latchHandler.reset();
logReceiver.awaitWrittenForTest();
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header v2\n", new String(Files.readAllBytes(logFileName)));
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header v2" + System.lineSeparator(), new String(Files.readAllBytes(logFileName)));
logReceiver.rotate();
logReceiver.awaitWrittenForTest();
Assert.assertFalse(Files.exists(logFileName));
Path secondLogRotate = logDirectory.resolve("server." + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + "-1.log");
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header v2\n", new String(Files.readAllBytes(secondLogRotate)));
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header v2" + System.lineSeparator(), new String(Files.readAllBytes(secondLogRotate)));

} finally {
client.getConnectionManager().shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void verifySingleLogMessageToFile(Path logFileName, DefaultAccessLogRece
latchHandler.await();
logReceiver.awaitWrittenForTest();
String data = new String(Files.readAllBytes(logFileName));
String[] lines = data.split("\n");
String[] lines = data.split(System.lineSeparator());
Assert.assertEquals("#Fields: " + PATTERN, lines[0]);
Assert.assertEquals("#Version: 2.0", lines[1]);
Assert.assertEquals("#Software: " + Version.getFullVersionString(), lines[2]);
Expand Down