Search in sources :

Example 11 with Event

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());
}
Also used : Tools(loghub.Tools) Event(loghub.Event) Test(org.junit.Test)

Example 12 with Event

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());
}
Also used : Tools(loghub.Tools) Event(loghub.Event) Test(org.junit.Test)

Example 13 with Event

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));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Example 14 with Event

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"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Example 15 with Event

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());
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Event (loghub.Event)102 Test (org.junit.Test)90 Properties (loghub.configuration.Properties)63 Pipeline (loghub.Pipeline)23 Date (java.util.Date)19 Map (java.util.Map)18 HashMap (java.util.HashMap)14 IOException (java.io.IOException)13 Tools (loghub.Tools)13 URL (java.net.URL)8 Collections (java.util.Collections)8 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)8 Level (org.apache.logging.log4j.Level)7 List (java.util.List)6 EventsProcessor (loghub.EventsProcessor)6 LogManager (org.apache.logging.log4j.LogManager)6 Logger (org.apache.logging.log4j.Logger)6 LogUtils (loghub.LogUtils)5 ProcessorException (loghub.ProcessorException)5 Assert (org.junit.Assert)5