aboutsummaryrefslogtreecommitdiffstats
path: root/vespalog
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-08-11 21:19:39 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-08-11 21:19:39 +0000
commit9435133c1fe4ef65ec1d9fe1b9d90677b76bbcfe (patch)
tree7f6fa87d653b183821126df3e5ef4ded313b4db5 /vespalog
parenta9775442179fd17067cd351051d803920c0d74fc (diff)
Stick to junit for simple test.
Diffstat (limited to 'vespalog')
-rw-r--r--vespalog/src/test/java/com/yahoo/log/FileLogTargetTest.java6
-rw-r--r--vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java13
-rw-r--r--vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java26
3 files changed, 19 insertions, 26 deletions
diff --git a/vespalog/src/test/java/com/yahoo/log/FileLogTargetTest.java b/vespalog/src/test/java/com/yahoo/log/FileLogTargetTest.java
index e449e7135d3..63fe2fd8d70 100644
--- a/vespalog/src/test/java/com/yahoo/log/FileLogTargetTest.java
+++ b/vespalog/src/test/java/com/yahoo/log/FileLogTargetTest.java
@@ -8,10 +8,8 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -43,6 +41,6 @@ public class FileLogTargetTest {
assertNotNull(out1);
OutputStream out2 = logTarget.open();
assertNotNull(out2);
- assertThat(out1, is(not(out2)));
+ assertNotEquals(out1, out2);
}
}
diff --git a/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java b/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java
index 230744bb26f..d1863d1ad6d 100644
--- a/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java
+++ b/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java
@@ -9,16 +9,13 @@ import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
-import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -128,12 +125,12 @@ public class LogSetupTestCase {
public void testZooKeeperFilter() throws IOException {
final File file = folder.newFile("zookeeper");
LogSetup.ZooKeeperFilter filter = new LogSetup.ZooKeeperFilter(file.getAbsolutePath());
- assertThat(filter.isLoggable(zookeeperLogRecord), is(false));
- //assertThat(filter.isLoggable(zookeeperLogRecordError), is(true));
- assertThat(filter.isLoggable(notzookeeperLogRecord), is(true));
+ assertFalse(filter.isLoggable(zookeeperLogRecord));
+ //assertTrue(filter.isLoggable(zookeeperLogRecordError));
+ assertTrue(filter.isLoggable(notzookeeperLogRecord));
File actualLogFile = new File(file.getParent(), "zookeeper.0.log"); // Real file name will have .0.log appended
String[] lines = VespaLogHandlerTestCase.readFile(actualLogFile.getAbsolutePath());
- assertThat(lines.length, is(1));
+ assertEquals(1, lines.length);
assertEquals(zookeeperLogRecordString, lines[0]);
}
@@ -146,7 +143,7 @@ public class LogSetupTestCase {
Logger.getLogger("TEST").log(LogLevel.DEBUG, "DEBUG");
LevelController levelController = LogSetup.getLogHandler().getLevelControl("TST");
assertNotNull(levelController);
- assertThat(levelController.getOnOffString(), is(expectedOnOffString));
+ assertEquals(expectedOnOffString, levelController.getOnOffString());
if (shouldLog != null) {
assertTrue(levelController.shouldLog(shouldLog));
}
diff --git a/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java b/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java
index 220e5e9271e..7a45cd8b1fb 100644
--- a/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java
+++ b/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java
@@ -22,10 +22,8 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import static java.time.Instant.ofEpochSecond;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -33,20 +31,20 @@ import static org.junit.Assert.fail;
* @author Bjorn Borud
*/
public class VespaLogHandlerTestCase {
- private static String hostname;
- private static String pid;
+ private final static String hostname;
+ private final static String pid;
- static LogRecord record1;
- static String record1String;
+ static final LogRecord record1;
+ static final String record1String;
- static LogRecord record2;
- private static String record2String;
+ static final LogRecord record2;
+ private static final String record2String;
- private static LogRecord record3;
- private static String record3String;
+ private static final LogRecord record3;
+ private static final String record3String;
- private static LogRecord record4;
- private static String record4String;
+ private static final LogRecord record4;
+ private static final String record4String;
static {
hostname = Util.getHostName();
@@ -191,7 +189,7 @@ public class VespaLogHandlerTestCase {
h.close();
String [] lines = target.getLines();
- assertThat(lines.length, is(4));
+ assertEquals(4, lines.length);
assertEquals(record1String, lines[0]);
assertEquals(record3String, lines[1]);
//assertEquals(record4String, lines[2]);
@@ -375,7 +373,7 @@ public class VespaLogHandlerTestCase {
}
private static class MockLevelControllerRepo implements LevelControllerRepo {
- private LevelController levelController;
+ private final LevelController levelController;
MockLevelControllerRepo(LevelController controller) {
this.levelController = controller;
}