use of loghub.Event in project LogHub by fbacchella.
the class TestTest method testKO.
@Test
public void testKO() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("testclause.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
sent.put("a", 2);
Tools.runProcessing(sent, conf.namedPipeLine.get("main"), conf);
Assert.assertEquals("conversion not expected", 2, sent.get("c"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestToJson method test1.
@Test
public void test1() throws ProcessorException {
Event e = Tools.getEvent();
Processor t = new ParseJson();
e.put("message", "{\"a\": [ 1, 2.0 , 3.01 , {\"b\": true} ] }");
e.process(t);
@SuppressWarnings("unchecked") Collection<Object> a = (Collection<Object>) e.get("a");
a.stream().forEach((i) -> logger.debug(i.getClass()));
logger.debug(e);
}
use of loghub.Event in project LogHub by fbacchella.
the class TestUrlDecoders method testUrlDecoderLoop.
@Test
public void testUrlDecoderLoop() throws ProcessorException {
DecodeUrl t = new DecodeUrl();
t.setFields(new String[] { "userAgent" });
t.setLoop(true);
Event e = Tools.getEvent();
e.put("q", "%22Paints%22+Oudalan");
e.put("userAgent", "%2520");
Tools.runProcessing(e, "main", Collections.singletonList(t));
Assert.assertEquals("key 'q' invalid", "%22Paints%22+Oudalan", e.get("q"));
Assert.assertEquals("key 'userAgent' not found", " ", e.get("userAgent"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestUrlDecoders method testUrlDecoder.
@Test
public void testUrlDecoder() throws ProcessorException {
DecodeUrl t = new DecodeUrl();
t.setFields(new String[] { "*" });
Event e = Tools.getEvent();
e.put("q", "%22Paints%22+Oudalan");
e.put("userAgent", "%2520");
Tools.runProcessing(e, "main", Collections.singletonList(t));
Assert.assertEquals("key 'q' invalid", "\"Paints\" Oudalan", e.get("q"));
Assert.assertEquals("key 'userAgent' not found", "%20", e.get("userAgent"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestUserAgent method test1.
@Test
public void test1() throws ProcessorException {
UserAgent ua = new UserAgent();
ua.setField("User-Agent");
ua.setCacheSize(10);
ua.setDestination("agent");
Assert.assertTrue("configuration failed", ua.configure(new Properties(Collections.emptyMap())));
String uaString = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3";
Event event = Tools.getEvent();
event.put("User-Agent", uaString);
Assert.assertTrue(ua.process(event));
System.out.println(event);
Object family = event.applyAtPath((i, j, k) -> i.get(j), new String[] { "agent", "userAgent", "family" }, null, false);
Assert.assertEquals("can't find user agent parsing", "Mobile Safari", family);
}
Aggregations