Remove TestNG in favor of JUnit

This commit is contained in:
Jochen Schalanda 2015-03-31 18:10:32 +02:00
parent 29f6a8c3f6
commit d521ccea60
3 changed files with 125 additions and 143 deletions

19
pom.xml
View File

@ -95,12 +95,6 @@
<version>3.0.9</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.21</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -184,19 +178,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<!-- For running both, junit and testng tests. -->
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.18.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

View File

@ -1,12 +1,12 @@
package org.graylog2.syslog4j.server.impl.event;
import org.joda.time.DateTime;
import org.testng.annotations.Test;
import org.junit.Test;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import static org.testng.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
public class SyslogServerEventTest {
private final InetAddress INET_ADDR = new InetSocketAddress(514).getAddress();
@ -22,11 +22,11 @@ public class SyslogServerEventTest {
final SyslogServerEvent event = buildEvent(message);
assertEquals(event.getDate(), new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate());
assertEquals(event.getFacility(), 4);
assertEquals(event.getHost(), "mymachine");
assertEquals(event.getLevel(), 2);
assertEquals(event.getMessage(), "mymachine su: 'su root' failed for lonvick on /dev/pts/8");
assertEquals(new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate(), event.getDate());
assertEquals(4, event.getFacility());
assertEquals("mymachine", event.getHost());
assertEquals(2, event.getLevel());
assertEquals("mymachine su: 'su root' failed for lonvick on /dev/pts/8", event.getMessage());
}
@Test
@ -36,11 +36,11 @@ public class SyslogServerEventTest {
final SyslogServerEvent event = buildEvent(message);
assertEquals(event.getDate(), new DateTime(new DateTime().getYear() + "-02-05T17:32:18").toDate());
assertEquals(event.getFacility(), 1);
assertEquals(event.getHost(), "10.0.0.99");
assertEquals(event.getLevel(), 5);
assertEquals(event.getMessage(), "10.0.0.99 Use the BFG!");
assertEquals(new DateTime(new DateTime().getYear() + "-02-05T17:32:18").toDate(), event.getDate());
assertEquals(1, event.getFacility());
assertEquals("10.0.0.99", event.getHost());
assertEquals(5, event.getLevel());
assertEquals("10.0.0.99 Use the BFG!", event.getMessage());
}
@Test
@ -51,11 +51,11 @@ public class SyslogServerEventTest {
final SyslogServerEvent event = buildEvent(message);
assertEquals(event.getDate(), new DateTime(new DateTime().getYear() + "-10-05T12:23:34").toDate());
assertEquals(event.getFacility(), 1);
assertEquals(event.getHost(), "hostname");
assertEquals(event.getLevel(), 3);
assertEquals(event.getMessage(), "hostname tag: hello world");
assertEquals(new DateTime(new DateTime().getYear() + "-10-05T12:23:34").toDate(), event.getDate());
assertEquals(1, event.getFacility());
assertEquals("hostname", event.getHost());
assertEquals(3, event.getLevel());
assertEquals("hostname tag: hello world", event.getMessage());
}
@Test
@ -66,11 +66,11 @@ public class SyslogServerEventTest {
final SyslogServerEvent event = buildEvent(message);
assertEquals(event.getDate(), new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate());
assertEquals(event.getFacility(), 4);
assertEquals(event.getHost(), "mymachine");
assertEquals(event.getLevel(), 2);
assertEquals(event.getMessage(), "mymachine su[123]: 'su root' failed for lonvick on /dev/pts/8");
assertEquals(new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate(), event.getDate());
assertEquals(4, event.getFacility());
assertEquals("mymachine", event.getHost());
assertEquals(2, event.getLevel());
assertEquals("mymachine su[123]: 'su root' failed for lonvick on /dev/pts/8", event.getMessage());
}
@Test
@ -94,11 +94,11 @@ public class SyslogServerEventTest {
final SyslogServerEvent event = buildEvent(message);
assertEquals(event.getDate(), new DateTime(new DateTime().getYear() + "-02-05T17:32:18").toDate());
assertEquals(event.getFacility(), 1);
assertEquals(event.getHost(), "10.0.0.99");
assertEquals(event.getLevel(), 5);
assertEquals(event.getMessage(), "10.0.0.99 Use the BFG!");
assertEquals(new DateTime(new DateTime().getYear() + "-02-05T17:32:18").toDate(), event.getDate());
assertEquals(1, event.getFacility());
assertEquals("10.0.0.99", event.getHost());
assertEquals(5, event.getLevel());
assertEquals("10.0.0.99 Use the BFG!", event.getMessage());
}
@Test
@ -110,11 +110,11 @@ public class SyslogServerEventTest {
final SyslogServerEvent event = buildEvent(message);
assertEquals(event.getDate(), new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate());
assertEquals(event.getFacility(), 12);
assertEquals(event.getHost(), "mymachine");
assertEquals(event.getLevel(), 2);
assertEquals(event.getMessage(), "mymachine su[123]: 'su root' failed for lonvick on /dev/pts/8");
assertEquals(new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate(), event.getDate());
assertEquals(12, event.getFacility());
assertEquals("mymachine", event.getHost());
assertEquals(2, event.getLevel());
assertEquals("mymachine su[123]: 'su root' failed for lonvick on /dev/pts/8", event.getMessage());
}
@Test
@ -126,11 +126,11 @@ public class SyslogServerEventTest {
final SyslogServerEvent event = buildEvent(message);
assertEquals(event.getDate(), new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate());
assertEquals(event.getFacility(), 13);
assertEquals(event.getHost(), "mymachine");
assertEquals(event.getLevel(), 2);
assertEquals(event.getMessage(), "mymachine su[123]: 'su root' failed for lonvick on /dev/pts/8");
assertEquals(new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate(), event.getDate());
assertEquals(13, event.getFacility());
assertEquals("mymachine", event.getHost());
assertEquals(2, event.getLevel());
assertEquals("mymachine su[123]: 'su root' failed for lonvick on /dev/pts/8", event.getMessage());
}
@Test
@ -142,11 +142,11 @@ public class SyslogServerEventTest {
final SyslogServerEvent event = buildEvent(message);
assertEquals(event.getDate(), new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate());
assertEquals(event.getFacility(), 14);
assertEquals(event.getHost(), "mymachine");
assertEquals(event.getLevel(), 2);
assertEquals(event.getMessage(), "mymachine su[123]: 'su root' failed for lonvick on /dev/pts/8");
assertEquals(new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate(), event.getDate());
assertEquals(14, event.getFacility());
assertEquals("mymachine", event.getHost());
assertEquals(2, event.getLevel());
assertEquals("mymachine su[123]: 'su root' failed for lonvick on /dev/pts/8", event.getMessage());
}
@Test
@ -158,11 +158,11 @@ public class SyslogServerEventTest {
final SyslogServerEvent event = buildEvent(message);
assertEquals(event.getDate(), new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate());
assertEquals(event.getFacility(), 15);
assertEquals(event.getHost(), "mymachine");
assertEquals(event.getLevel(), 2);
assertEquals(event.getMessage(), "mymachine su[123]: 'su root' failed for lonvick on /dev/pts/8");
assertEquals(new DateTime(new DateTime().getYear() + "-10-11T22:14:15").toDate(), event.getDate());
assertEquals(15, event.getFacility());
assertEquals("mymachine", event.getHost());
assertEquals(2, event.getLevel());
assertEquals("mymachine su[123]: 'su root' failed for lonvick on /dev/pts/8", event.getMessage());
}
}

