use of org.graylog2.gelfclient.transport.GelfTransport in project graylog2-server by Graylog2.
the class GelfOutputTest method testToGELFMessageWithInvalidNumericStringLevel.
@Test
public void testToGELFMessageWithInvalidNumericStringLevel() throws Exception {
final GelfTransport transport = mock(GelfTransport.class);
final GelfOutput gelfOutput = new GelfOutput(transport);
final DateTime now = DateTime.now(DateTimeZone.UTC);
final Message message = new Message("Test", "Source", now);
message.addField("level", "-1");
final GelfMessage gelfMessage = gelfOutput.toGELFMessage(message);
assertEquals(GelfMessageLevel.ALERT, gelfMessage.getLevel());
}
use of org.graylog2.gelfclient.transport.GelfTransport in project graylog2-server by Graylog2.
the class GelfOutputTest method testToGELFMessageWithInvalidTypeLevel.
@Test
public void testToGELFMessageWithInvalidTypeLevel() throws Exception {
final GelfTransport transport = mock(GelfTransport.class);
final GelfOutput gelfOutput = new GelfOutput(transport);
final DateTime now = DateTime.now(DateTimeZone.UTC);
final Message message = new Message("Test", "Source", now);
message.addField("level", new Object());
final GelfMessage gelfMessage = gelfOutput.toGELFMessage(message);
assertEquals(GelfMessageLevel.ALERT, gelfMessage.getLevel());
}
use of org.graylog2.gelfclient.transport.GelfTransport in project graylog2-server by Graylog2.
the class GelfOutputTest method testToGELFMessageWithValidNumericLevel.
@Test
public void testToGELFMessageWithValidNumericLevel() throws Exception {
final GelfTransport transport = mock(GelfTransport.class);
final GelfOutput gelfOutput = new GelfOutput(transport);
final DateTime now = DateTime.now(DateTimeZone.UTC);
final Message message = new Message("Test", "Source", now);
message.addField("level", 6);
final GelfMessage gelfMessage = gelfOutput.toGELFMessage(message);
assertEquals(GelfMessageLevel.INFO, gelfMessage.getLevel());
}
use of org.graylog2.gelfclient.transport.GelfTransport in project graylog2-server by Graylog2.
the class GelfOutputTest method testToGELFMessageWithInvalidNumericLevel.
@Test
public void testToGELFMessageWithInvalidNumericLevel() throws Exception {
final GelfTransport transport = mock(GelfTransport.class);
final GelfOutput gelfOutput = new GelfOutput(transport);
final DateTime now = DateTime.now(DateTimeZone.UTC);
final Message message = new Message("Test", "Source", now);
message.addField("level", -1L);
final GelfMessage gelfMessage = gelfOutput.toGELFMessage(message);
assertEquals(GelfMessageLevel.ALERT, gelfMessage.getLevel());
}
use of org.graylog2.gelfclient.transport.GelfTransport in project graylog2-server by Graylog2.
the class GelfOutputTest method testWrite.
@Test
public void testWrite() throws Exception {
final GelfTransport transport = mock(GelfTransport.class);
final Message message = mock(Message.class);
final GelfMessage gelfMessage = new GelfMessage("Test");
final GelfOutput gelfOutput = Mockito.spy(new GelfOutput(transport));
doReturn(gelfMessage).when(gelfOutput).toGELFMessage(message);
gelfOutput.write(message);
verify(transport).send(eq(gelfMessage));
}
Aggregations