use of loghub.configuration.ConfigListener.ObjectWrapped in project LogHub by fbacchella.
the class TestParser method testType.
@Test
public void testType() throws IOException {
CharStream cs = CharStreams.fromStream(getClass().getClassLoader().getResourceAsStream("types.conf"), CharsetUtil.UTF_8);
RouteLexer lexer = new RouteLexer(cs);
CommonTokenStream tokens = new CommonTokenStream(lexer);
RouteParser parser = new RouteParser(tokens);
parser.removeErrorListeners();
ConfigErrorListener errListener = new ConfigErrorListener();
parser.addErrorListener(errListener);
// begin parsing at init rule
loghub.RouteParser.ConfigurationContext tree = parser.configuration();
ConfigListener conf = new ConfigListener();
ParseTreeWalker walker = new ParseTreeWalker();
walker.walk(conf, tree);
Assert.assertEquals("stack not empty :" + conf.stack, 0, conf.stack.size());
ConfigListener.PipenodesList main = conf.pipelines.get("main");
ObjectDescription p = (ObjectDescription) main.processors.get(0);
Assert.assertTrue(((ObjectWrapped) p.beans.get("string")).wrapped instanceof String);
Assert.assertTrue(((ObjectWrapped) p.beans.get("boolean")).wrapped instanceof Boolean);
Assert.assertTrue(((ObjectWrapped) p.beans.get("int")).wrapped instanceof Integer);
Assert.assertTrue(((ObjectWrapped) p.beans.get("double")).wrapped instanceof Double);
Assert.assertArrayEquals(new Object[] { "0", 1, 1.0, true }, (Object[]) ((ObjectWrapped) p.beans.get("array")).wrapped);
}
Aggregations