summaryrefslogtreecommitdiffstats
path: root/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorn.christian@seime.no>2021-01-25 21:03:06 +0100
committerGitHub <noreply@github.com>2021-01-25 21:03:06 +0100
commite63726c06546e9701539face3aeeb09da8e134f3 (patch)
tree67b1369541122b354a57ac2a2a4e7edb800fcbfe /jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java
parenta86179f3190e78811df7e5dc18a12497d39ce3b1 (diff)
Revert "Refactor LogfileHandler [run-systemtests]"
Diffstat (limited to 'jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java')
-rw-r--r--jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java b/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java
index cd3c174a12e..f76312af61e 100644
--- a/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java
+++ b/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java
@@ -42,14 +42,20 @@ public class LogFileHandlerTestCase {
String pattern = root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S";
long[] rTimes = {1000, 2000, 10000};
+ Formatter formatter = new Formatter() {
+ public String format(LogRecord r) {
+ DateFormat df = new SimpleDateFormat("yyyy.MM.dd:HH:mm:ss.SSS");
+ String timeStamp = df.format(new Date(r.getMillis()));
+ return ("["+timeStamp+"]" + " " + formatMessage(r) + "\n");
+ }
+ };
LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, pattern, rTimes, null, new StringLogWriter());
long now = System.currentTimeMillis();
long millisPerDay = 60*60*24*1000;
long tomorrowDays = (now / millisPerDay) +1;
long tomorrowMillis = tomorrowDays * millisPerDay;
-
- assertThat(tomorrowMillis+1000).isEqualTo(h.logThread.getNextRotationTime(tomorrowMillis));
- assertThat(tomorrowMillis+10000).isEqualTo(h.logThread.getNextRotationTime(tomorrowMillis+3000));
+ assertThat(tomorrowMillis+1000).isEqualTo(h.getNextRotationTime(tomorrowMillis));
+ assertThat(tomorrowMillis+10000).isEqualTo(h.getNextRotationTime(tomorrowMillis+3000));
String message = "test";
h.publish(message);
h.publish( "another test");
@@ -121,7 +127,7 @@ public class LogFileHandlerTestCase {
String longMessage = formatter.format(new LogRecord(Level.INFO, "string which is way longer than the word test"));
handler.publish(longMessage);
- handler.flush();
+ handler.waitDrained();
assertThat(Files.size(Paths.get(firstFile))).isEqualTo(31);
final long expectedSecondFileLength = 72;
long secondFileLength;
@@ -166,7 +172,7 @@ public class LogFileHandlerTestCase {
for (int i = 0; i < logEntries; i++) {
h.publish("test");
}
- h.flush();
+ h.waitDrained();
String f1 = h.getFileName();
assertThat(f1).startsWith(root.getAbsolutePath() + "/logfilehandlertest.");
File uncompressed = new File(f1);