use of loghub.Event in project LogHub by fbacchella.
the class TestNettyNameResolver method badresolvernxdomain.
@Test(timeout = 6000)
public void badresolvernxdomain() throws Throwable {
Event e = Tools.getEvent();
// / resolve a no existing name
e.put("host", InetAddress.getByName("169.254.1.1"));
Tools.ProcessingStatus status = dorequest(i -> {
i.setField("host");
i.setDestination("fqdn");
i.setTimeout(1);
}, e, "1.1.254.169.in-addr.arpa");
e = status.mainQueue.take();
Assert.assertEquals("resolution not failed", null, e.get("fqdn"));
Assert.assertEquals("Queue not empty: " + status.mainQueue, 0, status.mainQueue.size());
Assert.assertEquals("Still waiting events: " + status.repository, 0, status.repository.waiting());
}
use of loghub.Event in project LogHub by fbacchella.
the class TestNettyNameResolver method arootasipv4addr.
@Test(timeout = 6000)
public void arootasipv4addr() throws Throwable {
Event e = Tools.getEvent();
// / resolving a.root-servers.net. in IPv4
e.put("host", InetAddress.getByName("198.41.0.4"));
Tools.ProcessingStatus status = dorequest(i -> {
i.setField("host");
i.setDestination("fqdn");
}, e, "4.0.41.198.in-addr.arpa");
e = status.mainQueue.take();
Assert.assertEquals("resolution failed", "a.root-servers.net", e.get("fqdn"));
Assert.assertEquals("Queue not empty: " + status.mainQueue, 0, status.mainQueue.size());
Assert.assertEquals("Still waiting events: " + status.repository, 0, status.repository.waiting());
}
use of loghub.Event in project LogHub by fbacchella.
the class TestOnigurumaRegex method testNoNamedPattern.
@Test
public void testNoNamedPattern() throws ProcessorException {
OnigurumaRegex grok = new OnigurumaRegex();
grok.setField("message");
grok.setPattern(".*");
Properties props = new Properties(Collections.emptyMap());
Assert.assertTrue("Failed to configure grok", grok.configure(props));
Event e = Tools.getEvent();
e.put("message", "<15>a text");
Assert.assertTrue(e.process(grok));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestOnigurumaRegex method testUtf2.
@Test
public void testUtf2() throws ProcessorException {
OnigurumaRegex grok = new OnigurumaRegex();
grok.setField("message");
grok.setPattern("<(?<syslog_pri>\\d+)>(?<message>é.*)");
Properties props = new Properties(Collections.emptyMap());
Assert.assertTrue("Failed to configure grok", grok.configure(props));
Event e = Tools.getEvent();
e.put("message", "<15>éa text");
Assert.assertTrue(e.process(grok));
Assert.assertEquals("Didn't find the good syslog priority", "15", e.get("syslog_pri"));
Assert.assertEquals("Didn't find the good syslog message", "éa text", e.get("message"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestScanBinary method simpleTestWithVariableLengthName2s.
@Test
public void simpleTestWithVariableLengthName2s() throws ProcessorException {
ScanBinary fs = new ScanBinary();
fs.setBitsNames(new String[] { "a", "b", "c" });
fs.setFieldsLength(new Integer[] { 3, 2, 1 });
fs.configure(new Properties(Collections.emptyMap()));
Event e = Event.emptyEvent(ConnectionContext.EMPTY);
e.put("binary", 0b110101);
Assert.assertTrue(fs.processMessage(e, "binary", "value"));
@SuppressWarnings("unchecked") Map<String, Number> value = (Map<String, Number>) e.get("value");
Assert.assertEquals(0b101, value.get("a").intValue());
Assert.assertEquals(0b10, value.get("b").intValue());
Assert.assertEquals(0b1, value.get("c").intValue());
}
Aggregations