use of loghub.Event in project LogHub by fbacchella.
the class TestConditions method testif.
@Test
public void testif() throws ProcessorException, ConfigException, IOException {
Properties conf = Tools.loadConf("conditions.conf");
Event sent = Tools.getEvent();
sent.put("a", "1");
Tools.runProcessing(sent, conf.namedPipeLine.get("ifpipe"), conf);
Assert.assertEquals("conversion not expected", String.class, sent.get("a").getClass());
}
use of loghub.Event in project LogHub by fbacchella.
the class TestConditions method testsuccess.
@Test
public void testsuccess() throws ProcessorException, ConfigException, IOException {
Properties conf = Tools.loadConf("conditions.conf");
Event sent = Tools.getEvent();
sent.put("a", "1");
Tools.runProcessing(sent, conf.namedPipeLine.get("successpipe"), conf);
Assert.assertEquals("conversion not expected", "success", sent.get("test"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestDateParser method test2.
@Test
public void test2() throws ProcessorException {
DateParser parse = new DateParser();
parse.setPattern("yyyy-MM-dd'T'HH:m:ss.SSSSSSXXX");
parse.setField("field");
Assert.assertTrue(parse.configure(new Properties(Collections.emptyMap())));
Event event = Tools.getEvent();
event.put("field", "1970-01-01T00:00:00.000000+01:00");
parse.process(event);
Date date = (Date) event.get("field");
Assert.assertEquals("date not parsed", -3600000, date.getTime());
}
use of loghub.Event in project LogHub by fbacchella.
the class TestDateParser method test3.
@Test
public void test3() throws ProcessorException {
DateParser parse = new DateParser();
parse.setPattern("yyyy-MM-dd'T'HH:m:ss");
parse.setTimezone("Z");
parse.setField("field");
Assert.assertTrue(parse.configure(new Properties(Collections.emptyMap())));
Event event = Tools.getEvent();
event.put("field", "1970-01-01T00:00:00");
parse.process(event);
Date date = (Date) event.get("field");
Assert.assertEquals("date not parsed", 0L, date.getTime());
}
use of loghub.Event in project LogHub by fbacchella.
the class TestDateParser method test4.
@Test
public void test4() throws ProcessorException {
DateParser parse = new DateParser();
parse.setField("field");
Assert.assertTrue(parse.configure(new Properties(Collections.emptyMap())));
Event event = Tools.getEvent();
event.put("field", "Tue, 3 Jun 2008 11:05:30 +0110");
parse.process(event);
Assert.assertTrue("date not parsed", event.get("field") instanceof Date);
Date date = (Date) event.get("field");
Assert.assertEquals("date not parsed", 1212486930000L, date.getTime());
}
Aggregations