use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestTest method testSub.
@Test(timeout = 2000)
public void testSub() throws InterruptedException, ProcessorException, 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);
conf.mainQueue.add(sent);
EventsProcessor ep = new EventsProcessor(conf.mainQueue, conf.outputQueues, conf.namedPipeLine, conf.maxSteps, conf.repository);
sent.inject(conf.namedPipeLine.get("subpipe"), conf.mainQueue);
ep.start();
Event received = conf.outputQueues.get("subpipe").take();
Assert.assertEquals("conversion not expected", 2, received.get("d"));
ep.interrupt();
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestTest method testOK.
@Test
public void testOK() throws InterruptedException, ProcessorException, 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", 1);
Tools.runProcessing(sent, conf.namedPipeLine.get("main"), conf);
Assert.assertEquals("conversion not expected", 1, sent.get("b"));
}
use of loghub.configuration.Properties 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.configuration.Properties 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);
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestTrap method testbig.
// @Test
// public void testone() throws InterruptedException, IOException {
// BlockingQueue<Event> receiver = new ArrayBlockingQueue<>(1);
// SnmpTrap r = new SnmpTrap(receiver, new Pipeline(Collections.emptyList(), "testone", null));
// r.setPort(0);
// Assert.assertTrue("Failed to configure trap receiver", r.configure(new Properties(Collections.emptyMap())));;
// List<String> content = r.smartPrint(new OID("1.0.8802.1.1.2.1.1.2.5"));
// Assert.assertEquals(1, content.size());
// Assert.assertEquals("lldpMessageTxHoldMultiplier", content.get(0));
// r.close();
// }
@Ignore
@Test
public void testbig() throws InterruptedException, IOException {
BlockingQueue<Event> receiver = new ArrayBlockingQueue<>(2);
SnmpTrap r = new SnmpTrap(receiver, new Pipeline(Collections.emptyList(), "testbig", null));
r.setPort(0);
Map<String, Object> props = new HashMap<>();
props.put("mibdirs", new String[] { "/usr/share/snmp/mibs", "/tmp/mibs" });
Assert.assertTrue(r.configure(new Properties(props)));
r.start();
CommandResponderEvent trapEvent = new CommandResponderEvent(new MessageDispatcherImpl(), new DefaultUdpTransportMapping(), TransportIpAddress.parse("127.0.0.1/162"), 0, 0, null, 0, null, null, 0, null);
PDU pdu = new PDU();
pdu.add(new VariableBinding(new OID("1.0.8802.1.1.2.1.4.1.1.8.207185300.2.15079"), new OctetString("vnet7")));
pdu.add(new VariableBinding(new OID("1.0.8802.1.1.2.1.3.7.1.4.2"), new OctetString("eth0")));
pdu.add(new VariableBinding(new OID("1.0.8802.1.1.2.1.4.1.1.9.207185300.2.15079"), new OctetString("localhost")));
pdu.add(new VariableBinding(new OID("1.3.6.1.6.3.1.1.4.1"), new OctetString("lldpRemTablesChange")));
trapEvent.setPDU(pdu);
r.processPdu(trapEvent);
Event e = receiver.poll();
logger.debug(e.getClass());
@SuppressWarnings("unchecked") Map<String, ?> details = (Map<String, ?>) e.get("lldpRemSysName");
Assert.assertEquals(3, Array.getLength(details.get("index")));
Assert.assertEquals("localhost", details.get("value"));
r.interrupt();
}
Aggregations