Search in sources :

Example 76 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestMapper method test3.

@Test
public void test3() throws ProcessorException, InterruptedException, ConfigException, IOException {
    Properties conf = Tools.loadConf("map.conf");
    for (Pipeline pipe : conf.pipelines) {
        Assert.assertTrue("configuration failed", pipe.configure(conf));
    }
    Event sent = Tools.getEvent();
    sent.put("a", 3);
    Tools.runProcessing(sent, conf.namedPipeLine.get("mapper2"), conf);
    Assert.assertEquals("conversion not expected", 3, sent.get("a"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Pipeline(loghub.Pipeline) Test(org.junit.Test)

Example 77 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestNameResolver method test2.

@Test
public void test2() throws UnknownHostException, ProcessorException {
    NameResolver nr = new NameResolver();
    nr.setResolver("8.8.8.8");
    nr.setField("host");
    nr.setDestination("fqdn");
    nr.configure(new Properties(Collections.emptyMap()));
    Event e = Tools.getEvent();
    // / resolving a.root-servers.net.
    e.put("host", InetAddress.getByName("198.41.0.4"));
    Assert.assertTrue(nr.process(e));
    Assert.assertEquals("resolution failed", "a.root-servers.net", e.get("fqdn"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Example 78 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestNameResolver method test3.

@Test
public void test3() throws UnknownHostException, ProcessorException {
    NameResolver nr = new NameResolver();
    nr.setResolver("8.8.8.8");
    nr.setField("host");
    nr.setDestination("fqdn_${field%s}");
    nr.setTimeout(5);
    nr.configure(new Properties(Collections.emptyMap()));
    Event e = Tools.getEvent();
    // / resolving a.root-servers.net.
    e.put("host", InetAddress.getByName("2001:503:ba3e::2:30"));
    nr.process(e);
    Assert.assertEquals("resolution failed", "a.root-servers.net", e.get("fqdn_host"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Example 79 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestNettyNameResolver method arootasipv6string.

@Test(timeout = 6000)
public void arootasipv6string() throws ProcessorException, InterruptedException, ConfigException, IOException {
    Event e = Tools.getEvent();
    // resolving a.root-servers.net. in IPv6 as a String
    e.put("host", "2001:503:ba3e::2:30");
    Tools.ProcessingStatus status = dorequest(i -> {
        i.setField("host");
        i.setDestination("fqdn");
    }, e, "0.3.0.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.e.3.a.b.3.0.5.0.1.0.0.2.ip6.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 80 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestNettyNameResolver method arootasipv4string.

@Test(timeout = 6000)
public void arootasipv4string() throws ProcessorException, InterruptedException {
    Event e = Tools.getEvent();
    // / resolving a.root-servers.net. in IPv4 as String
    e.put("host", "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)

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