Search in sources :

Example 56 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestConditions method testif.

@Test
public void testif() throws ProcessorException, ConfigException, IOException {
    Properties conf = Tools.loadConf("conditions.conf");
    Event sent = Tools.getEvent();
    sent.put("a", "1");
    Tools.runProcessing(sent, conf.namedPipeLine.get("ifpipe"), conf);
    Assert.assertEquals("conversion not expected", String.class, sent.get("a").getClass());
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Example 57 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestConditions method testsuccess.

@Test
public void testsuccess() throws ProcessorException, ConfigException, IOException {
    Properties conf = Tools.loadConf("conditions.conf");
    Event sent = Tools.getEvent();
    sent.put("a", "1");
    Tools.runProcessing(sent, conf.namedPipeLine.get("successpipe"), conf);
    Assert.assertEquals("conversion not expected", "success", sent.get("test"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Example 58 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestDateParser method test2.

@Test
public void test2() throws ProcessorException {
    DateParser parse = new DateParser();
    parse.setPattern("yyyy-MM-dd'T'HH:m:ss.SSSSSSXXX");
    parse.setField("field");
    Assert.assertTrue(parse.configure(new Properties(Collections.emptyMap())));
    Event event = Tools.getEvent();
    event.put("field", "1970-01-01T00:00:00.000000+01:00");
    parse.process(event);
    Date date = (Date) event.get("field");
    Assert.assertEquals("date not parsed", -3600000, date.getTime());
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Date(java.util.Date) Test(org.junit.Test)

Example 59 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestDateParser method test3.

@Test
public void test3() throws ProcessorException {
    DateParser parse = new DateParser();
    parse.setPattern("yyyy-MM-dd'T'HH:m:ss");
    parse.setTimezone("Z");
    parse.setField("field");
    Assert.assertTrue(parse.configure(new Properties(Collections.emptyMap())));
    Event event = Tools.getEvent();
    event.put("field", "1970-01-01T00:00:00");
    parse.process(event);
    Date date = (Date) event.get("field");
    Assert.assertEquals("date not parsed", 0L, date.getTime());
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Date(java.util.Date) Test(org.junit.Test)

Example 60 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestDateParser method test4.

@Test
public void test4() throws ProcessorException {
    DateParser parse = new DateParser();
    parse.setField("field");
    Assert.assertTrue(parse.configure(new Properties(Collections.emptyMap())));
    Event event = Tools.getEvent();
    event.put("field", "Tue, 3 Jun 2008 11:05:30 +0110");
    parse.process(event);
    Assert.assertTrue("date not parsed", event.get("field") instanceof Date);
    Date date = (Date) event.get("field");
    Assert.assertEquals("date not parsed", 1212486930000L, date.getTime());
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Date(java.util.Date) 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