summaryrefslogtreecommitdiffstats
path: root/vespalog
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2019-03-04 15:19:21 +0100
committergjoranv <gv@verizonmedia.com>2019-03-04 15:21:23 +0100
commit89e0a748bd591a4279683fe28a05a49c1a3e53d1 (patch)
treea7d5627c4a5868fbcadb9de02f9ab38022461019 /vespalog
parent9f16e096695672c95f36bda6348d659b7fbab2eb (diff)
JDK 11: Replace LogRecord.setMillis with setInstant.
- Suppress deprecation warnings locally instead of globally in controller-server.
Diffstat (limited to 'vespalog')
-rw-r--r--vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java13
-rw-r--r--vespalog/src/test/java/com/yahoo/log/VespaFormatterTestCase.java25
-rw-r--r--vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java12
3 files changed, 25 insertions, 25 deletions
diff --git a/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java b/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java
index d476b111e4f..d0e2baf47c5 100644
--- a/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java
+++ b/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java
@@ -2,6 +2,7 @@
package com.yahoo.log;
import java.io.IOException;
+import java.time.Instant;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.Level;
@@ -20,8 +21,6 @@ import static org.hamcrest.CoreMatchers.is;
*
* @author Bjorn Borud
*/
-// TODO: Remove annotation and replace setMillis with setInstant when we don't support Java 8 anymore.
-@SuppressWarnings("deprecation")
public class LogSetupTestCase {
// For testing zookeeper log records
protected static LogRecord zookeeperLogRecord;
@@ -44,11 +43,11 @@ public class LogSetupTestCase {
zookeeperLogRecord = new LogRecord(Level.WARNING, "zookeeper log record");
zookeeperLogRecord.setLoggerName("org.apache.zookeeper.server.NIOServerCnxn");
- zookeeperLogRecord.setMillis(1107011348029L);
+ zookeeperLogRecord.setInstant(Instant.ofEpochMilli(1107011348029L));
curatorLogRecord = new LogRecord(Level.WARNING, "curator log record");
curatorLogRecord.setLoggerName("org.apache.curator.utils.DefaultTracerDriver");
- curatorLogRecord.setMillis(1107011348029L);
+ curatorLogRecord.setInstant(Instant.ofEpochMilli(1107011348029L));
hostname = Util.getHostName();
pid = Util.getPID();
@@ -62,15 +61,15 @@ public class LogSetupTestCase {
zookeeperLogRecordError = new LogRecord(Level.SEVERE, "zookeeper error");
zookeeperLogRecordError.setLoggerName("org.apache.zookeeper.server.NIOServerCnxn");
- zookeeperLogRecordError.setMillis(1107011348029L);
+ zookeeperLogRecordError.setInstant(Instant.ofEpochMilli(1107011348029L));
curatorLogRecordError = new LogRecord(Level.SEVERE, "curator log record");
curatorLogRecordError.setLoggerName("org.apache.curator.utils.DefaultTracerDriver");
- curatorLogRecordError.setMillis(1107011348029L);
+ curatorLogRecordError.setInstant(Instant.ofEpochMilli(1107011348029L));
notzookeeperLogRecord = new LogRecord(Level.WARNING, "not zookeeper log record");
notzookeeperLogRecord.setLoggerName("org.apache.foo.Bar");
- notzookeeperLogRecord.setMillis(1107011348029L);
+ notzookeeperLogRecord.setInstant(Instant.ofEpochMilli(1107011348029L));
}
@Test
diff --git a/vespalog/src/test/java/com/yahoo/log/VespaFormatterTestCase.java b/vespalog/src/test/java/com/yahoo/log/VespaFormatterTestCase.java
index 9da71b2ad2e..cbfbd609f61 100644
--- a/vespalog/src/test/java/com/yahoo/log/VespaFormatterTestCase.java
+++ b/vespalog/src/test/java/com/yahoo/log/VespaFormatterTestCase.java
@@ -1,21 +1,22 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.log;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-import org.junit.Test;
import org.junit.Before;
import org.junit.Ignore;
+import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.is;
+import java.time.Instant;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author Bjorn Borud
*/
-// TODO: Remove annotation and replace setMillis with setInstant when we don't support Java 8 anymore.
-@SuppressWarnings("deprecation")
public class VespaFormatterTestCase {
private String hostname;
@@ -36,7 +37,7 @@ public class VespaFormatterTestCase {
pid = Util.getPID();
testRecord1 = new LogRecord(Level.INFO, "this is a test");
- testRecord1.setMillis(1098709021843L);
+ testRecord1.setInstant(Instant.ofEpochMilli(1098709021843L));
testRecord1.setThreadID(123);
expected1 = "1098709021.843\t"
@@ -59,7 +60,7 @@ public class VespaFormatterTestCase {
testRecord2 = new LogRecord(Level.INFO, "this is a test");
- testRecord2.setMillis(1098709021843L);
+ testRecord2.setInstant(Instant.ofEpochMilli(1098709021843L));
testRecord2.setThreadID(123);
testRecord2.setLoggerName("org.foo");
@@ -100,12 +101,12 @@ public class VespaFormatterTestCase {
/**
* test that {0} etc is replaced properly
*/
- @Test
+ @Test
public void testTextFormatting () {
VespaFormatter formatter = new VespaFormatter(serviceName, app);
LogRecord testRecord = new LogRecord(Level.INFO, "this {1} is {0} test");
- testRecord.setMillis(1098709021843L);
+ testRecord.setInstant(Instant.ofEpochMilli(1098709021843L));
testRecord.setThreadID(123);
testRecord.setLoggerName("org.foo");
Object[] params = { "a small", "message" };
diff --git a/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java b/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java
index 5cbd130c05a..d18bce2f4ec 100644
--- a/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java
+++ b/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java
@@ -6,6 +6,7 @@ import org.junit.Before;
import org.junit.Test;
import java.io.*;
+import java.time.Instant;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.BrokenBarrierException;
@@ -14,14 +15,13 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
+import static java.time.Instant.ofEpochMilli;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
/**
* @author Bjorn Borud
*/
-// TODO: Remove annotation and replace setMillis with setInstant when we don't support Java 8 anymore.
-@SuppressWarnings("deprecation")
public class VespaLogHandlerTestCase {
protected static String hostname;
protected static String pid;
@@ -43,7 +43,7 @@ public class VespaLogHandlerTestCase {
pid = Util.getPID();
record1 = new LogRecord(Level.INFO, "This is a test");
- record1.setMillis(1100011348029L);
+ record1.setInstant(ofEpochMilli(1100011348029L));
record1String = "1100011348.029\t"
+ hostname
+ "\t"
@@ -53,7 +53,7 @@ public class VespaLogHandlerTestCase {
+ "\tmy-test-config-id\tTST\tinfo\tThis is a test";
record2 = new LogRecord(Level.FINE, "This is a test too");
- record2.setMillis(1100021348029L);
+ record2.setInstant(ofEpochMilli(1100021348029L));
record2.setLoggerName("com.yahoo.log.test");
record2String = "1100021348.029\t"
+ hostname
@@ -63,7 +63,7 @@ public class VespaLogHandlerTestCase {
record3 = new LogRecord(Level.WARNING, "another test");
record3.setLoggerName("com.yahoo.log.test");
- record3.setMillis(1107011348029L);
+ record3.setInstant(ofEpochMilli(1107011348029L));
record3String = "1107011348.029\t"
+ hostname
+ "\t"
@@ -73,7 +73,7 @@ public class VespaLogHandlerTestCase {
record4 = new LogRecord(Level.WARNING, "unicode \u00E6\u00F8\u00E5 test \u7881 unicode");
record4.setLoggerName("com.yahoo.log.test");
- record4.setMillis(1107011348029L);
+ record4.setInstant(ofEpochMilli(1107011348029L));
record4String = "1107011348.029\t"
+ hostname
+ "\t"