Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/test/java/HttpEventCollectorUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import com.splunk.logging.HttpEventCollectorErrorHandler;
import com.splunk.logging.HttpEventCollectorEventInfo;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import sun.rmi.runtime.Log;

import java.io.ByteArrayInputStream;
Expand All @@ -34,6 +36,10 @@
import java.util.logging.Logger;

public class HttpEventCollectorUnitTest {

@Rule
public TestRule watcher = new SplunkTestWatcher();

@Test
public void log4j_simple() throws Exception {
HashMap<String, String> userInputs = new HashMap<String, String>();
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/HttpEventCollector_JavaLoggingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;

import java.util.logging.Logger;

Expand All @@ -33,6 +35,9 @@ public final class HttpEventCollector_JavaLoggingTest {
List<List<HttpEventCollectorEventInfo>> errors = new ArrayList<List<HttpEventCollectorEventInfo>>();
List<HttpEventCollectorErrorHandler.ServerErrorException> logEx = new ArrayList<HttpEventCollectorErrorHandler.ServerErrorException>();

@Rule
public TestRule watcher = new SplunkTestWatcher();

/**
* sending a message via httplogging using java.logging to splunk
*/
Expand Down Expand Up @@ -430,7 +435,6 @@ public void eventsIsIndexedInOrderOfSent() throws Exception {
TestUtil.verifyEventsSentInOrder(prefix, totalEventsCount, indexName);

TestUtil.deleteHttpEventCollectorToken(httpEventCollectorName);
System.out.println("====================== Test pass=========================");
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/HttpEventCollector_Log4j2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.core.LoggerContext;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.apache.logging.log4j.Logger;
import org.junit.rules.TestRule;

public final class HttpEventCollector_Log4j2Test {
private String httpEventCollectorName = "Log4j2Test";
List<List<HttpEventCollectorEventInfo>> errors = new ArrayList<List<HttpEventCollectorEventInfo>>();
List<HttpEventCollectorErrorHandler.ServerErrorException> logEx = new ArrayList<>();

@Rule
public TestRule watcher = new SplunkTestWatcher();

/**
* sending a message via httplogging using log4j2 to splunk
*/
Expand Down Expand Up @@ -62,7 +67,6 @@ public void canSendEventUsingLog4j2() throws Exception, IOException, Interrupted
TestUtil.verifyEventsSentToSplunk(msgs);

TestUtil.deleteHttpEventCollectorToken(httpEventCollectorName);
System.out.println("====================== Test pass=========================");
}


Expand Down Expand Up @@ -100,7 +104,6 @@ public void canSendEventUsingLog4j2WithOptions() throws Exception, IOException,
TestUtil.verifyEventsSentToSplunk(msgs);

TestUtil.deleteHttpEventCollectorToken(httpEventCollectorName);
System.out.println("====================== Test pass=========================");
}

/**
Expand Down Expand Up @@ -368,7 +371,6 @@ public void eventsIsIndexedInOrderOfSent() throws Exception {
TestUtil.verifyEventsSentInOrder(prefix,totalEventsCount,indexName);

TestUtil.deleteHttpEventCollectorToken(httpEventCollectorName);
System.out.println("====================== Test pass=========================");
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/HttpEventCollector_LogbackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,6 +35,9 @@ public final class HttpEventCollector_LogbackTest {
List<List<HttpEventCollectorEventInfo>> errors = new ArrayList<List<HttpEventCollectorEventInfo>>();
List<HttpEventCollectorErrorHandler.ServerErrorException> logEx = new ArrayList<HttpEventCollectorErrorHandler.ServerErrorException>();

@Rule
public TestRule watcher = new SplunkTestWatcher();

/**
* sending a message via httplogging using logback to splunk
*/
Expand Down Expand Up @@ -361,7 +366,6 @@ public void eventsIsIndexedInOrderOfSent() throws Exception {
TestUtil.verifyEventsSentInOrder(prefix, totalEventsCount, indexName);

TestUtil.deleteHttpEventCollectorToken(httpEventCollectorName);
System.out.println("====================== Test pass=========================");
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/HttpEventCollector_Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.splunk.logging.HttpEventCollectorErrorHandler;
import com.splunk.logging.HttpEventCollectorEventInfo;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;

import java.io.*;
Expand All @@ -30,6 +31,7 @@
import java.lang.reflect.*;

import com.splunk.*;
import org.junit.rules.TestRule;
import org.slf4j.*;

public class HttpEventCollector_Test {
Expand Down Expand Up @@ -90,6 +92,9 @@ private static String setupHttpEventCollector(boolean batching) throws Exceptio
return token;
}

@Rule
public TestRule watcher = new SplunkTestWatcher();

@Test
public void LogToSplunkViaDifferentLoggers() throws Exception {
LogToSplunk(false);
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/HttpLoggerStressTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import org.apache.logging.log4j.Logger;

import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;

import java.io.*;
Expand All @@ -12,6 +13,7 @@
import java.lang.reflect.*;

import com.splunk.*;
import org.junit.rules.TestRule;

public class HttpLoggerStressTest {
private static class DataSender implements Runnable {
Expand Down Expand Up @@ -105,6 +107,9 @@ private static void setupHttpEventCollector() throws Exception {
TestUtil.resetLog4j2Configuration("log4j2_template.xml", "log4j2.xml", userInputs);
}

@Rule
public TestRule watcher = new SplunkTestWatcher();

@Test
public void canSendEventUsingJavaLogging() throws Exception {
long startTime = System.currentTimeMillis()/1000;
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/JULFunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* under the License.
*/
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;

import java.io.BufferedReader;
import java.io.IOException;
Expand All @@ -26,6 +28,9 @@

public class JULFunctionalTest {

@Rule
public TestRule watcher = new SplunkTestWatcher();

/**
* Try writing a message via TCP to java.util.logging to validate the example configuration.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/Log4jFunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;

public class Log4jFunctionalTest {

@Rule
public TestRule watcher = new SplunkTestWatcher();

/**
* Try writing a message via TCP to log4j 2 to validate the example configuration.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/LogbackFunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@
* under the License.
*/
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LogbackFunctionalTest {

@Rule
public TestRule watcher = new SplunkTestWatcher();

/**
* Try writing a message via TCP to logback to validate the example configuration.
*/
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/SplunkCimLogEventUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

import com.splunk.logging.SplunkCimLogEvent;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -25,6 +27,10 @@
* Check that SplunkCimLogEvent produces what we expect it to.
*/
public class SplunkCimLogEventUnitTest {

@Rule
public TestRule watcher = new SplunkTestWatcher();

@Test
public void addFieldWithCharValue() {
SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/SplunkTestWatcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;

public class SplunkTestWatcher extends TestWatcher {

@Override
protected void starting(Description description) {
System.out.println("Starting test: " + description.getMethodName());
}

@Override
protected void succeeded(Description description) {
System.out.println("====================== Test pass=========================");
}

@Override
protected void finished(Description description) {
// GitHub pipeline is not including output from last test failure
System.out.flush();
}
}