use of org.apache.camel.parser.ParserResult in project camel by apache.
the class RoasterRouteBuilderCamelTestSupportTest method parse.
@Test
public void parse() throws Exception {
JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyRouteTest.java"));
MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, false);
for (ParserResult result : list) {
LOG.info("Consumer: " + result.getElement());
}
Assert.assertEquals("direct:foo", list.get(0).getElement());
list = CamelJavaParserHelper.parseCamelProducerUris(method, true, false);
for (ParserResult result : list) {
LOG.info("Producer: " + result.getElement());
}
Assert.assertEquals("mock:foo", list.get(0).getElement());
}
use of org.apache.camel.parser.ParserResult in project camel by apache.
the class RoasterRouteBuilderConfigureTest method parse.
@Test
public void parse() throws Exception {
JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java"));
MethodSource<JavaClassSource> method = clazz.getMethod("configure");
List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, false);
for (ParserResult result : list) {
LOG.info("Consumer: " + result.getElement());
}
Assert.assertEquals("timer:foo", list.get(0).getElement());
list = CamelJavaParserHelper.parseCamelProducerUris(method, true, false);
for (ParserResult result : list) {
LOG.info("Producer: " + result.getElement());
}
Assert.assertEquals("log:a", list.get(0).getElement());
Assert.assertEquals("mock:tap", list.get(1).getElement());
Assert.assertEquals("log:b", list.get(2).getElement());
}
use of org.apache.camel.parser.ParserResult in project camel by apache.
the class RoasterRouteBuilderEmptyUriTest method parse.
@Test
public void parse() throws Exception {
JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java"));
MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, false);
for (ParserResult result : list) {
LOG.info("Consumer: " + result.getElement());
}
Assert.assertEquals("direct:foo", list.get(0).getElement());
list = CamelJavaParserHelper.parseCamelProducerUris(method, true, false);
Assert.assertEquals(1, list.size());
for (ParserResult result : list) {
LOG.info("Producer: " + result.getElement());
Assert.assertFalse("Should be invalid", result.isParsed());
}
}
use of org.apache.camel.parser.ParserResult in project camel by apache.
the class RoasterSimpleProcessorTest method parse.
@Test
public void parse() throws Exception {
JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java"));
MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
List<CamelEndpointDetails> details = new ArrayList<CamelEndpointDetails>();
RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java", details);
LOG.info("{}", details);
List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
for (ParserResult result : list) {
LOG.info("Consumer: " + result.getElement());
}
Assert.assertEquals("direct:start", list.get(0).getElement());
list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
for (ParserResult result : list) {
LOG.info("Producer: " + result.getElement());
}
Assert.assertEquals(0, list.size());
Assert.assertEquals(1, details.size());
Assert.assertEquals("direct:start", details.get(0).getEndpointUri());
}
use of org.apache.camel.parser.ParserResult in project camel by apache.
the class RoasterSimpleRouteBuilderConfigureTest method parse.
@Test
public void parse() throws Exception {
JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java"));
MethodSource<JavaClassSource> method = clazz.getMethod("configure");
List<ParserResult> list = CamelJavaParserHelper.parseCamelSimpleExpressions(method);
for (ParserResult simple : list) {
LOG.info("Simple: " + simple.getElement());
LOG.info(" Line: " + findLineNumber(simple.getPosition()));
}
Assert.assertEquals("${body} > 100", list.get(0).getElement());
Assert.assertEquals(true, list.get(0).getPredicate());
Assert.assertEquals(27, findLineNumber(list.get(0).getPosition()));
Assert.assertEquals("${body} > 200", list.get(1).getElement());
Assert.assertEquals(true, list.get(1).getPredicate());
Assert.assertEquals(30, findLineNumber(list.get(1).getPosition()));
}
Aggregations