use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestServer method testSimple.
@Test(timeout = 2000)
public void testSimple() throws InterruptedException {
Properties empty = new Properties(Collections.emptyMap());
BlockingQueue<Event> receiver = new ArrayBlockingQueue<>(1);
TesterReceiver r = new TesterReceiver(receiver, new Pipeline(Collections.emptyList(), "testone", null));
r.configure(empty);
final ChannelFuture[] sent = new ChannelFuture[1];
EventLoopGroup workerGroup = new DefaultEventLoopGroup();
Bootstrap b = new Bootstrap();
b.group(workerGroup);
b.channel(LocalChannel.class);
b.handler(new SimpleChannelInboundHandler<ByteBuf>() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
sent[0] = ctx.writeAndFlush(Unpooled.copiedBuffer("Message\r\n", CharsetUtil.UTF_8));
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
}
});
// Start the client.
ChannelFuture f = b.connect(new LocalAddress(TestServer.class.getCanonicalName())).sync();
Thread.sleep(100);
sent[0].sync();
f.channel().close();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
Event e = receiver.poll();
Assert.assertEquals("Message", e.get("message"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestConditions method testfailure.
@Test
public void testfailure() throws InterruptedException, ProcessorException, ConfigException, IOException {
Properties conf = Tools.loadConf("conditions.conf");
Event sent = Tools.getEvent();
sent.put("a", "a");
Tools.runProcessing(sent, conf.namedPipeLine.get("failurepipe"), conf);
Assert.assertEquals("conversion not expected", "a", sent.get("a"));
Assert.assertEquals("conversion not expected", "failure", sent.get("test"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestConditions method testignored.
@Test
public void testignored() throws InterruptedException, ProcessorException, ConfigException, IOException {
Properties conf = Tools.loadConf("conditions.conf");
Event sent = Tools.getEvent();
sent.put("z", "1");
Tools.runProcessing(sent, conf.namedPipeLine.get("ignore"), conf);
Assert.assertEquals("success was called", null, sent.get("b"));
Assert.assertEquals("failure was called", null, sent.get("c"));
Assert.assertEquals("exception was called", null, sent.get("d"));
Assert.assertEquals("Event was processed, when it should not have been", "1", sent.get("z"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestConditions method testsubpipe.
@Test
public void testsubpipe() throws InterruptedException, ProcessorException, ConfigException, IOException {
Properties conf = Tools.loadConf("conditions.conf");
Event sent = Tools.getEvent();
sent.put("a", "1");
Tools.runProcessing(sent, conf.namedPipeLine.get("subpipe"), conf);
Assert.assertEquals("sup pipeline not processed", 1, sent.get("b"));
Assert.assertEquals("sup pipeline not processed", 2, sent.get("c"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestDateParser method testAgain2.
@Test
public void testAgain2() throws ProcessorException {
DateParser parse = new DateParser();
parse.setPattern("MMM dd HH:mm:ss.SSS");
parse.setTimezone("CET");
parse.setField("field");
Assert.assertTrue(parse.configure(new Properties(Collections.emptyMap())));
Event event = Tools.getEvent();
event.put("field", "Jul 26 16:40:22.238");
parse.process(event);
Date date = (Date) event.get("field");
OffsetDateTime t = OffsetDateTime.ofInstant(date.toInstant(), ZoneId.of("GMT"));
Assert.assertEquals("date not parsed", 14, t.getLong(ChronoField.HOUR_OF_DAY));
}
Aggregations