use of loghub.configuration.Properties 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.configuration.Properties 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());
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestEtl method test1.
@Test
public void test1() throws ProcessorException {
Etl.Assign etl = new Etl.Assign();
etl.setLvalue(new String[] { "a", "b" });
etl.setExpression("event.c + 1");
boolean done = etl.configure(new Properties(Collections.emptyMap()));
Assert.assertTrue("configuration failed", done);
Event event = Tools.getEvent();
event.put("c", 0);
event.process(etl);
Assert.assertEquals("evaluation failed", 1, event.applyAtPath((i, j, k) -> i.get(j), new String[] { "a", "b" }, null, false));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestEtl method test5.
@Test
public void test5() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("etl.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
sent.put("a", "a");
Tools.runProcessing(sent, conf.namedPipeLine.get("main"), conf);
Assert.assertEquals("conversion not expected", "a", sent.get("a"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestEtl method test7.
@Test
public void test7() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("etl.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
Map<String, Object> b = new HashMap<>(1);
b.put("c", 1);
sent.put("b", b);
Tools.runProcessing(sent, conf.namedPipeLine.get("third"), conf);
Assert.assertEquals("conversion not expected", 1, sent.get("a"));
}
Aggregations