Search in sources :

Example 56 with Properties

use of loghub.configuration.Properties in project LogHub by fbacchella.

the class TestMapper method test2.

@Test
public void test2() 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", 1);
    Tools.runProcessing(sent, conf.namedPipeLine.get("mapper2"), conf);
    Assert.assertEquals("conversion not expected", "b", sent.get("a"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Pipeline(loghub.Pipeline) Test(org.junit.Test)

Example 57 with Properties

use of loghub.configuration.Properties 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 58 with Properties

use of loghub.configuration.Properties 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 59 with Properties

use of loghub.configuration.Properties 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 60 with Properties

use of loghub.configuration.Properties in project LogHub by fbacchella.

the class TestOnigurumaRegex method testLoadPatterns1.

@Test
public void testLoadPatterns1() 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)

Aggregations

Properties (loghub.configuration.Properties)74 Test (org.junit.Test)65 Event (loghub.Event)64 Pipeline (loghub.Pipeline)23 Date (java.util.Date)17 Map (java.util.Map)13 IOException (java.io.IOException)12 HashMap (java.util.HashMap)10 Collections (java.util.Collections)7 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)7 Level (org.apache.logging.log4j.Level)7 LogManager (org.apache.logging.log4j.LogManager)7 Logger (org.apache.logging.log4j.Logger)7 LogUtils (loghub.LogUtils)6 ProcessorException (loghub.ProcessorException)6 Tools (loghub.Tools)6 Assert (org.junit.Assert)6 BeforeClass (org.junit.BeforeClass)6 ConfigException (loghub.configuration.ConfigException)5 StringReader (java.io.StringReader)4