use of loghub.Event in project LogHub by fbacchella.
the class TestWrapping method testSourceLoading.
@SuppressWarnings("unchecked")
@Test
public void testSourceLoading() throws ConfigException, IOException, ProcessorException, InterruptedException {
Properties conf = Tools.loadConf("wrap.conf");
Event ev = Event.emptyEvent(null);
ev.put("a", new HashMap<Object, Object>());
EventsProcessor ep = new EventsProcessor(conf.mainQueue, conf.outputQueues, conf.namedPipeLine, conf.maxSteps, conf.repository);
ev.inject(conf.namedPipeLine.get("main"), conf.mainQueue);
ep.start();
Event processed = conf.outputQueues.get("main").poll(1, TimeUnit.SECONDS);
Assert.assertEquals("b", ((Map<String, Object>) processed.get("a")).get("c"));
}
use of loghub.Event 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.Event 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.Event 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.Event 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"));
}
Aggregations