ChannelBuffer buff = ChannelBuffers.buffer(100);
buff.writeBytes((priority+goodData1).getBytes());
String priority2 = "<20>";
String goodData2 = "Good really good data\n";
buff.writeBytes((priority2+goodData2).getBytes());
Event e = util.extractEvent(buff);
if(e == null){
throw new NullPointerException("Event is null");
}
Map<String, String> headers = e.getHeaders();
Assert.assertEquals("1", headers.get(SyslogUtils.SYSLOG_FACILITY));
Assert.assertEquals("2", headers.get(SyslogUtils.SYSLOG_SEVERITY));
Assert.assertEquals(null,
headers.get(SyslogUtils.EVENT_STATUS));
Assert.assertEquals(priority + goodData1.trim(),
new String(e.getBody()).trim());
Event e2 = util.extractEvent(buff);
if(e2 == null){
throw new NullPointerException("Event is null");
}
Map<String, String> headers2 = e2.getHeaders();
Assert.assertEquals("2", headers2.get(SyslogUtils.SYSLOG_FACILITY));
Assert.assertEquals("4", headers2.get(SyslogUtils.SYSLOG_SEVERITY));
Assert.assertEquals(null,
headers.get(SyslogUtils.EVENT_STATUS));
Assert.assertEquals(priority2 + goodData2.trim(),
new String(e2.getBody()).trim());
}