aboutsummaryrefslogtreecommitdiffstats
path: root/logserver/src/test/java/com
diff options
context:
space:
mode:
authorHarald Musum <musum@yahoo-inc.com>2017-05-24 08:20:38 +0200
committerHarald Musum <musum@yahoo-inc.com>2017-05-24 08:20:38 +0200
commit08f088a3b8ec618b0d94ea13d6639bc9ff044ff6 (patch)
treedaa05b4ef4855022f4b35101b0c46b44a44ce644 /logserver/src/test/java/com
parent0e84e9bbaf713ee446af28e029bfc0dbec367df3 (diff)
Reindent and minor cleanups, no functional changes
Diffstat (limited to 'logserver/src/test/java/com')
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/FlusherTestCase.java2
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/ServerTestCase.java29
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/filter/test/LogFilterManagerTestCase.java3
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/filter/test/MetricsFilterTestCase.java10
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/filter/test/NoMetricsFilterTestCase.java6
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/formatter/test/LogFormatterManagerTestCase.java3
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/formatter/test/NullFormatterTestCase.java5
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/formatter/test/TextFormatterTestCase.java7
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/handlers/HandlerThreadTestCase.java2
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/handlers/archive/ArchiverHandlerTestCase.java52
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/handlers/archive/test/.gitignore0
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/handlers/lasterrorsholder/LastErrorsHolderTestCase.java25
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/handlers/logmetrics/test/LogMetricsTestCase.java144
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/handlers/replicator/FormattedBufferCacheTestCase.java6
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorPluginTestCase.java8
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorTestCase.java18
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/httphandlers/.gitignore0
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/net/control/test/LevelsTestCase.java15
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/net/test/LogConnectionTestCase.java2
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/test/LogDispatcherTestCase.java35
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/test/LogMessageTestCase.java4
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/test/MockLogEntries.java6
22 files changed, 193 insertions, 189 deletions
diff --git a/logserver/src/test/java/com/yahoo/logserver/FlusherTestCase.java b/logserver/src/test/java/com/yahoo/logserver/FlusherTestCase.java
index 79d16de61f0..d6953fd3bc3 100644
--- a/logserver/src/test/java/com/yahoo/logserver/FlusherTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/FlusherTestCase.java
@@ -19,7 +19,7 @@ public class FlusherTestCase {
Thread.sleep(5000);
flusher.interrupt();
flusher.join();
- assertTrue(handler.flushCalled>0);
+ assertTrue(handler.flushCalled > 0);
}
}
diff --git a/logserver/src/test/java/com/yahoo/logserver/ServerTestCase.java b/logserver/src/test/java/com/yahoo/logserver/ServerTestCase.java
index 1a6cd304d79..4d0c08ac151 100644
--- a/logserver/src/test/java/com/yahoo/logserver/ServerTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/ServerTestCase.java
@@ -2,7 +2,6 @@
package com.yahoo.logserver;
import com.yahoo.log.LogSetup;
-import com.yahoo.logserver.Server;
import com.yahoo.logserver.handlers.LogHandler;
import com.yahoo.logserver.handlers.logmetrics.LogMetricsPlugin;
import com.yahoo.logserver.test.LogDispatcherTestCase;
@@ -10,17 +9,18 @@ import com.yahoo.logserver.test.LogDispatcherTestCase;
import java.io.IOException;
import org.junit.*;
+
import static org.junit.Assert.*;
/**
* Unit tests for the Server class.
*
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class ServerTestCase {
@Test
- public void testStartupAndRegHandlers() throws IOException, InterruptedException {
+ public void testStartupAndRegHandlers() throws IOException, InterruptedException {
Server.help();
Server server = Server.getInstance();
server.initialize(18322);
@@ -29,20 +29,19 @@ public class ServerTestCase {
serverThread.start();
assertTrue(serverThread.isAlive());
LogHandler handler = new LogDispatcherTestCase.MockHandler();
- server.registerLogHandler(handler , "foo");
+ server.registerLogHandler(handler, "foo");
assertEquals(Server.threadNameForHandler().get(handler), "foo");
server.unregisterLogHandler(handler);
assertEquals(Server.threadNameForHandler().get(handler), null);
- serverThread.interrupt();
- try {
- serverThread.join();
- assertTrue(true);
- }
- catch (InterruptedException e) {
- fail();
- }
- }
-
+ serverThread.interrupt();
+ try {
+ serverThread.join();
+ assertTrue(true);
+ } catch (InterruptedException e) {
+ fail();
+ }
+ }
+
@Test
public void testPluginLoaderClassLoading() {
AbstractPluginLoader loader = new BuiltinPluginLoader();
@@ -51,5 +50,5 @@ public class ServerTestCase {
System.setProperty("logserver.logmetrics.enable", "true");
loader.loadFromClass(LogMetricsPlugin.class); // Hm, no way to verify it was loaded
}
-
+
}
diff --git a/logserver/src/test/java/com/yahoo/logserver/filter/test/LogFilterManagerTestCase.java b/logserver/src/test/java/com/yahoo/logserver/filter/test/LogFilterManagerTestCase.java
index 439c8e3978f..b2d4d322456 100644
--- a/logserver/src/test/java/com/yahoo/logserver/filter/test/LogFilterManagerTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/filter/test/LogFilterManagerTestCase.java
@@ -10,12 +10,13 @@ import com.yahoo.logserver.filter.NullFilter;
import com.yahoo.logserver.filter.MuteFilter;
import org.junit.*;
+
import static org.junit.Assert.*;
public class LogFilterManagerTestCase {
@Test
- public void testSystemFilters () {
+ public void testSystemFilters() {
LogFilter f;
f = LogFilterManager.getLogFilter("system.allevents");
diff --git a/logserver/src/test/java/com/yahoo/logserver/filter/test/MetricsFilterTestCase.java b/logserver/src/test/java/com/yahoo/logserver/filter/test/MetricsFilterTestCase.java
index fa22daac0d8..67733c8260b 100644
--- a/logserver/src/test/java/com/yahoo/logserver/filter/test/MetricsFilterTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/filter/test/MetricsFilterTestCase.java
@@ -12,25 +12,23 @@ import com.yahoo.log.LogMessage;
import com.yahoo.logserver.filter.MetricsFilter;
import org.junit.*;
+
import static org.junit.Assert.*;
public class MetricsFilterTestCase {
@Test
- public void testValueEvents ()
- throws InvalidLogFormatException, IOException {
+ public void testValueEvents() throws InvalidLogFormatException, IOException {
MetricsFilter filter = new MetricsFilter();
String filename = "src/test/files/value-events.txt";
BufferedReader br = new BufferedReader(new FileReader(filename));
- for (String line = br.readLine(); line != null; line = br.readLine())
- {
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
LogMessage m = LogMessage.parseNativeFormat(line);
assertNotNull(m);
try {
Event event = m.getEvent();
assertNotNull(event);
- }
- catch (MalformedEventException e) {
+ } catch (MalformedEventException e) {
fail();
}
diff --git a/logserver/src/test/java/com/yahoo/logserver/filter/test/NoMetricsFilterTestCase.java b/logserver/src/test/java/com/yahoo/logserver/filter/test/NoMetricsFilterTestCase.java
index 5d6be5c16c7..ddd427ffb76 100644
--- a/logserver/src/test/java/com/yahoo/logserver/filter/test/NoMetricsFilterTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/filter/test/NoMetricsFilterTestCase.java
@@ -13,6 +13,7 @@ import com.yahoo.logserver.filter.MetricsFilter;
import com.yahoo.logserver.filter.NoMetricsFilter;
import org.junit.*;
+
import static org.junit.Assert.*;
/**
@@ -21,7 +22,7 @@ import static org.junit.Assert.*;
public class NoMetricsFilterTestCase {
@Test
- public void testValueEvents () throws InvalidLogFormatException, IOException {
+ public void testValueEvents() throws InvalidLogFormatException, IOException {
NoMetricsFilter filter = new NoMetricsFilter();
MetricsFilter metricsFilter = new MetricsFilter();
@@ -34,8 +35,7 @@ public class NoMetricsFilterTestCase {
try {
Event event = m.getEvent();
assertNotNull(event);
- }
- catch (MalformedEventException e) {
+ } catch (MalformedEventException e) {
fail();
}
diff --git a/logserver/src/test/java/com/yahoo/logserver/formatter/test/LogFormatterManagerTestCase.java b/logserver/src/test/java/com/yahoo/logserver/formatter/test/LogFormatterManagerTestCase.java
index 288300f9251..774cd68e995 100644
--- a/logserver/src/test/java/com/yahoo/logserver/formatter/test/LogFormatterManagerTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/formatter/test/LogFormatterManagerTestCase.java
@@ -11,12 +11,13 @@ import com.yahoo.logserver.formatter.NullFormatter;
import com.yahoo.logserver.formatter.TextFormatter;
import org.junit.*;
+
import static org.junit.Assert.*;
/**
* Test the LogFormatterManager
*
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class LogFormatterManagerTestCase {
diff --git a/logserver/src/test/java/com/yahoo/logserver/formatter/test/NullFormatterTestCase.java b/logserver/src/test/java/com/yahoo/logserver/formatter/test/NullFormatterTestCase.java
index b0fc7ea09c0..3a02b7a1d05 100644
--- a/logserver/src/test/java/com/yahoo/logserver/formatter/test/NullFormatterTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/formatter/test/NullFormatterTestCase.java
@@ -10,17 +10,18 @@ import com.yahoo.logserver.formatter.NullFormatter;
import com.yahoo.logserver.test.MockLogEntries;
import org.junit.*;
+
import static org.junit.Assert.*;
/**
* Test the NullFormatter
*
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class NullFormatterTestCase {
@Test
- public void testNullFormatter () {
+ public void testNullFormatter() {
NullFormatter nf = new NullFormatter();
LogMessage[] ms = MockLogEntries.getMessages();
for (LogMessage m : ms) {
diff --git a/logserver/src/test/java/com/yahoo/logserver/formatter/test/TextFormatterTestCase.java b/logserver/src/test/java/com/yahoo/logserver/formatter/test/TextFormatterTestCase.java
index 2e7e2d38b57..2e5f3ac3d8f 100644
--- a/logserver/src/test/java/com/yahoo/logserver/formatter/test/TextFormatterTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/formatter/test/TextFormatterTestCase.java
@@ -11,12 +11,13 @@ import com.yahoo.logserver.formatter.TextFormatter;
import com.yahoo.logserver.test.MockLogEntries;
import org.junit.*;
+
import static org.junit.Assert.*;
/**
* Test the TextFormatter
*
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class TextFormatterTestCase {
@@ -24,7 +25,7 @@ public class TextFormatterTestCase {
* Just simple test to make sure it doesn't die on us
*/
@Test
- public void testTextFormatter () {
+ public void testTextFormatter() {
TextFormatter tf = new TextFormatter();
LogMessage[] ms = MockLogEntries.getMessages();
for (int i = 0; i < ms.length; i++) {
@@ -36,7 +37,7 @@ public class TextFormatterTestCase {
* Test that a specific log message is formatted correctly
*/
@Test
- public void testSpecificMessage () throws InvalidLogFormatException {
+ public void testSpecificMessage() throws InvalidLogFormatException {
String l = "1115200798.195568\texample.yahoo.com\t65819\ttopleveldispatch\tfdispatch.queryperf\tevent\tvalue/1 name=\"query_eval_time_avg_s\" value=0.0229635972697721825";
String result = "2005-05-04 09:59:58 example.yahoo.com 65819 topleveldispatch fdispatch.queryperf EVENT value/1 name=\"query_eval_time_avg_s\" value=0.0229635972697721825\n";
LogMessage m = LogMessage.parseNativeFormat(l);
diff --git a/logserver/src/test/java/com/yahoo/logserver/handlers/HandlerThreadTestCase.java b/logserver/src/test/java/com/yahoo/logserver/handlers/HandlerThreadTestCase.java
index 930b6e7c5ad..e7bfb112848 100644
--- a/logserver/src/test/java/com/yahoo/logserver/handlers/HandlerThreadTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/handlers/HandlerThreadTestCase.java
@@ -92,5 +92,5 @@ public class HandlerThreadTestCase {
thread.interrupt();
thread.join();
}
-
+
}
diff --git a/logserver/src/test/java/com/yahoo/logserver/handlers/archive/ArchiverHandlerTestCase.java b/logserver/src/test/java/com/yahoo/logserver/handlers/archive/ArchiverHandlerTestCase.java
index ec1b0d962ef..0e29d9e80d4 100644
--- a/logserver/src/test/java/com/yahoo/logserver/handlers/archive/ArchiverHandlerTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/handlers/archive/ArchiverHandlerTestCase.java
@@ -21,15 +21,15 @@ import org.junit.rules.TemporaryFolder;
import static org.junit.Assert.*;
/**
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class ArchiverHandlerTestCase {
private static final String[] mStrings = {
- "1095159244.095\thost\t1/2\tservice\tcomponent\tinfo\tpayload1",
- "1095206399.000\thost\t1/2\tservice\tcomponent\tinfo\tpayload2",
- "1095206400.000\thost\t1/2\tservice\tcomponent\tinfo\tpayload3",
- "1095206401.000\thost\t1/2\tservice\tcomponent\tinfo\tpayload4",
+ "1095159244.095\thost\t1/2\tservice\tcomponent\tinfo\tpayload1",
+ "1095206399.000\thost\t1/2\tservice\tcomponent\tinfo\tpayload2",
+ "1095206400.000\thost\t1/2\tservice\tcomponent\tinfo\tpayload3",
+ "1095206401.000\thost\t1/2\tservice\tcomponent\tinfo\tpayload4",
};
private static final LogMessage[] msg = new LogMessage[mStrings.length];
@@ -59,20 +59,19 @@ public class ArchiverHandlerTestCase {
* [00:00:00.000, 23:59:59.999].
*/
@Test
- public void testDateHash () throws IOException {
+ public void testDateHash() throws IOException {
File tmpDir = temporaryFolder.newFolder();
try {
ArchiverHandler a = new ArchiverHandler(tmpDir.getAbsolutePath(),
- 1024);
+ 1024);
long now = 1095159244095L;
long midnight = 1095206400000L;
assertEquals(2004091410, a.dateHash(now));
- assertEquals(2004091423, a.dateHash(midnight-1));
+ assertEquals(2004091423, a.dateHash(midnight - 1));
assertEquals(2004091500, a.dateHash(midnight));
- assertEquals(2004091500, a.dateHash(midnight+1));
+ assertEquals(2004091500, a.dateHash(midnight + 1));
a.close();
- }
- finally {
+ } finally {
IOUtils.recursiveDeleteDir(tmpDir);
}
}
@@ -85,7 +84,7 @@ public class ArchiverHandlerTestCase {
File tmpDir = temporaryFolder.newFolder();
try {
ArchiverHandler a = new ArchiverHandler(tmpDir.getAbsolutePath(),
- 1024);
+ 1024);
LogMessage msg1 = LogMessage.parseNativeFormat("1139322725\thost\tthread\tservice\tcomponent\tinfo\tpayload");
LogMessage msg2 = LogMessage.parseNativeFormat("1161172200\thost\tthread\tservice\tcomponent\tinfo\tpayload");
assertEquals(tmpDir.getAbsolutePath() + "/2006/02/07/14", a.getPrefix(msg1));
@@ -94,8 +93,7 @@ public class ArchiverHandlerTestCase {
a.close();
} catch (InvalidLogFormatException e) {
fail(e.toString());
- }
- finally {
+ } finally {
IOUtils.recursiveDeleteDir(tmpDir);
}
}
@@ -105,7 +103,7 @@ public class ArchiverHandlerTestCase {
* written.
*/
@Test
- public void testLogging () throws java.io.IOException, InvalidLogFormatException {
+ public void testLogging() throws java.io.IOException, InvalidLogFormatException {
File tmpDir = temporaryFolder.newFolder();
try {
ArchiverHandler a = new ArchiverHandler(tmpDir.getAbsolutePath(),
@@ -141,8 +139,7 @@ public class ArchiverHandlerTestCase {
BufferedReader br = new BufferedReader(new FileReader(f));
for (String line = br.readLine();
line != null;
- line = br.readLine())
- {
+ line = br.readLine()) {
// primitive check if the messages match
boolean foundMatch = false;
for (int k = 0; k < mStrings.length; k++) {
@@ -156,7 +153,7 @@ public class ArchiverHandlerTestCase {
// try to instantiate messages to ensure that they
// are parseable
@SuppressWarnings("unused")
- LogMessage m = LogMessage.parseNativeFormat(line);
+ LogMessage m = LogMessage.parseNativeFormat(line);
messageCount++;
}
br.close();
@@ -165,8 +162,7 @@ public class ArchiverHandlerTestCase {
// verify that the number of log messages written equals
// the number of log messages we have in our test
assertEquals(mStrings.length, messageCount);
- }
- finally {
+ } finally {
IOUtils.recursiveDeleteDir(tmpDir);
}
}
@@ -175,7 +171,7 @@ public class ArchiverHandlerTestCase {
* Make sure that the file is rotated after N bytes
*/
@Test
- public void testRotation () throws IOException {
+ public void testRotation() throws IOException {
File tmpDir = temporaryFolder.newFolder();
try {
ArchiverHandler a = new ArchiverHandler(tmpDir.getAbsolutePath(),
@@ -197,8 +193,7 @@ public class ArchiverHandlerTestCase {
BufferedReader br = new BufferedReader(new FileReader(f));
for (String line = br.readLine();
line != null;
- line = br.readLine())
- {
+ line = br.readLine()) {
assertTrue(msg[1].toString().equals((line + "\n")));
msgCount++;
}
@@ -208,21 +203,20 @@ public class ArchiverHandlerTestCase {
// make sure we have no more than 3 files
assertTrue(! (new File(prefix + "-3").exists()));
- }
- finally {
+ } finally {
IOUtils.recursiveDeleteDir(tmpDir);
}
}
-
+
@Test
public void testCacheEldestEntry() throws IOException {
LogWriterLRUCache cache = new LogWriterLRUCache(5, (float) 0.75);
- for (int i = 0 ; i < cache.maxEntries+10 ; i++) {
+ for (int i = 0; i < cache.maxEntries + 10; i++) {
cache.put(i, new LogWriter("/tmp/", 5));
}
assertEquals(cache.size(), cache.maxEntries);
}
-
+
@Test
public void testArchiverPlugin() {
ArchiverPlugin ap = new ArchiverPlugin();
@@ -239,5 +233,5 @@ public class ArchiverHandlerTestCase {
}
ap.shutdownPlugin();
}
-
+
}
diff --git a/logserver/src/test/java/com/yahoo/logserver/handlers/archive/test/.gitignore b/logserver/src/test/java/com/yahoo/logserver/handlers/archive/test/.gitignore
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/logserver/src/test/java/com/yahoo/logserver/handlers/archive/test/.gitignore
+++ /dev/null
diff --git a/logserver/src/test/java/com/yahoo/logserver/handlers/lasterrorsholder/LastErrorsHolderTestCase.java b/logserver/src/test/java/com/yahoo/logserver/handlers/lasterrorsholder/LastErrorsHolderTestCase.java
index ba857c51f5c..507c087b469 100644
--- a/logserver/src/test/java/com/yahoo/logserver/handlers/lasterrorsholder/LastErrorsHolderTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/handlers/lasterrorsholder/LastErrorsHolderTestCase.java
@@ -26,9 +26,9 @@ public class LastErrorsHolderTestCase {
private static final int serverPort = 18324;
private static final int lastErrorsHolderPort = 18326;
- Server server;
- Thread serverThread;
- LastErrorsHolder lastErrorsHolder;
+ private Server server;
+ private Thread serverThread;
+ private LastErrorsHolder lastErrorsHolder;
@Before
public void setUp() throws InterruptedException, IOException {
@@ -41,11 +41,11 @@ public class LastErrorsHolderTestCase {
@After
public void tearDown() throws InterruptedException {
- if (serverThread!=null) {
+ if (serverThread != null) {
serverThread.interrupt();
serverThread.join();
}
- if (lastErrorsHolder !=null) lastErrorsHolder.close();
+ if (lastErrorsHolder != null) lastErrorsHolder.close();
}
public String connectAndGetLogMessages() throws InterruptedException, IOException {
@@ -77,9 +77,12 @@ public class LastErrorsHolderTestCase {
@Test
public void testLastErrorsHolder() throws IOException, InvalidLogFormatException, InterruptedException {
- LastErrorsHolder.Message logMessage1 = new LastErrorsHolder.Message(1433996283, "host1.yahoo.com", "container", LogLevel.ERROR.getName(), "foo");
- LastErrorsHolder.Message logMessage2 = new LastErrorsHolder.Message(1433996284, "host2.yahoo.com", "container", LogLevel.ERROR.getName(), "bar");
- LastErrorsHolder.Message logMessage3 = new LastErrorsHolder.Message(1433996285, "host2.yahoo.com", "container", LogLevel.INFO.getName(), "bar");
+ LastErrorsHolder.Message logMessage1 = new LastErrorsHolder.Message(1433996283, "host1.yahoo.com", "container", LogLevel.ERROR
+ .getName(), "foo");
+ LastErrorsHolder.Message logMessage2 = new LastErrorsHolder.Message(1433996284, "host2.yahoo.com", "container", LogLevel.ERROR
+ .getName(), "bar");
+ LastErrorsHolder.Message logMessage3 = new LastErrorsHolder.Message(1433996285, "host2.yahoo.com", "container", LogLevel.INFO
+ .getName(), "bar");
LastErrorsHolder.Messages messages = new LastErrorsHolder.Messages();
@@ -107,11 +110,13 @@ public class LastErrorsHolderTestCase {
}
private LogMessage createLogMessage(LastErrorsHolder.Message message) throws InvalidLogFormatException {
- return createLogMessage(message.getTime(), message.getHostname(), message.getService(), message.getLogLevel(), message.getMessage());
+ return createLogMessage(message.getTime(), message.getHostname(), message.getService(), message.getLogLevel(), message
+ .getMessage());
}
private LogMessage createLogMessage(long time, String hostname, String service, String logLevel, String message) throws InvalidLogFormatException {
- return LogMessage.parseNativeFormat(String.format("%d\t%s\t1/1\t%s\tcomponent\t%s\t%s", time, hostname, service, logLevel.toLowerCase(), message));
+ return LogMessage.parseNativeFormat(String.format("%d\t%s\t1/1\t%s\tcomponent\t%s\t%s", time, hostname, service, logLevel
+ .toLowerCase(), message));
}
}
diff --git a/logserver/src/test/java/com/yahoo/logserver/handlers/logmetrics/test/LogMetricsTestCase.java b/logserver/src/test/java/com/yahoo/logserver/handlers/logmetrics/test/LogMetricsTestCase.java
index 4aece1a6b32..3aaa98bae15 100644
--- a/logserver/src/test/java/com/yahoo/logserver/handlers/logmetrics/test/LogMetricsTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/handlers/logmetrics/test/LogMetricsTestCase.java
@@ -10,97 +10,97 @@ import com.yahoo.logserver.handlers.logmetrics.LogMetricsPlugin;
import com.yahoo.plugin.SystemPropertyConfig;
import org.junit.*;
+
import static org.junit.Assert.*;
/**
* @author hmusum
*/
public class LogMetricsTestCase {
- // Some of the tests depend upon the number of messages for a
- // host, log level etc. to succeed, so you may have update the
- // tests if you change something in mStrings. config, debug and
- // spam are filtered out and not handled.
- private static final String[] mStrings = {
- "1095159244.095\thostA\t1/2\tservice\tcomponent\tconfig\tpayload1",
- "1095206399.000\thostA\t1/2\tservice\tcomponent\tinfo\tpayload2",
- "1095206400.000\thostA\t1/2\tservice\tcomponent\tinfo\tpayload3",
- "1095206401.000\thostA\t1/2\tservice\tcomponent\tinfo\tpayload4",
- "1095206402.000\thostA\t1/2\tservice\tcomponent\twarning\tpayload5",
- "1095206403.000\thostA\t1/2\tservice\tcomponent\terror\tpayload6",
- "1095206404.000\thostB\t1/2\tservice\tcomponent\tinfo\tpayload7",
- "1095206405.000\thostB\t1/2\tservice\tcomponent\tfatal\tpayload8",
- "1095206406.000\thostB\t1/2\tservice\tcomponent\tdebug\tpayload9",
- };
-
- private static final LogMessage[] msg = new LogMessage[mStrings.length];
-
- static {
- try {
- for (int i = 0; i < mStrings.length; i++) {
- msg[i] = LogMessage.parseNativeFormat(mStrings[i]);
- }
- } catch (InvalidLogFormatException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Log some messages to the handler and verify that they are
- * counted by the handler and that the count for each level is
- * correct.
- */
+ // Some of the tests depend upon the number of messages for a
+ // host, log level etc. to succeed, so you may have update the
+ // tests if you change something in mStrings. config, debug and
+ // spam are filtered out and not handled.
+ private static final String[] mStrings = {
+ "1095159244.095\thostA\t1/2\tservice\tcomponent\tconfig\tpayload1",
+ "1095206399.000\thostA\t1/2\tservice\tcomponent\tinfo\tpayload2",
+ "1095206400.000\thostA\t1/2\tservice\tcomponent\tinfo\tpayload3",
+ "1095206401.000\thostA\t1/2\tservice\tcomponent\tinfo\tpayload4",
+ "1095206402.000\thostA\t1/2\tservice\tcomponent\twarning\tpayload5",
+ "1095206403.000\thostA\t1/2\tservice\tcomponent\terror\tpayload6",
+ "1095206404.000\thostB\t1/2\tservice\tcomponent\tinfo\tpayload7",
+ "1095206405.000\thostB\t1/2\tservice\tcomponent\tfatal\tpayload8",
+ "1095206406.000\thostB\t1/2\tservice\tcomponent\tdebug\tpayload9",
+ };
+
+ private static final LogMessage[] msg = new LogMessage[mStrings.length];
+
+ static {
+ try {
+ for (int i = 0; i < mStrings.length; i++) {
+ msg[i] = LogMessage.parseNativeFormat(mStrings[i]);
+ }
+ } catch (InvalidLogFormatException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Log some messages to the handler and verify that they are
+ * counted by the handler and that the count for each level is
+ * correct.
+ */
@Test
- public void testLevelCountTotal () throws java.io.IOException, InvalidLogFormatException {
- LogMetricsHandler a = new LogMetricsHandler();
+ public void testLevelCountTotal() throws java.io.IOException, InvalidLogFormatException {
+ LogMetricsHandler a = new LogMetricsHandler();
for (LogMessage aMsg : msg) {
a.handle(aMsg);
}
- long count = a.getMetricsCount();
- a.close();
- // Not all messages are processes (debug and spam)
- assertEquals(count, 7);
- }
-
+ long count = a.getMetricsCount();
+ a.close();
+ // Not all messages are processes (debug and spam)
+ assertEquals(count, 7);
+ }
- /**
- * Log some messages to the handler and verify that they are
- * counted by the handler and that the count for each level is
- * correct (the count for each host is summed into one count for
- * each level).
- */
+ /**
+ * Log some messages to the handler and verify that they are
+ * counted by the handler and that the count for each level is
+ * correct (the count for each host is summed into one count for
+ * each level).
+ */
@Test
- public void testLevelCountAggregated () throws java.io.IOException, InvalidLogFormatException {
- LogMetricsHandler a = new LogMetricsHandler();
+ public void testLevelCountAggregated() throws java.io.IOException, InvalidLogFormatException {
+ LogMetricsHandler a = new LogMetricsHandler();
for (LogMessage aMsg : msg) {
a.handle(aMsg);
}
- Map<String, Long> levelCount = a.getMetricsPerLevel();
- assertEquals(levelCount.entrySet().size(), 5);
- for (Map.Entry<String, Long> entry : levelCount.entrySet()) {
- String key = entry.getKey();
- if (key.equals("config")) {
- assertEquals(entry.getValue(), new Long(1));
- } else if (key.equals("info")) {
- assertEquals(entry.getValue(), new Long(4));
- } else if (key.equals("warning")) {
- assertEquals(entry.getValue(), new Long(1));
- } else if (key.equals("severe")) {
- assertEquals(entry.getValue(), new Long(0));
- } else if (key.equals("error")) {
- assertEquals(entry.getValue(), new Long(1));
- } else if (key.equals("fatal")) {
- assertEquals(entry.getValue(), new Long(1));
- } else if (key.equals("debug")) {
- assertEquals(entry.getValue(), new Long(0)); // always 0
- }
- }
- a.close();
- }
+ Map<String, Long> levelCount = a.getMetricsPerLevel();
+ assertEquals(levelCount.entrySet().size(), 5);
+ for (Map.Entry<String, Long> entry : levelCount.entrySet()) {
+ String key = entry.getKey();
+ if (key.equals("config")) {
+ assertEquals(entry.getValue(), new Long(1));
+ } else if (key.equals("info")) {
+ assertEquals(entry.getValue(), new Long(4));
+ } else if (key.equals("warning")) {
+ assertEquals(entry.getValue(), new Long(1));
+ } else if (key.equals("severe")) {
+ assertEquals(entry.getValue(), new Long(0));
+ } else if (key.equals("error")) {
+ assertEquals(entry.getValue(), new Long(1));
+ } else if (key.equals("fatal")) {
+ assertEquals(entry.getValue(), new Long(1));
+ } else if (key.equals("debug")) {
+ assertEquals(entry.getValue(), new Long(0)); // always 0
+ }
+ }
+ a.close();
+ }
@Test
public void testLogMetricsPlugin() {
@@ -118,5 +118,5 @@ public class LogMetricsTestCase {
}
lp.shutdownPlugin();
}
-
+
}
diff --git a/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/FormattedBufferCacheTestCase.java b/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/FormattedBufferCacheTestCase.java
index b0d846a2965..333f0ed1095 100644
--- a/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/FormattedBufferCacheTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/FormattedBufferCacheTestCase.java
@@ -7,6 +7,7 @@
package com.yahoo.logserver.handlers.replicator;
import java.nio.ByteBuffer;
+
import com.yahoo.logserver.handlers.replicator.FormattedBufferCache;
import com.yahoo.log.LogMessage;
import com.yahoo.logserver.formatter.LogFormatter;
@@ -14,17 +15,18 @@ import com.yahoo.logserver.formatter.LogFormatterManager;
import com.yahoo.logserver.test.MockLogEntries;
import org.junit.*;
+
import static org.junit.Assert.*;
/**
* Unit tests for thge LogMessage class.
*
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class FormattedBufferCacheTestCase {
@Test
- public void testCache () {
+ public void testCache() {
LogMessage msgs[] = MockLogEntries.getMessages();
FormattedBufferCache cache = new FormattedBufferCache();
String n[] = LogFormatterManager.getFormatterNames();
diff --git a/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorPluginTestCase.java b/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorPluginTestCase.java
index dbb0b7817f6..e10349c7414 100644
--- a/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorPluginTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorPluginTestCase.java
@@ -12,19 +12,19 @@ import com.yahoo.plugin.SystemPropertyConfig;
public class ReplicatorPluginTestCase {
ReplicatorPlugin rp;
-
+
@Before
public void setUp() {
rp = new ReplicatorPlugin();
}
-
+
@After
public void tearDown() {
- if (rp!=null) {
+ if (rp != null) {
rp.shutdownPlugin();
}
}
-
+
@Test
public void testReplicatorPlugin() {
System.setProperty("replicatorplugin.test.port", "18325");
diff --git a/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorTestCase.java b/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorTestCase.java
index 3f8ed840273..7c884c6e0a3 100644
--- a/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorTestCase.java
@@ -53,21 +53,21 @@ public class ReplicatorTestCase {
@After
public void tearDown() throws InterruptedException {
- if (serverThread!=null) {
+ if (serverThread != null) {
serverThread.interrupt();
serverThread.join();
}
- if (replicator!=null) replicator.close();
+ if (replicator != null) replicator.close();
}
@Test
public void testReplicator() throws IOException, InvalidLogFormatException {
LogMessage msg = LogMessage.
- parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\tevent\tfoo");
+ parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\tevent\tfoo");
assertFalse(conn.isLoggable(msg)); // Default all muted
conn.onUse("system.all");
assertTrue(conn.isLoggable(msg));
- assertTrue(conn.getTotalBytesWritten()>50); // Should be in this ballpark
+ assertTrue(conn.getTotalBytesWritten() > 50); // Should be in this ballpark
conn.onCommand("use system.mute");
assertFalse(conn.isLoggable(msg));
assertEquals("system.mute", conn.getLogFilterName());
@@ -87,7 +87,7 @@ public class ReplicatorTestCase {
assertEquals(22, conn.getNumHandled()); // 4 formatters
conn.onCommand("listformatters");
assertEquals(26, conn.getNumHandled()); // 4 formatters
-
+
conn.onStats();
assertEquals(27, conn.getNumHandled()); // 1 line
conn.onCommand("stats");
@@ -113,21 +113,21 @@ public class ReplicatorTestCase {
});
conn.onUse("test.onlyerror");
assertFalse(conn.isLoggable(LogMessage.
- parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\tdebug\tfoo")));
+ parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\tdebug\tfoo")));
assertTrue(conn.isLoggable(LogMessage.
- parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\terror\tbar")));
+ parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\terror\tbar")));
assertEquals(conn.selectOps(), 1);
assertEquals(conn.description(), "Only error");
conn.setFilter(null);
assertTrue(conn.isLoggable(LogMessage.
- parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\terror\tbar")));
+ parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\terror\tbar")));
assertEquals(conn.description(), "No filter defined");
assertEquals(conn.getRemoteHost(), "localhost");
conn.onFormatter("nonexistant");
assertEquals(conn.formatter, LogFormatterManager.getLogFormatter("system.nullformatter")); // unchanged
conn.onUse("nonexistant");
assertTrue(conn.isLoggable(LogMessage.
- parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\terror\tbar")));
+ parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\terror\tbar")));
conn.close();
}
diff --git a/logserver/src/test/java/com/yahoo/logserver/httphandlers/.gitignore b/logserver/src/test/java/com/yahoo/logserver/httphandlers/.gitignore
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/logserver/src/test/java/com/yahoo/logserver/httphandlers/.gitignore
+++ /dev/null
diff --git a/logserver/src/test/java/com/yahoo/logserver/net/control/test/LevelsTestCase.java b/logserver/src/test/java/com/yahoo/logserver/net/control/test/LevelsTestCase.java
index 5f0897187c4..d81db60473c 100644
--- a/logserver/src/test/java/com/yahoo/logserver/net/control/test/LevelsTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/net/control/test/LevelsTestCase.java
@@ -5,10 +5,11 @@ import com.yahoo.logserver.net.control.Levels;
import com.yahoo.logserver.net.control.State;
import org.junit.*;
+
import static org.junit.Assert.*;
/**
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class LevelsTestCase {
/**
@@ -29,10 +30,9 @@ public class LevelsTestCase {
* which has been deemed to be "reasonable". In general, it will
* specify forwarding all log levels except "debug" and it will
* specify "spam" to be turned off.
- *
*/
@Test
- public void testDefaultLevels () {
+ public void testDefaultLevels() {
Levels levels = new Levels();
assertSame(State.FORWARD, levels.getLevelState("event"));
assertSame(State.FORWARD, levels.getLevelState("fatal"));
@@ -47,7 +47,6 @@ public class LevelsTestCase {
/**
* This test also documents/verifies the default behavior
* of the Levels class.
- *
*/
@Test
public void testToString() {
@@ -62,20 +61,20 @@ public class LevelsTestCase {
* Clone testing
*/
@Test
- public void testClone () {
+ public void testClone() {
Levels l1 = Levels.parse("error=noforward");
assertEquals(l1.toString(), l1.clone().toString());
assertSame(State.NOFORWARD, l1.getLevelState("error"));
- assertSame(State.NOFORWARD, ((Levels)l1.clone()).getLevelState("error"));
+ assertSame(State.NOFORWARD, ((Levels) l1.clone()).getLevelState("error"));
assertSame(l1.getLevelState("error"),
- ((Levels)l1.clone()).getLevelState("error"));
+ ((Levels) l1.clone()).getLevelState("error"));
}
/**
* test parser
*/
@Test
- public void testUpdateLevels () {
+ public void testUpdateLevels() {
Levels l1 = Levels.parse("error=noforward");
assertSame(State.NOFORWARD, l1.getLevelState("error"));
diff --git a/logserver/src/test/java/com/yahoo/logserver/net/test/LogConnectionTestCase.java b/logserver/src/test/java/com/yahoo/logserver/net/test/LogConnectionTestCase.java
index 90835930fc0..077cef2d543 100644
--- a/logserver/src/test/java/com/yahoo/logserver/net/test/LogConnectionTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/net/test/LogConnectionTestCase.java
@@ -27,7 +27,7 @@ import static org.junit.Assert.*;
* Unit tests for the log connection class. Wow is this too
* complex!
*
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class LogConnectionTestCase {
private static final Logger log = Logger.getLogger(LogConnectionTestCase.class.getName());
diff --git a/logserver/src/test/java/com/yahoo/logserver/test/LogDispatcherTestCase.java b/logserver/src/test/java/com/yahoo/logserver/test/LogDispatcherTestCase.java
index 37ad625247d..eba3508253d 100644
--- a/logserver/src/test/java/com/yahoo/logserver/test/LogDispatcherTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/test/LogDispatcherTestCase.java
@@ -10,48 +10,51 @@ import com.yahoo.log.LogMessage;
import com.yahoo.logserver.handlers.LogHandler;
import org.junit.*;
+
import static org.junit.Assert.*;
/**
* Unit tests for thge LogMessage class.
*
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class LogDispatcherTestCase {
private static LogMessage sample1;
private static LogMessage sample2;
+
static {
try {
sample1 = LogMessage.parseNativeFormat("1096639280.524133 malfunction 26851 - logtest info Starting up, called as ./log/logtest");
sample2 = LogMessage.parseNativeFormat("1096639280.524133 malfunction 26851 - logtest info More crap");
- }
- catch (InvalidLogFormatException e) {
+ } catch (InvalidLogFormatException e) {
assertTrue(false);
}
}
public static class MockHandler implements LogHandler {
- public final List<LogMessage> messages= new ArrayList<LogMessage>(5);
+ public final List<LogMessage> messages = new ArrayList<LogMessage>(5);
public int flushCalled = 0;
public int closeCalled = 0;
- public void handle (LogMessage msg) {
+ public void handle(LogMessage msg) {
messages.add(msg);
}
- public void handle (List<LogMessage> messages) {
- for (LogMessage lm : messages) {
- handle(lm);
- }
+ public void handle(List<LogMessage> messages) {
+ for (LogMessage lm : messages) {
+ handle(lm);
+ }
}
- public void flush () {
+ public void flush() {
flushCalled++;
}
- public void close () {
+
+ public void close() {
closeCalled++;
}
- public String getName () {
+
+ public String getName() {
return MockHandler.class.getName();
}
}
@@ -73,7 +76,7 @@ public class LogDispatcherTestCase {
}
@Test
- public void testTestLogHandlerRegistration () {
+ public void testTestLogHandlerRegistration() {
MockHandler handler = new MockHandler();
LogDispatcher dispatcher = new LogDispatcher();
dispatcher.registerLogHandler(handler);
@@ -86,7 +89,7 @@ public class LogDispatcherTestCase {
}
@Test
- public void testMessageCount () {
+ public void testMessageCount() {
MockHandler handler = new MockHandler();
LogDispatcher dispatcher = new LogDispatcher();
dispatcher.registerLogHandler(handler);
@@ -102,7 +105,7 @@ public class LogDispatcherTestCase {
}
@Test
- public void testVerifyMessages () {
+ public void testVerifyMessages() {
MockHandler handler = new MockHandler();
LogDispatcher dispatcher = new LogDispatcher();
dispatcher.registerLogHandler(handler);
@@ -116,7 +119,7 @@ public class LogDispatcherTestCase {
// TODO: this test makes very little sense until we refactor a bit
@Test
- public void testClose () {
+ public void testClose() {
MockHandler handler = new MockHandler();
LogDispatcher dispatcher = new LogDispatcher();
dispatcher.registerLogHandler(handler);
diff --git a/logserver/src/test/java/com/yahoo/logserver/test/LogMessageTestCase.java b/logserver/src/test/java/com/yahoo/logserver/test/LogMessageTestCase.java
index a9bb8084a7c..97f3d22e620 100644
--- a/logserver/src/test/java/com/yahoo/logserver/test/LogMessageTestCase.java
+++ b/logserver/src/test/java/com/yahoo/logserver/test/LogMessageTestCase.java
@@ -16,9 +16,9 @@ import org.junit.*;
import static org.junit.Assert.*;
/**
- * Unit tests for thge LogMessage class.
+ * Unit tests for the LogMessage class.
*
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class LogMessageTestCase {
diff --git a/logserver/src/test/java/com/yahoo/logserver/test/MockLogEntries.java b/logserver/src/test/java/com/yahoo/logserver/test/MockLogEntries.java
index 18cf8afb8a0..9912192b850 100644
--- a/logserver/src/test/java/com/yahoo/logserver/test/MockLogEntries.java
+++ b/logserver/src/test/java/com/yahoo/logserver/test/MockLogEntries.java
@@ -14,7 +14,7 @@ import java.util.List;
* This class is used to gain access to a bunch of log entries
* so we can use the same log messages in several different tests
*
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public class MockLogEntries {
private static final MockLogEntries instance = new MockLogEntries();
@@ -25,7 +25,7 @@ public class MockLogEntries {
* Private constructor which reads the log messages and builds
* an array of LogMessage entries.
*/
- private MockLogEntries () {
+ private MockLogEntries() {
List<LogMessage> msgs = new LinkedList<LogMessage>();
try {
String name = "src/test/files/logEntries.txt";
@@ -35,7 +35,7 @@ public class MockLogEntries {
msgs.add(m);
}
} catch (InvalidLogFormatException | IOException e) {
- // do nothing
+ // do nothing
}
LogMessage[] m = new LogMessage[msgs.size()];