use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestOnigurumaRegex method testLoadPatterns2.
@Test
public void testLoadPatterns2() throws ProcessorException {
OnigurumaRegex grok = new OnigurumaRegex();
grok.setField("message");
grok.setPattern("<(?<syslog_pri>\\d+)>(?<char>.)(?<char>.)(?<message>.*)");
Properties props = new Properties(Collections.emptyMap());
Assert.assertFalse("Failed to configure grok", grok.configure(props));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestOnigurumaRegex method testUtf1.
@Test
public void testUtf1() 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.configuration.Properties in project LogHub by fbacchella.
the class TestOnigurumaRegex method testLoadPatterns3.
// Test missing optionnal pattern
@Test
public void testLoadPatterns3() throws ProcessorException {
OnigurumaRegex grok = new OnigurumaRegex();
grok.setField("message");
grok.setPattern("^(?<prefix>\\*|\\.)?(?<message>.*)");
Properties props = new Properties(Collections.emptyMap());
Assert.assertTrue("Failed to configure grok", grok.configure(props));
Event e = Tools.getEvent();
e.put("message", "a text");
Assert.assertTrue(e.process(grok));
Assert.assertEquals("Didn't find the good message", "a text", e.get("message"));
Assert.assertEquals("Should not have found the prefix", null, e.get("prefix"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestScanBinary method simpleTestWithNames.
@Test
public void simpleTestWithNames() throws ProcessorException {
ScanBinary fs = new ScanBinary();
fs.setBitsNames(new String[] { "PF_PROT", "PF_WRITE", "PF_USER", "PF_RSVD", "PF_INSTR" });
fs.configure(new Properties(Collections.emptyMap()));
Event e = Event.emptyEvent(ConnectionContext.EMPTY);
e.put("binary", "13");
Assert.assertTrue(fs.processMessage(e, "binary", "value"));
Assert.assertArrayEquals("Bad decoding of bitfield", new String[] { "PF_PROT", "PF_USER", "PF_RSVD" }, (String[]) e.get("value"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestScanBinary method simpleTestWithVariableLengthNames.
@Test
public void simpleTestWithVariableLengthNames() throws ProcessorException {
ScanBinary fs = new ScanBinary();
fs.setBitsNames(new String[] { "a", "b", "c" });
fs.setAsMap(true);
fs.configure(new Properties(Collections.emptyMap()));
Event e = Event.emptyEvent(ConnectionContext.EMPTY);
e.put("binary", 0b101);
Assert.assertTrue(fs.processMessage(e, "binary", "value"));
@SuppressWarnings("unchecked") Map<String, Number> value = (Map<String, Number>) e.get("value");
Assert.assertEquals(1, value.get("a").intValue());
Assert.assertEquals(0, value.get("b").intValue());
Assert.assertEquals(1, value.get("c").intValue());
}
Aggregations