use of loghub.Tools.ProcessingStatus in project LogHub by fbacchella.
the class TestFileMap method testone.
@Test
public void testone() throws ProcessorException {
URL ifpixurl = getClass().getResource("/ipfix-information-elements.csv");
FileMap s = new FileMap();
s.setMappingFile(ifpixurl.getFile());
s.setCsvFormat("RFC4180");
s.setKeyName("ElementID");
s.setValueName("Name");
s.configure(null);
Mapper p = new Mapper();
p.setField(new String[] { "type" });
p.setLvalue(new String[] { "type" });
p.setMap(s);
Event e = Tools.getEvent();
e.put("type", "1");
ProcessingStatus ps = Tools.runProcessing(e, "main", Collections.singletonList(p));
Event ep = ps.mainQueue.remove();
Assert.assertEquals("octetDeltaCount", ep.get("type"));
}
use of loghub.Tools.ProcessingStatus in project LogHub by fbacchella.
the class ProcessorTest method test.
@Test
public void test() throws IOException, DecodeException, ProcessorException, InterruptedException {
Processor p = new Processor();
InputStream is = getClass().getResourceAsStream("/netflow/packets/ipfix.dat");
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[8 * 1024];
for (int length; (length = is.read(buffer)) != -1; ) {
out.write(buffer, 0, length);
}
ByteBuf bbuffer = Unpooled.wrappedBuffer(out.toByteArray());
Decoder nfd = new NetflowDecoder();
IpConnectionContext dummyctx = new IpConnectionContext(new InetSocketAddress(0), new InetSocketAddress(0), null);
Map<String, Object> content = nfd.decode(dummyctx, bbuffer);
Event e = Tools.getEvent();
e.setTimestamp((Date) content.remove(Event.TIMESTAMPKEY));
e.putAll(content);
ProcessingStatus ps = Tools.runProcessing(e, "main", Collections.singletonList(p));
logger.debug(ps.mainQueue.remove());
logger.debug(ps.mainQueue.remove());
logger.debug(ps.mainQueue.remove());
logger.debug(ps.mainQueue.remove());
logger.debug(ps.mainQueue.remove());
logger.debug(ps.mainQueue.remove());
logger.debug(ps.mainQueue.remove());
logger.debug(ps.mainQueue.remove());
Assert.assertTrue(ps.mainQueue.isEmpty());
}
Aggregations