Skip to content

Commit

Permalink
Merge pull request #792 from jstourac/accessLogTestsFix
Browse files Browse the repository at this point in the history
[UNDERTOW-1574] Failing access log tests due to different new-line ch…
  • Loading branch information
fl4via committed Jul 29, 2019
2 parents 0b97ab2 + 9c570a7 commit 8b2bb8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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

0 comments on commit 8b2bb8b

Please sign in to comment.