View File

@ -1,14 +1,15 @@
package org.graylog2.syslog4j.server.impl.event.structured;
import org.joda.time.DateTime;
import org.testng.annotations.Test;
import org.junit.Test;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Map;
import static org.testng.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
public class StructuredSyslogServerEventTest {
private final InetAddress INET_ADDR = new InetSocketAddress(514).getAddress();
@ -24,7 +25,7 @@ public class StructuredSyslogServerEventTest {
final StructuredSyslogServerEvent event = buildEvent(message);
Map<String, Object> structuredData = new HashMap<String, Object>() {
Map<String, Map<String, String>> structuredData = new HashMap<String, Map<String, String>>() {
{
put("exampleSDID@32473", new HashMap<String, String>() {
{
@ -36,17 +37,17 @@ public class StructuredSyslogServerEventTest {
}
};
assertEquals(event.getApplicationName(), "evntslog");
assertEquals(event.getDateTime(), new DateTime("2012-12-25T22:14:15.003Z"));
assertEquals(event.getFacility(), 20);
assertEquals(event.getHost(), "mymachine.example.com");
assertEquals(event.getLevel(), 5);
assertEquals(event.getMessage(), "ID47 [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"] BOMAn application event log entry");
assertEquals(event.getProcessId(), null);
assertEquals("evntslog", event.getApplicationName());
assertEquals(new DateTime("2012-12-25T22:14:15.003Z"), event.getDateTime());
assertEquals(20, event.getFacility());
assertEquals("mymachine.example.com", event.getHost());
assertEquals(5, event.getLevel());
assertEquals("ID47 [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"] BOMAn application event log entry", event.getMessage());
assertEquals(null, event.getProcessId());
assertEquals(event.getStructuredMessage().getStructuredData(), structuredData);
assertEquals(event.getStructuredMessage().getMessageId(), "ID47");
assertEquals(event.getStructuredMessage().getMessage(), "BOMAn application event log entry");
assertEquals(structuredData, event.getStructuredMessage().getStructuredData());
assertEquals("ID47", event.getStructuredMessage().getMessageId());
assertEquals("BOMAn application event log entry", event.getStructuredMessage().getMessage());
}
@Test
@ -56,7 +57,7 @@ public class StructuredSyslogServerEventTest {
final StructuredSyslogServerEvent event = buildEvent(message);
Map<String, Object> structuredData = new HashMap<String, Object>() {
Map<String, Map<String, String>> structuredData = new HashMap<String, Map<String, String>>() {
{
put("mdc@18060", new HashMap<String, String>() {
{
@ -70,17 +71,17 @@ public class StructuredSyslogServerEventTest {
}
};
assertEquals(event.getApplicationName(), "app");
assertEquals(event.getDateTime(), new DateTime("2015-01-06T20:56:33.287Z"));
assertEquals(event.getFacility(), 23);
assertEquals(event.getHost(), "app-1");
assertEquals(event.getLevel(), 6);
assertEquals(event.getMessage(), "- [mdc@18060 ip=\"::ffff:132.213.51.30\" logger=\"{c.corp.Handler}\" session=\"4ot7\" user=\"user@example.com\" user-agent=\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/7.1.2 Safari/537.85.11\"] User page 13 requested");
assertEquals(event.getProcessId(), null);
assertEquals("app", event.getApplicationName());
assertEquals(new DateTime("2015-01-06T20:56:33.287Z"), event.getDateTime());
assertEquals(23, event.getFacility());
assertEquals("app-1", event.getHost());
assertEquals(6, event.getLevel());
assertEquals("- [mdc@18060 ip=\"::ffff:132.213.51.30\" logger=\"{c.corp.Handler}\" session=\"4ot7\" user=\"user@example.com\" user-agent=\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/7.1.2 Safari/537.85.11\"] User page 13 requested", event.getMessage());
assertEquals(null, event.getProcessId());
assertEquals(event.getStructuredMessage().getStructuredData(), structuredData);
assertEquals(event.getStructuredMessage().getMessageId(), null);
assertEquals(event.getStructuredMessage().getMessage(), "User page 13 requested");
assertEquals(structuredData, event.getStructuredMessage().getStructuredData());
assertEquals(null, event.getStructuredMessage().getMessageId());
assertEquals("User page 13 requested", event.getStructuredMessage().getMessage());
}
@Test
@ -90,17 +91,17 @@ public class StructuredSyslogServerEventTest {
final StructuredSyslogServerEvent event = buildEvent(message);
assertEquals(event.getApplicationName(), null);
assertEquals(event.getDateTime(), new DateTime("2015-01-11T15:35:21.335797Z"));
assertEquals(event.getFacility(), 16);
assertEquals(event.getHost(), "s000000.example.com");
assertEquals(event.getLevel(), 0);
assertEquals(event.getMessage(), "- - tralala");
assertEquals(event.getProcessId(), null);
assertEquals(null, event.getApplicationName());
assertEquals(new DateTime("2015-01-11T15:35:21.335797Z"), event.getDateTime());
assertEquals(16, event.getFacility());
assertEquals("s000000.example.com", event.getHost());
assertEquals(0, event.getLevel());
assertEquals("- - tralala", event.getMessage());
assertEquals(null, event.getProcessId());
assertEquals(event.getStructuredMessage().getStructuredData(), null);
assertEquals(event.getStructuredMessage().getMessageId(), null);
assertEquals(event.getStructuredMessage().getMessage(), "- - tralala");
assertEquals(null, event.getStructuredMessage().getStructuredData());
assertEquals(null, event.getStructuredMessage().getMessageId());
assertEquals("- - tralala", event.getStructuredMessage().getMessage());
}
@Test
@ -110,7 +111,7 @@ public class StructuredSyslogServerEventTest {
final StructuredSyslogServerEvent event = buildEvent(message);
Map<String, Object> structuredData = new HashMap<String, Object>() {
Map<String, Map<String, String>> structuredData = new HashMap<String, Map<String, String>>() {
{
put("exampleSDID@32473", new HashMap<String, String>() {
{
@ -128,17 +129,17 @@ public class StructuredSyslogServerEventTest {
}
};
assertEquals(event.getApplicationName(), "evntslog");
assertEquals(event.getDateTime(), new DateTime("2003-10-11T22:14:15.003Z"));
assertEquals(event.getFacility(), 20);
assertEquals(event.getHost(), "mymachine.example.com");
assertEquals(event.getLevel(), 5);
assertEquals(event.getMessage(), "ID47 [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"][examplePriority@32473 class=\"high\"]");
assertEquals(event.getProcessId(), null);
assertEquals("evntslog", event.getApplicationName());
assertEquals(new DateTime("2003-10-11T22:14:15.003Z"), event.getDateTime());
assertEquals(20, event.getFacility());
assertEquals("mymachine.example.com", event.getHost());
assertEquals(5, event.getLevel());
assertEquals("ID47 [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"][examplePriority@32473 class=\"high\"]", event.getMessage());
assertEquals(null, event.getProcessId());
assertEquals(event.getStructuredMessage().getStructuredData(), structuredData);
assertEquals(event.getStructuredMessage().getMessageId(), "ID47");
assertEquals(event.getStructuredMessage().getMessage(), "");
assertEquals(structuredData, event.getStructuredMessage().getStructuredData());
assertEquals("ID47", event.getStructuredMessage().getMessageId());
assertEquals("", event.getStructuredMessage().getMessage());
}
@ -149,17 +150,17 @@ public class StructuredSyslogServerEventTest {
final StructuredSyslogServerEvent event = buildEvent(message);
assertEquals(event.getApplicationName(), "myproc");
assertEquals(event.getDateTime(), new DateTime("2003-08-24T05:14:15.000003-07:00"));
assertEquals(event.getFacility(), 20);
assertEquals(event.getHost(), "192.0.2.1");
assertEquals(event.getLevel(), 5);
assertEquals(event.getMessage(), "- - %% It's time to make the do-nuts.");
assertEquals(event.getProcessId(), "8710");
assertEquals("myproc", event.getApplicationName());
assertEquals(new DateTime("2003-08-24T05:14:15.000003-07:00"), event.getDateTime());
assertEquals(20, event.getFacility());
assertEquals("192.0.2.1", event.getHost());
assertEquals(5, event.getLevel());
assertEquals("- - %% It's time to make the do-nuts.", event.getMessage());
assertEquals("8710", event.getProcessId());
assertEquals(event.getStructuredMessage().getStructuredData(), null);
assertEquals(event.getStructuredMessage().getMessageId(), null);
assertEquals(event.getStructuredMessage().getMessage(), "- - %% It's time to make the do-nuts.");
assertEquals(null, event.getStructuredMessage().getStructuredData());
assertEquals(null, event.getStructuredMessage().getMessageId());
assertEquals("- - %% It's time to make the do-nuts.", event.getStructuredMessage().getMessage());
}
@Test
@ -170,7 +171,7 @@ public class StructuredSyslogServerEventTest {
final StructuredSyslogServerEvent event = buildEvent(message);
Map<String, Object> structuredData = new HashMap<String, Object>() {
Map<String, Map<String, String>> structuredData = new HashMap<String, Map<String, String>>() {
{
put("meta", new HashMap<String, String>() {
{
@ -180,17 +181,17 @@ public class StructuredSyslogServerEventTest {
}
};
assertEquals(event.getApplicationName(), "syslog-ng");
assertEquals(event.getDateTime(), new DateTime("2014-10-21T10:21:09.000Z"));
assertEquals(event.getFacility(), 5);
assertEquals(event.getHost(), "c4dc57ba1ebb");
assertEquals(event.getLevel(), 5);
assertEquals(event.getMessage(), "- [meta sequenceId=\"1\"] syslog-ng starting up; version='3.5.3'");
assertEquals(event.getProcessId(), "7120");
assertEquals("syslog-ng", event.getApplicationName());
assertEquals(new DateTime("2014-10-21T10:21:09.000Z"), event.getDateTime());
assertEquals(5, event.getFacility());
assertEquals("c4dc57ba1ebb", event.getHost());
assertEquals(5, event.getLevel());
assertEquals("- [meta sequenceId=\"1\"] syslog-ng starting up; version='3.5.3'", event.getMessage());
assertEquals("7120", event.getProcessId());
assertEquals(event.getStructuredMessage().getStructuredData(), structuredData);
assertEquals(event.getStructuredMessage().getMessageId(), null);
assertEquals(event.getStructuredMessage().getMessage(), "syslog-ng starting up; version='3.5.3'");
assertEquals(structuredData, event.getStructuredMessage().getStructuredData());
assertEquals(null, event.getStructuredMessage().getMessageId());
assertEquals("syslog-ng starting up; version='3.5.3'", event.getStructuredMessage().getMessage());
}
@Test
@ -200,7 +201,7 @@ public class StructuredSyslogServerEventTest {
final StructuredSyslogServerEvent event = buildEvent(message);
Map<String, Object> structuredData = new HashMap<String, Object>() {
Map<String, Map<String, String>> structuredData = new HashMap<String, Map<String, String>>() {
{
put("meta", new HashMap<String, String>() {
{
@ -210,16 +211,16 @@ public class StructuredSyslogServerEventTest {
}
};
assertEquals(event.getApplicationName(), "syslog-ng");
assertEquals(event.getDateTime(), new DateTime("2014-10-21T10:21:09.000Z"));
assertEquals(event.getFacility(), 5);
assertEquals(event.getHost(), "c4dc57ba1ebb");
assertEquals(event.getLevel(), 5);
assertEquals(event.getMessage(), "- [meta sequenceId=\"1\"] syslog-ng starting up; version='3.5.3'");
assertEquals(event.getProcessId(), "7120");
assertEquals("syslog-ng", event.getApplicationName());
assertEquals(new DateTime("2014-10-21T10:21:09.000Z"), event.getDateTime());
assertEquals(5, event.getFacility());
assertEquals("c4dc57ba1ebb", event.getHost());
assertEquals(5, event.getLevel());
assertEquals("- [meta sequenceId=\"1\"] syslog-ng starting up; version='3.5.3'", event.getMessage());
assertEquals("7120", event.getProcessId());
assertEquals(event.getStructuredMessage().getStructuredData(), structuredData);
assertEquals(event.getStructuredMessage().getMessageId(), null);
assertEquals(event.getStructuredMessage().getMessage(), "syslog-ng starting up; version='3.5.3'");
assertEquals(structuredData, event.getStructuredMessage().getStructuredData());
assertEquals(null, event.getStructuredMessage().getMessageId());
assertEquals("syslog-ng starting up; version='3.5.3'", event.getStructuredMessage().getMessage());
}
}