use of org.apache.nifi.processors.standard.syslog.SyslogEvent in project nifi by apache.
the class TestSyslogParser method testRFC3164DoubleDigitDay.
@Test
public void testRFC3164DoubleDigitDay() {
final String pri = "31";
final String stamp = "Oct 13 14:14:43";
final String host = "localhost";
final String body = "AppleCameraAssistant[470]: DeviceMessageNotificationCallback: kIOPMMessageSystemPowerEventOccurred: 0x00000000";
final String message = "<" + pri + ">" + stamp + " " + host + " " + body;
final byte[] bytes = message.getBytes(CHARSET);
final ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
buffer.clear();
buffer.put(bytes);
final SyslogEvent event = parser.parseEvent(buffer);
Assert.assertNotNull(event);
Assert.assertEquals(pri, event.getPriority());
Assert.assertEquals("7", event.getSeverity());
Assert.assertEquals("3", event.getFacility());
Assert.assertNull(event.getVersion());
Assert.assertEquals(stamp, event.getTimeStamp());
Assert.assertEquals(host, event.getHostName());
Assert.assertEquals(body, event.getMsgBody());
Assert.assertEquals(message, event.getFullMessage());
Assert.assertTrue(event.isValid());
}
Aggregations