Search in sources :

Example 11 with ParserResult

use of org.apache.camel.parser.ParserResult in project camel by apache.

the class RoasterSimpleToFTest method parse.

@Test
public void parse() throws Exception {
    JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java"));
    MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
    List<CamelEndpointDetails> details = new ArrayList<>();
    RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.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("toF", list.get(0).getNode());
    Assert.assertEquals("log:a?level={{%s}}", list.get(0).getElement());
    Assert.assertEquals(1, list.size());
    Assert.assertEquals(2, details.size());
    Assert.assertEquals("direct:start", details.get(0).getEndpointUri());
    Assert.assertEquals("log:a?level={{%s}}", details.get(1).getEndpointUri());
}
Also used : CamelEndpointDetails(org.apache.camel.parser.model.CamelEndpointDetails) ParserResult(org.apache.camel.parser.ParserResult) ArrayList(java.util.ArrayList) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) File(java.io.File) Test(org.junit.Test)

Example 12 with ParserResult

use of org.apache.camel.parser.ParserResult in project camel by apache.

the class RoasterSplitTokenizeTest method parse.

@Test
public void parse() throws Exception {
    JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java"));
    MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
    List<CamelEndpointDetails> details = new ArrayList<>();
    RouteBuilderParser.parseRouteBuilderEndpoints(clazz, "src/test/java", "org/apache/camel/parser/SplitTokenizeTest.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:a", list.get(0).getElement());
    Assert.assertEquals("direct:b", list.get(1).getElement());
    Assert.assertEquals("direct:c", list.get(2).getElement());
    Assert.assertEquals("direct:d", list.get(3).getElement());
    Assert.assertEquals("direct:e", list.get(4).getElement());
    Assert.assertEquals("direct:f", list.get(5).getElement());
    list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
    for (ParserResult result : list) {
        LOG.info("Producer: " + result.getElement());
    }
    Assert.assertEquals("mock:split", list.get(0).getElement());
    Assert.assertEquals("mock:split", list.get(1).getElement());
    Assert.assertEquals("mock:split", list.get(2).getElement());
    Assert.assertEquals("mock:split", list.get(3).getElement());
    Assert.assertEquals("mock:split", list.get(4).getElement());
    Assert.assertEquals("mock:split", list.get(5).getElement());
    Assert.assertEquals(12, details.size());
    Assert.assertEquals("direct:a", details.get(0).getEndpointUri());
    Assert.assertEquals("mock:split", details.get(11).getEndpointUri());
}
Also used : CamelEndpointDetails(org.apache.camel.parser.model.CamelEndpointDetails) ParserResult(org.apache.camel.parser.ParserResult) ArrayList(java.util.ArrayList) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) File(java.io.File) Test(org.junit.Test)

Example 13 with ParserResult

use of org.apache.camel.parser.ParserResult in project camel by apache.

the class RoasterCdiConcatRouteBuilderConfigureTest method parse.

@Test
public void parse() throws Exception {
    JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java"));
    MethodSource<JavaClassSource> method = clazz.getMethod("configure");
    List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
    for (ParserResult result : list) {
        LOG.info("Consumer: " + result.getElement());
    }
    Assert.assertEquals("timer:foo?period=4999", list.get(0).getElement());
    list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
    for (ParserResult result : list) {
        LOG.info("Producer: " + result.getElement());
    }
    Assert.assertEquals("log:a", list.get(0).getElement());
    Assert.assertEquals("netty4-http:http:someserver:80/hello", list.get(1).getElement());
}
Also used : ParserResult(org.apache.camel.parser.ParserResult) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) File(java.io.File) Test(org.junit.Test)

Example 14 with ParserResult

use of org.apache.camel.parser.ParserResult in project camel by apache.

the class RoasterCdiRouteBuilderConfigureTest method parse.

@Test
public void parse() throws Exception {
    JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java"));
    MethodSource<JavaClassSource> method = clazz.getMethod("configure");
    List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
    for (ParserResult result : list) {
        LOG.info("Consumer: " + result.getElement());
    }
    Assert.assertEquals("timer:foo?period=4999", list.get(0).getElement());
    list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
    for (ParserResult result : list) {
        LOG.info("Producer: " + result.getElement());
    }
    Assert.assertEquals("log:a", list.get(0).getElement());
    Assert.assertEquals("netty4-http:http:someserver:80/hello", list.get(1).getElement());
}
Also used : ParserResult(org.apache.camel.parser.ParserResult) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) File(java.io.File) Test(org.junit.Test)

Example 15 with ParserResult

use of org.apache.camel.parser.ParserResult in project camel by apache.

the class RoasterConcatFieldRouteBuilderConfigureTest method parse.

@Test
public void parse() throws Exception {
    JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java"));
    MethodSource<JavaClassSource> method = clazz.getMethod("configure");
    List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
    for (ParserResult result : list) {
        LOG.info("Consumer: " + result.getElement());
    }
    Assert.assertEquals("ftp:localhost:{{ftpPort}}/myapp?password=admin&username=admin", list.get(0).getElement());
    list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
    for (ParserResult result : list) {
        LOG.info("Producer: " + result.getElement());
    }
    Assert.assertEquals("log:b", list.get(0).getElement());
}
Also used : ParserResult(org.apache.camel.parser.ParserResult) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) File(java.io.File) Test(org.junit.Test)

Aggregations

ParserResult (org.apache.camel.parser.ParserResult)23 File (java.io.File)19 JavaClassSource (org.jboss.forge.roaster.model.source.JavaClassSource)19 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)9 CamelEndpointDetails (org.apache.camel.parser.model.CamelEndpointDetails)5 Expression (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Expression)4 InfixExpression (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.InfixExpression)4 ParenthesizedExpression (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ParenthesizedExpression)4 List (java.util.List)2 Block (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Block)2 ExpressionStatement (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ExpressionStatement)2 MethodDeclaration (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodDeclaration)2 StatementFieldSource (org.apache.camel.parser.roaster.StatementFieldSource)1 ASTNode (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode)1 MemberValuePair (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MemberValuePair)1 MethodInvocation (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodInvocation)1 NormalAnnotation (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NormalAnnotation)1 SimpleName (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleName)1 SingleMemberAnnotation (org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SingleMemberAnnotation)1