Search in sources :

Example 6 with JavaClassSource

use of org.jboss.forge.roaster.model.source.JavaClassSource in project camel by apache.

the class RoasterNewLineConstRouteBuilderConfigureTest method parse.

@Test
public void parse() throws Exception {
    JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.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("file:output?fileExist=Append&chmod=777&allowNullBody=true", list.get(0).getElement());
    Assert.assertEquals("log:b", 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 7 with JavaClassSource

use of org.jboss.forge.roaster.model.source.JavaClassSource 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());
}
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 8 with JavaClassSource

use of org.jboss.forge.roaster.model.source.JavaClassSource 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());
}
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 9 with JavaClassSource

use of org.jboss.forge.roaster.model.source.JavaClassSource 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());
    }
}
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 10 with JavaClassSource

use of org.jboss.forge.roaster.model.source.JavaClassSource 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());
}
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)

Aggregations

JavaClassSource (org.jboss.forge.roaster.model.source.JavaClassSource)95 File (java.io.File)37 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)26 ParserResult (org.apache.camel.parser.ParserResult)19 List (java.util.List)15 IOException (java.io.IOException)14 MethodSource (org.jboss.forge.roaster.model.source.MethodSource)12 InputStream (java.io.InputStream)10 Collections (java.util.Collections)10 Roaster (org.jboss.forge.roaster.Roaster)10 BufferedReader (java.io.BufferedReader)8 HashMap (java.util.HashMap)8 Matcher (java.util.regex.Matcher)8 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)8 ObjectProperty (org.kie.workbench.common.services.datamodeller.core.ObjectProperty)8 Arrays (java.util.Arrays)7 Map (java.util.Map)7 Import (org.jboss.forge.roaster.model.source.Import)7 ClassTypeResolver (org.kie.soup.project.datamodel.commons.types.ClassTypeResolver)7