You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/12/05 13:12:34 UTC
[01/25] camel git commit: CAMEL-10559: maven plugin to validate using
the route parser. Donated from fabric8 project.
Repository: camel
Updated Branches:
refs/heads/master 1d23b6214 -> 19e59f35a
CAMEL-10559: maven plugin to validate using the route parser. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7c4b41f9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7c4b41f9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7c4b41f9
Branch: refs/heads/master
Commit: 7c4b41f9c2a3b8294fe1042eeacf6fea03c7ac8c
Parents: 68ddc37
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 14:03:28 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
.../src/main/docs/camel-maven-plugin.adoc | 233 +++++++++++++++++++
1 file changed, 233 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7c4b41f9/tooling/maven/camel-maven-plugin/src/main/docs/camel-maven-plugin.adoc
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-maven-plugin/src/main/docs/camel-maven-plugin.adoc b/tooling/maven/camel-maven-plugin/src/main/docs/camel-maven-plugin.adoc
new file mode 100644
index 0000000..83706f6
--- /dev/null
+++ b/tooling/maven/camel-maven-plugin/src/main/docs/camel-maven-plugin.adoc
@@ -0,0 +1,233 @@
+= Camel Maven Plugin
+
+The Camel Maven Plugin supports the following goals
+
+ - camel:run - To run your Camel application
+ - camel:validate - To validate your source code for invalid Camel endpoint uris
+
+== camel:run
+
+The `camel:run` goal of the Camel Maven Plugin is used to run your Camel Spring configurations in a forked JVM from Maven.
+A good example application to get you started is the Spring Example.
+
+ cd examples/camel-example-spring
+ mvn camel:run
+
+This makes it very easy to spin up and test your routing rules without having to write a main(...) method;
+it also lets you create multiple jars to host different sets of routing rules and easily test them independently.
+
+How this works is that the plugin will compile the source code in the maven project,
+then boot up a Spring ApplicationContext using the XML configuration files on the classpath at `META-INF/spring/*.xml`
+
+If you want to boot up your Camel routes a little faster, you could try the `camel:embedded` instead.
+
+== Running OSGi Blueprint
+
+The `camel:run` plugin also supports running a Blueprint application, and by default it scans for OSGi blueprint files in
+`OSGI-INF/blueprint/*.xml`
+
+You would need to configure the camel:run plugin to use blueprint, by setting useBlueprint to true as shown below
+
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <configuration>
+ <useBlueprint>true</useBlueprint>
+ </configuration>
+ </plugin>
+
+This allows you to boot up any Blueprint services you wish - whether they are Camel-related, or any other Blueprint.
+
+The `camel:run` goal is able to auto detect if camel-blueprint is on the classpath or there is blueprint XML files
+in the project, and therefore you no longer have to configure the useBlueprint option.
+
+=== Using limited Blueprint container
+
+We use the Felix Connector project as the blueprint container. This project is not a full fledged blueprint container.
+For that you can use Apache Karaf or Apache ServiceMix.
+You can use the applicationContextUri configuration to specify an explicit blueprint XML file, such as:
+
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <configuration>
+ <useBlueprint>true</useBlueprint>
+ <applicationContextUri>myBlueprint.xml</applicationContextUri>
+ <!-- ConfigAdmin options which have been added since Camel 2.12.0 -->
+ <configAdminPid>test</configAdminPid>
+ <configAdminFileName>/user/test/etc/test.cfg</configAdminFileName>
+ </configuration>
+ </plugin>
+
+The `applicationContextUri` will currently load the file from the classpath, so in the example above the
+`myBlueprint.xml` file must be in the root of the classpath.
+
+The `configAdminPid` is the pid name which will be used as the pid name for configuration admin service when
+loading the persistence properties file.
+
+The `configAdminFileName` is the file name which will be used to load the configuration admin service properties file.
+
+
+== Running CDI
+
+The `camel:run` plugin also supports running a CDI application
+
+This allows you to boot up any CDI services you wish - whether they are Camel-related, or any other CDI enabled services.
+You should add the CDI container of your choice (e.g. Weld or OpenWebBeans) to the dependencies of the camel-maven-plugin such as in this example.
+
+From the source of Camel you can run a CDI example via
+
+ cd examples/camel-example-cdi
+ mvn compile camel:run
+
+== Logging the classpath
+
+You can configure whether the classpath should be logged when `camel:run` executes.
+You can enable this in the configuration using:
+
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <configuration>
+ <logClasspath>true</logClasspath>
+ </configuration>
+ </plugin>
+
+## Fabric8 Camel Maven Plugin
+
+This maven plugin makes it possible to run some of the [Forge](forge.md) commands from Maven command line.
+
+
+== camel:validate
+
+For validating Camel endpoints in the source code:
+
+Then you can run the validate goal from the command line or from within your Java editor such as IDEA or Eclipse.
+
+ mvn camel:validate
+
+You can also enable the plugin to automatic run as part of the build to catch these errors.
+
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <version>2.19.0</version>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>validate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+The phase determines when the plugin runs. In the sample above the phase is `process-classes` which runs after
+the compilation of the main source code.
+
+The maven plugin can also be configured to validate the test source code , which means that the phase should be
+changed accordingly to `process-test-classes` as shown below:
+
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <version>2.19.0</version>
+ <executions>
+ <execution>
+ <configuration>
+ <includeTest>true</includeTest>
+ </configuration>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>validate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+
+=== Running the goal on any Maven project
+
+You can also run the validate goal on any Maven project without having to add the plugin to the `pom.xml` file.
+Doing so requires to specify the plugin using its fully qualified name. For example to run the goal on
+the `camel-example-cdi` from Apache Camel you can run
+
+ $cd camel-example-cdi
+ $mvn org.apache.camel:camel-maven-plugin:2.19.0:validate
+
+which then runs and outputs the following:
+
+```
+[INFO] ------------------------------------------------------------------------
+[INFO] Building Camel :: Example :: CDI 2.19.0
+[INFO] ------------------------------------------------------------------------
+[INFO]
+[INFO] --- camel-maven-plugin:2.19.0:validate (default-cli) @ camel-example-cdi ---
+[INFO] Endpoint validation success: (4 = passed, 0 = invalid, 0 = incapable, 0 = unknown components)
+[INFO] Simple validation success: (0 = passed, 0 = invalid)
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+```
+
+The validation passed, and 4 endpoints was validated. Now suppose we made a typo in one of the Camel endpoint uris in the source code, such as:
+
+ @Uri("timer:foo?period=5000")
+
+is changed to include a typo error in the `period` option
+
+ @Uri("timer:foo?perid=5000")
+
+And when running the validate goal again reports the following:
+
+```
+[INFO] ------------------------------------------------------------------------
+[INFO] Building Camel :: Example :: CDI 2.19.0
+[INFO] ------------------------------------------------------------------------
+[INFO]
+[INFO] --- camel-maven-plugin:2.19.0:validate (default-cli) @ camel-example-cdi ---
+[WARNING] Endpoint validation error at: org.apache.camel.example.cdi.MyRoutes(MyRoutes.java:32)
+
+ timer:foo?perid=5000
+
+ perid Unknown option. Did you mean: [period]
+
+
+[WARNING] Endpoint validation error: (3 = passed, 1 = invalid, 0 = incapable, 0 = unknown components)
+[INFO] Simple validation success: (0 = passed, 0 = invalid)
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+```
+
+
+=== Options
+
+The maven plugin supports the following options which can be configured from the command line (use `-D` syntax), or defined in the `pom.xml` file in the `<configuration>` tag.
+
+|========================================
+| Parameter | Default Value | Description
+| downloadVersion | true | Whether to allow downloading Camel catalog version from the internet. This is needed if the project uses a different Camel version than this plugin is using by default.
+| failOnError | false | Whether to fail if invalid Camel endpoints was found. By default the plugin logs the errors at WARN level.
+| logUnparseable | false | Whether to log endpoint URIs which was un-parsable and therefore not possible to validate.
+| includeJava | true | Whether to include Java files to be validated for invalid Camel endpoints.
+| includeXml | true | Whether to include XML files to be validated for invalid Camel endpoints.
+| includeTest | false | Whether to include test source code.
+| includes | | To filter the names of java and xml files to only include files matching any of the given list of patterns (wildcard and regular expression). Multiple values can be separated by comma.
+| excludes | | To filter the names of java and xml files to exclude files matching any of the given list of patterns (wildcard and regular expression). Multiple values can be separated by comma.
+| ignoreUnknownComponent | true | Whether to ignore unknown components.
+| ignoreIncapable | true | Whether to ignore incapable of parsing the endpoint uri or simple expression.
+| ignoreLenientProperties | true | Whether to ignore components that uses lenient properties. When this is true, then the uri validation is stricter but would fail on properties that are not part of the component but in the uri because of using lenient properties. For example using the HTTP components to provide query parameters in the endpoint uri.
+| showAll | false | Whether to show all endpoints and simple expressions (both invalid and valid).
+| downloadVersion | true | Whether to allow downloading Camel catalog version from the internet. This is needed if the project uses a different Camel version than this plugin is using by default..
+|========================================
+
+
+=== Validating include test
+
+If you have a Maven project then you can run the plugin to validate the endpoints in the unit test source code as well.
+You can pass in the options using `-D` style as shown:
+
+ $cd myproject
+ $mvn org.apache.camel:camel-maven-plugin:2.19.0:validate -DincludeTest=true
+
[12/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
index d964a0d..e0c3eee 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
index 926d62d..88ee8f2 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
index c2e95f8..de37bf8 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
index 56c530e..4243dff 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
index b39fc2d..66aa612 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
@@ -19,11 +19,12 @@ package org.apache.camel.parser.xml;
import java.io.FileInputStream;
import java.io.InputStream;
+import org.w3c.dom.Element;
+
import org.apache.camel.parser.CamelXmlHelper;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.w3c.dom.Element;
import static org.junit.Assert.assertNotNull;
[09/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSplitTokenizeTest.java
deleted file mode 100644
index c12a5e3..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSplitTokenizeTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterSplitTokenizeTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterSplitTokenizeTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/SimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/SimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/SimpleProcessorTest.java
deleted file mode 100644
index 3c5f7b3..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/SimpleProcessorTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-
-public class SimpleProcessorTest extends CamelTestSupport {
-
- public void testProcess() throws Exception {
- String out = template.requestBody("direct:start", "Hello World", String.class);
- assertEquals("Bye World", out);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start").process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getOut().setBody("Bye World");
- }
- });
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/SplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/SplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/SplitTokenizeTest.java
deleted file mode 100644
index 251e531..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/SplitTokenizeTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-
-public class SplitTokenizeTest extends CamelTestSupport {
-
- public void testSplitTokenizerA() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("Claus", "James", "Willem");
-
- template.sendBody("direct:a", "Claus,James,Willem");
-
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerB() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("Claus", "James", "Willem");
-
- template.sendBodyAndHeader("direct:b", "Hello World", "myHeader", "Claus,James,Willem");
-
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerC() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("Claus", "James", "Willem");
-
- template.sendBody("direct:c", "Claus James Willem");
-
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerD() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("[Claus]", "[James]", "[Willem]");
-
- template.sendBody("direct:d", "[Claus][James][Willem]");
-
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerE() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("<person>Claus</person>", "<person>James</person>", "<person>Willem</person>");
-
- String xml = "<persons><person>Claus</person><person>James</person><person>Willem</person></persons>";
- template.sendBody("direct:e", xml);
-
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerEWithSlash() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- String xml = "<persons><person attr='/' /></persons>";
- mock.expectedBodiesReceived("<person attr='/' />");
- template.sendBody("direct:e", xml);
- mock.assertIsSatisfied();
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerF() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("<person name=\"Claus\"/>", "<person>James</person>", "<person>Willem</person>");
-
- String xml = "<persons><person/><person name=\"Claus\"/><person>James</person><person>Willem</person></persons>";
- template.sendBody("direct:f", xml);
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
-
- from("direct:a")
- .split().tokenize(",")
- .to("mock:split");
-
- from("direct:b")
- .split().tokenize(",", "myHeader")
- .to("mock:split");
-
- from("direct:c")
- .split().tokenize("(\\W+)\\s*", null, true)
- .to("mock:split");
-
- from("direct:d")
- .split().tokenizePair("[", "]", true)
- .to("mock:split");
-
- from("direct:e")
- .split().tokenizeXML("person")
- .to("mock:split");
-
- from("direct:f")
- .split().xpath("//person")
- // To test the body is not empty
- // it will call the ObjectHelper.evaluateValuePredicate()
- .filter().simple("${body}")
- .to("mock:split");
-
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
new file mode 100644
index 0000000..1a4336e
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public abstract class MyBasePortRouteBuilder extends RouteBuilder {
+
+ public int getNextPort() {
+ return 8080;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
new file mode 100644
index 0000000..1360d00
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.Uri;
+
+public class MyCdiConcatRouteBuilder extends RouteBuilder {
+
+ private static final int DELAY = 4999;
+ private static final int PORT = 80;
+
+ @Inject
+ @Uri("timer:foo?period=" + DELAY)
+ private Endpoint inputEndpoint;
+
+ @Inject
+ @Uri("log:a")
+ private Endpoint loga;
+
+ @EndpointInject(uri = "netty4-http:http:someserver:" + PORT + "/hello")
+ private Endpoint mynetty;
+
+ @Override
+ public void configure() throws Exception {
+ from(inputEndpoint)
+ .log("I was here")
+ .to(loga)
+ .to(mynetty);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
new file mode 100644
index 0000000..16261bb
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.Uri;
+
+public class MyCdiRouteBuilder extends RouteBuilder {
+
+ @Inject
+ @Uri("timer:foo?period=4999")
+ private Endpoint inputEndpoint;
+
+ @Inject
+ @Uri("log:a")
+ private Endpoint loga;
+
+ @Inject
+ @Uri("netty4-http:http:someserver:80/hello")
+ private Endpoint mynetty;
+
+ @Override
+ public void configure() throws Exception {
+ from(inputEndpoint)
+ .log("I was here")
+ .to(loga)
+ .to(mynetty);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
new file mode 100644
index 0000000..7fedeaf
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyConcatFieldRouteBuilder extends RouteBuilder {
+
+ private int ftpPort;
+ private String ftp = "ftp:localhost:" + ftpPort + "/myapp?password=admin&username=admin";
+
+ @Override
+ public void configure() throws Exception {
+ from(ftp)
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
new file mode 100644
index 0000000..5cdfa5d
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+public class MyFieldMethodCallRouteBuilder extends MyBasePortRouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ int port2 = getNextPort();
+
+ from("netty-http:http://0.0.0.0:{{port}}/foo")
+ .to("mock:input1")
+ .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
+ from("netty-http:http://0.0.0.0:" + port2 + "/bar")
+ .to("mock:input2")
+ .transform().constant("Bye World");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
new file mode 100644
index 0000000..7515c58
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyFieldRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ String exists = "Override";
+
+ from("timer:foo")
+ .toD("file:output?fileExist=" + exists)
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
new file mode 100644
index 0000000..0409d4b
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class MyLocalAddRouteBuilderTest extends CamelTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Test
+ public void testFoo() throws Exception {
+ log.info("Adding a route locally");
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("mock:foo");
+ }
+ });
+ context.start();
+
+ getMockEndpoint("mock:foo").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
new file mode 100644
index 0000000..2a56891
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyMethodCallRouteBuilder extends RouteBuilder {
+
+ private String whatToDoWhenExists() {
+ return "Override";
+ }
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .to("file:output?fileExist=" + whatToDoWhenExists())
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
new file mode 100644
index 0000000..bf8f16b
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class MyNettyTest extends CamelTestSupport {
+
+ public int getNextPort() {
+ return 8080;
+ }
+
+ @Test
+ public void testFoo() throws Exception {
+ // noop
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ int port2 = getNextPort();
+
+ @Override
+ public void configure() throws Exception {
+ from("netty-http:http://0.0.0.0:{{port}}/foo")
+ .to("mock:input1")
+ .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
+ from("netty-http:http://0.0.0.0:" + port2 + "/bar")
+ .to("mock:input2")
+ .transform().constant("Bye World");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
new file mode 100644
index 0000000..95a0a4f
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyNewLineConstRouteBuilder extends RouteBuilder {
+
+ private static final String EXISTS = "Append";
+ private static final int MOD = 770;
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .toD("file:output?fileExist=" + EXISTS
+ + "&chmod=" + (MOD + 6 + 1)
+ + "&allowNullBody=true")
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
new file mode 100644
index 0000000..4b34945
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyNewLineRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .toD("file:output?fileExist=Append"
+ + "&chmod=777"
+ + "&allowNullBody=true")
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
new file mode 100644
index 0000000..5bc9803
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .log("I was here")
+ .toD("log:a")
+ .wireTap("mock:tap")
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
new file mode 100644
index 0000000..82732d2
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class MyRouteEmptyUriTest extends CamelTestSupport {
+
+ @Test
+ public void testFoo() throws Exception {
+ // noop
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:foo")
+ .to(""); // is empty on purpose
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
new file mode 100644
index 0000000..1a03847
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class MyRouteTest extends CamelTestSupport {
+
+ @Test
+ public void testFoo() throws Exception {
+ // noop
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:foo")
+ .to("mock:foo");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
new file mode 100644
index 0000000..490a575
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MySimpleRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .filter(simple("${body} > 100"))
+ .toD("log:a")
+ .end()
+ .filter().simple("${body} > 200")
+ .to("log:b")
+ .end()
+ .to("log:c");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
new file mode 100644
index 0000000..105791f
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.builder.RouteBuilder;
+
+public class MySimpleToDRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+
+ String uri = "log:c";
+
+ from("direct:start")
+ .toD("log:a", true)
+ .to(ExchangePattern.InOnly, "log:b")
+ .to(uri);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
new file mode 100644
index 0000000..89b3f0e
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
@@ -0,0 +1,27 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MySimpleToFRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .toF("log:a?level=%s", "info");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..90d0423
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterCdiConcatRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterCdiConcatRouteBuilderConfigureTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..2c0677c
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ * <p/>
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterCdiRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterCdiRouteBuilderConfigureTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..a74d161
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterConcatFieldRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterConcatFieldRouteBuilderConfigureTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
new file mode 100644
index 0000000..5d54b7c
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
@@ -0,0 +1,72 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterEndpointInjectTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterEndpointInjectTest.class);
+
+ @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 = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<CamelEndpointDetails> details = new ArrayList<>();
+ RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java", details);
+ LOG.info("{}", details);
+
+ Assert.assertEquals("timer:foo?period=4999", details.get(0).getEndpointUri());
+ Assert.assertEquals("27", details.get(0).getLineNumber());
+
+ Assert.assertEquals("log:a", details.get(1).getEndpointUri());
+ Assert.assertEquals("31", details.get(1).getLineNumber());
+
+ Assert.assertEquals("netty4-http:http:someserver:80/hello", details.get(2).getEndpointUri());
+ Assert.assertEquals("35", details.get(2).getLineNumber());
+
+ 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(2, list.size());
+
+ Assert.assertEquals(5, details.size());
+ Assert.assertEquals("log:a", details.get(3).getEndpointUri());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..d3c7e72
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterFieldRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterFieldRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.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", list.get(0).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("file:output?fileExist=Override", list.get(0).getElement());
+ Assert.assertEquals("log:b", list.get(1).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..18e589e
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMethodCallRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMethodCallRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.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", list.get(0).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("file:output?fileExist={{whatToDoWhenExists}}", list.get(0).getElement());
+ Assert.assertEquals("log:b", list.get(1).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..2be99cf
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMyFieldMethodCallRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMyFieldMethodCallRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.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("netty-http:http://0.0.0.0:{{port}}/foo", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("mock:input1", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+ Assert.assertEquals("mock:input2", list.get(2).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
new file mode 100644
index 0000000..523f906
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMyLocalAddRouteBuilderTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMyLocalAddRouteBuilderTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+ Assert.assertNull(method);
+
+ List<MethodSource<JavaClassSource>> methods = CamelJavaParserHelper.findInlinedConfigureMethods(clazz);
+ Assert.assertEquals(1, methods.size());
+ method = methods.get(0);
+
+ List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Consumer: " + result.getElement());
+ }
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
new file mode 100644
index 0000000..a787671
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMyNettyTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMyNettyTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyNettyTest.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Consumer: " + result.getElement());
+ }
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{port}}/foo", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("mock:input1", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+ Assert.assertEquals("mock:input2", list.get(2).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..c6c36e5
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterNewLineConstRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterNewLineConstRouteBuilderConfigureTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..999bcfd
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterNewLineRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterNewLineRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
new file mode 100644
index 0000000..b9e902b
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterRouteBuilderCamelTestSupportTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderCamelTestSupportTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..896b938
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderConfigureTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
new file mode 100644
index 0000000..4391365
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterRouteBuilderEmptyUriTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderEmptyUriTest.class);
+
+ @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());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
new file mode 100644
index 0000000..e0bcf99
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
@@ -0,0 +1,63 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleProcessorTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleProcessorTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..18e96dd
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
@@ -0,0 +1,70 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleRouteBuilderConfigureTest.class);
+
+ @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(26, findLineNumber(list.get(0).getPosition()));
+ Assert.assertEquals("${body} > 200", list.get(1).getElement());
+ Assert.assertEquals(29, findLineNumber(list.get(1).getPosition()));
+ }
+
+ public static int findLineNumber(int pos) throws Exception {
+ int lines = 0;
+ int current = 0;
+ File file = new File("src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java");
+ try (BufferedReader br = new BufferedReader(new FileReader(file))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ lines++;
+ current += line.length();
+ if (current > pos) {
+ return lines;
+ }
+ }
+ }
+ return -1;
+ }
+
+}
[19/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
deleted file mode 100644
index 36fc443..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.apache.camel.parser.model.CamelSimpleExpressionDetails;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Expression;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MemberValuePair;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.jboss.forge.roaster.model.Annotation;
-import org.jboss.forge.roaster.model.source.FieldSource;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.jboss.forge.roaster.model.util.Strings;
-
-/**
- * A Camel RouteBuilder parser that parses Camel Java routes source code.
- * <p/>
- * This implementation is higher level details, and uses the lower level parser {@link CamelJavaParserHelper}.
- */
-public final class RouteBuilderParser {
-
- private RouteBuilderParser() {
- }
-
- /**
- * Parses the java source class to discover Camel endpoints.
- *
- * @param clazz the java source class
- * @param baseDir the base of the source code
- * @param fullyQualifiedFileName the fully qualified source code file name
- * @param endpoints list to add discovered and parsed endpoints
- */
- public static void parseRouteBuilderEndpoints(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
- List<CamelEndpointDetails> endpoints) {
- parseRouteBuilderEndpoints(clazz, baseDir, fullyQualifiedFileName, endpoints, null, false);
- }
-
- /**
- * Parses the java source class to discover Camel endpoints.
- *
- * @param clazz the java source class
- * @param baseDir the base of the source code
- * @param fullyQualifiedFileName the fully qualified source code file name
- * @param endpoints list to add discovered and parsed endpoints
- * @param unparsable list of unparsable nodes
- * @param includeInlinedRouteBuilders whether to include inlined route builders in the parsing
- */
- public static void parseRouteBuilderEndpoints(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
- List<CamelEndpointDetails> endpoints, List<String> unparsable, boolean includeInlinedRouteBuilders) {
-
- // look for fields which are not used in the route
- for (FieldSource<JavaClassSource> field : clazz.getFields()) {
-
- // is the field annotated with a Camel endpoint
- String uri = null;
- Expression exp = null;
- for (Annotation ann : field.getAnnotations()) {
- boolean valid = "org.apache.camel.EndpointInject".equals(ann.getQualifiedName()) || "org.apache.camel.cdi.Uri".equals(ann.getQualifiedName());
- if (valid) {
- exp = (Expression) ann.getInternal();
- if (exp instanceof SingleMemberAnnotation) {
- exp = ((SingleMemberAnnotation) exp).getValue();
- } else if (exp instanceof NormalAnnotation) {
- List values = ((NormalAnnotation) exp).values();
- for (Object value : values) {
- MemberValuePair pair = (MemberValuePair) value;
- if ("uri".equals(pair.getName().toString())) {
- exp = pair.getValue();
- break;
- }
- }
- }
- uri = CamelJavaParserHelper.getLiteralValue(clazz, null, exp);
- }
- }
-
- // we only want to add fields which are not used in the route
- if (!Strings.isBlank(uri) && findEndpointByUri(endpoints, uri) == null) {
-
- // we only want the relative dir name from the
- String fileName = fullyQualifiedFileName;
- if (fileName.startsWith(baseDir)) {
- fileName = fileName.substring(baseDir.length() + 1);
- }
- String id = field.getName();
-
- CamelEndpointDetails detail = new CamelEndpointDetails();
- detail.setFileName(fileName);
- detail.setClassName(clazz.getQualifiedName());
- detail.setEndpointInstance(id);
- detail.setEndpointUri(uri);
- detail.setEndpointComponentName(endpointComponentName(uri));
-
- // favor the position of the expression which had the actual uri
- Object internal = exp != null ? exp : field.getInternal();
-
- // find position of field/expression
- if (internal instanceof ASTNode) {
- int pos = ((ASTNode) internal).getStartPosition();
- int line = findLineNumber(fullyQualifiedFileName, pos);
- if (line > -1) {
- detail.setLineNumber("" + line);
- }
- }
- // we do not know if this field is used as consumer or producer only, but we try
- // to find out by scanning the route in the configure method below
- endpoints.add(detail);
- }
- }
-
- // find all the configure methods
- List<MethodSource<JavaClassSource>> methods = new ArrayList<>();
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
- if (method != null) {
- methods.add(method);
- }
- if (includeInlinedRouteBuilders) {
- List<MethodSource<JavaClassSource>> inlinedMethods = CamelJavaParserHelper.findInlinedConfigureMethods(clazz);
- if (!inlinedMethods.isEmpty()) {
- methods.addAll(inlinedMethods);
- }
- }
-
- // look if any of these fields are used in the route only as consumer or producer, as then we can
- // determine this to ensure when we edit the endpoint we should only the options accordingly
- for (MethodSource<JavaClassSource> configureMethod : methods) {
- // consumers only
- List<ParserResult> uris = CamelJavaParserHelper.parseCamelConsumerUris(configureMethod, true, true);
- for (ParserResult result : uris) {
- if (!result.isParsed()) {
- if (unparsable != null) {
- unparsable.add(result.getElement());
- }
- } else {
- CamelEndpointDetails detail = findEndpointByUri(endpoints, result.getElement());
- if (detail != null) {
- // its a consumer only
- detail.setConsumerOnly(true);
- } else {
- String fileName = fullyQualifiedFileName;
- if (fileName.startsWith(baseDir)) {
- fileName = fileName.substring(baseDir.length() + 1);
- }
-
- detail = new CamelEndpointDetails();
- detail.setFileName(fileName);
- detail.setClassName(clazz.getQualifiedName());
- detail.setMethodName(configureMethod.getName());
- detail.setEndpointInstance(null);
- detail.setEndpointUri(result.getElement());
- int line = findLineNumber(fullyQualifiedFileName, result.getPosition());
- if (line > -1) {
- detail.setLineNumber("" + line);
- }
- detail.setEndpointComponentName(endpointComponentName(result.getElement()));
- detail.setConsumerOnly(true);
- detail.setProducerOnly(false);
- endpoints.add(detail);
- }
- }
- }
- // producer only
- uris = CamelJavaParserHelper.parseCamelProducerUris(configureMethod, true, true);
- for (ParserResult result : uris) {
- if (!result.isParsed()) {
- if (unparsable != null) {
- unparsable.add(result.getElement());
- }
- } else {
- CamelEndpointDetails detail = findEndpointByUri(endpoints, result.getElement());
- if (detail != null) {
- if (detail.isConsumerOnly()) {
- // its both a consumer and producer
- detail.setConsumerOnly(false);
- detail.setProducerOnly(false);
- } else {
- // its a producer only
- detail.setProducerOnly(true);
- }
- }
- // the same endpoint uri may be used in multiple places in the same route
- // so we should maybe add all of them
- String fileName = fullyQualifiedFileName;
- if (fileName.startsWith(baseDir)) {
- fileName = fileName.substring(baseDir.length() + 1);
- }
-
- detail = new CamelEndpointDetails();
- detail.setFileName(fileName);
- detail.setClassName(clazz.getQualifiedName());
- detail.setMethodName(configureMethod.getName());
- detail.setEndpointInstance(null);
- detail.setEndpointUri(result.getElement());
- int line = findLineNumber(fullyQualifiedFileName, result.getPosition());
- if (line > -1) {
- detail.setLineNumber("" + line);
- }
- detail.setEndpointComponentName(endpointComponentName(result.getElement()));
- detail.setConsumerOnly(false);
- detail.setProducerOnly(true);
- endpoints.add(detail);
- }
- }
- }
- }
-
- /**
- * Parses the java source class to discover Camel simple expressions.
- *
- * @param clazz the java source class
- * @param baseDir the base of the source code
- * @param fullyQualifiedFileName the fully qualified source code file name
- * @param simpleExpressions list to add discovered and parsed simple expressions
- */
- public static void parseRouteBuilderSimpleExpressions(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
- List<CamelSimpleExpressionDetails> simpleExpressions) {
-
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
- if (method != null) {
- List<ParserResult> expressions = CamelJavaParserHelper.parseCamelSimpleExpressions(method);
- for (ParserResult result : expressions) {
- if (result.isParsed()) {
- String fileName = fullyQualifiedFileName;
- if (fileName.startsWith(baseDir)) {
- fileName = fileName.substring(baseDir.length() + 1);
- }
-
- CamelSimpleExpressionDetails details = new CamelSimpleExpressionDetails();
- details.setFileName(fileName);
- details.setClassName(clazz.getQualifiedName());
- details.setMethodName("configure");
- int line = findLineNumber(fullyQualifiedFileName, result.getPosition());
- if (line > -1) {
- details.setLineNumber("" + line);
- }
- details.setSimple(result.getElement());
-
- simpleExpressions.add(details);
- }
- }
- }
- }
-
- private static CamelEndpointDetails findEndpointByUri(List<CamelEndpointDetails> endpoints, String uri) {
- for (CamelEndpointDetails detail : endpoints) {
- if (uri.equals(detail.getEndpointUri())) {
- return detail;
- }
- }
- return null;
- }
-
- private static int findLineNumber(String fullyQualifiedFileName, int position) {
- int lines = 0;
-
- try {
- int current = 0;
- try (BufferedReader br = new BufferedReader(new FileReader(new File(fullyQualifiedFileName)))) {
- String line;
- while ((line = br.readLine()) != null) {
- lines++;
- current += line.length() + 1; // add 1 for line feed
- if (current >= position) {
- return lines;
- }
- }
- }
- } catch (Exception e) {
- // ignore
- return -1;
- }
-
- return lines;
- }
-
- private static String endpointComponentName(String uri) {
- if (uri != null) {
- int idx = uri.indexOf(":");
- if (idx > 0) {
- return uri.substring(0, idx);
- }
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
deleted file mode 100644
index 2cca9df..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.InputStream;
-import java.util.List;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.apache.camel.parser.helper.CamelXmlHelper;
-import org.apache.camel.parser.helper.XmlLineNumberParser;
-
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.apache.camel.parser.model.CamelSimpleExpressionDetails;
-import org.jboss.forge.roaster.model.util.Strings;
-
-import static org.apache.camel.parser.helper.CamelXmlHelper.getSafeAttribute;
-
-/**
- * A Camel XML parser that parses Camel XML routes source code.
- * <p/>
- * This implementation is higher level details, and uses the lower level parser {@link CamelJavaParserHelper}.
- */
-public final class XmlRouteParser {
-
- private XmlRouteParser() {
- }
-
- /**
- * Parses the XML source to discover Camel endpoints.
- *
- * @param xml the xml file as input stream
- * @param baseDir the base of the source code
- * @param fullyQualifiedFileName the fully qualified source code file name
- * @param endpoints list to add discovered and parsed endpoints
- */
- public static void parseXmlRouteEndpoints(InputStream xml, String baseDir, String fullyQualifiedFileName,
- List<CamelEndpointDetails> endpoints) throws Exception {
-
- // find all the endpoints (currently only <endpoint> and within <route>)
- // try parse it as dom
- Document dom = null;
- try {
- dom = XmlLineNumberParser.parseXml(xml);
- } catch (Exception e) {
- // ignore as the xml file may not be valid at this point
- }
- if (dom != null) {
- List<Node> nodes = CamelXmlHelper.findAllEndpoints(dom);
- for (Node node : nodes) {
- String uri = getSafeAttribute(node, "uri");
- if (uri != null) {
- // trim and remove whitespace noise
- uri = trimEndpointUri(uri);
- }
- if (!Strings.isBlank(uri)) {
- String id = getSafeAttribute(node, "id");
- String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
- String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
-
- // we only want the relative dir name from the resource directory, eg META-INF/spring/foo.xml
- String fileName = fullyQualifiedFileName;
- if (fileName.startsWith(baseDir)) {
- fileName = fileName.substring(baseDir.length() + 1);
- }
-
- boolean consumerOnly = false;
- boolean producerOnly = false;
- String nodeName = node.getNodeName();
- if ("from".equals(nodeName) || "pollEnrich".equals(nodeName)) {
- consumerOnly = true;
- } else if ("to".equals(nodeName) || "enrich".equals(nodeName) || "wireTap".equals(nodeName)) {
- producerOnly = true;
- }
-
- CamelEndpointDetails detail = new CamelEndpointDetails();
- detail.setFileName(fileName);
- detail.setLineNumber(lineNumber);
- detail.setLineNumberEnd(lineNumberEnd);
- detail.setEndpointInstance(id);
- detail.setEndpointUri(uri);
- detail.setEndpointComponentName(endpointComponentName(uri));
- detail.setConsumerOnly(consumerOnly);
- detail.setProducerOnly(producerOnly);
- endpoints.add(detail);
- }
- }
- }
- }
-
- /**
- * Parses the XML source to discover Camel endpoints.
- *
- * @param xml the xml file as input stream
- * @param baseDir the base of the source code
- * @param fullyQualifiedFileName the fully qualified source code file name
- * @param simpleExpressions list to add discovered and parsed simple expressions
- */
- public static void parseXmlRouteSimpleExpressions(InputStream xml, String baseDir, String fullyQualifiedFileName,
- List<CamelSimpleExpressionDetails> simpleExpressions) throws Exception {
-
- // find all the simple expressions
- // try parse it as dom
- Document dom = null;
- try {
- dom = XmlLineNumberParser.parseXml(xml);
- } catch (Exception e) {
- // ignore as the xml file may not be valid at this point
- }
- if (dom != null) {
- List<Node> nodes = CamelXmlHelper.findAllSimpleExpressions(dom);
- for (Node node : nodes) {
- String simple = node.getTextContent();
- String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
- String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
-
- // we only want the relative dir name from the resource directory, eg META-INF/spring/foo.xml
- String fileName = fullyQualifiedFileName;
- if (fileName.startsWith(baseDir)) {
- fileName = fileName.substring(baseDir.length() + 1);
- }
-
- CamelSimpleExpressionDetails detail = new CamelSimpleExpressionDetails();
- detail.setFileName(fileName);
- detail.setLineNumber(lineNumber);
- detail.setLineNumberEnd(lineNumberEnd);
- detail.setSimple(simple);
- simpleExpressions.add(detail);
- }
- }
- }
-
- private static String endpointComponentName(String uri) {
- if (uri != null) {
- int idx = uri.indexOf(":");
- if (idx > 0) {
- return uri.substring(0, idx);
- }
- }
- return null;
- }
-
-
- private static String trimEndpointUri(String uri) {
- uri = uri.trim();
- // if the uri is using new-lines then remove whitespace noise before & and ? separator
- uri = uri.replaceAll("(\\s+)(\\&)", "$2");
- uri = uri.replaceAll("(\\&)(\\s+)", "$1");
- uri = uri.replaceAll("(\\?)(\\s+)", "$1");
- return uri;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
deleted file mode 100644
index 6df709a..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
+++ /dev/null
@@ -1,638 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.helper;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.RouteBuilderParser;
-import org.apache.camel.parser.roaster.AnonymousMethodSource;
-import org.apache.camel.parser.roaster.StatementFieldSource;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Block;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.BooleanLiteral;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ClassInstanceCreation;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Expression;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ExpressionStatement;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.InfixExpression;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MemberValuePair;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodInvocation;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NumberLiteral;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ParenthesizedExpression;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.QualifiedName;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ReturnStatement;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleName;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleType;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Statement;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.StringLiteral;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Type;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclaration;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclarationStatement;
-import org.jboss.forge.roaster.model.Annotation;
-import org.jboss.forge.roaster.model.source.AnnotationSource;
-import org.jboss.forge.roaster.model.source.FieldSource;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.jboss.forge.roaster.model.util.Strings;
-
-/**
- * A Camel Java parser that only depends on the Roaster API.
- * <p/>
- * This implementation is lower level details. For a higher level parser see {@link RouteBuilderParser}.
- */
-public final class CamelJavaParserHelper {
-
- private CamelJavaParserHelper() {
- // utility class
- }
-
- public static MethodSource<JavaClassSource> findConfigureMethod(JavaClassSource clazz) {
- MethodSource<JavaClassSource> method = clazz.getMethod("configure");
- // must be public void configure()
- if (method != null && method.isPublic() && method.getParameters().isEmpty() && method.getReturnType().isType("void")) {
- return method;
- }
-
- // maybe the route builder is from unit testing with camel-test as an anonymous inner class
- // there is a bit of code to dig out this using the eclipse jdt api
- method = findCreateRouteBuilderMethod(clazz);
- if (method != null) {
- return findConfigureMethodInCreateRouteBuilder(clazz, method);
- }
-
- return null;
- }
-
- public static List<MethodSource<JavaClassSource>> findInlinedConfigureMethods(JavaClassSource clazz) {
- List<MethodSource<JavaClassSource>> answer = new ArrayList<>();
-
- List<MethodSource<JavaClassSource>> methods = clazz.getMethods();
- if (methods != null) {
- for (MethodSource<JavaClassSource> method : methods) {
- if (method.isPublic()
- && (method.getParameters() == null || method.getParameters().isEmpty())
- && (method.getReturnType() == null || method.getReturnType().isType("void"))) {
- // maybe the method contains an inlined createRouteBuilder usually from an unit test method
- MethodSource<JavaClassSource> builder = findConfigureMethodInCreateRouteBuilder(clazz, method);
- if (builder != null) {
- answer.add(builder);
- }
- }
- }
- }
-
- return answer;
- }
-
- private static MethodSource<JavaClassSource> findCreateRouteBuilderMethod(JavaClassSource clazz) {
- MethodSource method = clazz.getMethod("createRouteBuilder");
- if (method != null && (method.isPublic() || method.isProtected()) && method.getParameters().isEmpty()) {
- return method;
- }
- return null;
- }
-
- private static MethodSource<JavaClassSource> findConfigureMethodInCreateRouteBuilder(JavaClassSource clazz, MethodSource<JavaClassSource> method) {
- // find configure inside the code
- MethodDeclaration md = (MethodDeclaration) method.getInternal();
- Block block = md.getBody();
- if (block != null) {
- List statements = block.statements();
- for (int i = 0; i < statements.size(); i++) {
- Statement stmt = (Statement) statements.get(i);
- Expression exp = null;
- if (stmt instanceof ReturnStatement) {
- ReturnStatement rs = (ReturnStatement) stmt;
- exp = rs.getExpression();
- } else if (stmt instanceof ExpressionStatement) {
- ExpressionStatement es = (ExpressionStatement) stmt;
- exp = es.getExpression();
- if (exp instanceof MethodInvocation) {
- MethodInvocation mi = (MethodInvocation) exp;
- for (Object arg : mi.arguments()) {
- if (arg instanceof ClassInstanceCreation) {
- exp = (Expression) arg;
- break;
- }
- }
- }
- }
- if (exp != null && exp instanceof ClassInstanceCreation) {
- ClassInstanceCreation cic = (ClassInstanceCreation) exp;
- boolean isRouteBuilder = false;
- if (cic.getType() instanceof SimpleType) {
- SimpleType st = (SimpleType) cic.getType();
- isRouteBuilder = "RouteBuilder".equals(st.getName().toString());
- }
- if (isRouteBuilder && cic.getAnonymousClassDeclaration() != null) {
- List body = cic.getAnonymousClassDeclaration().bodyDeclarations();
- for (int j = 0; j < body.size(); j++) {
- Object line = body.get(j);
- if (line instanceof MethodDeclaration) {
- MethodDeclaration amd = (MethodDeclaration) line;
- if ("configure".equals(amd.getName().toString())) {
- return new AnonymousMethodSource(clazz, amd);
- }
- }
- }
- }
- }
- }
- }
-
- return null;
- }
-
- public static List<ParserResult> parseCamelConsumerUris(MethodSource<JavaClassSource> method, boolean strings, boolean fields) {
- return doParseCamelUris(method, true, false, strings, fields);
- }
-
- public static List<ParserResult> parseCamelProducerUris(MethodSource<JavaClassSource> method, boolean strings, boolean fields) {
- return doParseCamelUris(method, false, true, strings, fields);
- }
-
- private static List<ParserResult> doParseCamelUris(MethodSource<JavaClassSource> method, boolean consumers, boolean producers,
- boolean strings, boolean fields) {
-
- List<ParserResult> answer = new ArrayList<ParserResult>();
-
- if (method != null) {
- MethodDeclaration md = (MethodDeclaration) method.getInternal();
- Block block = md.getBody();
- if (block != null) {
- for (Object statement : md.getBody().statements()) {
- // must be a method call expression
- if (statement instanceof ExpressionStatement) {
- ExpressionStatement es = (ExpressionStatement) statement;
- Expression exp = es.getExpression();
-
- List<ParserResult> uris = new ArrayList<ParserResult>();
- parseExpression(method.getOrigin(), block, exp, uris, consumers, producers, strings, fields);
- if (!uris.isEmpty()) {
- // reverse the order as we will grab them from last->first
- Collections.reverse(uris);
- answer.addAll(uris);
- }
- }
- }
- }
- }
-
- return answer;
- }
-
- private static void parseExpression(JavaClassSource clazz, Block block, Expression exp, List<ParserResult> uris,
- boolean consumers, boolean producers, boolean strings, boolean fields) {
- if (exp == null) {
- return;
- }
- if (exp instanceof MethodInvocation) {
- MethodInvocation mi = (MethodInvocation) exp;
- doParseCamelUris(clazz, block, mi, uris, consumers, producers, strings, fields);
- // if the method was called on another method, then recursive
- exp = mi.getExpression();
- parseExpression(clazz, block, exp, uris, consumers, producers, strings, fields);
- }
- }
-
- private static void doParseCamelUris(JavaClassSource clazz, Block block, MethodInvocation mi, List<ParserResult> uris,
- boolean consumers, boolean producers, boolean strings, boolean fields) {
- String name = mi.getName().getIdentifier();
-
- if (consumers) {
- if ("from".equals(name)) {
- List args = mi.arguments();
- if (args != null) {
- for (Object arg : args) {
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- }
- if ("fromF".equals(name)) {
- List args = mi.arguments();
- // the first argument is where the uri is
- if (args != null && args.size() >= 1) {
- Object arg = args.get(0);
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- if ("pollEnrich".equals(name)) {
- List args = mi.arguments();
- // the first argument is where the uri is
- if (args != null && args.size() >= 1) {
- Object arg = args.get(0);
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- }
-
- if (producers) {
- if ("to".equals(name) || "toD".equals(name)) {
- List args = mi.arguments();
- if (args != null) {
- for (Object arg : args) {
- // skip if the arg is a boolean, ExchangePattern or Iterateable, type
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- }
- if ("toF".equals(name)) {
- List args = mi.arguments();
- // the first argument is where the uri is
- if (args != null && args.size() >= 1) {
- Object arg = args.get(0);
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- if ("enrich".equals(name) || "wireTap".equals(name)) {
- List args = mi.arguments();
- // the first argument is where the uri is
- if (args != null && args.size() >= 1) {
- Object arg = args.get(0);
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- }
- }
-
- private static boolean isValidArgument(String node, Object arg) {
- // skip boolean argument, as toD can accept a boolean value
- if (arg instanceof BooleanLiteral) {
- return false;
- }
- // skip ExchangePattern argument
- if (arg instanceof QualifiedName) {
- QualifiedName qn = (QualifiedName) arg;
- String name = qn.getFullyQualifiedName();
- if (name.startsWith("ExchangePattern")) {
- return false;
- }
- }
- return true;
- }
-
- private static void extractEndpointUriFromArgument(String node, JavaClassSource clazz, Block block, List<ParserResult> uris, Object arg, boolean strings, boolean fields) {
- if (strings) {
- String uri = getLiteralValue(clazz, block, (Expression) arg);
- if (!Strings.isBlank(uri)) {
- int position = ((Expression) arg).getStartPosition();
-
- // if the node is fromF or toF, then replace all %s with {{%s}} as we cannot parse that value
- if ("fromF".equals(node) || "toF".equals(node)) {
- uri = uri.replaceAll("\\%s", "\\{\\{\\%s\\}\\}");
- }
-
- uris.add(new ParserResult(node, position, uri));
- return;
- }
- }
- if (fields && arg instanceof SimpleName) {
- FieldSource field = getField(clazz, block, (SimpleName) arg);
- if (field != null) {
- // find the endpoint uri from the annotation
- AnnotationSource annotation = field.getAnnotation("org.apache.camel.cdi.Uri");
- if (annotation == null) {
- annotation = field.getAnnotation("org.apache.camel.EndpointInject");
- }
- if (annotation != null) {
- Expression exp = (Expression) annotation.getInternal();
- if (exp instanceof SingleMemberAnnotation) {
- exp = ((SingleMemberAnnotation) exp).getValue();
- } else if (exp instanceof NormalAnnotation) {
- List values = ((NormalAnnotation) exp).values();
- for (Object value : values) {
- MemberValuePair pair = (MemberValuePair) value;
- if ("uri".equals(pair.getName().toString())) {
- exp = pair.getValue();
- break;
- }
- }
- }
- String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
- if (!Strings.isBlank(uri)) {
- int position = ((SimpleName) arg).getStartPosition();
- uris.add(new ParserResult(node, position, uri));
- }
- } else {
- // the field may be initialized using variables, so we need to evaluate those expressions
- Object fi = field.getInternal();
- if (fi instanceof VariableDeclaration) {
- Expression exp = ((VariableDeclaration) fi).getInitializer();
- String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
- if (!Strings.isBlank(uri)) {
- // we want the position of the field, and not in the route
- int position = ((VariableDeclaration) fi).getStartPosition();
- uris.add(new ParserResult(node, position, uri));
- }
- }
- }
- }
- }
-
- // cannot parse it so add a failure
- uris.add(new ParserResult(node, -1, arg.toString(), false));
- }
-
- public static List<ParserResult> parseCamelSimpleExpressions(MethodSource<JavaClassSource> method) {
- List<ParserResult> answer = new ArrayList<ParserResult>();
-
- MethodDeclaration md = (MethodDeclaration) method.getInternal();
- Block block = md.getBody();
- if (block != null) {
- for (Object statement : block.statements()) {
- // must be a method call expression
- if (statement instanceof ExpressionStatement) {
- ExpressionStatement es = (ExpressionStatement) statement;
- Expression exp = es.getExpression();
-
- List<ParserResult> expressions = new ArrayList<ParserResult>();
- parseExpression(null, method.getOrigin(), block, exp, expressions);
- if (!expressions.isEmpty()) {
- // reverse the order as we will grab them from last->first
- Collections.reverse(expressions);
- answer.addAll(expressions);
- }
- }
- }
- }
-
- return answer;
- }
-
- private static void parseExpression(String node, JavaClassSource clazz, Block block, Expression exp, List<ParserResult> expressions) {
- if (exp == null) {
- return;
- }
- if (exp instanceof MethodInvocation) {
- MethodInvocation mi = (MethodInvocation) exp;
- doParseCamelSimple(node, clazz, block, mi, expressions);
- // if the method was called on another method, then recursive
- exp = mi.getExpression();
- parseExpression(node, clazz, block, exp, expressions);
- }
- }
-
- private static void doParseCamelSimple(String node, JavaClassSource clazz, Block block, MethodInvocation mi, List<ParserResult> expressions) {
- String name = mi.getName().getIdentifier();
-
- if ("simple".equals(name)) {
- List args = mi.arguments();
- // the first argument is a string parameter for the simple expression
- if (args != null && args.size() >= 1) {
- // it is a String type
- Object arg = args.get(0);
- String simple = getLiteralValue(clazz, block, (Expression) arg);
- if (!Strings.isBlank(simple)) {
- int position = ((Expression) arg).getStartPosition();
- expressions.add(new ParserResult(node, position, simple));
- }
- }
- }
-
- // simple maybe be passed in as an argument
- List args = mi.arguments();
- if (args != null) {
- for (Object arg : args) {
- if (arg instanceof MethodInvocation) {
- MethodInvocation ami = (MethodInvocation) arg;
- doParseCamelSimple(node, clazz, block, ami, expressions);
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- private static FieldSource<JavaClassSource> getField(JavaClassSource clazz, Block block, SimpleName ref) {
- String fieldName = ref.getIdentifier();
- if (fieldName != null) {
- // find field in class
- FieldSource field = clazz != null ? clazz.getField(fieldName) : null;
- if (field == null) {
- field = findFieldInBlock(clazz, block, fieldName);
- }
- return field;
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private static FieldSource<JavaClassSource> findFieldInBlock(JavaClassSource clazz, Block block, String fieldName) {
- for (Object statement : block.statements()) {
- // try local statements first in the block
- if (statement instanceof VariableDeclarationStatement) {
- final Type type = ((VariableDeclarationStatement) statement).getType();
- for (Object obj : ((VariableDeclarationStatement) statement).fragments()) {
- if (obj instanceof VariableDeclarationFragment) {
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
- SimpleName name = fragment.getName();
- if (name != null && fieldName.equals(name.getIdentifier())) {
- return new StatementFieldSource(clazz, fragment, type);
- }
- }
- }
- }
-
- // okay the field may be burried inside an anonymous inner class as a field declaration
- // outside the configure method, so lets go back to the parent and see what we can find
- ASTNode node = block.getParent();
- if (node instanceof MethodDeclaration) {
- node = node.getParent();
- }
- if (node instanceof AnonymousClassDeclaration) {
- List declarations = ((AnonymousClassDeclaration) node).bodyDeclarations();
- for (Object dec : declarations) {
- if (dec instanceof FieldDeclaration) {
- FieldDeclaration fd = (FieldDeclaration) dec;
- final Type type = fd.getType();
- for (Object obj : fd.fragments()) {
- if (obj instanceof VariableDeclarationFragment) {
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
- SimpleName name = fragment.getName();
- if (name != null && fieldName.equals(name.getIdentifier())) {
- return new StatementFieldSource(clazz, fragment, type);
- }
- }
- }
- }
- }
- }
- }
- return null;
- }
-
- public static String getLiteralValue(JavaClassSource clazz, Block block, Expression expression) {
- // unwrap parenthesis
- if (expression instanceof ParenthesizedExpression) {
- expression = ((ParenthesizedExpression) expression).getExpression();
- }
-
- if (expression instanceof StringLiteral) {
- return ((StringLiteral) expression).getLiteralValue();
- } else if (expression instanceof BooleanLiteral) {
- return "" + ((BooleanLiteral) expression).booleanValue();
- } else if (expression instanceof NumberLiteral) {
- return ((NumberLiteral) expression).getToken();
- }
-
- // if it a method invocation then add a dummy value assuming the method invocation will return a valid response
- if (expression instanceof MethodInvocation) {
- String name = ((MethodInvocation) expression).getName().getIdentifier();
- return "{{" + name + "}}";
- }
-
- // if its a qualified name (usually a constant field in another class)
- // then add a dummy value as we cannot find the field value in other classes and maybe even outside the
- // source code we have access to
- if (expression instanceof QualifiedName) {
- QualifiedName qn = (QualifiedName) expression;
- String name = qn.getFullyQualifiedName();
- return "{{" + name + "}}";
- }
-
- if (expression instanceof SimpleName) {
- FieldSource<JavaClassSource> field = getField(clazz, block, (SimpleName) expression);
- if (field != null) {
- // is the field annotated with a Camel endpoint
- if (field.getAnnotations() != null) {
- for (Annotation ann : field.getAnnotations()) {
- boolean valid = "org.apache.camel.EndpointInject".equals(ann.getQualifiedName()) || "org.apache.camel.cdi.Uri".equals(ann.getQualifiedName());
- if (valid) {
- Expression exp = (Expression) ann.getInternal();
- if (exp instanceof SingleMemberAnnotation) {
- exp = ((SingleMemberAnnotation) exp).getValue();
- } else if (exp instanceof NormalAnnotation) {
- List values = ((NormalAnnotation) exp).values();
- for (Object value : values) {
- MemberValuePair pair = (MemberValuePair) value;
- if ("uri".equals(pair.getName().toString())) {
- exp = pair.getValue();
- break;
- }
- }
- }
- if (exp != null) {
- return getLiteralValue(clazz, block, exp);
- }
- }
- }
- }
- // is the field an org.apache.camel.Endpoint type?
- if ("Endpoint".equals(field.getType().getSimpleName())) {
- // then grab the uri from the first argument
- VariableDeclarationFragment vdf = (VariableDeclarationFragment) field.getInternal();
- expression = vdf.getInitializer();
- if (expression instanceof MethodInvocation) {
- MethodInvocation mi = (MethodInvocation) expression;
- List args = mi.arguments();
- if (args != null && args.size() > 0) {
- // the first argument has the endpoint uri
- expression = (Expression) args.get(0);
- return getLiteralValue(clazz, block, expression);
- }
- }
- } else {
- // no annotations so try its initializer
- VariableDeclarationFragment vdf = (VariableDeclarationFragment) field.getInternal();
- expression = vdf.getInitializer();
- if (expression == null) {
- // its a field which has no initializer, then add a dummy value assuming the field will be initialized at runtime
- return "{{" + field.getName() + "}}";
- } else {
- return getLiteralValue(clazz, block, expression);
- }
- }
- } else {
- // we could not find the field in this class/method, so its maybe from some other super class, so insert a dummy value
- final String fieldName = ((SimpleName) expression).getIdentifier();
- return "{{" + fieldName + "}}";
- }
- } else if (expression instanceof InfixExpression) {
- String answer = null;
- // is it a string that is concat together?
- InfixExpression ie = (InfixExpression) expression;
- if (InfixExpression.Operator.PLUS.equals(ie.getOperator())) {
-
- String val1 = getLiteralValue(clazz, block, ie.getLeftOperand());
- String val2 = getLiteralValue(clazz, block, ie.getRightOperand());
-
- // if numeric then we plus the values, otherwise we string concat
- boolean numeric = isNumericOperator(clazz, block, ie.getLeftOperand()) && isNumericOperator(clazz, block, ie.getRightOperand());
- if (numeric) {
- Long num1 = val1 != null ? Long.valueOf(val1) : 0;
- Long num2 = val2 != null ? Long.valueOf(val2) : 0;
- answer = "" + (num1 + num2);
- } else {
- answer = (val1 != null ? val1 : "") + (val2 != null ? val2 : "");
- }
-
- if (!answer.isEmpty()) {
- // include extended when we concat on 2 or more lines
- List extended = ie.extendedOperands();
- if (extended != null) {
- for (Object ext : extended) {
- String val3 = getLiteralValue(clazz, block, (Expression) ext);
- if (numeric) {
- Long num3 = val3 != null ? Long.valueOf(val3) : 0;
- Long num = Long.valueOf(answer);
- answer = "" + (num + num3);
- } else {
- answer += val3 != null ? val3 : "";
- }
- }
- }
- }
- }
- return answer;
- }
-
- return null;
- }
-
- private static boolean isNumericOperator(JavaClassSource clazz, Block block, Expression expression) {
- if (expression instanceof NumberLiteral) {
- return true;
- } else if (expression instanceof SimpleName) {
- FieldSource field = getField(clazz, block, (SimpleName) expression);
- if (field != null) {
- return field.getType().isType("int") || field.getType().isType("long")
- || field.getType().isType("Integer") || field.getType().isType("Long");
- }
- }
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
deleted file mode 100644
index 53d4783..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.helper;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.jboss.forge.roaster.model.util.Strings;
-
-/**
- * Various XML helper methods used for parsing XML routes.
- */
-public final class CamelXmlHelper {
-
- private CamelXmlHelper() {
- // utility class
- }
-
- public static String getSafeAttribute(Node node, String key) {
- if (node != null) {
- Node attr = node.getAttributes().getNamedItem(key);
- if (attr != null) {
- return attr.getNodeValue();
- }
- }
- return null;
- }
-
- public static List<Node> findAllEndpoints(Document dom) {
- List<Node> nodes = new ArrayList<>();
-
- NodeList list = dom.getElementsByTagName("endpoint");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- if ("endpoint".equals(child.getNodeName())) {
- // it may not be a camel namespace, so skip those
- String ns = child.getNamespaceURI();
- if (ns == null) {
- NamedNodeMap attrs = child.getAttributes();
- if (attrs != null) {
- Node node = attrs.getNamedItem("xmlns");
- if (node != null) {
- ns = node.getNodeValue();
- }
- }
- }
- // assume no namespace its for camel
- if (ns == null || ns.contains("camel")) {
- nodes.add(child);
- }
- }
- }
-
- list = dom.getElementsByTagName("onException");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- findAllUrisRecursive(child, nodes);
- }
- list = dom.getElementsByTagName("onCompletion");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- findAllUrisRecursive(child, nodes);
- }
- list = dom.getElementsByTagName("intercept");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- findAllUrisRecursive(child, nodes);
- }
- list = dom.getElementsByTagName("interceptFrom");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- findAllUrisRecursive(child, nodes);
- }
- list = dom.getElementsByTagName("interceptSendToEndpoint");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- findAllUrisRecursive(child, nodes);
- }
- list = dom.getElementsByTagName("rest");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- if ("route".equals(child.getNodeName()) || "to".equals(child.getNodeName())) {
- findAllUrisRecursive(child, nodes);
- }
- }
- list = dom.getElementsByTagName("route");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- if ("route".equals(child.getNodeName())) {
- findAllUrisRecursive(child, nodes);
- }
- }
-
- return nodes;
- }
-
- private static void findAllUrisRecursive(Node node, List<Node> nodes) {
- // okay its a route so grab all uri attributes we can find
- String url = getSafeAttribute(node, "uri");
- if (url != null) {
- nodes.add(node);
- }
-
- NodeList children = node.getChildNodes();
- if (children != null) {
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- findAllUrisRecursive(child, nodes);
- }
- }
- }
- }
-
- public static List<Node> findAllSimpleExpressions(Document dom) {
- List<Node> nodes = new ArrayList<>();
-
- NodeList list = dom.getElementsByTagName("route");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- if ("route".equals(child.getNodeName())) {
- findAllSimpleExpressionsRecursive(child, nodes);
- }
- }
-
- return nodes;
- }
-
- private static void findAllSimpleExpressionsRecursive(Node node, List<Node> nodes) {
- // okay its a route so grab if its <simple>
- if ("simple".equals(node.getNodeName())) {
- nodes.add(node);
- }
-
- NodeList children = node.getChildNodes();
- if (children != null) {
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- findAllSimpleExpressionsRecursive(child, nodes);
- }
- }
- }
- }
-
- public static Element getSelectedCamelElementNode(String key, InputStream resourceInputStream) throws Exception {
- Document root = loadCamelXmlFileAsDom(resourceInputStream);
- Element selectedElement = null;
- if (root != null) {
- Node selectedNode = findCamelNodeInDocument(root, key);
- if (selectedNode instanceof Element) {
- selectedElement = (Element) selectedNode;
- }
- }
- return selectedElement;
- }
-
- private static Document loadCamelXmlFileAsDom(InputStream resourceInputStream) throws Exception {
- // must enforce the namespace to be http://camel.apache.org/schema/spring which is what the camel-core JAXB model uses
- Document root = XmlLineNumberParser.parseXml(resourceInputStream, "camelContext,routes,rests", "http://camel.apache.org/schema/spring");
- return root;
- }
-
- private static Node findCamelNodeInDocument(Document root, String key) {
- Node selectedNode = null;
- if (root != null && !Strings.isBlank(key)) {
- String[] paths = key.split("/");
- NodeList camels = getCamelContextElements(root);
- if (camels != null) {
- Map<String, Integer> rootNodeCounts = new HashMap<>();
- for (int i = 0, size = camels.getLength(); i < size; i++) {
- Node node = camels.item(i);
- boolean first = true;
- for (String path : paths) {
- if (first) {
- first = false;
- String actual = getIdOrIndex(node, rootNodeCounts);
- if (!equal(actual, path)) {
- node = null;
- }
- } else {
- node = findCamelNodeForPath(node, path);
- }
- if (node == null) {
- break;
- }
- }
- if (node != null) {
- return node;
- }
- }
- }
- }
- return selectedNode;
- }
-
- private static Node findCamelNodeForPath(Node node, String path) {
- NodeList childNodes = node.getChildNodes();
- if (childNodes != null) {
- Map<String, Integer> nodeCounts = new HashMap<>();
- for (int i = 0, size = childNodes.getLength(); i < size; i++) {
- Node child = childNodes.item(i);
- if (child instanceof Element) {
- String actual = getIdOrIndex(child, nodeCounts);
- if (equal(actual, path)) {
- return child;
- }
- }
- }
- }
- return null;
- }
-
- private static String getIdOrIndex(Node node, Map<String, Integer> nodeCounts) {
- String answer = null;
- if (node instanceof Element) {
- Element element = (Element) node;
- String elementName = element.getTagName();
- if ("routes".equals(elementName)) {
- elementName = "camelContext";
- }
- Integer countObject = nodeCounts.get(elementName);
- int count = countObject != null ? countObject.intValue() : 0;
- nodeCounts.put(elementName, ++count);
- answer = element.getAttribute("id");
- if (Strings.isBlank(answer)) {
- answer = "_" + elementName + count;
- }
- }
- return answer;
- }
-
- private static NodeList getCamelContextElements(Document dom) {
- NodeList camels = dom.getElementsByTagName("camelContext");
- if (camels == null || camels.getLength() == 0) {
- camels = dom.getElementsByTagName("routes");
- }
- return camels;
- }
-
- private static boolean equal(Object a, Object b) {
- return a == b ? true : a != null && b != null && a.equals(b);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
deleted file mode 100644
index b214b1e..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.helper;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.util.Stack;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * An XML parser that uses SAX to include line and column number for each XML element in the parsed Document.
- * <p/>
- * The line number and column number can be obtained from a Node/Element using
- * <pre>
- * String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
- * String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
- * String columnNumber = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER);
- * String columnNumberEnd = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER_END);
- * </pre>
- */
-public final class XmlLineNumberParser {
-
- public static final String LINE_NUMBER = "lineNumber";
- public static final String COLUMN_NUMBER = "colNumber";
- public static final String LINE_NUMBER_END = "lineNumberEnd";
- public static final String COLUMN_NUMBER_END = "colNumberEnd";
-
- private XmlLineNumberParser() {
- }
-
- /**
- * Parses the XML.
- *
- * @param is the XML content as an input stream
- * @return the DOM model
- * @throws Exception is thrown if error parsing
- */
- public static Document parseXml(final InputStream is) throws Exception {
- return parseXml(is, null, null);
- }
-
- /**
- * Parses the XML.
- *
- * @param is the XML content as an input stream
- * @param rootNames one or more root names that is used as baseline for beginning the parsing, for example camelContext to start parsing
- * when Camel is discovered. Multiple names can be defined separated by comma
- * @param forceNamespace an optional namespace to force assign to each node. This may be needed for JAXB unmarshalling from XML -> POJO.
- * @return the DOM model
- * @throws Exception is thrown if error parsing
- */
- public static Document parseXml(final InputStream is, final String rootNames, final String forceNamespace) throws Exception {
- final Document doc;
- SAXParser parser;
- final SAXParserFactory factory = SAXParserFactory.newInstance();
- parser = factory.newSAXParser();
- final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- // turn off validator and loading external dtd
- dbf.setValidating(false);
- dbf.setNamespaceAware(true);
- dbf.setFeature("http://xml.org/sax/features/namespaces", false);
- dbf.setFeature("http://xml.org/sax/features/validation", false);
- dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
- dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
- dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
- dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
- final DocumentBuilder docBuilder = dbf.newDocumentBuilder();
- doc = docBuilder.newDocument();
-
- final Stack<Element> elementStack = new Stack<Element>();
- final StringBuilder textBuffer = new StringBuilder();
- final DefaultHandler handler = new DefaultHandler() {
- private Locator locator;
- private boolean found;
-
- @Override
- public void setDocumentLocator(final Locator locator) {
- this.locator = locator; // Save the locator, so that it can be used later for line tracking when traversing nodes.
- this.found = rootNames == null;
- }
-
- private boolean isRootName(String qName) {
- for (String root : rootNames.split(",")) {
- if (qName.equals(root)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException {
- addTextIfNeeded();
-
- if (rootNames != null && !found) {
- if (isRootName(qName)) {
- found = true;
- }
- }
-
- if (found) {
- Element el;
- if (forceNamespace != null) {
- el = doc.createElementNS(forceNamespace, qName);
- } else {
- el = doc.createElement(qName);
- }
-
- for (int i = 0; i < attributes.getLength(); i++) {
- el.setAttribute(attributes.getQName(i), attributes.getValue(i));
- }
-
- el.setUserData(LINE_NUMBER, String.valueOf(this.locator.getLineNumber()), null);
- el.setUserData(COLUMN_NUMBER, String.valueOf(this.locator.getColumnNumber()), null);
- elementStack.push(el);
- }
- }
-
- @Override
- public void endElement(final String uri, final String localName, final String qName) {
- if (!found) {
- return;
- }
-
- addTextIfNeeded();
-
- final Element closedEl = elementStack.isEmpty() ? null : elementStack.pop();
- if (closedEl != null) {
- if (elementStack.isEmpty()) {
- // Is this the root element?
- doc.appendChild(closedEl);
- } else {
- final Element parentEl = elementStack.peek();
- parentEl.appendChild(closedEl);
- }
-
- closedEl.setUserData(LINE_NUMBER_END, String.valueOf(this.locator.getLineNumber()), null);
- closedEl.setUserData(COLUMN_NUMBER_END, String.valueOf(this.locator.getColumnNumber()), null);
- }
- }
-
- @Override
- public void characters(final char ch[], final int start, final int length) throws SAXException {
- textBuffer.append(ch, start, length);
- }
-
- @Override
- public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException {
- // do not resolve external dtd
- return new InputSource(new StringReader(""));
- }
-
- // Outputs text accumulated under the current node
- private void addTextIfNeeded() {
- if (textBuffer.length() > 0) {
- final Element el = elementStack.isEmpty() ? null : elementStack.peek();
- if (el != null) {
- final Node textNode = doc.createTextNode(textBuffer.toString());
- el.appendChild(textNode);
- textBuffer.delete(0, textBuffer.length());
- }
- }
- }
- };
- parser.parse(is, handler);
-
- return doc;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
deleted file mode 100644
index 3b112a4..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.model;
-
-/**
- * Details about a parsed and discovered Camel endpoint.
- */
-public class CamelEndpointDetails {
-
- private String fileName;
- private String lineNumber;
- private String lineNumberEnd;
- private String className;
- private String methodName;
- private String endpointComponentName;
- private String endpointInstance;
- private String endpointUri;
- private boolean consumerOnly;
- private boolean producerOnly;
-
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- public String getLineNumber() {
- return lineNumber;
- }
-
- public void setLineNumber(String lineNumber) {
- this.lineNumber = lineNumber;
- }
-
- public String getLineNumberEnd() {
- return lineNumberEnd;
- }
-
- public void setLineNumberEnd(String lineNumberEnd) {
- this.lineNumberEnd = lineNumberEnd;
- }
-
- public String getClassName() {
- return className;
- }
-
- public void setClassName(String className) {
- this.className = className;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public void setMethodName(String methodName) {
- this.methodName = methodName;
- }
-
- public String getEndpointComponentName() {
- return endpointComponentName;
- }
-
- public void setEndpointComponentName(String endpointComponentName) {
- this.endpointComponentName = endpointComponentName;
- }
-
- public String getEndpointInstance() {
- return endpointInstance;
- }
-
- public void setEndpointInstance(String endpointInstance) {
- this.endpointInstance = endpointInstance;
- }
-
- public String getEndpointUri() {
- return endpointUri;
- }
-
- public void setEndpointUri(String endpointUri) {
- this.endpointUri = endpointUri;
- }
-
- public boolean isConsumerOnly() {
- return consumerOnly;
- }
-
- public void setConsumerOnly(boolean consumerOnly) {
- this.consumerOnly = consumerOnly;
- }
-
- public boolean isProducerOnly() {
- return producerOnly;
- }
-
- public void setProducerOnly(boolean producerOnly) {
- this.producerOnly = producerOnly;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- CamelEndpointDetails that = (CamelEndpointDetails) o;
-
- if (!fileName.equals(that.fileName)) {
- return false;
- }
- if (lineNumber != null ? !lineNumber.equals(that.lineNumber) : that.lineNumber != null) {
- return false;
- }
- if (lineNumberEnd != null ? !lineNumberEnd.equals(that.lineNumberEnd) : that.lineNumberEnd != null) {
- return false;
- }
- if (!className.equals(that.className)) {
- return false;
- }
- if (methodName != null ? !methodName.equals(that.methodName) : that.methodName != null) {
- return false;
- }
- if (endpointInstance != null ? !endpointInstance.equals(that.endpointInstance) : that.endpointInstance != null) {
- return false;
- }
- return endpointUri.equals(that.endpointUri);
-
- }
-
- @Override
- public int hashCode() {
- int result = fileName.hashCode();
- result = 31 * result + (lineNumber != null ? lineNumber.hashCode() : 0);
- result = 31 * result + (lineNumberEnd != null ? lineNumberEnd.hashCode() : 0);
- result = 31 * result + className.hashCode();
- result = 31 * result + (methodName != null ? methodName.hashCode() : 0);
- result = 31 * result + (endpointInstance != null ? endpointInstance.hashCode() : 0);
- result = 31 * result + endpointUri.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return "CamelEndpointDetails["
- + "fileName='" + fileName + '\''
- + ", lineNumber='" + lineNumber + '\''
- + ", lineNumberEnd='" + lineNumberEnd + '\''
- + ", className='" + className + '\''
- + ", methodName='" + methodName + '\''
- + ", endpointComponentName='" + endpointComponentName + '\''
- + ", endpointInstance='" + endpointInstance + '\''
- + ", endpointUri='" + endpointUri + '\''
- + ", consumerOnly=" + consumerOnly
- + ", producerOnly=" + producerOnly
- + ']';
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java
deleted file mode 100644
index 9d6db11..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.model;
-
-/**
- * Details about a parsed and discovered Camel simple expression.
- */
-public class CamelSimpleExpressionDetails {
-
- private String fileName;
- private String lineNumber;
- private String lineNumberEnd;
- private String className;
- private String methodName;
- private String simple;
- private boolean predicate;
- private boolean expression;
-
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- public String getLineNumber() {
- return lineNumber;
- }
-
- public void setLineNumber(String lineNumber) {
- this.lineNumber = lineNumber;
- }
-
- public String getLineNumberEnd() {
- return lineNumberEnd;
- }
-
- public void setLineNumberEnd(String lineNumberEnd) {
- this.lineNumberEnd = lineNumberEnd;
- }
-
- public String getClassName() {
- return className;
- }
-
- public void setClassName(String className) {
- this.className = className;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public void setMethodName(String methodName) {
- this.methodName = methodName;
- }
-
- public String getSimple() {
- return simple;
- }
-
- public void setSimple(String simple) {
- this.simple = simple;
- }
-
- public boolean isPredicate() {
- return predicate;
- }
-
- public void setPredicate(boolean predicate) {
- this.predicate = predicate;
- }
-
- public boolean isExpression() {
- return expression;
- }
-
- public void setExpression(boolean expression) {
- this.expression = expression;
- }
-
- @Override
- public String toString() {
- return simple;
- }
-}
[08/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
new file mode 100644
index 0000000..1b46807
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
@@ -0,0 +1,72 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleToDTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleToDTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<CamelEndpointDetails> details = new ArrayList<>();
+ RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.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("toD", list.get(0).getNode());
+ Assert.assertEquals("log:a", list.get(0).getElement());
+ Assert.assertEquals("to", list.get(1).getNode());
+ Assert.assertEquals("log:b", list.get(1).getElement());
+ Assert.assertEquals("to", list.get(2).getNode());
+ Assert.assertEquals("log:c", list.get(2).getElement());
+ Assert.assertEquals(3, list.size());
+
+ Assert.assertEquals(4, details.size());
+ Assert.assertEquals("direct:start", details.get(0).getEndpointUri());
+ Assert.assertEquals("log:a", details.get(1).getEndpointUri());
+ Assert.assertEquals("log:b", details.get(2).getEndpointUri());
+ Assert.assertEquals("log:c", details.get(3).getEndpointUri());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
new file mode 100644
index 0000000..d964a0d
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleToFTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleToFTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
new file mode 100644
index 0000000..926d62d
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSplitTokenizeTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSplitTokenizeTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
new file mode 100644
index 0000000..c2e95f8
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+public class SimpleProcessorTest extends CamelTestSupport {
+
+ public void testProcess() throws Exception {
+ String out = template.requestBody("direct:start", "Hello World", String.class);
+ assertEquals("Bye World", out);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ exchange.getOut().setBody("Bye World");
+ }
+ });
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
new file mode 100644
index 0000000..56c530e
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
@@ -0,0 +1,125 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+public class SplitTokenizeTest extends CamelTestSupport {
+
+ public void testSplitTokenizerA() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("Claus", "James", "Willem");
+
+ template.sendBody("direct:a", "Claus,James,Willem");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerB() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("Claus", "James", "Willem");
+
+ template.sendBodyAndHeader("direct:b", "Hello World", "myHeader", "Claus,James,Willem");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerC() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("Claus", "James", "Willem");
+
+ template.sendBody("direct:c", "Claus James Willem");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerD() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("[Claus]", "[James]", "[Willem]");
+
+ template.sendBody("direct:d", "[Claus][James][Willem]");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerE() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("<person>Claus</person>", "<person>James</person>", "<person>Willem</person>");
+
+ String xml = "<persons><person>Claus</person><person>James</person><person>Willem</person></persons>";
+ template.sendBody("direct:e", xml);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerEWithSlash() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ String xml = "<persons><person attr='/' /></persons>";
+ mock.expectedBodiesReceived("<person attr='/' />");
+ template.sendBody("direct:e", xml);
+ mock.assertIsSatisfied();
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerF() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("<person name=\"Claus\"/>", "<person>James</person>", "<person>Willem</person>");
+
+ String xml = "<persons><person/><person name=\"Claus\"/><person>James</person><person>Willem</person></persons>";
+ template.sendBody("direct:f", xml);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ from("direct:a")
+ .split().tokenize(",")
+ .to("mock:split");
+
+ from("direct:b")
+ .split().tokenize(",", "myHeader")
+ .to("mock:split");
+
+ from("direct:c")
+ .split().tokenize("(\\W+)\\s*", null, true)
+ .to("mock:split");
+
+ from("direct:d")
+ .split().tokenizePair("[", "]", true)
+ .to("mock:split");
+
+ from("direct:e")
+ .split().tokenizeXML("person")
+ .to("mock:split");
+
+ from("direct:f")
+ .split().xpath("//person")
+ // To test the body is not empty
+ // it will call the ObjectHelper.evaluateValuePredicate()
+ .filter().simple("${body}")
+ .to("mock:split");
+
+ }
+ };
+ }
+}
[16/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: route parser for java and xml to parse source code. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cf41dadd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cf41dadd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cf41dadd
Branch: refs/heads/master
Commit: cf41dadd8691eedc96af356129cad3e088a6a05b
Parents: c48c58e
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 13:13:33 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
.../camel/parser/AnonymousMethodSource.java | 426 -------------
.../camel/parser/CamelJavaParserHelper.java | 634 ------------------
.../org/apache/camel/parser/CamelXmlHelper.java | 265 --------
.../org/apache/camel/parser/ParserResult.java | 28 +-
.../apache/camel/parser/RouteBuilderParser.java | 57 +-
.../camel/parser/StatementFieldSource.java | 278 --------
.../camel/parser/XmlLineNumberParser.java | 197 ------
.../org/apache/camel/parser/XmlRouteParser.java | 32 +-
.../parser/helper/CamelJavaParserHelper.java | 638 +++++++++++++++++++
.../camel/parser/helper/CamelXmlHelper.java | 268 ++++++++
.../parser/helper/XmlLineNumberParser.java | 197 ++++++
.../parser/model/CamelEndpointDetails.java | 3 +
.../camel/parser/model/CamelSimpleDetails.java | 98 ---
.../model/CamelSimpleExpressionDetails.java | 101 +++
.../parser/roaster/AnonymousMethodSource.java | 426 +++++++++++++
.../parser/roaster/StatementFieldSource.java | 278 ++++++++
...asterCdiConcatRouteBuilderConfigureTest.java | 2 +-
.../RoasterCdiRouteBuilderConfigureTest.java | 2 +-
...terConcatFieldRouteBuilderConfigureTest.java | 2 +-
.../parser/java/RoasterEndpointInjectTest.java | 2 +-
.../RoasterFieldRouteBuilderConfigureTest.java | 2 +-
...sterMethodCallRouteBuilderConfigureTest.java | 2 +-
...ieldMethodCallRouteBuilderConfigureTest.java | 2 +-
.../java/RoasterMyLocalAddRouteBuilderTest.java | 2 +-
.../camel/parser/java/RoasterMyNettyTest.java | 2 +-
...erNewLineConstRouteBuilderConfigureTest.java | 2 +-
...RoasterNewLineRouteBuilderConfigureTest.java | 2 +-
...RoasterRouteBuilderCamelTestSupportTest.java | 2 +-
.../java/RoasterRouteBuilderConfigureTest.java | 2 +-
.../java/RoasterRouteBuilderEmptyUriTest.java | 2 +-
.../parser/java/RoasterSimpleProcessorTest.java | 2 +-
.../RoasterSimpleRouteBuilderConfigureTest.java | 2 +-
.../camel/parser/java/RoasterSimpleToDTest.java | 2 +-
.../camel/parser/java/RoasterSimpleToFTest.java | 2 +-
.../parser/java/RoasterSplitTokenizeTest.java | 2 +-
.../parser/xml/FindElementInRoutesTest.java | 2 +-
36 files changed, 2017 insertions(+), 1949 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/AnonymousMethodSource.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/AnonymousMethodSource.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/AnonymousMethodSource.java
deleted file mode 100644
index 777d34e..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/AnonymousMethodSource.java
+++ /dev/null
@@ -1,426 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.lang.annotation.Annotation;
-import java.util.List;
-
-import org.jboss.forge.roaster.model.JavaType;
-import org.jboss.forge.roaster.model.Type;
-import org.jboss.forge.roaster.model.TypeVariable;
-import org.jboss.forge.roaster.model.Visibility;
-import org.jboss.forge.roaster.model.source.AnnotationSource;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.JavaDocSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.jboss.forge.roaster.model.source.ParameterSource;
-import org.jboss.forge.roaster.model.source.TypeVariableSource;
-
-/**
- * In use when we have discovered a RouteBuilder being as anonymous inner class
- */
-public class AnonymousMethodSource implements MethodSource<JavaClassSource> {
-
- // this implementation should only implement the needed logic to support the parser
-
- private final JavaClassSource origin;
- private final Object internal;
-
- public AnonymousMethodSource(JavaClassSource origin, Object internal) {
- this.origin = origin;
- this.internal = internal;
- }
-
- @Override
- public MethodSource<JavaClassSource> setDefault(boolean b) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setSynchronized(boolean b) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setNative(boolean b) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setReturnType(Class<?> aClass) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setReturnType(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setReturnType(JavaType<?> javaType) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setReturnTypeVoid() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setBody(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setConstructor(boolean b) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setParameters(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> addThrows(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> addThrows(Class<? extends Exception> aClass) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeThrows(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeThrows(Class<? extends Exception> aClass) {
- return null;
- }
-
- @Override
- public boolean isSynchronized() {
- return false;
- }
-
- @Override
- public boolean isNative() {
- return false;
- }
-
- @Override
- public String getBody() {
- return null;
- }
-
- @Override
- public boolean isConstructor() {
- return false;
- }
-
- @Override
- public Type<JavaClassSource> getReturnType() {
- return null;
- }
-
- @Override
- public boolean isReturnTypeVoid() {
- return false;
- }
-
- @Override
- public List<ParameterSource<JavaClassSource>> getParameters() {
- return null;
- }
-
- @Override
- public String toSignature() {
- return null;
- }
-
- @Override
- public List<String> getThrownExceptions() {
- return null;
- }
-
- @Override
- public boolean isDefault() {
- return false;
- }
-
- @Override
- public ParameterSource<JavaClassSource> addParameter(Class<?> aClass, String s) {
- return null;
- }
-
- @Override
- public ParameterSource<JavaClassSource> addParameter(String s, String s1) {
- return null;
- }
-
- @Override
- public ParameterSource<JavaClassSource> addParameter(JavaType<?> javaType, String s) {
- return null;
- }
-
- @Override
- public void removeAllAnnotations() {
- }
-
- @Override
- public MethodSource<JavaClassSource> removeParameter(ParameterSource<JavaClassSource> parameterSource) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeParameter(Class<?> aClass, String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeParameter(String s, String s1) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeParameter(JavaType<?> javaType, String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setAbstract(boolean b) {
- return null;
- }
-
- @Override
- public List<AnnotationSource<JavaClassSource>> getAnnotations() {
- return null;
- }
-
- @Override
- public boolean hasAnnotation(Class<? extends Annotation> aClass) {
- return false;
- }
-
- @Override
- public boolean hasAnnotation(String s) {
- return false;
- }
-
- @Override
- public AnnotationSource<JavaClassSource> getAnnotation(Class<? extends Annotation> aClass) {
- return null;
- }
-
- @Override
- public AnnotationSource<JavaClassSource> getAnnotation(String s) {
- return null;
- }
-
- @Override
- public AnnotationSource<JavaClassSource> addAnnotation() {
- return null;
- }
-
- @Override
- public AnnotationSource<JavaClassSource> addAnnotation(Class<? extends Annotation> aClass) {
- return null;
- }
-
- @Override
- public AnnotationSource<JavaClassSource> addAnnotation(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeAnnotation(org.jboss.forge.roaster.model.Annotation<JavaClassSource> annotation) {
- return null;
- }
-
- @Override
- public List<TypeVariableSource<JavaClassSource>> getTypeVariables() {
- return null;
- }
-
- @Override
- public TypeVariableSource<JavaClassSource> getTypeVariable(String s) {
- return null;
- }
-
- @Override
- public TypeVariableSource<JavaClassSource> addTypeVariable() {
- return null;
- }
-
- @Override
- public TypeVariableSource<JavaClassSource> addTypeVariable(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeTypeVariable(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeTypeVariable(TypeVariable<?> typeVariable) {
- return null;
- }
-
- @Override
- public boolean hasJavaDoc() {
- return false;
- }
-
- @Override
- public boolean isAbstract() {
- return false;
- }
-
- @Override
- public MethodSource<JavaClassSource> setFinal(boolean b) {
- return null;
- }
-
- @Override
- public boolean isFinal() {
- return false;
- }
-
- @Override
- public Object getInternal() {
- return internal;
- }
-
- @Override
- public JavaDocSource<MethodSource<JavaClassSource>> getJavaDoc() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeJavaDoc() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setName(String s) {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public JavaClassSource getOrigin() {
- return origin;
- }
-
- @Override
- public MethodSource<JavaClassSource> setStatic(boolean b) {
- return null;
- }
-
- @Override
- public boolean isStatic() {
- return false;
- }
-
- @Override
- public MethodSource<JavaClassSource> setPackagePrivate() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setPublic() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setPrivate() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setProtected() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setVisibility(Visibility visibility) {
- return null;
- }
-
- @Override
- public boolean isPackagePrivate() {
- return false;
- }
-
- @Override
- public boolean isPublic() {
- return false;
- }
-
- @Override
- public boolean isPrivate() {
- return false;
- }
-
- @Override
- public boolean isProtected() {
- return false;
- }
-
- @Override
- public Visibility getVisibility() {
- return null;
- }
-
- @Override
- public int getColumnNumber() {
- return 0;
- }
-
- @Override
- public int getStartPosition() {
- return 0;
- }
-
- @Override
- public int getEndPosition() {
- return 0;
- }
-
- @Override
- public int getLineNumber() {
- return 0;
- }
-
- @Override
- public boolean hasTypeVariable(String arg0) {
- return false;
- }
-
- @Override
- public MethodSource<JavaClassSource> setReturnType(Type<?> arg0) {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
deleted file mode 100644
index 5cd1e1c..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
+++ /dev/null
@@ -1,634 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Block;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.BooleanLiteral;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ClassInstanceCreation;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Expression;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ExpressionStatement;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.InfixExpression;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MemberValuePair;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodInvocation;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NumberLiteral;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ParenthesizedExpression;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.QualifiedName;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ReturnStatement;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleName;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleType;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Statement;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.StringLiteral;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Type;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclaration;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclarationStatement;
-import org.jboss.forge.roaster.model.Annotation;
-import org.jboss.forge.roaster.model.source.AnnotationSource;
-import org.jboss.forge.roaster.model.source.FieldSource;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.jboss.forge.roaster.model.util.Strings;
-
-/**
- * A Camel Java parser that only depends on the Roaster API.
- * <p/>
- * This implementation is lower level details. For a higher level parser see {@link RouteBuilderParser}.
- */
-public final class CamelJavaParserHelper {
-
- private CamelJavaParserHelper() {
- // utility class
- }
-
- public static MethodSource<JavaClassSource> findConfigureMethod(JavaClassSource clazz) {
- MethodSource<JavaClassSource> method = clazz.getMethod("configure");
- // must be public void configure()
- if (method != null && method.isPublic() && method.getParameters().isEmpty() && method.getReturnType().isType("void")) {
- return method;
- }
-
- // maybe the route builder is from unit testing with camel-test as an anonymous inner class
- // there is a bit of code to dig out this using the eclipse jdt api
- method = findCreateRouteBuilderMethod(clazz);
- if (method != null) {
- return findConfigureMethodInCreateRouteBuilder(clazz, method);
- }
-
- return null;
- }
-
- public static List<MethodSource<JavaClassSource>> findInlinedConfigureMethods(JavaClassSource clazz) {
- List<MethodSource<JavaClassSource>> answer = new ArrayList<>();
-
- List<MethodSource<JavaClassSource>> methods = clazz.getMethods();
- if (methods != null) {
- for (MethodSource<JavaClassSource> method : methods) {
- if (method.isPublic()
- && (method.getParameters() == null || method.getParameters().isEmpty())
- && (method.getReturnType() == null || method.getReturnType().isType("void"))) {
- // maybe the method contains an inlined createRouteBuilder usually from an unit test method
- MethodSource<JavaClassSource> builder = findConfigureMethodInCreateRouteBuilder(clazz, method);
- if (builder != null) {
- answer.add(builder);
- }
- }
- }
- }
-
- return answer;
- }
-
- private static MethodSource<JavaClassSource> findCreateRouteBuilderMethod(JavaClassSource clazz) {
- MethodSource method = clazz.getMethod("createRouteBuilder");
- if (method != null && (method.isPublic() || method.isProtected()) && method.getParameters().isEmpty()) {
- return method;
- }
- return null;
- }
-
- private static MethodSource<JavaClassSource> findConfigureMethodInCreateRouteBuilder(JavaClassSource clazz, MethodSource<JavaClassSource> method) {
- // find configure inside the code
- MethodDeclaration md = (MethodDeclaration) method.getInternal();
- Block block = md.getBody();
- if (block != null) {
- List statements = block.statements();
- for (int i = 0; i < statements.size(); i++) {
- Statement stmt = (Statement) statements.get(i);
- Expression exp = null;
- if (stmt instanceof ReturnStatement) {
- ReturnStatement rs = (ReturnStatement) stmt;
- exp = rs.getExpression();
- } else if (stmt instanceof ExpressionStatement) {
- ExpressionStatement es = (ExpressionStatement) stmt;
- exp = es.getExpression();
- if (exp instanceof MethodInvocation) {
- MethodInvocation mi = (MethodInvocation) exp;
- for (Object arg : mi.arguments()) {
- if (arg instanceof ClassInstanceCreation) {
- exp = (Expression) arg;
- break;
- }
- }
- }
- }
- if (exp != null && exp instanceof ClassInstanceCreation) {
- ClassInstanceCreation cic = (ClassInstanceCreation) exp;
- boolean isRouteBuilder = false;
- if (cic.getType() instanceof SimpleType) {
- SimpleType st = (SimpleType) cic.getType();
- isRouteBuilder = "RouteBuilder".equals(st.getName().toString());
- }
- if (isRouteBuilder && cic.getAnonymousClassDeclaration() != null) {
- List body = cic.getAnonymousClassDeclaration().bodyDeclarations();
- for (int j = 0; j < body.size(); j++) {
- Object line = body.get(j);
- if (line instanceof MethodDeclaration) {
- MethodDeclaration amd = (MethodDeclaration) line;
- if ("configure".equals(amd.getName().toString())) {
- return new AnonymousMethodSource(clazz, amd);
- }
- }
- }
- }
- }
- }
- }
-
- return null;
- }
-
- public static List<ParserResult> parseCamelConsumerUris(MethodSource<JavaClassSource> method, boolean strings, boolean fields) {
- return doParseCamelUris(method, true, false, strings, fields);
- }
-
- public static List<ParserResult> parseCamelProducerUris(MethodSource<JavaClassSource> method, boolean strings, boolean fields) {
- return doParseCamelUris(method, false, true, strings, fields);
- }
-
- private static List<ParserResult> doParseCamelUris(MethodSource<JavaClassSource> method, boolean consumers, boolean producers,
- boolean strings, boolean fields) {
-
- List<ParserResult> answer = new ArrayList<ParserResult>();
-
- if (method != null) {
- MethodDeclaration md = (MethodDeclaration) method.getInternal();
- Block block = md.getBody();
- if (block != null) {
- for (Object statement : md.getBody().statements()) {
- // must be a method call expression
- if (statement instanceof ExpressionStatement) {
- ExpressionStatement es = (ExpressionStatement) statement;
- Expression exp = es.getExpression();
-
- List<ParserResult> uris = new ArrayList<ParserResult>();
- parseExpression(method.getOrigin(), block, exp, uris, consumers, producers, strings, fields);
- if (!uris.isEmpty()) {
- // reverse the order as we will grab them from last->first
- Collections.reverse(uris);
- answer.addAll(uris);
- }
- }
- }
- }
- }
-
- return answer;
- }
-
- private static void parseExpression(JavaClassSource clazz, Block block, Expression exp, List<ParserResult> uris,
- boolean consumers, boolean producers, boolean strings, boolean fields) {
- if (exp == null) {
- return;
- }
- if (exp instanceof MethodInvocation) {
- MethodInvocation mi = (MethodInvocation) exp;
- doParseCamelUris(clazz, block, mi, uris, consumers, producers, strings, fields);
- // if the method was called on another method, then recursive
- exp = mi.getExpression();
- parseExpression(clazz, block, exp, uris, consumers, producers, strings, fields);
- }
- }
-
- private static void doParseCamelUris(JavaClassSource clazz, Block block, MethodInvocation mi, List<ParserResult> uris,
- boolean consumers, boolean producers, boolean strings, boolean fields) {
- String name = mi.getName().getIdentifier();
-
- if (consumers) {
- if ("from".equals(name)) {
- List args = mi.arguments();
- if (args != null) {
- for (Object arg : args) {
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- }
- if ("fromF".equals(name)) {
- List args = mi.arguments();
- // the first argument is where the uri is
- if (args != null && args.size() >= 1) {
- Object arg = args.get(0);
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- if ("pollEnrich".equals(name)) {
- List args = mi.arguments();
- // the first argument is where the uri is
- if (args != null && args.size() >= 1) {
- Object arg = args.get(0);
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- }
-
- if (producers) {
- if ("to".equals(name) || "toD".equals(name)) {
- List args = mi.arguments();
- if (args != null) {
- for (Object arg : args) {
- // skip if the arg is a boolean, ExchangePattern or Iterateable, type
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- }
- if ("toF".equals(name)) {
- List args = mi.arguments();
- // the first argument is where the uri is
- if (args != null && args.size() >= 1) {
- Object arg = args.get(0);
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- if ("enrich".equals(name) || "wireTap".equals(name)) {
- List args = mi.arguments();
- // the first argument is where the uri is
- if (args != null && args.size() >= 1) {
- Object arg = args.get(0);
- if (isValidArgument(name, arg)) {
- extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
- }
- }
- }
- }
- }
-
- private static boolean isValidArgument(String node, Object arg) {
- // skip boolean argument, as toD can accept a boolean value
- if (arg instanceof BooleanLiteral) {
- return false;
- }
- // skip ExchangePattern argument
- if (arg instanceof QualifiedName) {
- QualifiedName qn = (QualifiedName) arg;
- String name = qn.getFullyQualifiedName();
- if (name.startsWith("ExchangePattern")) {
- return false;
- }
- }
- return true;
- }
-
- private static void extractEndpointUriFromArgument(String node, JavaClassSource clazz, Block block, List<ParserResult> uris, Object arg, boolean strings, boolean fields) {
- if (strings) {
- String uri = getLiteralValue(clazz, block, (Expression) arg);
- if (!Strings.isBlank(uri)) {
- int position = ((Expression) arg).getStartPosition();
-
- // if the node is fromF or toF, then replace all %s with {{%s}} as we cannot parse that value
- if ("fromF".equals(node) || "toF".equals(node)) {
- uri = uri.replaceAll("\\%s", "\\{\\{\\%s\\}\\}");
- }
-
- uris.add(new ParserResult(node, position, uri));
- return;
- }
- }
- if (fields && arg instanceof SimpleName) {
- FieldSource field = getField(clazz, block, (SimpleName) arg);
- if (field != null) {
- // find the endpoint uri from the annotation
- AnnotationSource annotation = field.getAnnotation("org.apache.camel.cdi.Uri");
- if (annotation == null) {
- annotation = field.getAnnotation("org.apache.camel.EndpointInject");
- }
- if (annotation != null) {
- Expression exp = (Expression) annotation.getInternal();
- if (exp instanceof SingleMemberAnnotation) {
- exp = ((SingleMemberAnnotation) exp).getValue();
- } else if (exp instanceof NormalAnnotation) {
- List values = ((NormalAnnotation) exp).values();
- for (Object value : values) {
- MemberValuePair pair = (MemberValuePair) value;
- if ("uri".equals(pair.getName().toString())) {
- exp = pair.getValue();
- break;
- }
- }
- }
- String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
- if (!Strings.isBlank(uri)) {
- int position = ((SimpleName) arg).getStartPosition();
- uris.add(new ParserResult(node, position, uri));
- }
- } else {
- // the field may be initialized using variables, so we need to evaluate those expressions
- Object fi = field.getInternal();
- if (fi instanceof VariableDeclaration) {
- Expression exp = ((VariableDeclaration) fi).getInitializer();
- String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
- if (!Strings.isBlank(uri)) {
- // we want the position of the field, and not in the route
- int position = ((VariableDeclaration) fi).getStartPosition();
- uris.add(new ParserResult(node, position, uri));
- }
- }
- }
- }
- }
-
- // cannot parse it so add a failure
- uris.add(new ParserResult(node, -1, arg.toString(), false));
- }
-
- public static List<ParserResult> parseCamelSimpleExpressions(MethodSource<JavaClassSource> method) {
- List<ParserResult> answer = new ArrayList<ParserResult>();
-
- MethodDeclaration md = (MethodDeclaration) method.getInternal();
- Block block = md.getBody();
- if (block != null) {
- for (Object statement : block.statements()) {
- // must be a method call expression
- if (statement instanceof ExpressionStatement) {
- ExpressionStatement es = (ExpressionStatement) statement;
- Expression exp = es.getExpression();
-
- List<ParserResult> expressions = new ArrayList<ParserResult>();
- parseExpression(null, method.getOrigin(), block, exp, expressions);
- if (!expressions.isEmpty()) {
- // reverse the order as we will grab them from last->first
- Collections.reverse(expressions);
- answer.addAll(expressions);
- }
- }
- }
- }
-
- return answer;
- }
-
- private static void parseExpression(String node, JavaClassSource clazz, Block block, Expression exp, List<ParserResult> expressions) {
- if (exp == null) {
- return;
- }
- if (exp instanceof MethodInvocation) {
- MethodInvocation mi = (MethodInvocation) exp;
- doParseCamelSimple(node, clazz, block, mi, expressions);
- // if the method was called on another method, then recursive
- exp = mi.getExpression();
- parseExpression(node, clazz, block, exp, expressions);
- }
- }
-
- private static void doParseCamelSimple(String node, JavaClassSource clazz, Block block, MethodInvocation mi, List<ParserResult> expressions) {
- String name = mi.getName().getIdentifier();
-
- if ("simple".equals(name)) {
- List args = mi.arguments();
- // the first argument is a string parameter for the simple expression
- if (args != null && args.size() >= 1) {
- // it is a String type
- Object arg = args.get(0);
- String simple = getLiteralValue(clazz, block, (Expression) arg);
- if (!Strings.isBlank(simple)) {
- int position = ((Expression) arg).getStartPosition();
- expressions.add(new ParserResult(node, position, simple));
- }
- }
- }
-
- // simple maybe be passed in as an argument
- List args = mi.arguments();
- if (args != null) {
- for (Object arg : args) {
- if (arg instanceof MethodInvocation) {
- MethodInvocation ami = (MethodInvocation) arg;
- doParseCamelSimple(node, clazz, block, ami, expressions);
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- private static FieldSource<JavaClassSource> getField(JavaClassSource clazz, Block block, SimpleName ref) {
- String fieldName = ref.getIdentifier();
- if (fieldName != null) {
- // find field in class
- FieldSource field = clazz != null ? clazz.getField(fieldName) : null;
- if (field == null) {
- field = findFieldInBlock(clazz, block, fieldName);
- }
- return field;
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private static FieldSource<JavaClassSource> findFieldInBlock(JavaClassSource clazz, Block block, String fieldName) {
- for (Object statement : block.statements()) {
- // try local statements first in the block
- if (statement instanceof VariableDeclarationStatement) {
- final Type type = ((VariableDeclarationStatement) statement).getType();
- for (Object obj : ((VariableDeclarationStatement) statement).fragments()) {
- if (obj instanceof VariableDeclarationFragment) {
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
- SimpleName name = fragment.getName();
- if (name != null && fieldName.equals(name.getIdentifier())) {
- return new StatementFieldSource(clazz, fragment, type);
- }
- }
- }
- }
-
- // okay the field may be burried inside an anonymous inner class as a field declaration
- // outside the configure method, so lets go back to the parent and see what we can find
- ASTNode node = block.getParent();
- if (node instanceof MethodDeclaration) {
- node = node.getParent();
- }
- if (node instanceof AnonymousClassDeclaration) {
- List declarations = ((AnonymousClassDeclaration) node).bodyDeclarations();
- for (Object dec : declarations) {
- if (dec instanceof FieldDeclaration) {
- FieldDeclaration fd = (FieldDeclaration) dec;
- final Type type = fd.getType();
- for (Object obj : fd.fragments()) {
- if (obj instanceof VariableDeclarationFragment) {
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
- SimpleName name = fragment.getName();
- if (name != null && fieldName.equals(name.getIdentifier())) {
- return new StatementFieldSource(clazz, fragment, type);
- }
- }
- }
- }
- }
- }
- }
- return null;
- }
-
- public static String getLiteralValue(JavaClassSource clazz, Block block, Expression expression) {
- // unwrap parenthesis
- if (expression instanceof ParenthesizedExpression) {
- expression = ((ParenthesizedExpression) expression).getExpression();
- }
-
- if (expression instanceof StringLiteral) {
- return ((StringLiteral) expression).getLiteralValue();
- } else if (expression instanceof BooleanLiteral) {
- return "" + ((BooleanLiteral) expression).booleanValue();
- } else if (expression instanceof NumberLiteral) {
- return ((NumberLiteral) expression).getToken();
- }
-
- // if it a method invocation then add a dummy value assuming the method invocation will return a valid response
- if (expression instanceof MethodInvocation) {
- String name = ((MethodInvocation) expression).getName().getIdentifier();
- return "{{" + name + "}}";
- }
-
- // if its a qualified name (usually a constant field in another class)
- // then add a dummy value as we cannot find the field value in other classes and maybe even outside the
- // source code we have access to
- if (expression instanceof QualifiedName) {
- QualifiedName qn = (QualifiedName) expression;
- String name = qn.getFullyQualifiedName();
- return "{{" + name + "}}";
- }
-
- if (expression instanceof SimpleName) {
- FieldSource<JavaClassSource> field = getField(clazz, block, (SimpleName) expression);
- if (field != null) {
- // is the field annotated with a Camel endpoint
- if (field.getAnnotations() != null) {
- for (Annotation ann : field.getAnnotations()) {
- boolean valid = "org.apache.camel.EndpointInject".equals(ann.getQualifiedName()) || "org.apache.camel.cdi.Uri".equals(ann.getQualifiedName());
- if (valid) {
- Expression exp = (Expression) ann.getInternal();
- if (exp instanceof SingleMemberAnnotation) {
- exp = ((SingleMemberAnnotation) exp).getValue();
- } else if (exp instanceof NormalAnnotation) {
- List values = ((NormalAnnotation) exp).values();
- for (Object value : values) {
- MemberValuePair pair = (MemberValuePair) value;
- if ("uri".equals(pair.getName().toString())) {
- exp = pair.getValue();
- break;
- }
- }
- }
- if (exp != null) {
- return getLiteralValue(clazz, block, exp);
- }
- }
- }
- }
- // is the field an org.apache.camel.Endpoint type?
- if ("Endpoint".equals(field.getType().getSimpleName())) {
- // then grab the uri from the first argument
- VariableDeclarationFragment vdf = (VariableDeclarationFragment) field.getInternal();
- expression = vdf.getInitializer();
- if (expression instanceof MethodInvocation) {
- MethodInvocation mi = (MethodInvocation) expression;
- List args = mi.arguments();
- if (args != null && args.size() > 0) {
- // the first argument has the endpoint uri
- expression = (Expression) args.get(0);
- return getLiteralValue(clazz, block, expression);
- }
- }
- } else {
- // no annotations so try its initializer
- VariableDeclarationFragment vdf = (VariableDeclarationFragment) field.getInternal();
- expression = vdf.getInitializer();
- if (expression == null) {
- // its a field which has no initializer, then add a dummy value assuming the field will be initialized at runtime
- return "{{" + field.getName() + "}}";
- } else {
- return getLiteralValue(clazz, block, expression);
- }
- }
- } else {
- // we could not find the field in this class/method, so its maybe from some other super class, so insert a dummy value
- final String fieldName = ((SimpleName) expression).getIdentifier();
- return "{{" + fieldName + "}}";
- }
- } else if (expression instanceof InfixExpression) {
- String answer = null;
- // is it a string that is concat together?
- InfixExpression ie = (InfixExpression) expression;
- if (InfixExpression.Operator.PLUS.equals(ie.getOperator())) {
-
- String val1 = getLiteralValue(clazz, block, ie.getLeftOperand());
- String val2 = getLiteralValue(clazz, block, ie.getRightOperand());
-
- // if numeric then we plus the values, otherwise we string concat
- boolean numeric = isNumericOperator(clazz, block, ie.getLeftOperand()) && isNumericOperator(clazz, block, ie.getRightOperand());
- if (numeric) {
- Long num1 = val1 != null ? Long.valueOf(val1) : 0;
- Long num2 = val2 != null ? Long.valueOf(val2) : 0;
- answer = "" + (num1 + num2);
- } else {
- answer = (val1 != null ? val1 : "") + (val2 != null ? val2 : "");
- }
-
- if (!answer.isEmpty()) {
- // include extended when we concat on 2 or more lines
- List extended = ie.extendedOperands();
- if (extended != null) {
- for (Object ext : extended) {
- String val3 = getLiteralValue(clazz, block, (Expression) ext);
- if (numeric) {
- Long num3 = val3 != null ? Long.valueOf(val3) : 0;
- Long num = Long.valueOf(answer);
- answer = "" + (num + num3);
- } else {
- answer += val3 != null ? val3 : "";
- }
- }
- }
- }
- }
- return answer;
- }
-
- return null;
- }
-
- private static boolean isNumericOperator(JavaClassSource clazz, Block block, Expression expression) {
- if (expression instanceof NumberLiteral) {
- return true;
- } else if (expression instanceof SimpleName) {
- FieldSource field = getField(clazz, block, (SimpleName) expression);
- if (field != null) {
- return field.getType().isType("int") || field.getType().isType("long")
- || field.getType().isType("Integer") || field.getType().isType("Long");
- }
- }
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java
deleted file mode 100644
index 3e81a3f..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.jboss.forge.roaster.model.util.Strings;
-
-public final class CamelXmlHelper {
-
- private CamelXmlHelper() {
- // utility class
- }
-
- public static String getSafeAttribute(Node node, String key) {
- if (node != null) {
- Node attr = node.getAttributes().getNamedItem(key);
- if (attr != null) {
- return attr.getNodeValue();
- }
- }
- return null;
- }
-
- public static List<Node> findAllEndpoints(Document dom) {
- List<Node> nodes = new ArrayList<>();
-
- NodeList list = dom.getElementsByTagName("endpoint");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- if ("endpoint".equals(child.getNodeName())) {
- // it may not be a camel namespace, so skip those
- String ns = child.getNamespaceURI();
- if (ns == null) {
- NamedNodeMap attrs = child.getAttributes();
- if (attrs != null) {
- Node node = attrs.getNamedItem("xmlns");
- if (node != null) {
- ns = node.getNodeValue();
- }
- }
- }
- // assume no namespace its for camel
- if (ns == null || ns.contains("camel")) {
- nodes.add(child);
- }
- }
- }
-
- list = dom.getElementsByTagName("onException");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- findAllUrisRecursive(child, nodes);
- }
- list = dom.getElementsByTagName("onCompletion");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- findAllUrisRecursive(child, nodes);
- }
- list = dom.getElementsByTagName("intercept");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- findAllUrisRecursive(child, nodes);
- }
- list = dom.getElementsByTagName("interceptFrom");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- findAllUrisRecursive(child, nodes);
- }
- list = dom.getElementsByTagName("interceptSendToEndpoint");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- findAllUrisRecursive(child, nodes);
- }
- list = dom.getElementsByTagName("rest");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- if ("route".equals(child.getNodeName()) || "to".equals(child.getNodeName())) {
- findAllUrisRecursive(child, nodes);
- }
- }
- list = dom.getElementsByTagName("route");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- if ("route".equals(child.getNodeName())) {
- findAllUrisRecursive(child, nodes);
- }
- }
-
- return nodes;
- }
-
- private static void findAllUrisRecursive(Node node, List<Node> nodes) {
- // okay its a route so grab all uri attributes we can find
- String url = getSafeAttribute(node, "uri");
- if (url != null) {
- nodes.add(node);
- }
-
- NodeList children = node.getChildNodes();
- if (children != null) {
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- findAllUrisRecursive(child, nodes);
- }
- }
- }
- }
-
- public static List<Node> findAllSimpleExpressions(Document dom) {
- List<Node> nodes = new ArrayList<>();
-
- NodeList list = dom.getElementsByTagName("route");
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- if ("route".equals(child.getNodeName())) {
- findAllSimpleExpressionsRecursive(child, nodes);
- }
- }
-
- return nodes;
- }
-
- private static void findAllSimpleExpressionsRecursive(Node node, List<Node> nodes) {
- // okay its a route so grab if its <simple>
- if ("simple".equals(node.getNodeName())) {
- nodes.add(node);
- }
-
- NodeList children = node.getChildNodes();
- if (children != null) {
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- findAllSimpleExpressionsRecursive(child, nodes);
- }
- }
- }
- }
-
- public static Element getSelectedCamelElementNode(String key, InputStream resourceInputStream) throws Exception {
- Document root = loadCamelXmlFileAsDom(resourceInputStream);
- Element selectedElement = null;
- if (root != null) {
- Node selectedNode = findCamelNodeInDocument(root, key);
- if (selectedNode instanceof Element) {
- selectedElement = (Element) selectedNode;
- }
- }
- return selectedElement;
- }
-
- private static Document loadCamelXmlFileAsDom(InputStream resourceInputStream) throws Exception {
- // TODO:
- Document root = XmlLineNumberParser.parseXml(resourceInputStream, "camelContext,routes,rests", "http://camel.apache.org/schema/spring");
- return root;
- }
-
- private static Node findCamelNodeInDocument(Document root, String key) {
- Node selectedNode = null;
- if (root != null && !Strings.isBlank(key)) {
- String[] paths = key.split("/");
- NodeList camels = getCamelContextElements(root);
- if (camels != null) {
- Map<String, Integer> rootNodeCounts = new HashMap<>();
- for (int i = 0, size = camels.getLength(); i < size; i++) {
- Node node = camels.item(i);
- boolean first = true;
- for (String path : paths) {
- if (first) {
- first = false;
- String actual = getIdOrIndex(node, rootNodeCounts);
- if (!equal(actual, path)) {
- node = null;
- }
- } else {
- node = findCamelNodeForPath(node, path);
- }
- if (node == null) {
- break;
- }
- }
- if (node != null) {
- return node;
- }
- }
- }
- }
- return selectedNode;
- }
-
- private static Node findCamelNodeForPath(Node node, String path) {
- NodeList childNodes = node.getChildNodes();
- if (childNodes != null) {
- Map<String, Integer> nodeCounts = new HashMap<>();
- for (int i = 0, size = childNodes.getLength(); i < size; i++) {
- Node child = childNodes.item(i);
- if (child instanceof Element) {
- String actual = getIdOrIndex(child, nodeCounts);
- if (equal(actual, path)) {
- return child;
- }
- }
- }
- }
- return null;
- }
-
- private static String getIdOrIndex(Node node, Map<String, Integer> nodeCounts) {
- String answer = null;
- if (node instanceof Element) {
- Element element = (Element) node;
- String elementName = element.getTagName();
- if ("routes".equals(elementName)) {
- elementName = "camelContext";
- }
- Integer countObject = nodeCounts.get(elementName);
- int count = countObject != null ? countObject.intValue() : 0;
- nodeCounts.put(elementName, ++count);
- answer = element.getAttribute("id");
- if (Strings.isBlank(answer)) {
- answer = "_" + elementName + count;
- }
- }
- return answer;
- }
-
- private static NodeList getCamelContextElements(Document dom) {
- NodeList camels = dom.getElementsByTagName("camelContext");
- if (camels == null || camels.getLength() == 0) {
- camels = dom.getElementsByTagName("routes");
- }
- return camels;
- }
-
- private static boolean equal(Object a, Object b) {
- return a == b ? true : a != null && b != null && a.equals(b);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
index 445147d..4ef2fc4 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.parser;
+/**
+ * Result of parsing Camel RouteBuilder or XML routes from the source code.
+ */
public class ParserResult {
private final String node;
@@ -34,30 +37,31 @@ public class ParserResult {
this.parsed = parsed;
}
+ /**
+ * Character based position in the source code (not line based).
+ */
public int getPosition() {
return position;
}
- public void setPosition(int position) {
- this.position = position;
- }
-
+ /**
+ * The element such as a Camel endpoint uri
+ */
public String getElement() {
return element;
}
- public void setElement(String element) {
- this.element = element;
- }
-
+ /**
+ * Whether the element was successfully parsed. If the parser cannot parse
+ * the element for whatever reason this will return <tt>false</tt>.
+ */
public boolean isParsed() {
return parsed;
}
- public void setParsed(boolean parsed) {
- this.parsed = parsed;
- }
-
+ /**
+ * The node which is typically a Camel EIP name such as <tt>to</tt>, <tt>wireTap</tt> etc.
+ */
public String getNode() {
return node;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
index b2d806b..1bba303 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,8 +22,9 @@ import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.apache.camel.parser.model.CamelSimpleDetails;
+import org.apache.camel.parser.model.CamelSimpleExpressionDetails;
import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode;
import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Expression;
import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MemberValuePair;
@@ -45,11 +46,29 @@ public final class RouteBuilderParser {
private RouteBuilderParser() {
}
+ /**
+ * Parses the java source class to discover Camel endpoints.
+ *
+ * @param clazz the java source class
+ * @param baseDir the base of the source code
+ * @param fullyQualifiedFileName the fully qualified source code file name
+ * @param endpoints list to add discovered and parsed endpoints
+ */
public static void parseRouteBuilderEndpoints(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
List<CamelEndpointDetails> endpoints) {
parseRouteBuilderEndpoints(clazz, baseDir, fullyQualifiedFileName, endpoints, null, false);
}
+ /**
+ * Parses the java source class to discover Camel endpoints.
+ *
+ * @param clazz the java source class
+ * @param baseDir the base of the source code
+ * @param fullyQualifiedFileName the fully qualified source code file name
+ * @param endpoints list to add discovered and parsed endpoints
+ * @param unparsable list of unparsable nodes
+ * @param includeInlinedRouteBuilders whether to include inlined route builders in the parsing
+ */
public static void parseRouteBuilderEndpoints(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
List<CamelEndpointDetails> endpoints, List<String> unparsable, boolean includeInlinedRouteBuilders) {
@@ -209,17 +228,16 @@ public final class RouteBuilderParser {
}
}
- private static CamelEndpointDetails findEndpointByUri(List<CamelEndpointDetails> endpoints, String uri) {
- for (CamelEndpointDetails detail : endpoints) {
- if (uri.equals(detail.getEndpointUri())) {
- return detail;
- }
- }
- return null;
- }
-
+ /**
+ * Parses the java source class to discover Camel simple expressions.
+ *
+ * @param clazz the java source class
+ * @param baseDir the base of the source code
+ * @param fullyQualifiedFileName the fully qualified source code file name
+ * @param simpleExpressions list to add discovered and parsed simple expressions
+ */
public static void parseRouteBuilderSimpleExpressions(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
- List<CamelSimpleDetails> simpleExpressions) {
+ List<CamelSimpleExpressionDetails> simpleExpressions) {
MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
if (method != null) {
@@ -231,7 +249,7 @@ public final class RouteBuilderParser {
fileName = fileName.substring(baseDir.length() + 1);
}
- CamelSimpleDetails details = new CamelSimpleDetails();
+ CamelSimpleExpressionDetails details = new CamelSimpleExpressionDetails();
details.setFileName(fileName);
details.setClassName(clazz.getQualifiedName());
details.setMethodName("configure");
@@ -247,6 +265,15 @@ public final class RouteBuilderParser {
}
}
+ private static CamelEndpointDetails findEndpointByUri(List<CamelEndpointDetails> endpoints, String uri) {
+ for (CamelEndpointDetails detail : endpoints) {
+ if (uri.equals(detail.getEndpointUri())) {
+ return detail;
+ }
+ }
+ return null;
+ }
+
private static int findLineNumber(String fullyQualifiedFileName, int position) {
int lines = 0;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/StatementFieldSource.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/StatementFieldSource.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/StatementFieldSource.java
deleted file mode 100644
index 1daa85d..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/StatementFieldSource.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.util.List;
-
-import org.jboss.forge.roaster.model.Annotation;
-import org.jboss.forge.roaster.model.JavaType;
-import org.jboss.forge.roaster.model.Type;
-import org.jboss.forge.roaster.model.Visibility;
-import org.jboss.forge.roaster.model.impl.TypeImpl;
-import org.jboss.forge.roaster.model.source.AnnotationSource;
-import org.jboss.forge.roaster.model.source.FieldSource;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.JavaDocSource;
-
-public class StatementFieldSource implements FieldSource {
-
- // this implementation should only implement the needed logic to support the parser
-
- private final JavaClassSource origin;
- private final Object internal;
- private final Type type;
-
- public StatementFieldSource(JavaClassSource origin, Object internal, Object typeInternal) {
- this.origin = origin;
- this.internal = internal;
- this.type = new TypeImpl(origin, typeInternal);
- }
-
- @Override
- public FieldSource setType(Class clazz) {
- return null;
- }
-
- @Override
- public FieldSource setType(String type) {
- return null;
- }
-
- @Override
- public FieldSource setLiteralInitializer(String value) {
- return null;
- }
-
- @Override
- public FieldSource setStringInitializer(String value) {
- return null;
- }
-
- @Override
- public FieldSource setTransient(boolean value) {
- return null;
- }
-
- @Override
- public FieldSource setVolatile(boolean value) {
- return null;
- }
-
- @Override
- public FieldSource setType(JavaType entity) {
- return null;
- }
-
- @Override
- public List<AnnotationSource> getAnnotations() {
- return null;
- }
-
- @Override
- public boolean hasAnnotation(String type) {
- return false;
- }
-
- @Override
- public boolean hasAnnotation(Class type) {
- return false;
- }
-
- @Override
- public AnnotationSource getAnnotation(String type) {
- return null;
- }
-
- @Override
- public AnnotationSource addAnnotation() {
- return null;
- }
-
- @Override
- public AnnotationSource addAnnotation(String className) {
- return null;
- }
-
- @Override
- public void removeAllAnnotations() {
- }
-
- @Override
- public Object removeAnnotation(Annotation annotation) {
- return null;
- }
-
- @Override
- public AnnotationSource addAnnotation(Class type) {
- return null;
- }
-
- @Override
- public AnnotationSource getAnnotation(Class type) {
- return null;
- }
-
- @Override
- public Type getType() {
- return type;
- }
-
- @Override
- public String getStringInitializer() {
- return null;
- }
-
- @Override
- public String getLiteralInitializer() {
- return null;
- }
-
- @Override
- public boolean isTransient() {
- return false;
- }
-
- @Override
- public boolean isVolatile() {
- return false;
- }
-
- @Override
- public Object setFinal(boolean finl) {
- return null;
- }
-
- @Override
- public boolean isFinal() {
- return false;
- }
-
- @Override
- public Object getInternal() {
- return internal;
- }
-
- @Override
- public JavaDocSource getJavaDoc() {
- return null;
- }
-
- @Override
- public boolean hasJavaDoc() {
- return false;
- }
-
- @Override
- public Object removeJavaDoc() {
- return null;
- }
-
- @Override
- public Object setName(String name) {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public Object getOrigin() {
- return origin;
- }
-
- @Override
- public Object setStatic(boolean value) {
- return null;
- }
-
- @Override
- public boolean isStatic() {
- return false;
- }
-
- @Override
- public Object setPackagePrivate() {
- return null;
- }
-
- @Override
- public Object setPublic() {
- return null;
- }
-
- @Override
- public Object setPrivate() {
- return null;
- }
-
- @Override
- public Object setProtected() {
- return null;
- }
-
- @Override
- public Object setVisibility(Visibility scope) {
- return null;
- }
-
- @Override
- public boolean isPackagePrivate() {
- return false;
- }
-
- @Override
- public boolean isPublic() {
- return false;
- }
-
- @Override
- public boolean isPrivate() {
- return false;
- }
-
- @Override
- public boolean isProtected() {
- return false;
- }
-
- @Override
- public Visibility getVisibility() {
- return null;
- }
-
- @Override
- public int getColumnNumber() {
- return 0;
- }
-
- @Override
- public int getStartPosition() {
- return 0;
- }
-
- @Override
- public int getEndPosition() {
- return 0;
- }
-
- @Override
- public int getLineNumber() {
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java
deleted file mode 100644
index f955409..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.util.Stack;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * An XML parser that uses SAX to include line and column number for each XML element in the parsed Document.
- * <p/>
- * The line number and column number can be obtained from a Node/Element using
- * <pre>
- * String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
- * String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
- * String columnNumber = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER);
- * String columnNumberEnd = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER_END);
- * </pre>
- */
-public final class XmlLineNumberParser {
-
- public static final String LINE_NUMBER = "lineNumber";
- public static final String COLUMN_NUMBER = "colNumber";
- public static final String LINE_NUMBER_END = "lineNumberEnd";
- public static final String COLUMN_NUMBER_END = "colNumberEnd";
-
- private XmlLineNumberParser() {
- }
-
- /**
- * Parses the XML.
- *
- * @param is the XML content as an input stream
- * @return the DOM model
- * @throws Exception is thrown if error parsing
- */
- public static Document parseXml(final InputStream is) throws Exception {
- return parseXml(is, null, null);
- }
-
- /**
- * Parses the XML.
- *
- * @param is the XML content as an input stream
- * @param rootNames one or more root names that is used as baseline for beginning the parsing, for example camelContext to start parsing
- * when Camel is discovered. Multiple names can be defined separated by comma
- * @param forceNamespace an optional namespace to force assign to each node. This may be needed for JAXB unmarshalling from XML -> POJO.
- * @return the DOM model
- * @throws Exception is thrown if error parsing
- */
- public static Document parseXml(final InputStream is, final String rootNames, final String forceNamespace) throws Exception {
- final Document doc;
- SAXParser parser;
- final SAXParserFactory factory = SAXParserFactory.newInstance();
- parser = factory.newSAXParser();
- final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- // turn off validator and loading external dtd
- dbf.setValidating(false);
- dbf.setNamespaceAware(true);
- dbf.setFeature("http://xml.org/sax/features/namespaces", false);
- dbf.setFeature("http://xml.org/sax/features/validation", false);
- dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
- dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
- dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
- dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
- final DocumentBuilder docBuilder = dbf.newDocumentBuilder();
- doc = docBuilder.newDocument();
-
- final Stack<Element> elementStack = new Stack<Element>();
- final StringBuilder textBuffer = new StringBuilder();
- final DefaultHandler handler = new DefaultHandler() {
- private Locator locator;
- private boolean found;
-
- @Override
- public void setDocumentLocator(final Locator locator) {
- this.locator = locator; // Save the locator, so that it can be used later for line tracking when traversing nodes.
- this.found = rootNames == null;
- }
-
- private boolean isRootName(String qName) {
- for (String root : rootNames.split(",")) {
- if (qName.equals(root)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException {
- addTextIfNeeded();
-
- if (rootNames != null && !found) {
- if (isRootName(qName)) {
- found = true;
- }
- }
-
- if (found) {
- Element el;
- if (forceNamespace != null) {
- el = doc.createElementNS(forceNamespace, qName);
- } else {
- el = doc.createElement(qName);
- }
-
- for (int i = 0; i < attributes.getLength(); i++) {
- el.setAttribute(attributes.getQName(i), attributes.getValue(i));
- }
-
- el.setUserData(LINE_NUMBER, String.valueOf(this.locator.getLineNumber()), null);
- el.setUserData(COLUMN_NUMBER, String.valueOf(this.locator.getColumnNumber()), null);
- elementStack.push(el);
- }
- }
-
- @Override
- public void endElement(final String uri, final String localName, final String qName) {
- if (!found) {
- return;
- }
-
- addTextIfNeeded();
-
- final Element closedEl = elementStack.isEmpty() ? null : elementStack.pop();
- if (closedEl != null) {
- if (elementStack.isEmpty()) {
- // Is this the root element?
- doc.appendChild(closedEl);
- } else {
- final Element parentEl = elementStack.peek();
- parentEl.appendChild(closedEl);
- }
-
- closedEl.setUserData(LINE_NUMBER_END, String.valueOf(this.locator.getLineNumber()), null);
- closedEl.setUserData(COLUMN_NUMBER_END, String.valueOf(this.locator.getColumnNumber()), null);
- }
- }
-
- @Override
- public void characters(final char ch[], final int start, final int length) throws SAXException {
- textBuffer.append(ch, start, length);
- }
-
- @Override
- public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException {
- // do not resolve external dtd
- return new InputSource(new StringReader(""));
- }
-
- // Outputs text accumulated under the current node
- private void addTextIfNeeded() {
- if (textBuffer.length() > 0) {
- final Element el = elementStack.isEmpty() ? null : elementStack.peek();
- if (el != null) {
- final Node textNode = doc.createTextNode(textBuffer.toString());
- el.appendChild(textNode);
- textBuffer.delete(0, textBuffer.length());
- }
- }
- }
- };
- parser.parse(is, handler);
-
- return doc;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
index 6e72821..67cbbde 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
@@ -19,20 +19,36 @@ package org.apache.camel.parser;
import java.io.InputStream;
import java.util.List;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelXmlHelper;
+import org.apache.camel.parser.helper.XmlLineNumberParser;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.apache.camel.parser.model.CamelSimpleDetails;
+import org.apache.camel.parser.model.CamelSimpleExpressionDetails;
import org.jboss.forge.roaster.model.util.Strings;
-import static org.apache.camel.parser.CamelXmlHelper.getSafeAttribute;
+import static org.apache.camel.parser.helper.CamelXmlHelper.getSafeAttribute;
+/**
+ * A Camel XML parser that parses Camel XML routes source code.
+ * <p/>
+ * This implementation is higher level details, and uses the lower level parser {@link CamelJavaParserHelper}.
+ */
public final class XmlRouteParser {
private XmlRouteParser() {
}
+ /**
+ * Parses the XML source to discover Camel endpoints.
+ *
+ * @param xml the xml file as input stream
+ * @param baseDir the base of the source code
+ * @param fullyQualifiedFileName the fully qualified source code file name
+ * @param endpoints list to add discovered and parsed endpoints
+ */
public static void parseXmlRouteEndpoints(InputStream xml, String baseDir, String fullyQualifiedFileName,
List<CamelEndpointDetails> endpoints) throws Exception {
@@ -87,8 +103,16 @@ public final class XmlRouteParser {
}
}
+ /**
+ * Parses the XML source to discover Camel endpoints.
+ *
+ * @param xml the xml file as input stream
+ * @param baseDir the base of the source code
+ * @param fullyQualifiedFileName the fully qualified source code file name
+ * @param simpleExpressions list to add discovered and parsed simple expressions
+ */
public static void parseXmlRouteSimpleExpressions(InputStream xml, String baseDir, String fullyQualifiedFileName,
- List<CamelSimpleDetails> simpleExpressions) throws Exception {
+ List<CamelSimpleExpressionDetails> simpleExpressions) throws Exception {
// find all the simple expressions
// try parse it as dom
@@ -111,7 +135,7 @@ public final class XmlRouteParser {
fileName = fileName.substring(baseDir.length() + 1);
}
- CamelSimpleDetails detail = new CamelSimpleDetails();
+ CamelSimpleExpressionDetails detail = new CamelSimpleExpressionDetails();
detail.setFileName(fileName);
detail.setLineNumber(lineNumber);
detail.setLineNumberEnd(lineNumberEnd);
[14/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
index 3b5350c..f096713 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
index e38a8fb..2449e39 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
index f8a7342..90e7ff9 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
index fefd805..0d92c2a 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
@@ -20,7 +20,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.apache.camel.parser.RouteBuilderParser;
import org.apache.camel.parser.model.CamelEndpointDetails;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
index 5ea3a0a..51a47b2 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
@@ -21,7 +21,7 @@ import java.io.File;
import java.io.FileReader;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
index 30225d4..63f3388 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
@@ -20,7 +20,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.apache.camel.parser.RouteBuilderParser;
import org.apache.camel.parser.model.CamelEndpointDetails;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
index e0c3eee..877a892 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
@@ -20,7 +20,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.apache.camel.parser.RouteBuilderParser;
import org.apache.camel.parser.model.CamelEndpointDetails;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
index 88ee8f2..03aea83 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
@@ -20,7 +20,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.apache.camel.parser.RouteBuilderParser;
import org.apache.camel.parser.model.CamelEndpointDetails;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
index 66aa612..f15dd0e 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
@@ -21,7 +21,7 @@ import java.io.InputStream;
import org.w3c.dom.Element;
-import org.apache.camel.parser.CamelXmlHelper;
+import org.apache.camel.parser.helper.CamelXmlHelper;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
[13/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: route parser for java and xml to parse source code. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/30daaeac
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/30daaeac
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/30daaeac
Branch: refs/heads/master
Commit: 30daaeacd25ad6d30c5529ea27b3571c87df3bca
Parents: 86cb392
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 12:24:34 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
.../camel/parser/CamelJavaParserHelper.java | 14 +++--
.../org/apache/camel/parser/CamelXmlHelper.java | 11 ++--
.../apache/camel/parser/RouteBuilderParser.java | 11 ++--
.../camel/parser/XmlLineNumberParser.java | 3 ++
.../org/apache/camel/parser/XmlRouteParser.java | 5 +-
.../parser/model/CamelEndpointDetails.java | 55 +++++++++++++-------
.../parser/java/MyBasePortRouteBuilder.java | 23 ++++----
.../parser/java/MyCdiConcatRouteBuilder.java | 23 ++++----
.../camel/parser/java/MyCdiRouteBuilder.java | 23 ++++----
.../parser/java/MyConcatFieldRouteBuilder.java | 23 ++++----
.../java/MyFieldMethodCallRouteBuilder.java | 23 ++++----
.../camel/parser/java/MyFieldRouteBuilder.java | 23 ++++----
.../parser/java/MyLocalAddRouteBuilderTest.java | 23 ++++----
.../parser/java/MyMethodCallRouteBuilder.java | 23 ++++----
.../apache/camel/parser/java/MyNettyTest.java | 23 ++++----
.../parser/java/MyNewLineConstRouteBuilder.java | 23 ++++----
.../parser/java/MyNewLineRouteBuilder.java | 23 ++++----
.../camel/parser/java/MyRouteBuilder.java | 23 ++++----
.../camel/parser/java/MyRouteEmptyUriTest.java | 23 ++++----
.../apache/camel/parser/java/MyRouteTest.java | 23 ++++----
.../camel/parser/java/MySimpleRouteBuilder.java | 23 ++++----
.../camel/parser/java/MySimpleToDRoute.java | 23 ++++----
.../camel/parser/java/MySimpleToFRoute.java | 23 ++++----
...asterCdiConcatRouteBuilderConfigureTest.java | 23 ++++----
.../RoasterCdiRouteBuilderConfigureTest.java | 23 ++++----
...terConcatFieldRouteBuilderConfigureTest.java | 23 ++++----
.../parser/java/RoasterEndpointInjectTest.java | 23 ++++----
.../RoasterFieldRouteBuilderConfigureTest.java | 23 ++++----
...sterMethodCallRouteBuilderConfigureTest.java | 23 ++++----
...ieldMethodCallRouteBuilderConfigureTest.java | 23 ++++----
.../java/RoasterMyLocalAddRouteBuilderTest.java | 23 ++++----
.../camel/parser/java/RoasterMyNettyTest.java | 23 ++++----
...erNewLineConstRouteBuilderConfigureTest.java | 23 ++++----
...RoasterNewLineRouteBuilderConfigureTest.java | 23 ++++----
...RoasterRouteBuilderCamelTestSupportTest.java | 23 ++++----
.../java/RoasterRouteBuilderConfigureTest.java | 23 ++++----
.../java/RoasterRouteBuilderEmptyUriTest.java | 23 ++++----
.../parser/java/RoasterSimpleProcessorTest.java | 23 ++++----
.../RoasterSimpleRouteBuilderConfigureTest.java | 23 ++++----
.../camel/parser/java/RoasterSimpleToDTest.java | 23 ++++----
.../camel/parser/java/RoasterSimpleToFTest.java | 23 ++++----
.../parser/java/RoasterSplitTokenizeTest.java | 23 ++++----
.../camel/parser/java/SimpleProcessorTest.java | 23 ++++----
.../camel/parser/java/SplitTokenizeTest.java | 23 ++++----
.../parser/xml/FindElementInRoutesTest.java | 3 +-
45 files changed, 524 insertions(+), 452 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
index 71d442d..ca37a7a 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
@@ -58,7 +58,11 @@ import org.jboss.forge.roaster.model.util.Strings;
* <p/>
* This implementation is lower level details. For a higher level parser see {@link RouteBuilderParser}.
*/
-public class CamelJavaParserHelper {
+public final class CamelJavaParserHelper {
+
+ private CamelJavaParserHelper() {
+ // utility class
+ }
public static MethodSource<JavaClassSource> findConfigureMethod(JavaClassSource clazz) {
MethodSource<JavaClassSource> method = clazz.getMethod("configure");
@@ -584,11 +588,11 @@ public class CamelJavaParserHelper {
// if numeric then we plus the values, otherwise we string concat
boolean numeric = isNumericOperator(clazz, block, ie.getLeftOperand()) && isNumericOperator(clazz, block, ie.getRightOperand());
if (numeric) {
- Long num1 = (val1 != null ? Long.valueOf(val1) : 0);
- Long num2 = (val2 != null ? Long.valueOf(val2) : 0);
+ Long num1 = val1 != null ? Long.valueOf(val1) : 0;
+ Long num2 = val2 != null ? Long.valueOf(val2) : 0;
answer = "" + (num1 + num2);
} else {
- answer = (val1 != null ? val1 : "") + (val2 != null ? val2 : "");
+ answer = val1 != null ? val1 : val2;
}
if (!answer.isEmpty()) {
@@ -598,7 +602,7 @@ public class CamelJavaParserHelper {
for (Object ext : extended) {
String val3 = getLiteralValue(clazz, block, (Expression) ext);
if (numeric) {
- Long num3 = (val3 != null ? Long.valueOf(val3) : 0);
+ Long num3 = val3 != null ? Long.valueOf(val3) : 0;
Long num = Long.valueOf(answer);
answer = "" + (num + num3);
} else {
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java
index b4a7848..3e81a3f 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java
@@ -22,14 +22,19 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.jboss.forge.roaster.model.util.Strings;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-public class CamelXmlHelper {
+import org.jboss.forge.roaster.model.util.Strings;
+
+public final class CamelXmlHelper {
+
+ private CamelXmlHelper() {
+ // utility class
+ }
public static String getSafeAttribute(Node node, String key) {
if (node != null) {
@@ -254,7 +259,7 @@ public class CamelXmlHelper {
}
private static boolean equal(Object a, Object b) {
- return a == b?true:a != null && b != null && a.equals(b);
+ return a == b ? true : a != null && b != null && a.equals(b);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
index b84888a..b2d806b 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,7 +40,10 @@ import org.jboss.forge.roaster.model.util.Strings;
* <p/>
* This implementation is higher level details, and uses the lower level parser {@link CamelJavaParserHelper}.
*/
-public class RouteBuilderParser {
+public final class RouteBuilderParser {
+
+ private RouteBuilderParser() {
+ }
public static void parseRouteBuilderEndpoints(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
List<CamelEndpointDetails> endpoints) {
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java
index c2fffce..f955409 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java
@@ -52,6 +52,9 @@ public final class XmlLineNumberParser {
public static final String LINE_NUMBER_END = "lineNumberEnd";
public static final String COLUMN_NUMBER_END = "colNumberEnd";
+ private XmlLineNumberParser() {
+ }
+
/**
* Parses the XML.
*
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
index 1b206cb..6e72821 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
@@ -28,7 +28,10 @@ import org.jboss.forge.roaster.model.util.Strings;
import static org.apache.camel.parser.CamelXmlHelper.getSafeAttribute;
-public class XmlRouteParser {
+public final class XmlRouteParser {
+
+ private XmlRouteParser() {
+ }
public static void parseXmlRouteEndpoints(InputStream xml, String baseDir, String fullyQualifiedFileName,
List<CamelEndpointDetails> endpoints) throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
index 2255c1d..9b03710 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
@@ -111,18 +111,33 @@ public class CamelEndpointDetails {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
CamelEndpointDetails that = (CamelEndpointDetails) o;
- if (!fileName.equals(that.fileName)) return false;
- if (lineNumber != null ? !lineNumber.equals(that.lineNumber) : that.lineNumber != null) return false;
- if (lineNumberEnd != null ? !lineNumberEnd.equals(that.lineNumberEnd) : that.lineNumberEnd != null) return false;
- if (!className.equals(that.className)) return false;
- if (methodName != null ? !methodName.equals(that.methodName) : that.methodName != null) return false;
- if (endpointInstance != null ? !endpointInstance.equals(that.endpointInstance) : that.endpointInstance != null)
+ if (!fileName.equals(that.fileName)) {
+ return false;
+ }
+ if (lineNumber != null ? !lineNumber.equals(that.lineNumber) : that.lineNumber != null) {
+ return false;
+ }
+ if (lineNumberEnd != null ? !lineNumberEnd.equals(that.lineNumberEnd) : that.lineNumberEnd != null) {
+ return false;
+ }
+ if (!className.equals(that.className)) {
+ return false;
+ }
+ if (methodName != null ? !methodName.equals(that.methodName) : that.methodName != null) {
+ return false;
+ }
+ if (endpointInstance != null ? !endpointInstance.equals(that.endpointInstance) : that.endpointInstance != null) {
return false;
+ }
return endpointUri.equals(that.endpointUri);
}
@@ -141,17 +156,17 @@ public class CamelEndpointDetails {
@Override
public String toString() {
- return "CamelEndpointDetails[" +
- "fileName='" + fileName + '\'' +
- ", lineNumber='" + lineNumber + '\'' +
- ", lineNumberEnd='" + lineNumberEnd + '\'' +
- ", className='" + className + '\'' +
- ", methodName='" + methodName + '\'' +
- ", endpointComponentName='" + endpointComponentName + '\'' +
- ", endpointInstance='" + endpointInstance + '\'' +
- ", endpointUri='" + endpointUri + '\'' +
- ", consumerOnly=" + consumerOnly +
- ", producerOnly=" + producerOnly +
- ']';
+ return "CamelEndpointDetails["
+ + "fileName='" + fileName + '\''
+ + ", lineNumber='" + lineNumber + '\''
+ + ", lineNumberEnd='" + lineNumberEnd + '\''
+ + ", className='" + className + '\''
+ + ", methodName='" + methodName + '\''
+ + ", endpointComponentName='" + endpointComponentName + '\''
+ + ", endpointInstance='" + endpointInstance + '\''
+ + ", endpointUri='" + endpointUri + '\''
+ + ", consumerOnly=" + consumerOnly
+ + ", producerOnly=" + producerOnly
+ + ']';
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
index 1a4336e..e5fb01c 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
index 1360d00..374ffb9 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
index 16261bb..2bf3e78 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
index 7fedeaf..4322689 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
index 5cdfa5d..2a13f19 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
index 7515c58..b56595b 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
index 0409d4b..4a8de07 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
index 2a56891..f54541f 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
index bf8f16b..4391576 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
index 95a0a4f..4701c2e 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
index 4b34945..8213244 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
index 5bc9803..9c44803 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
index 82732d2..12a797d 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
index 1a03847..a6c4923 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
index 490a575..85bbe14 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
index 105791f..2825070 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
index 89b3f0e..3e43655 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
index 90d0423..0bd7fb1 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
index 2c0677c..16e01da 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
- * <p/>
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
index a74d161..9cd8f11 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
index 5d54b7c..121605a 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
index d3c7e72..75c6781 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
index 18e589e..24cec20 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
index 2be99cf..a715ca3 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
index 523f906..4c80879 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
index a787671..99e288a 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
index c6c36e5..b6b8ca0 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
index 999bcfd..6e40043 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
index b9e902b..3b5350c 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
index 896b938..e38a8fb 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
index 4391365..f8a7342 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
index e0bcf99..fefd805 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
index 18e96dd..313cef5 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
http://git-wip-us.apache.org/repos/asf/camel/blob/30daaeac/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
index 1b46807..30225d4 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
@@ -1,17 +1,18 @@
/**
- * Copyright 2005-2015 Red Hat, Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.camel.parser.java;
[06/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSplitTokenizeTest.java
new file mode 100644
index 0000000..c12a5e3
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSplitTokenizeTest.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSplitTokenizeTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSplitTokenizeTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/SimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/SimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/SimpleProcessorTest.java
new file mode 100644
index 0000000..3c5f7b3
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/SimpleProcessorTest.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+public class SimpleProcessorTest extends CamelTestSupport {
+
+ public void testProcess() throws Exception {
+ String out = template.requestBody("direct:start", "Hello World", String.class);
+ assertEquals("Bye World", out);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ exchange.getOut().setBody("Bye World");
+ }
+ });
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/SplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/SplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/SplitTokenizeTest.java
new file mode 100644
index 0000000..251e531
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/SplitTokenizeTest.java
@@ -0,0 +1,125 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+public class SplitTokenizeTest extends CamelTestSupport {
+
+ public void testSplitTokenizerA() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("Claus", "James", "Willem");
+
+ template.sendBody("direct:a", "Claus,James,Willem");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerB() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("Claus", "James", "Willem");
+
+ template.sendBodyAndHeader("direct:b", "Hello World", "myHeader", "Claus,James,Willem");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerC() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("Claus", "James", "Willem");
+
+ template.sendBody("direct:c", "Claus James Willem");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerD() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("[Claus]", "[James]", "[Willem]");
+
+ template.sendBody("direct:d", "[Claus][James][Willem]");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerE() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("<person>Claus</person>", "<person>James</person>", "<person>Willem</person>");
+
+ String xml = "<persons><person>Claus</person><person>James</person><person>Willem</person></persons>";
+ template.sendBody("direct:e", xml);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerEWithSlash() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ String xml = "<persons><person attr='/' /></persons>";
+ mock.expectedBodiesReceived("<person attr='/' />");
+ template.sendBody("direct:e", xml);
+ mock.assertIsSatisfied();
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerF() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("<person name=\"Claus\"/>", "<person>James</person>", "<person>Willem</person>");
+
+ String xml = "<persons><person/><person name=\"Claus\"/><person>James</person><person>Willem</person></persons>";
+ template.sendBody("direct:f", xml);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ from("direct:a")
+ .split().tokenize(",")
+ .to("mock:split");
+
+ from("direct:b")
+ .split().tokenize(",", "myHeader")
+ .to("mock:split");
+
+ from("direct:c")
+ .split().tokenize("(\\W+)\\s*", null, true)
+ .to("mock:split");
+
+ from("direct:d")
+ .split().tokenizePair("[", "]", true)
+ .to("mock:split");
+
+ from("direct:e")
+ .split().tokenizeXML("person")
+ .to("mock:split");
+
+ from("direct:f")
+ .split().xpath("//person")
+ // To test the body is not empty
+ // it will call the ObjectHelper.evaluateValuePredicate()
+ .filter().simple("${body}")
+ .to("mock:split");
+
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/resources/log4j2.properties b/tooling/route-parser/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..2f66eb5
--- /dev/null
+++ b/tooling/route-parser/src/test/resources/log4j2.properties
@@ -0,0 +1,30 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/route-parser-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+logger.parser.name = org.apache.camel.parser
+logger.parser.level = DEBUG
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
[03/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: route parser for java and xml to parse source code. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c48c58ea
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c48c58ea
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c48c58ea
Branch: refs/heads/master
Commit: c48c58eaefc3b5c356423c8c816b254b7336aad8
Parents: b9e7ea8
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 12:44:15 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
.../main/java/org/apache/camel/parser/CamelJavaParserHelper.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/c48c58ea/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
index ca37a7a..5cd1e1c 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
@@ -592,7 +592,7 @@ public final class CamelJavaParserHelper {
Long num2 = val2 != null ? Long.valueOf(val2) : 0;
answer = "" + (num1 + num2);
} else {
- answer = val1 != null ? val1 : val2;
+ answer = (val1 != null ? val1 : "") + (val2 != null ? val2 : "");
}
if (!answer.isEmpty()) {
[02/25] camel git commit: CAMEL-10559: maven plugin to validate using
the route parser. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: maven plugin to validate using the route parser. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/68ddc37c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/68ddc37c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/68ddc37c
Branch: refs/heads/master
Commit: 68ddc37c0bf9653de7827ded01da9681a9754a33
Parents: 88ba906
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 13:45:55 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
tooling/maven/camel-maven-plugin/pom.xml | 34 +-
.../org/apache/camel/maven/ValidateMojo.java | 639 +++++++++++++++++++
.../camel/maven/helper/EndpointHelper.java | 105 +++
3 files changed, 777 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/68ddc37c/tooling/maven/camel-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-maven-plugin/pom.xml b/tooling/maven/camel-maven-plugin/pom.xml
index ec98c6b..fffc520 100644
--- a/tooling/maven/camel-maven-plugin/pom.xml
+++ b/tooling/maven/camel-maven-plugin/pom.xml
@@ -71,7 +71,39 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-cdi</artifactId>
</dependency>
-
+
+ <!-- camel-catalog -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-catalog</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-catalog-lucene</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-catalog-maven</artifactId>
+ </dependency>
+
+ <!-- camel route parser -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-route-parser</artifactId>
+ </dependency>
+
+ <!-- roaster java parser -->
+ <dependency>
+ <groupId>org.jboss.forge.roaster</groupId>
+ <artifactId>roaster-api</artifactId>
+ <version>${roaster-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.forge.roaster</groupId>
+ <artifactId>roaster-jdt</artifactId>
+ <version>${roaster-version}</version>
+ </dependency>
+
<!-- logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
http://git-wip-us.apache.org/repos/asf/camel/blob/68ddc37c/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
new file mode 100644
index 0000000..c5ed912
--- /dev/null
+++ b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
@@ -0,0 +1,639 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.catalog.EndpointValidationResult;
+import org.apache.camel.catalog.SimpleValidationResult;
+import org.apache.camel.catalog.lucene.LuceneSuggestionStrategy;
+import org.apache.camel.catalog.maven.MavenVersionManager;
+import org.apache.camel.maven.helper.EndpointHelper;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.XmlRouteParser;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.apache.camel.parser.model.CamelSimpleExpressionDetails;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.mojo.exec.AbstractExecMojo;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.JavaType;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+
+/**
+ * Parses the source code and validates the Camel routes has valid endpoint uris and simple expressions.
+ *
+ * @goal validate
+ * @requiresDependencyResolution compile+runtime
+ * @execute phase="process-test-classes"
+ */
+public class ValidateMojo extends AbstractExecMojo {
+
+ /**
+ * The maven project.
+ *
+ * @parameter property="project"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * Whether to fail if invalid Camel endpoints was found. By default the plugin logs the errors at WARN level
+ *
+ * @parameter property="camel.failOnError"
+ * default-value="false"
+ */
+ private boolean failOnError;
+
+ /**
+ * Whether to log endpoint URIs which was un-parsable and therefore not possible to validate
+ *
+ * @parameter property="camel.logUnparseable"
+ * default-value="false"
+ */
+ private boolean logUnparseable;
+
+ /**
+ * Whether to include Java files to be validated for invalid Camel endpoints
+ *
+ * @parameter property="camel.includeJava"
+ * default-value="true"
+ */
+ private boolean includeJava;
+
+ /**
+ * Whether to include XML files to be validated for invalid Camel endpoints
+ *
+ * @parameter property="camel.includeXml"
+ * default-value="true"
+ */
+ private boolean includeXml;
+
+ /**
+ * Whether to include test source code
+ *
+ * @parameter property="camel.includeTest"
+ * default-value="false"
+ */
+ private boolean includeTest;
+
+ /**
+ * To filter the names of java and xml files to only include files matching any of the given list of patterns (wildcard and regular expression).
+ * Multiple values can be separated by comma.
+ *
+ * @parameter property="camel.includes"
+ */
+ private String includes;
+
+ /**
+ * To filter the names of java and xml files to exclude files matching any of the given list of patterns (wildcard and regular expression).
+ * Multiple values can be separated by comma.
+ *
+ * @parameter property="camel.excludes"
+ */
+ private String excludes;
+
+ /**
+ * Whether to ignore unknown components
+ *
+ * @parameter property="camel.ignoreUnknownComponent"
+ * default-value="true"
+ */
+ private boolean ignoreUnknownComponent;
+
+ /**
+ * Whether to ignore incapable of parsing the endpoint uri
+ *
+ * @parameter property="camel.ignoreIncapable"
+ * default-value="true"
+ */
+ private boolean ignoreIncapable;
+
+ /**
+ * Whether to ignore components that uses lenient properties. When this is true, then the uri validation is stricter
+ * but would fail on properties that are not part of the component but in the uri because of using lenient properties.
+ * For example using the HTTP components to provide query parameters in the endpoint uri.
+ *
+ * @parameter property="camel.ignoreLenientProperties"
+ * default-value="true"
+ */
+ private boolean ignoreLenientProperties;
+
+ /**
+ * Whether to show all endpoints and simple expressions (both invalid and valid).
+ *
+ * @parameter property="camel.showAll"
+ * default-value="false"
+ */
+ private boolean showAll;
+
+ /**
+ * Whether to allow downloading Camel catalog version from the internet. This is needed if the project
+ * uses a different Camel version than this plugin is using by default.
+ *
+ * @parameter property="camel.downloadVersion"
+ * default-value="true"
+ */
+ private boolean downloadVersion;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ CamelCatalog catalog = new DefaultCamelCatalog();
+ // add activemq as known component
+ catalog.addComponent("activemq", "org.apache.activemq.camel.component.ActiveMQComponent");
+ // enable did you mean
+ catalog.setSuggestionStrategy(new LuceneSuggestionStrategy());
+ // enable loading other catalog versions dynamically
+ catalog.setVersionManager(new MavenVersionManager());
+ // enable caching
+ catalog.enableCache();
+
+ if (downloadVersion) {
+ String catalogVersion = catalog.getCatalogVersion();
+ String version = findCamelVersion(project);
+ if (version != null && !version.equals(catalogVersion)) {
+ // the project uses a different Camel version so attempt to load it
+ getLog().info("Downloading Camel version: " + version);
+ boolean loaded = catalog.loadVersion(version);
+ if (!loaded) {
+ getLog().warn("Error downloading Camel version: " + version);
+ }
+ }
+ }
+
+ // if using the same version as the fabric8-camel-maven-plugin we must still load it
+ if (catalog.getLoadedVersion() == null) {
+ catalog.loadVersion(catalog.getCatalogVersion());
+ }
+
+ if (catalog.getLoadedVersion() != null) {
+ getLog().info("Using Camel version: " + catalog.getLoadedVersion());
+ } else {
+ // force load version from the fabric8-camel-maven-plugin
+ getLog().info("Using Camel version: " + catalog.getCatalogVersion());
+ }
+
+ List<CamelEndpointDetails> endpoints = new ArrayList<>();
+ List<CamelSimpleExpressionDetails> simpleExpressions = new ArrayList<>();
+ Set<File> javaFiles = new LinkedHashSet<File>();
+ Set<File> xmlFiles = new LinkedHashSet<File>();
+
+ // find all java route builder classes
+ if (includeJava) {
+ List list = project.getCompileSourceRoots();
+ for (Object obj : list) {
+ String dir = (String) obj;
+ findJavaFiles(new File(dir), javaFiles);
+ }
+ if (includeTest) {
+ list = project.getTestCompileSourceRoots();
+ for (Object obj : list) {
+ String dir = (String) obj;
+ findJavaFiles(new File(dir), javaFiles);
+ }
+ }
+ }
+ // find all xml routes
+ if (includeXml) {
+ List list = project.getResources();
+ for (Object obj : list) {
+ Resource dir = (Resource) obj;
+ findXmlFiles(new File(dir.getDirectory()), xmlFiles);
+ }
+ if (includeTest) {
+ list = project.getTestResources();
+ for (Object obj : list) {
+ Resource dir = (Resource) obj;
+ findXmlFiles(new File(dir.getDirectory()), xmlFiles);
+ }
+ }
+ }
+
+ for (File file : javaFiles) {
+ if (matchFile(file)) {
+ try {
+ List<CamelEndpointDetails> fileEndpoints = new ArrayList<>();
+ List<CamelSimpleExpressionDetails> fileSimpleExpressions = new ArrayList<>();
+ List<String> unparsable = new ArrayList<>();
+
+ // parse the java source code and find Camel RouteBuilder classes
+ String fqn = file.getPath();
+ String baseDir = ".";
+ JavaType out = Roaster.parse(file);
+ // we should only parse java classes (not interfaces and enums etc)
+ if (out != null && out instanceof JavaClassSource) {
+ JavaClassSource clazz = (JavaClassSource) out;
+ RouteBuilderParser.parseRouteBuilderEndpoints(clazz, baseDir, fqn, fileEndpoints, unparsable, includeTest);
+ RouteBuilderParser.parseRouteBuilderSimpleExpressions(clazz, baseDir, fqn, fileSimpleExpressions);
+
+ // add what we found in this file to the total list
+ endpoints.addAll(fileEndpoints);
+ simpleExpressions.addAll(fileSimpleExpressions);
+
+ // was there any unparsable?
+ if (logUnparseable && !unparsable.isEmpty()) {
+ for (String uri : unparsable) {
+ getLog().warn("Cannot parse endpoint uri " + uri + " in java file " + file);
+ }
+ }
+ }
+ } catch (Exception e) {
+ getLog().warn("Error parsing java file " + file + " code due " + e.getMessage(), e);
+ }
+ }
+ }
+ for (File file : xmlFiles) {
+ if (matchFile(file)) {
+ try {
+ List<CamelEndpointDetails> fileEndpoints = new ArrayList<>();
+ List<CamelSimpleExpressionDetails> fileSimpleExpressions = new ArrayList<>();
+
+ // parse the xml source code and find Camel routes
+ String fqn = file.getPath();
+ String baseDir = ".";
+
+ InputStream is = new FileInputStream(file);
+ XmlRouteParser.parseXmlRouteEndpoints(is, baseDir, fqn, fileEndpoints);
+ is.close();
+ // need a new stream
+ is = new FileInputStream(file);
+ XmlRouteParser.parseXmlRouteSimpleExpressions(is, baseDir, fqn, fileSimpleExpressions);
+ is.close();
+
+ // add what we found in this file to the total list
+ endpoints.addAll(fileEndpoints);
+ simpleExpressions.addAll(fileSimpleExpressions);
+ } catch (Exception e) {
+ getLog().warn("Error parsing xml file " + file + " code due " + e.getMessage(), e);
+ }
+ }
+ }
+
+ int endpointErrors = 0;
+ int unknownComponents = 0;
+ int incapableErrors = 0;
+ for (CamelEndpointDetails detail : endpoints) {
+ EndpointValidationResult result = catalog.validateEndpointProperties(detail.getEndpointUri(), ignoreLenientProperties);
+
+ boolean ok = result.isSuccess();
+ if (!ok && ignoreUnknownComponent && result.getUnknownComponent() != null) {
+ // if we failed due unknown component then be okay if we should ignore that
+ unknownComponents++;
+ ok = true;
+ }
+ if (!ok && ignoreIncapable && result.getIncapable() != null) {
+ // if we failed due incapable then be okay if we should ignore that
+ incapableErrors++;
+ ok = true;
+ }
+ if (!ok) {
+ if (result.getUnknownComponent() != null) {
+ unknownComponents++;
+ } else if (result.getIncapable() != null) {
+ incapableErrors++;
+ } else {
+ endpointErrors++;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("Endpoint validation error at: ");
+ if (detail.getClassName() != null && detail.getLineNumber() != null) {
+ // this is from java code
+ sb.append(detail.getClassName());
+ if (detail.getMethodName() != null) {
+ sb.append(".").append(detail.getMethodName());
+ }
+ sb.append("(").append(asSimpleClassName(detail.getClassName())).append(".java:");
+ sb.append(detail.getLineNumber()).append(")");
+ } else if (detail.getLineNumber() != null) {
+ // this is from xml
+ String fqn = stripRootPath(asRelativeFile(detail.getFileName()));
+ if (fqn.endsWith(".xml")) {
+ fqn = fqn.substring(0, fqn.length() - 4);
+ fqn = asPackageName(fqn);
+ }
+ sb.append(fqn);
+ sb.append("(").append(asSimpleClassName(fqn)).append(".xml:");
+ sb.append(detail.getLineNumber()).append(")");
+ } else {
+ sb.append(detail.getFileName());
+ }
+ sb.append("\n\n");
+ String out = result.summaryErrorMessage(false);
+ sb.append(out);
+ sb.append("\n\n");
+
+ getLog().warn(sb.toString());
+ } else if (showAll) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Endpoint validation passsed at: ");
+ if (detail.getClassName() != null && detail.getLineNumber() != null) {
+ // this is from java code
+ sb.append(detail.getClassName());
+ if (detail.getMethodName() != null) {
+ sb.append(".").append(detail.getMethodName());
+ }
+ sb.append("(").append(asSimpleClassName(detail.getClassName())).append(".java:");
+ sb.append(detail.getLineNumber()).append(")");
+ } else if (detail.getLineNumber() != null) {
+ // this is from xml
+ String fqn = stripRootPath(asRelativeFile(detail.getFileName()));
+ if (fqn.endsWith(".xml")) {
+ fqn = fqn.substring(0, fqn.length() - 4);
+ fqn = asPackageName(fqn);
+ }
+ sb.append(fqn);
+ sb.append("(").append(asSimpleClassName(fqn)).append(".xml:");
+ sb.append(detail.getLineNumber()).append(")");
+ } else {
+ sb.append(detail.getFileName());
+ }
+ sb.append("\n");
+ sb.append("\n\t").append(result.getUri());
+ sb.append("\n\n");
+
+ getLog().info(sb.toString());
+ }
+ }
+ String endpointSummary;
+ if (endpointErrors == 0) {
+ int ok = endpoints.size() - endpointErrors - incapableErrors - unknownComponents;
+ endpointSummary = String.format("Endpoint validation success: (%s = passed, %s = invalid, %s = incapable, %s = unknown components)", ok, endpointErrors, incapableErrors, unknownComponents);
+ } else {
+ int ok = endpoints.size() - endpointErrors - incapableErrors - unknownComponents;
+ endpointSummary = String.format("Endpoint validation error: (%s = passed, %s = invalid, %s = incapable, %s = unknown components)", ok, endpointErrors, incapableErrors, unknownComponents);
+ }
+
+ if (endpointErrors > 0) {
+ getLog().warn(endpointSummary);
+ } else {
+ getLog().info(endpointSummary);
+ }
+
+ int simpleErrors = 0;
+ for (CamelSimpleExpressionDetails detail : simpleExpressions) {
+ SimpleValidationResult result = catalog.validateSimpleExpression(detail.getSimple());
+ if (!result.isSuccess()) {
+ simpleErrors++;
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("Simple validation error at: ");
+ if (detail.getClassName() != null && detail.getLineNumber() != null) {
+ // this is from java code
+ sb.append(detail.getClassName());
+ if (detail.getMethodName() != null) {
+ sb.append(".").append(detail.getMethodName());
+ }
+ sb.append("(").append(asSimpleClassName(detail.getClassName())).append(".java:");
+ sb.append(detail.getLineNumber()).append(")");
+ } else if (detail.getLineNumber() != null) {
+ // this is from xml
+ String fqn = stripRootPath(asRelativeFile(detail.getFileName()));
+ if (fqn.endsWith(".xml")) {
+ fqn = fqn.substring(0, fqn.length() - 4);
+ fqn = asPackageName(fqn);
+ }
+ sb.append(fqn);
+ sb.append("(").append(asSimpleClassName(fqn)).append(".xml:");
+ sb.append(detail.getLineNumber()).append(")");
+ } else {
+ sb.append(detail.getFileName());
+ }
+ sb.append("\n");
+ String[] lines = result.getError().split("\n");
+ for (String line : lines) {
+ sb.append("\n\t").append(line);
+ }
+ sb.append("\n");
+
+ getLog().warn(sb.toString());
+ } else if (showAll) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Simple validation passed at: ");
+ if (detail.getClassName() != null && detail.getLineNumber() != null) {
+ // this is from java code
+ sb.append(detail.getClassName());
+ if (detail.getMethodName() != null) {
+ sb.append(".").append(detail.getMethodName());
+ }
+ sb.append("(").append(asSimpleClassName(detail.getClassName())).append(".java:");
+ sb.append(detail.getLineNumber()).append(")");
+ } else if (detail.getLineNumber() != null) {
+ // this is from xml
+ String fqn = stripRootPath(asRelativeFile(detail.getFileName()));
+ if (fqn.endsWith(".xml")) {
+ fqn = fqn.substring(0, fqn.length() - 4);
+ fqn = asPackageName(fqn);
+ }
+ sb.append(fqn);
+ sb.append("(").append(asSimpleClassName(fqn)).append(".xml:");
+ sb.append(detail.getLineNumber()).append(")");
+ } else {
+ sb.append(detail.getFileName());
+ }
+ sb.append("\n");
+ sb.append("\n\t").append(result.getSimple());
+ sb.append("\n\n");
+
+ getLog().info(sb.toString());
+ }
+ }
+
+ String simpleSummary;
+ if (simpleErrors == 0) {
+ int ok = simpleExpressions.size() - simpleErrors;
+ simpleSummary = String.format("Simple validation success: (%s = passed, %s = invalid)", ok, simpleErrors);
+ } else {
+ int ok = simpleExpressions.size() - simpleErrors;
+ simpleSummary = String.format("Simple validation error: (%s = passed, %s = invalid)", ok, simpleErrors);
+ }
+
+ if (failOnError && (endpointErrors > 0 || simpleErrors > 0)) {
+ throw new MojoExecutionException(endpointSummary + "\n" + simpleSummary);
+ }
+
+ if (simpleErrors > 0) {
+ getLog().warn(simpleSummary);
+ } else {
+ getLog().info(simpleSummary);
+ }
+ }
+
+ private static String findCamelVersion(MavenProject project) {
+ Dependency candidate = null;
+
+ List list = project.getDependencies();
+ for (Object obj : list) {
+ Dependency dep = (Dependency) obj;
+ if ("org.apache.camel".equals(dep.getGroupId())) {
+ if ("camel-core".equals(dep.getArtifactId())) {
+ // favor camel-core
+ candidate = dep;
+ break;
+ } else {
+ candidate = dep;
+ }
+ }
+ }
+ if (candidate != null) {
+ return candidate.getVersion();
+ }
+
+ return null;
+ }
+
+ private void findJavaFiles(File dir, Set<File> javaFiles) {
+ File[] files = dir.isDirectory() ? dir.listFiles() : null;
+ if (files != null) {
+ for (File file : files) {
+ if (file.getName().endsWith(".java")) {
+ javaFiles.add(file);
+ } else if (file.isDirectory()) {
+ findJavaFiles(file, javaFiles);
+ }
+ }
+ }
+ }
+
+ private void findXmlFiles(File dir, Set<File> xmlFiles) {
+ File[] files = dir.isDirectory() ? dir.listFiles() : null;
+ if (files != null) {
+ for (File file : files) {
+ if (file.getName().endsWith(".xml")) {
+ xmlFiles.add(file);
+ } else if (file.isDirectory()) {
+ findXmlFiles(file, xmlFiles);
+ }
+ }
+ }
+ }
+
+ private boolean matchFile(File file) {
+ if (excludes == null && includes == null) {
+ return true;
+ }
+
+ // exclude take precedence
+ if (excludes != null) {
+ for (String exclude : excludes.split(",")) {
+ exclude = exclude.trim();
+ // try both with and without directory in the name
+ String fqn = stripRootPath(asRelativeFile(file.getAbsolutePath()));
+ boolean match = EndpointHelper.matchPattern(fqn, exclude) || EndpointHelper.matchPattern(file.getName(), exclude);
+ if (match) {
+ return false;
+ }
+ }
+ }
+
+ // include
+ if (includes != null) {
+ for (String include : includes.split(",")) {
+ include = include.trim();
+ // try both with and without directory in the name
+ String fqn = stripRootPath(asRelativeFile(file.getAbsolutePath()));
+ boolean match = EndpointHelper.matchPattern(fqn, include) || EndpointHelper.matchPattern(file.getName(), include);
+ if (match) {
+ return true;
+ }
+ }
+ // did not match any includes
+ return false;
+ }
+
+ // was not excluded nor failed include so its accepted
+ return true;
+ }
+
+ private String asRelativeFile(String name) {
+ String answer = name;
+
+ String base = project.getBasedir().getAbsolutePath();
+ if (name.startsWith(base)) {
+ answer = name.substring(base.length());
+ // skip leading slash for relative path
+ if (answer.startsWith(File.separator)) {
+ answer = answer.substring(1);
+ }
+ }
+ return answer;
+ }
+
+ private String stripRootPath(String name) {
+ // strip out any leading source / resource directory
+
+ List list = project.getCompileSourceRoots();
+ for (Object obj : list) {
+ String dir = (String) obj;
+ dir = asRelativeFile(dir);
+ if (name.startsWith(dir)) {
+ return name.substring(dir.length() + 1);
+ }
+ }
+ list = project.getTestCompileSourceRoots();
+ for (Object obj : list) {
+ String dir = (String) obj;
+ dir = asRelativeFile(dir);
+ if (name.startsWith(dir)) {
+ return name.substring(dir.length() + 1);
+ }
+ }
+ List resources = project.getResources();
+ for (Object obj : resources) {
+ Resource resource = (Resource) obj;
+ String dir = asRelativeFile(resource.getDirectory());
+ if (name.startsWith(dir)) {
+ return name.substring(dir.length() + 1);
+ }
+ }
+ resources = project.getTestResources();
+ for (Object obj : resources) {
+ Resource resource = (Resource) obj;
+ String dir = asRelativeFile(resource.getDirectory());
+ if (name.startsWith(dir)) {
+ return name.substring(dir.length() + 1);
+ }
+ }
+
+ return name;
+ }
+
+ private static String asPackageName(String name) {
+ return name.replace(File.separator, ".");
+ }
+
+ private static String asSimpleClassName(String className) {
+ int dot = className.lastIndexOf('.');
+ if (dot > 0) {
+ return className.substring(dot + 1);
+ } else {
+ return className;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/68ddc37c/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/helper/EndpointHelper.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/helper/EndpointHelper.java b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/helper/EndpointHelper.java
new file mode 100644
index 0000000..94bed8c
--- /dev/null
+++ b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/helper/EndpointHelper.java
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.helper;
+
+import java.util.regex.PatternSyntaxException;
+
+public final class EndpointHelper {
+
+ /**
+ * Matches the name with the given pattern.
+ * <p/>
+ * The match rules are applied in this order:
+ * <ul>
+ * <li>exact match, returns true</li>
+ * <li>wildcard match (pattern ends with a * and the name starts with the pattern), returns true</li>
+ * <li>regular expression match, returns true</li>
+ * <li>otherwise returns false</li>
+ * </ul>
+ *
+ * @param name the name
+ * @param pattern a pattern to match
+ * @return <tt>true</tt> if match, <tt>false</tt> otherwise.
+ */
+ public static boolean matchPattern(String name, String pattern) {
+ if (name == null || pattern == null) {
+ return false;
+ }
+
+ if (name.equals(pattern)) {
+ // exact match
+ return true;
+ }
+
+ if (matchWildcard(name, pattern)) {
+ return true;
+ }
+
+ if (matchRegex(name, pattern)) {
+ return true;
+ }
+
+ // no match
+ return false;
+ }
+
+ /**
+ * Matches the name with the given pattern.
+ * <p/>
+ * The match rules are applied in this order:
+ * <ul>
+ * <li>wildcard match (pattern ends with a * and the name starts with the pattern), returns true</li>
+ * <li>otherwise returns false</li>
+ * </ul>
+ *
+ * @param name the name
+ * @param pattern a pattern to match
+ * @return <tt>true</tt> if match, <tt>false</tt> otherwise.
+ */
+ private static boolean matchWildcard(String name, String pattern) {
+ // we have wildcard support in that hence you can match with: file* to match any file endpoints
+ if (pattern.endsWith("*") && name.startsWith(pattern.substring(0, pattern.length() - 1))) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Matches the name with the given pattern.
+ * <p/>
+ * The match rules are applied in this order:
+ * <ul>
+ * <li>regular expression match, returns true</li>
+ * <li>otherwise returns false</li>
+ * </ul>
+ *
+ * @param name the name
+ * @param pattern a pattern to match
+ * @return <tt>true</tt> if match, <tt>false</tt> otherwise.
+ */
+ private static boolean matchRegex(String name, String pattern) {
+ // match by regular expression
+ try {
+ if (name.matches(pattern)) {
+ return true;
+ }
+ } catch (PatternSyntaxException e) {
+ // ignore
+ }
+ return false;
+ }
+}
[10/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: route parser for java and xml to parse source code. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b9253664
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b9253664
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b9253664
Branch: refs/heads/master
Commit: b92536643941895ddc42272af41472a16902a020
Parents: 745f46f
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 12:01:35 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
tooling/route-parser/pom.xml | 2 +
.../camel/parser/MyBasePortRouteBuilder.java | 26 ----
.../camel/parser/MyCdiConcatRouteBuilder.java | 48 -------
.../apache/camel/parser/MyCdiRouteBuilder.java | 45 -------
.../camel/parser/MyConcatFieldRouteBuilder.java | 30 -----
.../parser/MyFieldMethodCallRouteBuilder.java | 32 -----
.../camel/parser/MyFieldRouteBuilder.java | 30 -----
.../parser/MyLocalAddRouteBuilderTest.java | 51 --------
.../camel/parser/MyMethodCallRouteBuilder.java | 32 -----
.../org/apache/camel/parser/MyNettyTest.java | 51 --------
.../parser/MyNewLineConstRouteBuilder.java | 33 -----
.../camel/parser/MyNewLineRouteBuilder.java | 30 -----
.../org/apache/camel/parser/MyRouteBuilder.java | 30 -----
.../camel/parser/MyRouteEmptyUriTest.java | 41 ------
.../org/apache/camel/parser/MyRouteTest.java | 39 ------
.../camel/parser/MySimpleRouteBuilder.java | 33 -----
.../apache/camel/parser/MySimpleToDRoute.java | 33 -----
.../apache/camel/parser/MySimpleToFRoute.java | 27 ----
...asterCdiConcatRouteBuilderConfigureTest.java | 52 --------
.../RoasterCdiRouteBuilderConfigureTest.java | 52 --------
...terConcatFieldRouteBuilderConfigureTest.java | 51 --------
.../camel/parser/RoasterEndpointInjectTest.java | 69 ----------
.../RoasterFieldRouteBuilderConfigureTest.java | 52 --------
...sterMethodCallRouteBuilderConfigureTest.java | 52 --------
...ieldMethodCallRouteBuilderConfigureTest.java | 54 --------
.../RoasterMyLocalAddRouteBuilderTest.java | 54 --------
.../apache/camel/parser/RoasterMyNettyTest.java | 54 --------
...erNewLineConstRouteBuilderConfigureTest.java | 52 --------
...RoasterNewLineRouteBuilderConfigureTest.java | 52 --------
...RoasterRouteBuilderCamelTestSupportTest.java | 51 --------
.../RoasterRouteBuilderConfigureTest.java | 53 --------
.../parser/RoasterRouteBuilderEmptyUriTest.java | 52 --------
.../parser/RoasterSimpleProcessorTest.java | 60 ---------
.../RoasterSimpleRouteBuilderConfigureTest.java | 68 ----------
.../camel/parser/RoasterSimpleToDTest.java | 69 ----------
.../camel/parser/RoasterSimpleToFTest.java | 63 ----------
.../camel/parser/RoasterSplitTokenizeTest.java | 71 -----------
.../camel/parser/SimpleProcessorTest.java | 44 -------
.../apache/camel/parser/SplitTokenizeTest.java | 125 -------------------
.../parser/java/MyBasePortRouteBuilder.java | 26 ++++
.../parser/java/MyCdiConcatRouteBuilder.java | 48 +++++++
.../camel/parser/java/MyCdiRouteBuilder.java | 45 +++++++
.../parser/java/MyConcatFieldRouteBuilder.java | 30 +++++
.../java/MyFieldMethodCallRouteBuilder.java | 32 +++++
.../camel/parser/java/MyFieldRouteBuilder.java | 30 +++++
.../parser/java/MyLocalAddRouteBuilderTest.java | 51 ++++++++
.../parser/java/MyMethodCallRouteBuilder.java | 32 +++++
.../apache/camel/parser/java/MyNettyTest.java | 51 ++++++++
.../parser/java/MyNewLineConstRouteBuilder.java | 33 +++++
.../parser/java/MyNewLineRouteBuilder.java | 30 +++++
.../camel/parser/java/MyRouteBuilder.java | 30 +++++
.../camel/parser/java/MyRouteEmptyUriTest.java | 41 ++++++
.../apache/camel/parser/java/MyRouteTest.java | 39 ++++++
.../camel/parser/java/MySimpleRouteBuilder.java | 33 +++++
.../camel/parser/java/MySimpleToDRoute.java | 33 +++++
.../camel/parser/java/MySimpleToFRoute.java | 27 ++++
...asterCdiConcatRouteBuilderConfigureTest.java | 54 ++++++++
.../RoasterCdiRouteBuilderConfigureTest.java | 54 ++++++++
...terConcatFieldRouteBuilderConfigureTest.java | 53 ++++++++
.../parser/java/RoasterEndpointInjectTest.java | 72 +++++++++++
.../RoasterFieldRouteBuilderConfigureTest.java | 54 ++++++++
...sterMethodCallRouteBuilderConfigureTest.java | 54 ++++++++
...ieldMethodCallRouteBuilderConfigureTest.java | 56 +++++++++
.../java/RoasterMyLocalAddRouteBuilderTest.java | 56 +++++++++
.../camel/parser/java/RoasterMyNettyTest.java | 56 +++++++++
...erNewLineConstRouteBuilderConfigureTest.java | 54 ++++++++
...RoasterNewLineRouteBuilderConfigureTest.java | 54 ++++++++
...RoasterRouteBuilderCamelTestSupportTest.java | 53 ++++++++
.../java/RoasterRouteBuilderConfigureTest.java | 55 ++++++++
.../java/RoasterRouteBuilderEmptyUriTest.java | 54 ++++++++
.../parser/java/RoasterSimpleProcessorTest.java | 63 ++++++++++
.../RoasterSimpleRouteBuilderConfigureTest.java | 70 +++++++++++
.../camel/parser/java/RoasterSimpleToDTest.java | 72 +++++++++++
.../camel/parser/java/RoasterSimpleToFTest.java | 66 ++++++++++
.../parser/java/RoasterSplitTokenizeTest.java | 74 +++++++++++
.../camel/parser/java/SimpleProcessorTest.java | 44 +++++++
.../camel/parser/java/SplitTokenizeTest.java | 125 +++++++++++++++++++
77 files changed, 1906 insertions(+), 1861 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/pom.xml b/tooling/route-parser/pom.xml
index b374453..7d038dd 100644
--- a/tooling/route-parser/pom.xml
+++ b/tooling/route-parser/pom.xml
@@ -35,10 +35,12 @@
<dependencies>
+ <!-- the roaster-jdt is set as provided as different runtimes may have it out of the box -->
<dependency>
<groupId>org.jboss.forge.roaster</groupId>
<artifactId>roaster-jdt</artifactId>
<version>${roaster-version}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyBasePortRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyBasePortRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyBasePortRouteBuilder.java
deleted file mode 100644
index 1aa0f7c..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyBasePortRouteBuilder.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public abstract class MyBasePortRouteBuilder extends RouteBuilder {
-
- public int getNextPort() {
- return 8080;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiConcatRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiConcatRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiConcatRouteBuilder.java
deleted file mode 100644
index 9a44d71..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiConcatRouteBuilder.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.Uri;
-
-public class MyCdiConcatRouteBuilder extends RouteBuilder {
-
- private static final int DELAY = 4999;
- private static final int PORT = 80;
-
- @Inject
- @Uri("timer:foo?period=" + DELAY)
- private Endpoint inputEndpoint;
-
- @Inject
- @Uri("log:a")
- private Endpoint loga;
-
- @EndpointInject(uri = "netty4-http:http:someserver:" + PORT + "/hello")
- private Endpoint mynetty;
-
- @Override
- public void configure() throws Exception {
- from(inputEndpoint)
- .log("I was here")
- .to(loga)
- .to(mynetty);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java
deleted file mode 100644
index 480d7f1..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.Uri;
-
-public class MyCdiRouteBuilder extends RouteBuilder {
-
- @Inject
- @Uri("timer:foo?period=4999")
- private Endpoint inputEndpoint;
-
- @Inject
- @Uri("log:a")
- private Endpoint loga;
-
- @Inject
- @Uri("netty4-http:http:someserver:80/hello")
- private Endpoint mynetty;
-
- @Override
- public void configure() throws Exception {
- from(inputEndpoint)
- .log("I was here")
- .to(loga)
- .to(mynetty);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyConcatFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyConcatFieldRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyConcatFieldRouteBuilder.java
deleted file mode 100644
index 781a471..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyConcatFieldRouteBuilder.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyConcatFieldRouteBuilder extends RouteBuilder {
-
- private int ftpPort;
- private String ftp = "ftp:localhost:" + ftpPort + "/myapp?password=admin&username=admin";
-
- @Override
- public void configure() throws Exception {
- from(ftp)
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldMethodCallRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldMethodCallRouteBuilder.java
deleted file mode 100644
index 0b21b17..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldMethodCallRouteBuilder.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-public class MyFieldMethodCallRouteBuilder extends MyBasePortRouteBuilder {
-
- @Override
- public void configure() throws Exception {
- int port2 = getNextPort();
-
- from("netty-http:http://0.0.0.0:{{port}}/foo")
- .to("mock:input1")
- .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
- from("netty-http:http://0.0.0.0:" + port2 + "/bar")
- .to("mock:input2")
- .transform().constant("Bye World");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldRouteBuilder.java
deleted file mode 100644
index 7e3c21c..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldRouteBuilder.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyFieldRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- String exists = "Override";
-
- from("timer:foo")
- .toD("file:output?fileExist=" + exists)
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyLocalAddRouteBuilderTest.java
deleted file mode 100644
index 072a60b..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyLocalAddRouteBuilderTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
-
-@Ignore
-public class MyLocalAddRouteBuilderTest extends CamelTestSupport {
-
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- @Test
- public void testFoo() throws Exception {
- log.info("Adding a route locally");
-
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start")
- .to("mock:foo");
- }
- });
- context.start();
-
- getMockEndpoint("mock:foo").expectedMessageCount(1);
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyMethodCallRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyMethodCallRouteBuilder.java
deleted file mode 100644
index cfa900d..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyMethodCallRouteBuilder.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyMethodCallRouteBuilder extends RouteBuilder {
-
- private String whatToDoWhenExists() {
- return "Override";
- }
-
- @Override
- public void configure() throws Exception {
- from("timer:foo")
- .to("file:output?fileExist=" + whatToDoWhenExists())
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNettyTest.java
deleted file mode 100644
index af56cc1..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNettyTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
-
-@Ignore
-public class MyNettyTest extends CamelTestSupport {
-
- public int getNextPort() {
- return 8080;
- }
-
- @Test
- public void testFoo() throws Exception {
- // noop
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- int port2 = getNextPort();
-
- @Override
- public void configure() throws Exception {
- from("netty-http:http://0.0.0.0:{{port}}/foo")
- .to("mock:input1")
- .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
- from("netty-http:http://0.0.0.0:" + port2 + "/bar")
- .to("mock:input2")
- .transform().constant("Bye World");
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineConstRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineConstRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineConstRouteBuilder.java
deleted file mode 100644
index c7a4628..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineConstRouteBuilder.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyNewLineConstRouteBuilder extends RouteBuilder {
-
- private static final String EXISTS = "Append";
- private static final int MOD = 770;
-
- @Override
- public void configure() throws Exception {
- from("timer:foo")
- .toD("file:output?fileExist=" + EXISTS
- + "&chmod=" + (MOD + 6 + 1)
- + "&allowNullBody=true")
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineRouteBuilder.java
deleted file mode 100644
index 6eeff01..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineRouteBuilder.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyNewLineRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- from("timer:foo")
- .toD("file:output?fileExist=Append"
- + "&chmod=777"
- + "&allowNullBody=true")
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteBuilder.java
deleted file mode 100644
index a8d5dfdc..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteBuilder.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- from("timer:foo")
- .log("I was here")
- .toD("log:a")
- .wireTap("mock:tap")
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteEmptyUriTest.java
deleted file mode 100644
index 1a1cfa4..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteEmptyUriTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
-
-@Ignore
-public class MyRouteEmptyUriTest extends CamelTestSupport {
-
- @Test
- public void testFoo() throws Exception {
- // noop
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:foo")
- .to(""); // is empty on purpose
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteTest.java
deleted file mode 100644
index 0647945..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class MyRouteTest extends CamelTestSupport {
-
- @Test
- public void testFoo() throws Exception {
- // noop
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:foo")
- .to("mock:foo");
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleRouteBuilder.java
deleted file mode 100644
index cfd6bd1..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleRouteBuilder.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MySimpleRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- from("timer:foo")
- .filter(simple("${body} > 100"))
- .toD("log:a")
- .end()
- .filter().simple("${body} > 200")
- .to("log:b")
- .end()
- .to("log:c");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToDRoute.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToDRoute.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToDRoute.java
deleted file mode 100644
index bafce03..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToDRoute.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.builder.RouteBuilder;
-
-public class MySimpleToDRoute extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
-
- String uri = "log:c";
-
- from("direct:start")
- .toD("log:a", true)
- .to(ExchangePattern.InOnly, "log:b")
- .to(uri);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToFRoute.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToFRoute.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToFRoute.java
deleted file mode 100644
index 7180161..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToFRoute.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MySimpleToFRoute extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- from("direct:start")
- .toF("log:a?level=%s", "info");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiConcatRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiConcatRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiConcatRouteBuilderConfigureTest.java
deleted file mode 100644
index a1c3e54..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiConcatRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterCdiConcatRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterCdiConcatRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiRouteBuilderConfigureTest.java
deleted file mode 100644
index 3ced7bc..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- * <p/>
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterCdiRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterCdiRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterConcatFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterConcatFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterConcatFieldRouteBuilderConfigureTest.java
deleted file mode 100644
index 2f376e2..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterConcatFieldRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterConcatFieldRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterConcatFieldRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterEndpointInjectTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterEndpointInjectTest.java
deleted file mode 100644
index a61a95a..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterEndpointInjectTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterEndpointInjectTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterEndpointInjectTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java"));
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
-
- List<CamelEndpointDetails> details = new ArrayList<>();
- RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java", details);
- LOG.info("{}", details);
-
- Assert.assertEquals("timer:foo?period=4999", details.get(0).getEndpointUri());
- Assert.assertEquals("27", details.get(0).getLineNumber());
-
- Assert.assertEquals("log:a", details.get(1).getEndpointUri());
- Assert.assertEquals("31", details.get(1).getLineNumber());
-
- Assert.assertEquals("netty4-http:http:someserver:80/hello", details.get(2).getEndpointUri());
- Assert.assertEquals("35", details.get(2).getLineNumber());
-
- 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(2, list.size());
-
- Assert.assertEquals(5, details.size());
- Assert.assertEquals("log:a", details.get(3).getEndpointUri());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterFieldRouteBuilderConfigureTest.java
deleted file mode 100644
index 39d8944..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterFieldRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterFieldRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterFieldRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyFieldRouteBuilder.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", list.get(0).getElement());
-
- list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Producer: " + result.getElement());
- }
- Assert.assertEquals("file:output?fileExist=Override", list.get(0).getElement());
- Assert.assertEquals("log:b", list.get(1).getElement());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMethodCallRouteBuilderConfigureTest.java
deleted file mode 100644
index 09bf2b7..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMethodCallRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterMethodCallRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterMethodCallRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyMethodCallRouteBuilder.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", list.get(0).getElement());
-
- list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Producer: " + result.getElement());
- }
- Assert.assertEquals("file:output?fileExist={{whatToDoWhenExists}}", list.get(0).getElement());
- Assert.assertEquals("log:b", list.get(1).getElement());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
deleted file mode 100644
index 9cfe117..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterMyFieldMethodCallRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterMyFieldMethodCallRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyFieldMethodCallRouteBuilder.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("netty-http:http://0.0.0.0:{{port}}/foo", list.get(0).getElement());
- Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
-
- list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Producer: " + result.getElement());
- }
- Assert.assertEquals("mock:input1", list.get(0).getElement());
- Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
- Assert.assertEquals("mock:input2", list.get(2).getElement());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyLocalAddRouteBuilderTest.java
deleted file mode 100644
index 44c1189..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyLocalAddRouteBuilderTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterMyLocalAddRouteBuilderTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterMyLocalAddRouteBuilderTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyLocalAddRouteBuilderTest.java"));
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
- Assert.assertNull(method);
-
- List<MethodSource<JavaClassSource>> methods = CamelJavaParserHelper.findInlinedConfigureMethods(clazz);
- Assert.assertEquals(1, methods.size());
- method = methods.get(0);
-
- List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Consumer: " + result.getElement());
- }
-
- list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Producer: " + result.getElement());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyNettyTest.java
deleted file mode 100644
index cf48862..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyNettyTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterMyNettyTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterMyNettyTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyNettyTest.java"));
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
-
- List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Consumer: " + result.getElement());
- }
- Assert.assertEquals("netty-http:http://0.0.0.0:{{port}}/foo", list.get(0).getElement());
- Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
-
- list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Producer: " + result.getElement());
- }
- Assert.assertEquals("mock:input1", list.get(0).getElement());
- Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
- Assert.assertEquals("mock:input2", list.get(2).getElement());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineConstRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineConstRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineConstRouteBuilderConfigureTest.java
deleted file mode 100644
index c2dbb0e..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineConstRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterNewLineConstRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterNewLineConstRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineRouteBuilderConfigureTest.java
deleted file mode 100644
index ad3493b..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterNewLineRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterNewLineRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyNewLineRouteBuilder.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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderCamelTestSupportTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderCamelTestSupportTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderCamelTestSupportTest.java
deleted file mode 100644
index e74a5be..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderCamelTestSupportTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterRouteBuilderCamelTestSupportTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderCamelTestSupportTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderConfigureTest.java
deleted file mode 100644
index a5ab68a..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderEmptyUriTest.java
deleted file mode 100644
index 11b272b..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderEmptyUriTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterRouteBuilderEmptyUriTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderEmptyUriTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleProcessorTest.java
deleted file mode 100644
index 06f686a..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleProcessorTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterSimpleProcessorTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleProcessorTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/SimpleProcessorTest.java"));
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
-
- List<CamelEndpointDetails> details = new ArrayList<CamelEndpointDetails>();
- RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleRouteBuilderConfigureTest.java
deleted file mode 100644
index 38d1211..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.List;
-
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterSimpleRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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(26, findLineNumber(list.get(0).getPosition()));
- Assert.assertEquals("${body} > 200", list.get(1).getElement());
- Assert.assertEquals(29, findLineNumber(list.get(1).getPosition()));
- }
-
- public static int findLineNumber(int pos) throws Exception {
- int lines = 0;
- int current = 0;
- File file = new File("src/test/java/org/apache/camel/parser/MySimpleRouteBuilder.java");
- try (BufferedReader br = new BufferedReader(new FileReader(file))) {
- String line;
- while ((line = br.readLine()) != null) {
- lines++;
- current += line.length();
- if (current > pos) {
- return lines;
- }
- }
- }
- return -1;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToDTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToDTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToDTest.java
deleted file mode 100644
index 70a064a..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToDTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterSimpleToDTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleToDTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MySimpleToDRoute.java"));
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
-
- List<CamelEndpointDetails> details = new ArrayList<>();
- RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/MySimpleToDRoute.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("toD", list.get(0).getNode());
- Assert.assertEquals("log:a", list.get(0).getElement());
- Assert.assertEquals("to", list.get(1).getNode());
- Assert.assertEquals("log:b", list.get(1).getElement());
- Assert.assertEquals("to", list.get(2).getNode());
- Assert.assertEquals("log:c", list.get(2).getElement());
- Assert.assertEquals(3, list.size());
-
- Assert.assertEquals(4, details.size());
- Assert.assertEquals("direct:start", details.get(0).getEndpointUri());
- Assert.assertEquals("log:a", details.get(1).getEndpointUri());
- Assert.assertEquals("log:b", details.get(2).getEndpointUri());
- Assert.assertEquals("log:c", details.get(3).getEndpointUri());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b9253664/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToFTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToFTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToFTest.java
deleted file mode 100644
index 84eb77e..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToFTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Copyright 2005-2015 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.apache.camel.parser;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterSimpleToFTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleToFTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MySimpleToFRoute.java"));
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
-
- List<CamelEndpointDetails> details = new ArrayList<>();
- RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/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());
- }
-
-}
[07/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: route parser for java and xml to parse source code. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/745f46fd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/745f46fd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/745f46fd
Branch: refs/heads/master
Commit: 745f46fda1447ec5939767471f4ebeda2804d9e8
Parents: 42e4d97
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 11:58:46 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
tooling/route-parser/pom.xml | 58 ++++++++-
.../camel/parser/MyBasePortRouteBuilder.java | 26 ++++
.../camel/parser/MyCdiConcatRouteBuilder.java | 48 +++++++
.../apache/camel/parser/MyCdiRouteBuilder.java | 45 +++++++
.../camel/parser/MyConcatFieldRouteBuilder.java | 30 +++++
.../parser/MyFieldMethodCallRouteBuilder.java | 32 +++++
.../camel/parser/MyFieldRouteBuilder.java | 30 +++++
.../parser/MyLocalAddRouteBuilderTest.java | 51 ++++++++
.../camel/parser/MyMethodCallRouteBuilder.java | 32 +++++
.../org/apache/camel/parser/MyNettyTest.java | 51 ++++++++
.../parser/MyNewLineConstRouteBuilder.java | 33 +++++
.../camel/parser/MyNewLineRouteBuilder.java | 30 +++++
.../org/apache/camel/parser/MyRouteBuilder.java | 30 +++++
.../camel/parser/MyRouteEmptyUriTest.java | 41 ++++++
.../org/apache/camel/parser/MyRouteTest.java | 39 ++++++
.../camel/parser/MySimpleRouteBuilder.java | 33 +++++
.../apache/camel/parser/MySimpleToDRoute.java | 33 +++++
.../apache/camel/parser/MySimpleToFRoute.java | 27 ++++
...asterCdiConcatRouteBuilderConfigureTest.java | 52 ++++++++
.../RoasterCdiRouteBuilderConfigureTest.java | 52 ++++++++
...terConcatFieldRouteBuilderConfigureTest.java | 51 ++++++++
.../camel/parser/RoasterEndpointInjectTest.java | 69 ++++++++++
.../RoasterFieldRouteBuilderConfigureTest.java | 52 ++++++++
...sterMethodCallRouteBuilderConfigureTest.java | 52 ++++++++
...ieldMethodCallRouteBuilderConfigureTest.java | 54 ++++++++
.../RoasterMyLocalAddRouteBuilderTest.java | 54 ++++++++
.../apache/camel/parser/RoasterMyNettyTest.java | 54 ++++++++
...erNewLineConstRouteBuilderConfigureTest.java | 52 ++++++++
...RoasterNewLineRouteBuilderConfigureTest.java | 52 ++++++++
...RoasterRouteBuilderCamelTestSupportTest.java | 51 ++++++++
.../RoasterRouteBuilderConfigureTest.java | 53 ++++++++
.../parser/RoasterRouteBuilderEmptyUriTest.java | 52 ++++++++
.../parser/RoasterSimpleProcessorTest.java | 60 +++++++++
.../RoasterSimpleRouteBuilderConfigureTest.java | 68 ++++++++++
.../camel/parser/RoasterSimpleToDTest.java | 69 ++++++++++
.../camel/parser/RoasterSimpleToFTest.java | 63 ++++++++++
.../camel/parser/RoasterSplitTokenizeTest.java | 71 +++++++++++
.../camel/parser/SimpleProcessorTest.java | 44 +++++++
.../apache/camel/parser/SplitTokenizeTest.java | 125 +++++++++++++++++++
.../src/test/resources/log4j2.properties | 30 +++++
40 files changed, 1948 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/pom.xml b/tooling/route-parser/pom.xml
index b6f51a0..b374453 100644
--- a/tooling/route-parser/pom.xml
+++ b/tooling/route-parser/pom.xml
@@ -15,7 +15,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -33,11 +34,66 @@
</properties>
<dependencies>
+
<dependency>
<groupId>org.jboss.forge.roaster</groupId>
<artifactId>roaster-jdt</artifactId>
<version>${roaster-version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cdi</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-cdi</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyBasePortRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyBasePortRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyBasePortRouteBuilder.java
new file mode 100644
index 0000000..1aa0f7c
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyBasePortRouteBuilder.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public abstract class MyBasePortRouteBuilder extends RouteBuilder {
+
+ public int getNextPort() {
+ return 8080;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiConcatRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiConcatRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiConcatRouteBuilder.java
new file mode 100644
index 0000000..9a44d71
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiConcatRouteBuilder.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.Uri;
+
+public class MyCdiConcatRouteBuilder extends RouteBuilder {
+
+ private static final int DELAY = 4999;
+ private static final int PORT = 80;
+
+ @Inject
+ @Uri("timer:foo?period=" + DELAY)
+ private Endpoint inputEndpoint;
+
+ @Inject
+ @Uri("log:a")
+ private Endpoint loga;
+
+ @EndpointInject(uri = "netty4-http:http:someserver:" + PORT + "/hello")
+ private Endpoint mynetty;
+
+ @Override
+ public void configure() throws Exception {
+ from(inputEndpoint)
+ .log("I was here")
+ .to(loga)
+ .to(mynetty);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java
new file mode 100644
index 0000000..480d7f1
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.Uri;
+
+public class MyCdiRouteBuilder extends RouteBuilder {
+
+ @Inject
+ @Uri("timer:foo?period=4999")
+ private Endpoint inputEndpoint;
+
+ @Inject
+ @Uri("log:a")
+ private Endpoint loga;
+
+ @Inject
+ @Uri("netty4-http:http:someserver:80/hello")
+ private Endpoint mynetty;
+
+ @Override
+ public void configure() throws Exception {
+ from(inputEndpoint)
+ .log("I was here")
+ .to(loga)
+ .to(mynetty);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyConcatFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyConcatFieldRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyConcatFieldRouteBuilder.java
new file mode 100644
index 0000000..781a471
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyConcatFieldRouteBuilder.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyConcatFieldRouteBuilder extends RouteBuilder {
+
+ private int ftpPort;
+ private String ftp = "ftp:localhost:" + ftpPort + "/myapp?password=admin&username=admin";
+
+ @Override
+ public void configure() throws Exception {
+ from(ftp)
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldMethodCallRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldMethodCallRouteBuilder.java
new file mode 100644
index 0000000..0b21b17
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldMethodCallRouteBuilder.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+public class MyFieldMethodCallRouteBuilder extends MyBasePortRouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ int port2 = getNextPort();
+
+ from("netty-http:http://0.0.0.0:{{port}}/foo")
+ .to("mock:input1")
+ .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
+ from("netty-http:http://0.0.0.0:" + port2 + "/bar")
+ .to("mock:input2")
+ .transform().constant("Bye World");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldRouteBuilder.java
new file mode 100644
index 0000000..7e3c21c
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyFieldRouteBuilder.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyFieldRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ String exists = "Override";
+
+ from("timer:foo")
+ .toD("file:output?fileExist=" + exists)
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyLocalAddRouteBuilderTest.java
new file mode 100644
index 0000000..072a60b
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyLocalAddRouteBuilderTest.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class MyLocalAddRouteBuilderTest extends CamelTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Test
+ public void testFoo() throws Exception {
+ log.info("Adding a route locally");
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("mock:foo");
+ }
+ });
+ context.start();
+
+ getMockEndpoint("mock:foo").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyMethodCallRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyMethodCallRouteBuilder.java
new file mode 100644
index 0000000..cfa900d
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyMethodCallRouteBuilder.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyMethodCallRouteBuilder extends RouteBuilder {
+
+ private String whatToDoWhenExists() {
+ return "Override";
+ }
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .to("file:output?fileExist=" + whatToDoWhenExists())
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNettyTest.java
new file mode 100644
index 0000000..af56cc1
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNettyTest.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class MyNettyTest extends CamelTestSupport {
+
+ public int getNextPort() {
+ return 8080;
+ }
+
+ @Test
+ public void testFoo() throws Exception {
+ // noop
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ int port2 = getNextPort();
+
+ @Override
+ public void configure() throws Exception {
+ from("netty-http:http://0.0.0.0:{{port}}/foo")
+ .to("mock:input1")
+ .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
+ from("netty-http:http://0.0.0.0:" + port2 + "/bar")
+ .to("mock:input2")
+ .transform().constant("Bye World");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineConstRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineConstRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineConstRouteBuilder.java
new file mode 100644
index 0000000..c7a4628
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineConstRouteBuilder.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyNewLineConstRouteBuilder extends RouteBuilder {
+
+ private static final String EXISTS = "Append";
+ private static final int MOD = 770;
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .toD("file:output?fileExist=" + EXISTS
+ + "&chmod=" + (MOD + 6 + 1)
+ + "&allowNullBody=true")
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineRouteBuilder.java
new file mode 100644
index 0000000..6eeff01
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyNewLineRouteBuilder.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyNewLineRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .toD("file:output?fileExist=Append"
+ + "&chmod=777"
+ + "&allowNullBody=true")
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteBuilder.java
new file mode 100644
index 0000000..a8d5dfdc
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteBuilder.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .log("I was here")
+ .toD("log:a")
+ .wireTap("mock:tap")
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteEmptyUriTest.java
new file mode 100644
index 0000000..1a1cfa4
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteEmptyUriTest.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class MyRouteEmptyUriTest extends CamelTestSupport {
+
+ @Test
+ public void testFoo() throws Exception {
+ // noop
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:foo")
+ .to(""); // is empty on purpose
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteTest.java
new file mode 100644
index 0000000..0647945
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MyRouteTest.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class MyRouteTest extends CamelTestSupport {
+
+ @Test
+ public void testFoo() throws Exception {
+ // noop
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:foo")
+ .to("mock:foo");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleRouteBuilder.java
new file mode 100644
index 0000000..cfd6bd1
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleRouteBuilder.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MySimpleRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .filter(simple("${body} > 100"))
+ .toD("log:a")
+ .end()
+ .filter().simple("${body} > 200")
+ .to("log:b")
+ .end()
+ .to("log:c");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToDRoute.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToDRoute.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToDRoute.java
new file mode 100644
index 0000000..bafce03
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToDRoute.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.builder.RouteBuilder;
+
+public class MySimpleToDRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+
+ String uri = "log:c";
+
+ from("direct:start")
+ .toD("log:a", true)
+ .to(ExchangePattern.InOnly, "log:b")
+ .to(uri);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToFRoute.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToFRoute.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToFRoute.java
new file mode 100644
index 0000000..7180161
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/MySimpleToFRoute.java
@@ -0,0 +1,27 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MySimpleToFRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .toF("log:a?level=%s", "info");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiConcatRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiConcatRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiConcatRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..a1c3e54
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiConcatRouteBuilderConfigureTest.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterCdiConcatRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterCdiConcatRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..3ced7bc
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterCdiRouteBuilderConfigureTest.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ * <p/>
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterCdiRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterCdiRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterConcatFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterConcatFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterConcatFieldRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..2f376e2
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterConcatFieldRouteBuilderConfigureTest.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterConcatFieldRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterConcatFieldRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterEndpointInjectTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterEndpointInjectTest.java
new file mode 100644
index 0000000..a61a95a
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterEndpointInjectTest.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterEndpointInjectTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterEndpointInjectTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<CamelEndpointDetails> details = new ArrayList<>();
+ RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/MyCdiRouteBuilder.java", details);
+ LOG.info("{}", details);
+
+ Assert.assertEquals("timer:foo?period=4999", details.get(0).getEndpointUri());
+ Assert.assertEquals("27", details.get(0).getLineNumber());
+
+ Assert.assertEquals("log:a", details.get(1).getEndpointUri());
+ Assert.assertEquals("31", details.get(1).getLineNumber());
+
+ Assert.assertEquals("netty4-http:http:someserver:80/hello", details.get(2).getEndpointUri());
+ Assert.assertEquals("35", details.get(2).getLineNumber());
+
+ 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(2, list.size());
+
+ Assert.assertEquals(5, details.size());
+ Assert.assertEquals("log:a", details.get(3).getEndpointUri());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterFieldRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..39d8944
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterFieldRouteBuilderConfigureTest.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterFieldRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterFieldRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyFieldRouteBuilder.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", list.get(0).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("file:output?fileExist=Override", list.get(0).getElement());
+ Assert.assertEquals("log:b", list.get(1).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMethodCallRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..09bf2b7
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMethodCallRouteBuilderConfigureTest.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMethodCallRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMethodCallRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyMethodCallRouteBuilder.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", list.get(0).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("file:output?fileExist={{whatToDoWhenExists}}", list.get(0).getElement());
+ Assert.assertEquals("log:b", list.get(1).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..9cfe117
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMyFieldMethodCallRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMyFieldMethodCallRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyFieldMethodCallRouteBuilder.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("netty-http:http://0.0.0.0:{{port}}/foo", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("mock:input1", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+ Assert.assertEquals("mock:input2", list.get(2).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyLocalAddRouteBuilderTest.java
new file mode 100644
index 0000000..44c1189
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyLocalAddRouteBuilderTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMyLocalAddRouteBuilderTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMyLocalAddRouteBuilderTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyLocalAddRouteBuilderTest.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+ Assert.assertNull(method);
+
+ List<MethodSource<JavaClassSource>> methods = CamelJavaParserHelper.findInlinedConfigureMethods(clazz);
+ Assert.assertEquals(1, methods.size());
+ method = methods.get(0);
+
+ List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Consumer: " + result.getElement());
+ }
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyNettyTest.java
new file mode 100644
index 0000000..cf48862
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterMyNettyTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMyNettyTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMyNettyTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyNettyTest.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Consumer: " + result.getElement());
+ }
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{port}}/foo", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("mock:input1", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+ Assert.assertEquals("mock:input2", list.get(2).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineConstRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineConstRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineConstRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..c2dbb0e
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineConstRouteBuilderConfigureTest.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterNewLineConstRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterNewLineConstRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..ad3493b
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterNewLineRouteBuilderConfigureTest.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterNewLineRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterNewLineRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MyNewLineRouteBuilder.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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderCamelTestSupportTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderCamelTestSupportTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderCamelTestSupportTest.java
new file mode 100644
index 0000000..e74a5be
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderCamelTestSupportTest.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterRouteBuilderCamelTestSupportTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderCamelTestSupportTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..a5ab68a
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderConfigureTest.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderEmptyUriTest.java
new file mode 100644
index 0000000..11b272b
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterRouteBuilderEmptyUriTest.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterRouteBuilderEmptyUriTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderEmptyUriTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleProcessorTest.java
new file mode 100644
index 0000000..06f686a
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleProcessorTest.java
@@ -0,0 +1,60 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleProcessorTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleProcessorTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/SimpleProcessorTest.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<CamelEndpointDetails> details = new ArrayList<CamelEndpointDetails>();
+ RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..38d1211
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleRouteBuilderConfigureTest.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.List;
+
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/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(26, findLineNumber(list.get(0).getPosition()));
+ Assert.assertEquals("${body} > 200", list.get(1).getElement());
+ Assert.assertEquals(29, findLineNumber(list.get(1).getPosition()));
+ }
+
+ public static int findLineNumber(int pos) throws Exception {
+ int lines = 0;
+ int current = 0;
+ File file = new File("src/test/java/org/apache/camel/parser/MySimpleRouteBuilder.java");
+ try (BufferedReader br = new BufferedReader(new FileReader(file))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ lines++;
+ current += line.length();
+ if (current > pos) {
+ return lines;
+ }
+ }
+ }
+ return -1;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToDTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToDTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToDTest.java
new file mode 100644
index 0000000..70a064a
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToDTest.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleToDTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleToDTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MySimpleToDRoute.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<CamelEndpointDetails> details = new ArrayList<>();
+ RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/MySimpleToDRoute.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("toD", list.get(0).getNode());
+ Assert.assertEquals("log:a", list.get(0).getElement());
+ Assert.assertEquals("to", list.get(1).getNode());
+ Assert.assertEquals("log:b", list.get(1).getElement());
+ Assert.assertEquals("to", list.get(2).getNode());
+ Assert.assertEquals("log:c", list.get(2).getElement());
+ Assert.assertEquals(3, list.size());
+
+ Assert.assertEquals(4, details.size());
+ Assert.assertEquals("direct:start", details.get(0).getEndpointUri());
+ Assert.assertEquals("log:a", details.get(1).getEndpointUri());
+ Assert.assertEquals("log:b", details.get(2).getEndpointUri());
+ Assert.assertEquals("log:c", details.get(3).getEndpointUri());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/745f46fd/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToFTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToFTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToFTest.java
new file mode 100644
index 0000000..84eb77e
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/RoasterSimpleToFTest.java
@@ -0,0 +1,63 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleToFTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleToFTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/MySimpleToFRoute.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<CamelEndpointDetails> details = new ArrayList<>();
+ RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/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());
+ }
+
+}
[18/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java
deleted file mode 100644
index 234082a..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java
+++ /dev/null
@@ -1,426 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.roaster;
-
-import java.lang.annotation.Annotation;
-import java.util.List;
-
-import org.jboss.forge.roaster.model.JavaType;
-import org.jboss.forge.roaster.model.Type;
-import org.jboss.forge.roaster.model.TypeVariable;
-import org.jboss.forge.roaster.model.Visibility;
-import org.jboss.forge.roaster.model.source.AnnotationSource;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.JavaDocSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.jboss.forge.roaster.model.source.ParameterSource;
-import org.jboss.forge.roaster.model.source.TypeVariableSource;
-
-/**
- * In use when we have discovered a RouteBuilder being as anonymous inner class
- */
-public class AnonymousMethodSource implements MethodSource<JavaClassSource> {
-
- // this implementation should only implement the needed logic to support the parser
-
- private final JavaClassSource origin;
- private final Object internal;
-
- public AnonymousMethodSource(JavaClassSource origin, Object internal) {
- this.origin = origin;
- this.internal = internal;
- }
-
- @Override
- public MethodSource<JavaClassSource> setDefault(boolean b) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setSynchronized(boolean b) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setNative(boolean b) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setReturnType(Class<?> aClass) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setReturnType(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setReturnType(JavaType<?> javaType) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setReturnTypeVoid() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setBody(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setConstructor(boolean b) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setParameters(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> addThrows(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> addThrows(Class<? extends Exception> aClass) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeThrows(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeThrows(Class<? extends Exception> aClass) {
- return null;
- }
-
- @Override
- public boolean isSynchronized() {
- return false;
- }
-
- @Override
- public boolean isNative() {
- return false;
- }
-
- @Override
- public String getBody() {
- return null;
- }
-
- @Override
- public boolean isConstructor() {
- return false;
- }
-
- @Override
- public Type<JavaClassSource> getReturnType() {
- return null;
- }
-
- @Override
- public boolean isReturnTypeVoid() {
- return false;
- }
-
- @Override
- public List<ParameterSource<JavaClassSource>> getParameters() {
- return null;
- }
-
- @Override
- public String toSignature() {
- return null;
- }
-
- @Override
- public List<String> getThrownExceptions() {
- return null;
- }
-
- @Override
- public boolean isDefault() {
- return false;
- }
-
- @Override
- public ParameterSource<JavaClassSource> addParameter(Class<?> aClass, String s) {
- return null;
- }
-
- @Override
- public ParameterSource<JavaClassSource> addParameter(String s, String s1) {
- return null;
- }
-
- @Override
- public ParameterSource<JavaClassSource> addParameter(JavaType<?> javaType, String s) {
- return null;
- }
-
- @Override
- public void removeAllAnnotations() {
- }
-
- @Override
- public MethodSource<JavaClassSource> removeParameter(ParameterSource<JavaClassSource> parameterSource) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeParameter(Class<?> aClass, String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeParameter(String s, String s1) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeParameter(JavaType<?> javaType, String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setAbstract(boolean b) {
- return null;
- }
-
- @Override
- public List<AnnotationSource<JavaClassSource>> getAnnotations() {
- return null;
- }
-
- @Override
- public boolean hasAnnotation(Class<? extends Annotation> aClass) {
- return false;
- }
-
- @Override
- public boolean hasAnnotation(String s) {
- return false;
- }
-
- @Override
- public AnnotationSource<JavaClassSource> getAnnotation(Class<? extends Annotation> aClass) {
- return null;
- }
-
- @Override
- public AnnotationSource<JavaClassSource> getAnnotation(String s) {
- return null;
- }
-
- @Override
- public AnnotationSource<JavaClassSource> addAnnotation() {
- return null;
- }
-
- @Override
- public AnnotationSource<JavaClassSource> addAnnotation(Class<? extends Annotation> aClass) {
- return null;
- }
-
- @Override
- public AnnotationSource<JavaClassSource> addAnnotation(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeAnnotation(org.jboss.forge.roaster.model.Annotation<JavaClassSource> annotation) {
- return null;
- }
-
- @Override
- public List<TypeVariableSource<JavaClassSource>> getTypeVariables() {
- return null;
- }
-
- @Override
- public TypeVariableSource<JavaClassSource> getTypeVariable(String s) {
- return null;
- }
-
- @Override
- public TypeVariableSource<JavaClassSource> addTypeVariable() {
- return null;
- }
-
- @Override
- public TypeVariableSource<JavaClassSource> addTypeVariable(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeTypeVariable(String s) {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeTypeVariable(TypeVariable<?> typeVariable) {
- return null;
- }
-
- @Override
- public boolean hasJavaDoc() {
- return false;
- }
-
- @Override
- public boolean isAbstract() {
- return false;
- }
-
- @Override
- public MethodSource<JavaClassSource> setFinal(boolean b) {
- return null;
- }
-
- @Override
- public boolean isFinal() {
- return false;
- }
-
- @Override
- public Object getInternal() {
- return internal;
- }
-
- @Override
- public JavaDocSource<MethodSource<JavaClassSource>> getJavaDoc() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> removeJavaDoc() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setName(String s) {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public JavaClassSource getOrigin() {
- return origin;
- }
-
- @Override
- public MethodSource<JavaClassSource> setStatic(boolean b) {
- return null;
- }
-
- @Override
- public boolean isStatic() {
- return false;
- }
-
- @Override
- public MethodSource<JavaClassSource> setPackagePrivate() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setPublic() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setPrivate() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setProtected() {
- return null;
- }
-
- @Override
- public MethodSource<JavaClassSource> setVisibility(Visibility visibility) {
- return null;
- }
-
- @Override
- public boolean isPackagePrivate() {
- return false;
- }
-
- @Override
- public boolean isPublic() {
- return false;
- }
-
- @Override
- public boolean isPrivate() {
- return false;
- }
-
- @Override
- public boolean isProtected() {
- return false;
- }
-
- @Override
- public Visibility getVisibility() {
- return null;
- }
-
- @Override
- public int getColumnNumber() {
- return 0;
- }
-
- @Override
- public int getStartPosition() {
- return 0;
- }
-
- @Override
- public int getEndPosition() {
- return 0;
- }
-
- @Override
- public int getLineNumber() {
- return 0;
- }
-
- @Override
- public boolean hasTypeVariable(String arg0) {
- return false;
- }
-
- @Override
- public MethodSource<JavaClassSource> setReturnType(Type<?> arg0) {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java
deleted file mode 100644
index cbfcedc..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.roaster;
-
-import java.util.List;
-
-import org.jboss.forge.roaster.model.Annotation;
-import org.jboss.forge.roaster.model.JavaType;
-import org.jboss.forge.roaster.model.Type;
-import org.jboss.forge.roaster.model.Visibility;
-import org.jboss.forge.roaster.model.impl.TypeImpl;
-import org.jboss.forge.roaster.model.source.AnnotationSource;
-import org.jboss.forge.roaster.model.source.FieldSource;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.JavaDocSource;
-
-public class StatementFieldSource implements FieldSource {
-
- // this implementation should only implement the needed logic to support the parser
-
- private final JavaClassSource origin;
- private final Object internal;
- private final Type type;
-
- public StatementFieldSource(JavaClassSource origin, Object internal, Object typeInternal) {
- this.origin = origin;
- this.internal = internal;
- this.type = new TypeImpl(origin, typeInternal);
- }
-
- @Override
- public FieldSource setType(Class clazz) {
- return null;
- }
-
- @Override
- public FieldSource setType(String type) {
- return null;
- }
-
- @Override
- public FieldSource setLiteralInitializer(String value) {
- return null;
- }
-
- @Override
- public FieldSource setStringInitializer(String value) {
- return null;
- }
-
- @Override
- public FieldSource setTransient(boolean value) {
- return null;
- }
-
- @Override
- public FieldSource setVolatile(boolean value) {
- return null;
- }
-
- @Override
- public FieldSource setType(JavaType entity) {
- return null;
- }
-
- @Override
- public List<AnnotationSource> getAnnotations() {
- return null;
- }
-
- @Override
- public boolean hasAnnotation(String type) {
- return false;
- }
-
- @Override
- public boolean hasAnnotation(Class type) {
- return false;
- }
-
- @Override
- public AnnotationSource getAnnotation(String type) {
- return null;
- }
-
- @Override
- public AnnotationSource addAnnotation() {
- return null;
- }
-
- @Override
- public AnnotationSource addAnnotation(String className) {
- return null;
- }
-
- @Override
- public void removeAllAnnotations() {
- }
-
- @Override
- public Object removeAnnotation(Annotation annotation) {
- return null;
- }
-
- @Override
- public AnnotationSource addAnnotation(Class type) {
- return null;
- }
-
- @Override
- public AnnotationSource getAnnotation(Class type) {
- return null;
- }
-
- @Override
- public Type getType() {
- return type;
- }
-
- @Override
- public String getStringInitializer() {
- return null;
- }
-
- @Override
- public String getLiteralInitializer() {
- return null;
- }
-
- @Override
- public boolean isTransient() {
- return false;
- }
-
- @Override
- public boolean isVolatile() {
- return false;
- }
-
- @Override
- public Object setFinal(boolean finl) {
- return null;
- }
-
- @Override
- public boolean isFinal() {
- return false;
- }
-
- @Override
- public Object getInternal() {
- return internal;
- }
-
- @Override
- public JavaDocSource getJavaDoc() {
- return null;
- }
-
- @Override
- public boolean hasJavaDoc() {
- return false;
- }
-
- @Override
- public Object removeJavaDoc() {
- return null;
- }
-
- @Override
- public Object setName(String name) {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public Object getOrigin() {
- return origin;
- }
-
- @Override
- public Object setStatic(boolean value) {
- return null;
- }
-
- @Override
- public boolean isStatic() {
- return false;
- }
-
- @Override
- public Object setPackagePrivate() {
- return null;
- }
-
- @Override
- public Object setPublic() {
- return null;
- }
-
- @Override
- public Object setPrivate() {
- return null;
- }
-
- @Override
- public Object setProtected() {
- return null;
- }
-
- @Override
- public Object setVisibility(Visibility scope) {
- return null;
- }
-
- @Override
- public boolean isPackagePrivate() {
- return false;
- }
-
- @Override
- public boolean isPublic() {
- return false;
- }
-
- @Override
- public boolean isPrivate() {
- return false;
- }
-
- @Override
- public boolean isProtected() {
- return false;
- }
-
- @Override
- public Visibility getVisibility() {
- return null;
- }
-
- @Override
- public int getColumnNumber() {
- return 0;
- }
-
- @Override
- public int getStartPosition() {
- return 0;
- }
-
- @Override
- public int getEndPosition() {
- return 0;
- }
-
- @Override
- public int getLineNumber() {
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/resources/META-INF/LICENSE.txt b/tooling/route-parser/src/main/resources/META-INF/LICENSE.txt
deleted file mode 100755
index 6b0b127..0000000
--- a/tooling/route-parser/src/main/resources/META-INF/LICENSE.txt
+++ /dev/null
@@ -1,203 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/resources/META-INF/NOTICE.txt b/tooling/route-parser/src/main/resources/META-INF/NOTICE.txt
deleted file mode 100644
index 2e215bf..0000000
--- a/tooling/route-parser/src/main/resources/META-INF/NOTICE.txt
+++ /dev/null
@@ -1,11 +0,0 @@
- =========================================================================
- == NOTICE file corresponding to the section 4 d of ==
- == the Apache License, Version 2.0, ==
- == in this case for the Apache Camel distribution. ==
- =========================================================================
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- Please read the different LICENSE files present in the licenses directory of
- this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
deleted file mode 100644
index e5fb01c..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public abstract class MyBasePortRouteBuilder extends RouteBuilder {
-
- public int getNextPort() {
- return 8080;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
deleted file mode 100644
index 374ffb9..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.Uri;
-
-public class MyCdiConcatRouteBuilder extends RouteBuilder {
-
- private static final int DELAY = 4999;
- private static final int PORT = 80;
-
- @Inject
- @Uri("timer:foo?period=" + DELAY)
- private Endpoint inputEndpoint;
-
- @Inject
- @Uri("log:a")
- private Endpoint loga;
-
- @EndpointInject(uri = "netty4-http:http:someserver:" + PORT + "/hello")
- private Endpoint mynetty;
-
- @Override
- public void configure() throws Exception {
- from(inputEndpoint)
- .log("I was here")
- .to(loga)
- .to(mynetty);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
deleted file mode 100644
index 2bf3e78..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.Uri;
-
-public class MyCdiRouteBuilder extends RouteBuilder {
-
- @Inject
- @Uri("timer:foo?period=4999")
- private Endpoint inputEndpoint;
-
- @Inject
- @Uri("log:a")
- private Endpoint loga;
-
- @Inject
- @Uri("netty4-http:http:someserver:80/hello")
- private Endpoint mynetty;
-
- @Override
- public void configure() throws Exception {
- from(inputEndpoint)
- .log("I was here")
- .to(loga)
- .to(mynetty);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
deleted file mode 100644
index 4322689..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyConcatFieldRouteBuilder extends RouteBuilder {
-
- private int ftpPort;
- private String ftp = "ftp:localhost:" + ftpPort + "/myapp?password=admin&username=admin";
-
- @Override
- public void configure() throws Exception {
- from(ftp)
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
deleted file mode 100644
index 2a13f19..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-public class MyFieldMethodCallRouteBuilder extends MyBasePortRouteBuilder {
-
- @Override
- public void configure() throws Exception {
- int port2 = getNextPort();
-
- from("netty-http:http://0.0.0.0:{{port}}/foo")
- .to("mock:input1")
- .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
- from("netty-http:http://0.0.0.0:" + port2 + "/bar")
- .to("mock:input2")
- .transform().constant("Bye World");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
deleted file mode 100644
index b56595b..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyFieldRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- String exists = "Override";
-
- from("timer:foo")
- .toD("file:output?fileExist=" + exists)
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
deleted file mode 100644
index 4a8de07..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
-
-@Ignore
-public class MyLocalAddRouteBuilderTest extends CamelTestSupport {
-
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- @Test
- public void testFoo() throws Exception {
- log.info("Adding a route locally");
-
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start")
- .to("mock:foo");
- }
- });
- context.start();
-
- getMockEndpoint("mock:foo").expectedMessageCount(1);
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
deleted file mode 100644
index f54541f..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyMethodCallRouteBuilder extends RouteBuilder {
-
- private String whatToDoWhenExists() {
- return "Override";
- }
-
- @Override
- public void configure() throws Exception {
- from("timer:foo")
- .to("file:output?fileExist=" + whatToDoWhenExists())
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
deleted file mode 100644
index 4391576..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
-
-@Ignore
-public class MyNettyTest extends CamelTestSupport {
-
- public int getNextPort() {
- return 8080;
- }
-
- @Test
- public void testFoo() throws Exception {
- // noop
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- int port2 = getNextPort();
-
- @Override
- public void configure() throws Exception {
- from("netty-http:http://0.0.0.0:{{port}}/foo")
- .to("mock:input1")
- .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
- from("netty-http:http://0.0.0.0:" + port2 + "/bar")
- .to("mock:input2")
- .transform().constant("Bye World");
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
deleted file mode 100644
index 4701c2e..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyNewLineConstRouteBuilder extends RouteBuilder {
-
- private static final String EXISTS = "Append";
- private static final int MOD = 770;
-
- @Override
- public void configure() throws Exception {
- from("timer:foo")
- .toD("file:output?fileExist=" + EXISTS
- + "&chmod=" + (MOD + 6 + 1)
- + "&allowNullBody=true")
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
deleted file mode 100644
index 8213244..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyNewLineRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- from("timer:foo")
- .toD("file:output?fileExist=Append"
- + "&chmod=777"
- + "&allowNullBody=true")
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
deleted file mode 100644
index 9c44803..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- from("timer:foo")
- .log("I was here")
- .toD("log:a")
- .wireTap("mock:tap")
- .to("log:b");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
deleted file mode 100644
index 12a797d..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
-
-@Ignore
-public class MyRouteEmptyUriTest extends CamelTestSupport {
-
- @Test
- public void testFoo() throws Exception {
- // noop
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:foo")
- .to(""); // is empty on purpose
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
deleted file mode 100644
index a6c4923..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class MyRouteTest extends CamelTestSupport {
-
- @Test
- public void testFoo() throws Exception {
- // noop
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:foo")
- .to("mock:foo");
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
deleted file mode 100644
index 85bbe14..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MySimpleRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- from("timer:foo")
- .filter(simple("${body} > 100"))
- .toD("log:a")
- .end()
- .filter().simple("${body} > 200")
- .to("log:b")
- .end()
- .to("log:c");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
deleted file mode 100644
index 2825070..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.builder.RouteBuilder;
-
-public class MySimpleToDRoute extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
-
- String uri = "log:c";
-
- from("direct:start")
- .toD("log:a", true)
- .to(ExchangePattern.InOnly, "log:b")
- .to(uri);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
deleted file mode 100644
index 3e43655..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MySimpleToFRoute extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- from("direct:start")
- .toF("log:a?level=%s", "info");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
deleted file mode 100644
index 7d9abe4..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterCdiConcatRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterCdiConcatRouteBuilderConfigureTest.class);
-
- @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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
deleted file mode 100644
index 6abd424..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterCdiRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterCdiRouteBuilderConfigureTest.class);
-
- @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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
deleted file mode 100644
index a57ce23..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterConcatFieldRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterConcatFieldRouteBuilderConfigureTest.class);
-
- @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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
deleted file mode 100644
index 8ffb23b..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.RouteBuilderParser;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterEndpointInjectTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterEndpointInjectTest.class);
-
- @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 = CamelJavaParserHelper.findConfigureMethod(clazz);
-
- List<CamelEndpointDetails> details = new ArrayList<>();
- RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java", details);
- LOG.info("{}", details);
-
- Assert.assertEquals("timer:foo?period=4999", details.get(0).getEndpointUri());
- Assert.assertEquals("28", details.get(0).getLineNumber());
-
- Assert.assertEquals("log:a", details.get(1).getEndpointUri());
- Assert.assertEquals("32", details.get(1).getLineNumber());
-
- Assert.assertEquals("netty4-http:http:someserver:80/hello", details.get(2).getEndpointUri());
- Assert.assertEquals("36", details.get(2).getLineNumber());
-
- 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(2, list.size());
-
- Assert.assertEquals(5, details.size());
- Assert.assertEquals("log:a", details.get(3).getEndpointUri());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
deleted file mode 100644
index 5b16bd3..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterFieldRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterFieldRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.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", list.get(0).getElement());
-
- list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Producer: " + result.getElement());
- }
- Assert.assertEquals("file:output?fileExist=Override", list.get(0).getElement());
- Assert.assertEquals("log:b", list.get(1).getElement());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
deleted file mode 100644
index 00a8623..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterMethodCallRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterMethodCallRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.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", list.get(0).getElement());
-
- list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Producer: " + result.getElement());
- }
- Assert.assertEquals("file:output?fileExist={{whatToDoWhenExists}}", list.get(0).getElement());
- Assert.assertEquals("log:b", list.get(1).getElement());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
deleted file mode 100644
index 44b4539..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterMyFieldMethodCallRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterMyFieldMethodCallRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.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("netty-http:http://0.0.0.0:{{port}}/foo", list.get(0).getElement());
- Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
-
- list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Producer: " + result.getElement());
- }
- Assert.assertEquals("mock:input1", list.get(0).getElement());
- Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
- Assert.assertEquals("mock:input2", list.get(2).getElement());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
deleted file mode 100644
index 9b1495e..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterMyLocalAddRouteBuilderTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterMyLocalAddRouteBuilderTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java"));
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
- Assert.assertNull(method);
-
- List<MethodSource<JavaClassSource>> methods = CamelJavaParserHelper.findInlinedConfigureMethods(clazz);
- Assert.assertEquals(1, methods.size());
- method = methods.get(0);
-
- List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Consumer: " + result.getElement());
- }
-
- list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Producer: " + result.getElement());
- }
- }
-
-}
[04/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/route-parser/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/resources/META-INF/LICENSE.txt b/tooling/route-parser/src/main/resources/META-INF/LICENSE.txt
new file mode 100755
index 0000000..6b0b127
--- /dev/null
+++ b/tooling/route-parser/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/route-parser/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/resources/META-INF/NOTICE.txt b/tooling/route-parser/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/tooling/route-parser/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
[21/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
new file mode 100644
index 0000000..b214b1e
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
@@ -0,0 +1,197 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.helper;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.Stack;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * An XML parser that uses SAX to include line and column number for each XML element in the parsed Document.
+ * <p/>
+ * The line number and column number can be obtained from a Node/Element using
+ * <pre>
+ * String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
+ * String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
+ * String columnNumber = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER);
+ * String columnNumberEnd = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER_END);
+ * </pre>
+ */
+public final class XmlLineNumberParser {
+
+ public static final String LINE_NUMBER = "lineNumber";
+ public static final String COLUMN_NUMBER = "colNumber";
+ public static final String LINE_NUMBER_END = "lineNumberEnd";
+ public static final String COLUMN_NUMBER_END = "colNumberEnd";
+
+ private XmlLineNumberParser() {
+ }
+
+ /**
+ * Parses the XML.
+ *
+ * @param is the XML content as an input stream
+ * @return the DOM model
+ * @throws Exception is thrown if error parsing
+ */
+ public static Document parseXml(final InputStream is) throws Exception {
+ return parseXml(is, null, null);
+ }
+
+ /**
+ * Parses the XML.
+ *
+ * @param is the XML content as an input stream
+ * @param rootNames one or more root names that is used as baseline for beginning the parsing, for example camelContext to start parsing
+ * when Camel is discovered. Multiple names can be defined separated by comma
+ * @param forceNamespace an optional namespace to force assign to each node. This may be needed for JAXB unmarshalling from XML -> POJO.
+ * @return the DOM model
+ * @throws Exception is thrown if error parsing
+ */
+ public static Document parseXml(final InputStream is, final String rootNames, final String forceNamespace) throws Exception {
+ final Document doc;
+ SAXParser parser;
+ final SAXParserFactory factory = SAXParserFactory.newInstance();
+ parser = factory.newSAXParser();
+ final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ // turn off validator and loading external dtd
+ dbf.setValidating(false);
+ dbf.setNamespaceAware(true);
+ dbf.setFeature("http://xml.org/sax/features/namespaces", false);
+ dbf.setFeature("http://xml.org/sax/features/validation", false);
+ dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
+ dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ final DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ doc = docBuilder.newDocument();
+
+ final Stack<Element> elementStack = new Stack<Element>();
+ final StringBuilder textBuffer = new StringBuilder();
+ final DefaultHandler handler = new DefaultHandler() {
+ private Locator locator;
+ private boolean found;
+
+ @Override
+ public void setDocumentLocator(final Locator locator) {
+ this.locator = locator; // Save the locator, so that it can be used later for line tracking when traversing nodes.
+ this.found = rootNames == null;
+ }
+
+ private boolean isRootName(String qName) {
+ for (String root : rootNames.split(",")) {
+ if (qName.equals(root)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException {
+ addTextIfNeeded();
+
+ if (rootNames != null && !found) {
+ if (isRootName(qName)) {
+ found = true;
+ }
+ }
+
+ if (found) {
+ Element el;
+ if (forceNamespace != null) {
+ el = doc.createElementNS(forceNamespace, qName);
+ } else {
+ el = doc.createElement(qName);
+ }
+
+ for (int i = 0; i < attributes.getLength(); i++) {
+ el.setAttribute(attributes.getQName(i), attributes.getValue(i));
+ }
+
+ el.setUserData(LINE_NUMBER, String.valueOf(this.locator.getLineNumber()), null);
+ el.setUserData(COLUMN_NUMBER, String.valueOf(this.locator.getColumnNumber()), null);
+ elementStack.push(el);
+ }
+ }
+
+ @Override
+ public void endElement(final String uri, final String localName, final String qName) {
+ if (!found) {
+ return;
+ }
+
+ addTextIfNeeded();
+
+ final Element closedEl = elementStack.isEmpty() ? null : elementStack.pop();
+ if (closedEl != null) {
+ if (elementStack.isEmpty()) {
+ // Is this the root element?
+ doc.appendChild(closedEl);
+ } else {
+ final Element parentEl = elementStack.peek();
+ parentEl.appendChild(closedEl);
+ }
+
+ closedEl.setUserData(LINE_NUMBER_END, String.valueOf(this.locator.getLineNumber()), null);
+ closedEl.setUserData(COLUMN_NUMBER_END, String.valueOf(this.locator.getColumnNumber()), null);
+ }
+ }
+
+ @Override
+ public void characters(final char ch[], final int start, final int length) throws SAXException {
+ textBuffer.append(ch, start, length);
+ }
+
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException {
+ // do not resolve external dtd
+ return new InputSource(new StringReader(""));
+ }
+
+ // Outputs text accumulated under the current node
+ private void addTextIfNeeded() {
+ if (textBuffer.length() > 0) {
+ final Element el = elementStack.isEmpty() ? null : elementStack.peek();
+ if (el != null) {
+ final Node textNode = doc.createTextNode(textBuffer.toString());
+ el.appendChild(textNode);
+ textBuffer.delete(0, textBuffer.length());
+ }
+ }
+ }
+ };
+ parser.parse(is, handler);
+
+ return doc;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
new file mode 100644
index 0000000..3b112a4
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.model;
+
+/**
+ * Details about a parsed and discovered Camel endpoint.
+ */
+public class CamelEndpointDetails {
+
+ private String fileName;
+ private String lineNumber;
+ private String lineNumberEnd;
+ private String className;
+ private String methodName;
+ private String endpointComponentName;
+ private String endpointInstance;
+ private String endpointUri;
+ private boolean consumerOnly;
+ private boolean producerOnly;
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getLineNumber() {
+ return lineNumber;
+ }
+
+ public void setLineNumber(String lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ public String getLineNumberEnd() {
+ return lineNumberEnd;
+ }
+
+ public void setLineNumberEnd(String lineNumberEnd) {
+ this.lineNumberEnd = lineNumberEnd;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+ public String getEndpointComponentName() {
+ return endpointComponentName;
+ }
+
+ public void setEndpointComponentName(String endpointComponentName) {
+ this.endpointComponentName = endpointComponentName;
+ }
+
+ public String getEndpointInstance() {
+ return endpointInstance;
+ }
+
+ public void setEndpointInstance(String endpointInstance) {
+ this.endpointInstance = endpointInstance;
+ }
+
+ public String getEndpointUri() {
+ return endpointUri;
+ }
+
+ public void setEndpointUri(String endpointUri) {
+ this.endpointUri = endpointUri;
+ }
+
+ public boolean isConsumerOnly() {
+ return consumerOnly;
+ }
+
+ public void setConsumerOnly(boolean consumerOnly) {
+ this.consumerOnly = consumerOnly;
+ }
+
+ public boolean isProducerOnly() {
+ return producerOnly;
+ }
+
+ public void setProducerOnly(boolean producerOnly) {
+ this.producerOnly = producerOnly;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ CamelEndpointDetails that = (CamelEndpointDetails) o;
+
+ if (!fileName.equals(that.fileName)) {
+ return false;
+ }
+ if (lineNumber != null ? !lineNumber.equals(that.lineNumber) : that.lineNumber != null) {
+ return false;
+ }
+ if (lineNumberEnd != null ? !lineNumberEnd.equals(that.lineNumberEnd) : that.lineNumberEnd != null) {
+ return false;
+ }
+ if (!className.equals(that.className)) {
+ return false;
+ }
+ if (methodName != null ? !methodName.equals(that.methodName) : that.methodName != null) {
+ return false;
+ }
+ if (endpointInstance != null ? !endpointInstance.equals(that.endpointInstance) : that.endpointInstance != null) {
+ return false;
+ }
+ return endpointUri.equals(that.endpointUri);
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = fileName.hashCode();
+ result = 31 * result + (lineNumber != null ? lineNumber.hashCode() : 0);
+ result = 31 * result + (lineNumberEnd != null ? lineNumberEnd.hashCode() : 0);
+ result = 31 * result + className.hashCode();
+ result = 31 * result + (methodName != null ? methodName.hashCode() : 0);
+ result = 31 * result + (endpointInstance != null ? endpointInstance.hashCode() : 0);
+ result = 31 * result + endpointUri.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "CamelEndpointDetails["
+ + "fileName='" + fileName + '\''
+ + ", lineNumber='" + lineNumber + '\''
+ + ", lineNumberEnd='" + lineNumberEnd + '\''
+ + ", className='" + className + '\''
+ + ", methodName='" + methodName + '\''
+ + ", endpointComponentName='" + endpointComponentName + '\''
+ + ", endpointInstance='" + endpointInstance + '\''
+ + ", endpointUri='" + endpointUri + '\''
+ + ", consumerOnly=" + consumerOnly
+ + ", producerOnly=" + producerOnly
+ + ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java
new file mode 100644
index 0000000..9d6db11
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.model;
+
+/**
+ * Details about a parsed and discovered Camel simple expression.
+ */
+public class CamelSimpleExpressionDetails {
+
+ private String fileName;
+ private String lineNumber;
+ private String lineNumberEnd;
+ private String className;
+ private String methodName;
+ private String simple;
+ private boolean predicate;
+ private boolean expression;
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getLineNumber() {
+ return lineNumber;
+ }
+
+ public void setLineNumber(String lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ public String getLineNumberEnd() {
+ return lineNumberEnd;
+ }
+
+ public void setLineNumberEnd(String lineNumberEnd) {
+ this.lineNumberEnd = lineNumberEnd;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+ public String getSimple() {
+ return simple;
+ }
+
+ public void setSimple(String simple) {
+ this.simple = simple;
+ }
+
+ public boolean isPredicate() {
+ return predicate;
+ }
+
+ public void setPredicate(boolean predicate) {
+ this.predicate = predicate;
+ }
+
+ public boolean isExpression() {
+ return expression;
+ }
+
+ public void setExpression(boolean expression) {
+ this.expression = expression;
+ }
+
+ @Override
+ public String toString() {
+ return simple;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java
new file mode 100644
index 0000000..234082a
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java
@@ -0,0 +1,426 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.roaster;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+import org.jboss.forge.roaster.model.JavaType;
+import org.jboss.forge.roaster.model.Type;
+import org.jboss.forge.roaster.model.TypeVariable;
+import org.jboss.forge.roaster.model.Visibility;
+import org.jboss.forge.roaster.model.source.AnnotationSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.JavaDocSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.jboss.forge.roaster.model.source.ParameterSource;
+import org.jboss.forge.roaster.model.source.TypeVariableSource;
+
+/**
+ * In use when we have discovered a RouteBuilder being as anonymous inner class
+ */
+public class AnonymousMethodSource implements MethodSource<JavaClassSource> {
+
+ // this implementation should only implement the needed logic to support the parser
+
+ private final JavaClassSource origin;
+ private final Object internal;
+
+ public AnonymousMethodSource(JavaClassSource origin, Object internal) {
+ this.origin = origin;
+ this.internal = internal;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setDefault(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setSynchronized(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setNative(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(Class<?> aClass) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(JavaType<?> javaType) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnTypeVoid() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setBody(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setConstructor(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setParameters(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> addThrows(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> addThrows(Class<? extends Exception> aClass) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeThrows(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeThrows(Class<? extends Exception> aClass) {
+ return null;
+ }
+
+ @Override
+ public boolean isSynchronized() {
+ return false;
+ }
+
+ @Override
+ public boolean isNative() {
+ return false;
+ }
+
+ @Override
+ public String getBody() {
+ return null;
+ }
+
+ @Override
+ public boolean isConstructor() {
+ return false;
+ }
+
+ @Override
+ public Type<JavaClassSource> getReturnType() {
+ return null;
+ }
+
+ @Override
+ public boolean isReturnTypeVoid() {
+ return false;
+ }
+
+ @Override
+ public List<ParameterSource<JavaClassSource>> getParameters() {
+ return null;
+ }
+
+ @Override
+ public String toSignature() {
+ return null;
+ }
+
+ @Override
+ public List<String> getThrownExceptions() {
+ return null;
+ }
+
+ @Override
+ public boolean isDefault() {
+ return false;
+ }
+
+ @Override
+ public ParameterSource<JavaClassSource> addParameter(Class<?> aClass, String s) {
+ return null;
+ }
+
+ @Override
+ public ParameterSource<JavaClassSource> addParameter(String s, String s1) {
+ return null;
+ }
+
+ @Override
+ public ParameterSource<JavaClassSource> addParameter(JavaType<?> javaType, String s) {
+ return null;
+ }
+
+ @Override
+ public void removeAllAnnotations() {
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(ParameterSource<JavaClassSource> parameterSource) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(Class<?> aClass, String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(String s, String s1) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(JavaType<?> javaType, String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setAbstract(boolean b) {
+ return null;
+ }
+
+ @Override
+ public List<AnnotationSource<JavaClassSource>> getAnnotations() {
+ return null;
+ }
+
+ @Override
+ public boolean hasAnnotation(Class<? extends Annotation> aClass) {
+ return false;
+ }
+
+ @Override
+ public boolean hasAnnotation(String s) {
+ return false;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> getAnnotation(Class<? extends Annotation> aClass) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> getAnnotation(String s) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> addAnnotation() {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> addAnnotation(Class<? extends Annotation> aClass) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> addAnnotation(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeAnnotation(org.jboss.forge.roaster.model.Annotation<JavaClassSource> annotation) {
+ return null;
+ }
+
+ @Override
+ public List<TypeVariableSource<JavaClassSource>> getTypeVariables() {
+ return null;
+ }
+
+ @Override
+ public TypeVariableSource<JavaClassSource> getTypeVariable(String s) {
+ return null;
+ }
+
+ @Override
+ public TypeVariableSource<JavaClassSource> addTypeVariable() {
+ return null;
+ }
+
+ @Override
+ public TypeVariableSource<JavaClassSource> addTypeVariable(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeTypeVariable(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeTypeVariable(TypeVariable<?> typeVariable) {
+ return null;
+ }
+
+ @Override
+ public boolean hasJavaDoc() {
+ return false;
+ }
+
+ @Override
+ public boolean isAbstract() {
+ return false;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setFinal(boolean b) {
+ return null;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return false;
+ }
+
+ @Override
+ public Object getInternal() {
+ return internal;
+ }
+
+ @Override
+ public JavaDocSource<MethodSource<JavaClassSource>> getJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setName(String s) {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public JavaClassSource getOrigin() {
+ return origin;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setStatic(boolean b) {
+ return null;
+ }
+
+ @Override
+ public boolean isStatic() {
+ return false;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setPackagePrivate() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setPublic() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setPrivate() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setProtected() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setVisibility(Visibility visibility) {
+ return null;
+ }
+
+ @Override
+ public boolean isPackagePrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isPublic() {
+ return false;
+ }
+
+ @Override
+ public boolean isPrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isProtected() {
+ return false;
+ }
+
+ @Override
+ public Visibility getVisibility() {
+ return null;
+ }
+
+ @Override
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ @Override
+ public int getStartPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getEndPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getLineNumber() {
+ return 0;
+ }
+
+ @Override
+ public boolean hasTypeVariable(String arg0) {
+ return false;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(Type<?> arg0) {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java
new file mode 100644
index 0000000..cbfcedc
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java
@@ -0,0 +1,278 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.roaster;
+
+import java.util.List;
+
+import org.jboss.forge.roaster.model.Annotation;
+import org.jboss.forge.roaster.model.JavaType;
+import org.jboss.forge.roaster.model.Type;
+import org.jboss.forge.roaster.model.Visibility;
+import org.jboss.forge.roaster.model.impl.TypeImpl;
+import org.jboss.forge.roaster.model.source.AnnotationSource;
+import org.jboss.forge.roaster.model.source.FieldSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.JavaDocSource;
+
+public class StatementFieldSource implements FieldSource {
+
+ // this implementation should only implement the needed logic to support the parser
+
+ private final JavaClassSource origin;
+ private final Object internal;
+ private final Type type;
+
+ public StatementFieldSource(JavaClassSource origin, Object internal, Object typeInternal) {
+ this.origin = origin;
+ this.internal = internal;
+ this.type = new TypeImpl(origin, typeInternal);
+ }
+
+ @Override
+ public FieldSource setType(Class clazz) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setType(String type) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setLiteralInitializer(String value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setStringInitializer(String value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setTransient(boolean value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setVolatile(boolean value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setType(JavaType entity) {
+ return null;
+ }
+
+ @Override
+ public List<AnnotationSource> getAnnotations() {
+ return null;
+ }
+
+ @Override
+ public boolean hasAnnotation(String type) {
+ return false;
+ }
+
+ @Override
+ public boolean hasAnnotation(Class type) {
+ return false;
+ }
+
+ @Override
+ public AnnotationSource getAnnotation(String type) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource addAnnotation() {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource addAnnotation(String className) {
+ return null;
+ }
+
+ @Override
+ public void removeAllAnnotations() {
+ }
+
+ @Override
+ public Object removeAnnotation(Annotation annotation) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource addAnnotation(Class type) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource getAnnotation(Class type) {
+ return null;
+ }
+
+ @Override
+ public Type getType() {
+ return type;
+ }
+
+ @Override
+ public String getStringInitializer() {
+ return null;
+ }
+
+ @Override
+ public String getLiteralInitializer() {
+ return null;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return false;
+ }
+
+ @Override
+ public boolean isVolatile() {
+ return false;
+ }
+
+ @Override
+ public Object setFinal(boolean finl) {
+ return null;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return false;
+ }
+
+ @Override
+ public Object getInternal() {
+ return internal;
+ }
+
+ @Override
+ public JavaDocSource getJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public boolean hasJavaDoc() {
+ return false;
+ }
+
+ @Override
+ public Object removeJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public Object setName(String name) {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public Object getOrigin() {
+ return origin;
+ }
+
+ @Override
+ public Object setStatic(boolean value) {
+ return null;
+ }
+
+ @Override
+ public boolean isStatic() {
+ return false;
+ }
+
+ @Override
+ public Object setPackagePrivate() {
+ return null;
+ }
+
+ @Override
+ public Object setPublic() {
+ return null;
+ }
+
+ @Override
+ public Object setPrivate() {
+ return null;
+ }
+
+ @Override
+ public Object setProtected() {
+ return null;
+ }
+
+ @Override
+ public Object setVisibility(Visibility scope) {
+ return null;
+ }
+
+ @Override
+ public boolean isPackagePrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isPublic() {
+ return false;
+ }
+
+ @Override
+ public boolean isPrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isProtected() {
+ return false;
+ }
+
+ @Override
+ public Visibility getVisibility() {
+ return null;
+ }
+
+ @Override
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ @Override
+ public int getStartPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getEndPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getLineNumber() {
+ return 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/resources/META-INF/LICENSE.txt b/tooling/camel-route-parser/src/main/resources/META-INF/LICENSE.txt
new file mode 100755
index 0000000..6b0b127
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/resources/META-INF/NOTICE.txt b/tooling/camel-route-parser/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
new file mode 100644
index 0000000..e5fb01c
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyBasePortRouteBuilder.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public abstract class MyBasePortRouteBuilder extends RouteBuilder {
+
+ public int getNextPort() {
+ return 8080;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
new file mode 100644
index 0000000..374ffb9
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyCdiConcatRouteBuilder.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.Uri;
+
+public class MyCdiConcatRouteBuilder extends RouteBuilder {
+
+ private static final int DELAY = 4999;
+ private static final int PORT = 80;
+
+ @Inject
+ @Uri("timer:foo?period=" + DELAY)
+ private Endpoint inputEndpoint;
+
+ @Inject
+ @Uri("log:a")
+ private Endpoint loga;
+
+ @EndpointInject(uri = "netty4-http:http:someserver:" + PORT + "/hello")
+ private Endpoint mynetty;
+
+ @Override
+ public void configure() throws Exception {
+ from(inputEndpoint)
+ .log("I was here")
+ .to(loga)
+ .to(mynetty);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
new file mode 100644
index 0000000..2bf3e78
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.Uri;
+
+public class MyCdiRouteBuilder extends RouteBuilder {
+
+ @Inject
+ @Uri("timer:foo?period=4999")
+ private Endpoint inputEndpoint;
+
+ @Inject
+ @Uri("log:a")
+ private Endpoint loga;
+
+ @Inject
+ @Uri("netty4-http:http:someserver:80/hello")
+ private Endpoint mynetty;
+
+ @Override
+ public void configure() throws Exception {
+ from(inputEndpoint)
+ .log("I was here")
+ .to(loga)
+ .to(mynetty);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
new file mode 100644
index 0000000..4322689
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyConcatFieldRouteBuilder.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyConcatFieldRouteBuilder extends RouteBuilder {
+
+ private int ftpPort;
+ private String ftp = "ftp:localhost:" + ftpPort + "/myapp?password=admin&username=admin";
+
+ @Override
+ public void configure() throws Exception {
+ from(ftp)
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
new file mode 100644
index 0000000..2a13f19
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+public class MyFieldMethodCallRouteBuilder extends MyBasePortRouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ int port2 = getNextPort();
+
+ from("netty-http:http://0.0.0.0:{{port}}/foo")
+ .to("mock:input1")
+ .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
+ from("netty-http:http://0.0.0.0:" + port2 + "/bar")
+ .to("mock:input2")
+ .transform().constant("Bye World");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
new file mode 100644
index 0000000..b56595b
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyFieldRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ String exists = "Override";
+
+ from("timer:foo")
+ .toD("file:output?fileExist=" + exists)
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
new file mode 100644
index 0000000..4a8de07
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class MyLocalAddRouteBuilderTest extends CamelTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Test
+ public void testFoo() throws Exception {
+ log.info("Adding a route locally");
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("mock:foo");
+ }
+ });
+ context.start();
+
+ getMockEndpoint("mock:foo").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
new file mode 100644
index 0000000..f54541f
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyMethodCallRouteBuilder extends RouteBuilder {
+
+ private String whatToDoWhenExists() {
+ return "Override";
+ }
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .to("file:output?fileExist=" + whatToDoWhenExists())
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
new file mode 100644
index 0000000..4391576
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNettyTest.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class MyNettyTest extends CamelTestSupport {
+
+ public int getNextPort() {
+ return 8080;
+ }
+
+ @Test
+ public void testFoo() throws Exception {
+ // noop
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ int port2 = getNextPort();
+
+ @Override
+ public void configure() throws Exception {
+ from("netty-http:http://0.0.0.0:{{port}}/foo")
+ .to("mock:input1")
+ .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
+ from("netty-http:http://0.0.0.0:" + port2 + "/bar")
+ .to("mock:input2")
+ .transform().constant("Bye World");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
new file mode 100644
index 0000000..4701c2e
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineConstRouteBuilder.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyNewLineConstRouteBuilder extends RouteBuilder {
+
+ private static final String EXISTS = "Append";
+ private static final int MOD = 770;
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .toD("file:output?fileExist=" + EXISTS
+ + "&chmod=" + (MOD + 6 + 1)
+ + "&allowNullBody=true")
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
new file mode 100644
index 0000000..8213244
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyNewLineRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .toD("file:output?fileExist=Append"
+ + "&chmod=777"
+ + "&allowNullBody=true")
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
new file mode 100644
index 0000000..9c44803
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteBuilder.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .log("I was here")
+ .toD("log:a")
+ .wireTap("mock:tap")
+ .to("log:b");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
new file mode 100644
index 0000000..12a797d
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteEmptyUriTest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class MyRouteEmptyUriTest extends CamelTestSupport {
+
+ @Test
+ public void testFoo() throws Exception {
+ // noop
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:foo")
+ .to(""); // is empty on purpose
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
new file mode 100644
index 0000000..a6c4923
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MyRouteTest.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class MyRouteTest extends CamelTestSupport {
+
+ @Test
+ public void testFoo() throws Exception {
+ // noop
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:foo")
+ .to("mock:foo");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
new file mode 100644
index 0000000..85bbe14
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MySimpleRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo")
+ .filter(simple("${body} > 100"))
+ .toD("log:a")
+ .end()
+ .filter().simple("${body} > 200")
+ .to("log:b")
+ .end()
+ .to("log:c");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
new file mode 100644
index 0000000..2825070
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.builder.RouteBuilder;
+
+public class MySimpleToDRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+
+ String uri = "log:c";
+
+ from("direct:start")
+ .toD("log:a", true)
+ .to(ExchangePattern.InOnly, "log:b")
+ .to(uri);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
new file mode 100644
index 0000000..3e43655
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/MySimpleToFRoute.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MySimpleToFRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .toF("log:a?level=%s", "info");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..7d9abe4
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterCdiConcatRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterCdiConcatRouteBuilderConfigureTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..6abd424
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterCdiRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterCdiRouteBuilderConfigureTest.class);
+
+ @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());
+ }
+
+}
[22/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: route parser for java and xml to parse source code. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/88ba9063
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/88ba9063
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/88ba9063
Branch: refs/heads/master
Commit: 88ba9063c77e5e8625471c67d6c7cecaac58d4d6
Parents: 96e946e
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 13:28:49 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
apache-camel/pom.xml | 4 +
.../src/main/descriptors/common-bin.xml | 1 +
parent/pom.xml | 5 +
tooling/camel-route-parser/pom.xml | 99 +++
.../org/apache/camel/parser/ParserResult.java | 72 +++
.../apache/camel/parser/RouteBuilderParser.java | 310 +++++++++
.../org/apache/camel/parser/XmlRouteParser.java | 169 +++++
.../parser/helper/CamelJavaParserHelper.java | 638 +++++++++++++++++++
.../camel/parser/helper/CamelXmlHelper.java | 268 ++++++++
.../parser/helper/XmlLineNumberParser.java | 197 ++++++
.../parser/model/CamelEndpointDetails.java | 175 +++++
.../model/CamelSimpleExpressionDetails.java | 101 +++
.../parser/roaster/AnonymousMethodSource.java | 426 +++++++++++++
.../parser/roaster/StatementFieldSource.java | 278 ++++++++
.../src/main/resources/META-INF/LICENSE.txt | 203 ++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../parser/java/MyBasePortRouteBuilder.java | 27 +
.../parser/java/MyCdiConcatRouteBuilder.java | 49 ++
.../camel/parser/java/MyCdiRouteBuilder.java | 46 ++
.../parser/java/MyConcatFieldRouteBuilder.java | 31 +
.../java/MyFieldMethodCallRouteBuilder.java | 33 +
.../camel/parser/java/MyFieldRouteBuilder.java | 31 +
.../parser/java/MyLocalAddRouteBuilderTest.java | 52 ++
.../parser/java/MyMethodCallRouteBuilder.java | 33 +
.../apache/camel/parser/java/MyNettyTest.java | 52 ++
.../parser/java/MyNewLineConstRouteBuilder.java | 34 +
.../parser/java/MyNewLineRouteBuilder.java | 31 +
.../camel/parser/java/MyRouteBuilder.java | 31 +
.../camel/parser/java/MyRouteEmptyUriTest.java | 42 ++
.../apache/camel/parser/java/MyRouteTest.java | 40 ++
.../camel/parser/java/MySimpleRouteBuilder.java | 34 +
.../camel/parser/java/MySimpleToDRoute.java | 34 +
.../camel/parser/java/MySimpleToFRoute.java | 28 +
...asterCdiConcatRouteBuilderConfigureTest.java | 55 ++
.../RoasterCdiRouteBuilderConfigureTest.java | 55 ++
...terConcatFieldRouteBuilderConfigureTest.java | 54 ++
.../parser/java/RoasterEndpointInjectTest.java | 73 +++
.../RoasterFieldRouteBuilderConfigureTest.java | 55 ++
...sterMethodCallRouteBuilderConfigureTest.java | 55 ++
...ieldMethodCallRouteBuilderConfigureTest.java | 57 ++
.../java/RoasterMyLocalAddRouteBuilderTest.java | 57 ++
.../camel/parser/java/RoasterMyNettyTest.java | 57 ++
...erNewLineConstRouteBuilderConfigureTest.java | 55 ++
...RoasterNewLineRouteBuilderConfigureTest.java | 55 ++
...RoasterRouteBuilderCamelTestSupportTest.java | 54 ++
.../java/RoasterRouteBuilderConfigureTest.java | 56 ++
.../java/RoasterRouteBuilderEmptyUriTest.java | 55 ++
.../parser/java/RoasterSimpleProcessorTest.java | 64 ++
.../RoasterSimpleRouteBuilderConfigureTest.java | 71 +++
.../camel/parser/java/RoasterSimpleToDTest.java | 73 +++
.../camel/parser/java/RoasterSimpleToFTest.java | 67 ++
.../parser/java/RoasterSplitTokenizeTest.java | 75 +++
.../camel/parser/java/SimpleProcessorTest.java | 45 ++
.../camel/parser/java/SplitTokenizeTest.java | 126 ++++
.../parser/xml/FindElementInRoutesTest.java | 45 ++
.../parser/xml/XmlOnExceptionRouteTest.java | 55 ++
.../apache/camel/parser/xml/XmlRouteTest.java | 51 ++
.../src/test/resources/log4j2.properties | 30 +
.../camel/parser/xml/mycamel-onexception.xml | 33 +
.../org/apache/camel/parser/xml/mycamel.xml | 26 +
.../org/apache/camel/parser/xml/myroutes.xml | 19 +
tooling/pom.xml | 2 +-
tooling/route-parser/pom.xml | 99 ---
.../org/apache/camel/parser/ParserResult.java | 72 ---
.../apache/camel/parser/RouteBuilderParser.java | 310 ---------
.../org/apache/camel/parser/XmlRouteParser.java | 169 -----
.../parser/helper/CamelJavaParserHelper.java | 638 -------------------
.../camel/parser/helper/CamelXmlHelper.java | 268 --------
.../parser/helper/XmlLineNumberParser.java | 197 ------
.../parser/model/CamelEndpointDetails.java | 175 -----
.../model/CamelSimpleExpressionDetails.java | 101 ---
.../parser/roaster/AnonymousMethodSource.java | 426 -------------
.../parser/roaster/StatementFieldSource.java | 278 --------
.../src/main/resources/META-INF/LICENSE.txt | 203 ------
.../src/main/resources/META-INF/NOTICE.txt | 11 -
.../parser/java/MyBasePortRouteBuilder.java | 27 -
.../parser/java/MyCdiConcatRouteBuilder.java | 49 --
.../camel/parser/java/MyCdiRouteBuilder.java | 46 --
.../parser/java/MyConcatFieldRouteBuilder.java | 31 -
.../java/MyFieldMethodCallRouteBuilder.java | 33 -
.../camel/parser/java/MyFieldRouteBuilder.java | 31 -
.../parser/java/MyLocalAddRouteBuilderTest.java | 52 --
.../parser/java/MyMethodCallRouteBuilder.java | 33 -
.../apache/camel/parser/java/MyNettyTest.java | 52 --
.../parser/java/MyNewLineConstRouteBuilder.java | 34 -
.../parser/java/MyNewLineRouteBuilder.java | 31 -
.../camel/parser/java/MyRouteBuilder.java | 31 -
.../camel/parser/java/MyRouteEmptyUriTest.java | 42 --
.../apache/camel/parser/java/MyRouteTest.java | 40 --
.../camel/parser/java/MySimpleRouteBuilder.java | 34 -
.../camel/parser/java/MySimpleToDRoute.java | 34 -
.../camel/parser/java/MySimpleToFRoute.java | 28 -
...asterCdiConcatRouteBuilderConfigureTest.java | 55 --
.../RoasterCdiRouteBuilderConfigureTest.java | 55 --
...terConcatFieldRouteBuilderConfigureTest.java | 54 --
.../parser/java/RoasterEndpointInjectTest.java | 73 ---
.../RoasterFieldRouteBuilderConfigureTest.java | 55 --
...sterMethodCallRouteBuilderConfigureTest.java | 55 --
...ieldMethodCallRouteBuilderConfigureTest.java | 57 --
.../java/RoasterMyLocalAddRouteBuilderTest.java | 57 --
.../camel/parser/java/RoasterMyNettyTest.java | 57 --
...erNewLineConstRouteBuilderConfigureTest.java | 55 --
...RoasterNewLineRouteBuilderConfigureTest.java | 55 --
...RoasterRouteBuilderCamelTestSupportTest.java | 54 --
.../java/RoasterRouteBuilderConfigureTest.java | 56 --
.../java/RoasterRouteBuilderEmptyUriTest.java | 55 --
.../parser/java/RoasterSimpleProcessorTest.java | 64 --
.../RoasterSimpleRouteBuilderConfigureTest.java | 71 ---
.../camel/parser/java/RoasterSimpleToDTest.java | 73 ---
.../camel/parser/java/RoasterSimpleToFTest.java | 67 --
.../parser/java/RoasterSplitTokenizeTest.java | 75 ---
.../camel/parser/java/SimpleProcessorTest.java | 45 --
.../camel/parser/java/SplitTokenizeTest.java | 126 ----
.../parser/xml/FindElementInRoutesTest.java | 45 --
.../parser/xml/XmlOnExceptionRouteTest.java | 55 --
.../apache/camel/parser/xml/XmlRouteTest.java | 51 --
.../src/test/resources/log4j2.properties | 30 -
.../camel/parser/xml/mycamel-onexception.xml | 33 -
.../org/apache/camel/parser/xml/mycamel.xml | 26 -
.../org/apache/camel/parser/xml/myroutes.xml | 19 -
120 files changed, 5159 insertions(+), 5149 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index 839ba04..66d9c53 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -2166,6 +2166,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-commands-spring-boot</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-route-parser</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index 3717e70..d5146b4 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -280,6 +280,7 @@
<include>org.apache.camel:camel-commands-jolokia</include>
<include>org.apache.camel:camel-commands-spring-boot</include>
<include>org.apache.camel.karaf:camel-karaf-commands</include>
+ <include>org.apache.camel:camel-route-parser</include>
</includes>
</dependencySet>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 0ea685f..aba4928 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1990,6 +1990,11 @@
<artifactId>camel-karaf-commands</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-route-parser</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- camel misc -->
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/pom.xml b/tooling/camel-route-parser/pom.xml
new file mode 100644
index 0000000..f042fca
--- /dev/null
+++ b/tooling/camel-route-parser/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>tooling</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-route-parser</artifactId>
+ <name>Camel :: Tooling :: Camel Route Parser</name>
+ <description>Java and XML source code parser for Camel routes</description>
+
+ <dependencies>
+
+ <!-- the roaster-jdt is set as provided as different runtimes may have it out of the box -->
+ <dependency>
+ <groupId>org.jboss.forge.roaster</groupId>
+ <artifactId>roaster-jdt</artifactId>
+ <version>${roaster-version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- only test scopes for camel as we have no runtime dependency on camel -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cdi</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-cdi</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/ParserResult.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
new file mode 100644
index 0000000..4ef2fc4
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+/**
+ * Result of parsing Camel RouteBuilder or XML routes from the source code.
+ */
+public class ParserResult {
+
+ private final String node;
+ private boolean parsed;
+ private int position;
+ private String element;
+
+ public ParserResult(String node, int position, String element) {
+ this(node, position, element, true);
+ }
+
+ public ParserResult(String node, int position, String element, boolean parsed) {
+ this.node = node;
+ this.position = position;
+ this.element = element;
+ this.parsed = parsed;
+ }
+
+ /**
+ * Character based position in the source code (not line based).
+ */
+ public int getPosition() {
+ return position;
+ }
+
+ /**
+ * The element such as a Camel endpoint uri
+ */
+ public String getElement() {
+ return element;
+ }
+
+ /**
+ * Whether the element was successfully parsed. If the parser cannot parse
+ * the element for whatever reason this will return <tt>false</tt>.
+ */
+ public boolean isParsed() {
+ return parsed;
+ }
+
+ /**
+ * The node which is typically a Camel EIP name such as <tt>to</tt>, <tt>wireTap</tt> etc.
+ */
+ public String getNode() {
+ return node;
+ }
+
+ public String toString() {
+ return element;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
new file mode 100644
index 0000000..36fc443
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
@@ -0,0 +1,310 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.apache.camel.parser.model.CamelSimpleExpressionDetails;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Expression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MemberValuePair;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SingleMemberAnnotation;
+import org.jboss.forge.roaster.model.Annotation;
+import org.jboss.forge.roaster.model.source.FieldSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.jboss.forge.roaster.model.util.Strings;
+
+/**
+ * A Camel RouteBuilder parser that parses Camel Java routes source code.
+ * <p/>
+ * This implementation is higher level details, and uses the lower level parser {@link CamelJavaParserHelper}.
+ */
+public final class RouteBuilderParser {
+
+ private RouteBuilderParser() {
+ }
+
+ /**
+ * Parses the java source class to discover Camel endpoints.
+ *
+ * @param clazz the java source class
+ * @param baseDir the base of the source code
+ * @param fullyQualifiedFileName the fully qualified source code file name
+ * @param endpoints list to add discovered and parsed endpoints
+ */
+ public static void parseRouteBuilderEndpoints(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
+ List<CamelEndpointDetails> endpoints) {
+ parseRouteBuilderEndpoints(clazz, baseDir, fullyQualifiedFileName, endpoints, null, false);
+ }
+
+ /**
+ * Parses the java source class to discover Camel endpoints.
+ *
+ * @param clazz the java source class
+ * @param baseDir the base of the source code
+ * @param fullyQualifiedFileName the fully qualified source code file name
+ * @param endpoints list to add discovered and parsed endpoints
+ * @param unparsable list of unparsable nodes
+ * @param includeInlinedRouteBuilders whether to include inlined route builders in the parsing
+ */
+ public static void parseRouteBuilderEndpoints(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
+ List<CamelEndpointDetails> endpoints, List<String> unparsable, boolean includeInlinedRouteBuilders) {
+
+ // look for fields which are not used in the route
+ for (FieldSource<JavaClassSource> field : clazz.getFields()) {
+
+ // is the field annotated with a Camel endpoint
+ String uri = null;
+ Expression exp = null;
+ for (Annotation ann : field.getAnnotations()) {
+ boolean valid = "org.apache.camel.EndpointInject".equals(ann.getQualifiedName()) || "org.apache.camel.cdi.Uri".equals(ann.getQualifiedName());
+ if (valid) {
+ exp = (Expression) ann.getInternal();
+ if (exp instanceof SingleMemberAnnotation) {
+ exp = ((SingleMemberAnnotation) exp).getValue();
+ } else if (exp instanceof NormalAnnotation) {
+ List values = ((NormalAnnotation) exp).values();
+ for (Object value : values) {
+ MemberValuePair pair = (MemberValuePair) value;
+ if ("uri".equals(pair.getName().toString())) {
+ exp = pair.getValue();
+ break;
+ }
+ }
+ }
+ uri = CamelJavaParserHelper.getLiteralValue(clazz, null, exp);
+ }
+ }
+
+ // we only want to add fields which are not used in the route
+ if (!Strings.isBlank(uri) && findEndpointByUri(endpoints, uri) == null) {
+
+ // we only want the relative dir name from the
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+ String id = field.getName();
+
+ CamelEndpointDetails detail = new CamelEndpointDetails();
+ detail.setFileName(fileName);
+ detail.setClassName(clazz.getQualifiedName());
+ detail.setEndpointInstance(id);
+ detail.setEndpointUri(uri);
+ detail.setEndpointComponentName(endpointComponentName(uri));
+
+ // favor the position of the expression which had the actual uri
+ Object internal = exp != null ? exp : field.getInternal();
+
+ // find position of field/expression
+ if (internal instanceof ASTNode) {
+ int pos = ((ASTNode) internal).getStartPosition();
+ int line = findLineNumber(fullyQualifiedFileName, pos);
+ if (line > -1) {
+ detail.setLineNumber("" + line);
+ }
+ }
+ // we do not know if this field is used as consumer or producer only, but we try
+ // to find out by scanning the route in the configure method below
+ endpoints.add(detail);
+ }
+ }
+
+ // find all the configure methods
+ List<MethodSource<JavaClassSource>> methods = new ArrayList<>();
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+ if (method != null) {
+ methods.add(method);
+ }
+ if (includeInlinedRouteBuilders) {
+ List<MethodSource<JavaClassSource>> inlinedMethods = CamelJavaParserHelper.findInlinedConfigureMethods(clazz);
+ if (!inlinedMethods.isEmpty()) {
+ methods.addAll(inlinedMethods);
+ }
+ }
+
+ // look if any of these fields are used in the route only as consumer or producer, as then we can
+ // determine this to ensure when we edit the endpoint we should only the options accordingly
+ for (MethodSource<JavaClassSource> configureMethod : methods) {
+ // consumers only
+ List<ParserResult> uris = CamelJavaParserHelper.parseCamelConsumerUris(configureMethod, true, true);
+ for (ParserResult result : uris) {
+ if (!result.isParsed()) {
+ if (unparsable != null) {
+ unparsable.add(result.getElement());
+ }
+ } else {
+ CamelEndpointDetails detail = findEndpointByUri(endpoints, result.getElement());
+ if (detail != null) {
+ // its a consumer only
+ detail.setConsumerOnly(true);
+ } else {
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+
+ detail = new CamelEndpointDetails();
+ detail.setFileName(fileName);
+ detail.setClassName(clazz.getQualifiedName());
+ detail.setMethodName(configureMethod.getName());
+ detail.setEndpointInstance(null);
+ detail.setEndpointUri(result.getElement());
+ int line = findLineNumber(fullyQualifiedFileName, result.getPosition());
+ if (line > -1) {
+ detail.setLineNumber("" + line);
+ }
+ detail.setEndpointComponentName(endpointComponentName(result.getElement()));
+ detail.setConsumerOnly(true);
+ detail.setProducerOnly(false);
+ endpoints.add(detail);
+ }
+ }
+ }
+ // producer only
+ uris = CamelJavaParserHelper.parseCamelProducerUris(configureMethod, true, true);
+ for (ParserResult result : uris) {
+ if (!result.isParsed()) {
+ if (unparsable != null) {
+ unparsable.add(result.getElement());
+ }
+ } else {
+ CamelEndpointDetails detail = findEndpointByUri(endpoints, result.getElement());
+ if (detail != null) {
+ if (detail.isConsumerOnly()) {
+ // its both a consumer and producer
+ detail.setConsumerOnly(false);
+ detail.setProducerOnly(false);
+ } else {
+ // its a producer only
+ detail.setProducerOnly(true);
+ }
+ }
+ // the same endpoint uri may be used in multiple places in the same route
+ // so we should maybe add all of them
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+
+ detail = new CamelEndpointDetails();
+ detail.setFileName(fileName);
+ detail.setClassName(clazz.getQualifiedName());
+ detail.setMethodName(configureMethod.getName());
+ detail.setEndpointInstance(null);
+ detail.setEndpointUri(result.getElement());
+ int line = findLineNumber(fullyQualifiedFileName, result.getPosition());
+ if (line > -1) {
+ detail.setLineNumber("" + line);
+ }
+ detail.setEndpointComponentName(endpointComponentName(result.getElement()));
+ detail.setConsumerOnly(false);
+ detail.setProducerOnly(true);
+ endpoints.add(detail);
+ }
+ }
+ }
+ }
+
+ /**
+ * Parses the java source class to discover Camel simple expressions.
+ *
+ * @param clazz the java source class
+ * @param baseDir the base of the source code
+ * @param fullyQualifiedFileName the fully qualified source code file name
+ * @param simpleExpressions list to add discovered and parsed simple expressions
+ */
+ public static void parseRouteBuilderSimpleExpressions(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
+ List<CamelSimpleExpressionDetails> simpleExpressions) {
+
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+ if (method != null) {
+ List<ParserResult> expressions = CamelJavaParserHelper.parseCamelSimpleExpressions(method);
+ for (ParserResult result : expressions) {
+ if (result.isParsed()) {
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+
+ CamelSimpleExpressionDetails details = new CamelSimpleExpressionDetails();
+ details.setFileName(fileName);
+ details.setClassName(clazz.getQualifiedName());
+ details.setMethodName("configure");
+ int line = findLineNumber(fullyQualifiedFileName, result.getPosition());
+ if (line > -1) {
+ details.setLineNumber("" + line);
+ }
+ details.setSimple(result.getElement());
+
+ simpleExpressions.add(details);
+ }
+ }
+ }
+ }
+
+ private static CamelEndpointDetails findEndpointByUri(List<CamelEndpointDetails> endpoints, String uri) {
+ for (CamelEndpointDetails detail : endpoints) {
+ if (uri.equals(detail.getEndpointUri())) {
+ return detail;
+ }
+ }
+ return null;
+ }
+
+ private static int findLineNumber(String fullyQualifiedFileName, int position) {
+ int lines = 0;
+
+ try {
+ int current = 0;
+ try (BufferedReader br = new BufferedReader(new FileReader(new File(fullyQualifiedFileName)))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ lines++;
+ current += line.length() + 1; // add 1 for line feed
+ if (current >= position) {
+ return lines;
+ }
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ return -1;
+ }
+
+ return lines;
+ }
+
+ private static String endpointComponentName(String uri) {
+ if (uri != null) {
+ int idx = uri.indexOf(":");
+ if (idx > 0) {
+ return uri.substring(0, idx);
+ }
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
new file mode 100644
index 0000000..2cca9df
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
@@ -0,0 +1,169 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelXmlHelper;
+import org.apache.camel.parser.helper.XmlLineNumberParser;
+
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.apache.camel.parser.model.CamelSimpleExpressionDetails;
+import org.jboss.forge.roaster.model.util.Strings;
+
+import static org.apache.camel.parser.helper.CamelXmlHelper.getSafeAttribute;
+
+/**
+ * A Camel XML parser that parses Camel XML routes source code.
+ * <p/>
+ * This implementation is higher level details, and uses the lower level parser {@link CamelJavaParserHelper}.
+ */
+public final class XmlRouteParser {
+
+ private XmlRouteParser() {
+ }
+
+ /**
+ * Parses the XML source to discover Camel endpoints.
+ *
+ * @param xml the xml file as input stream
+ * @param baseDir the base of the source code
+ * @param fullyQualifiedFileName the fully qualified source code file name
+ * @param endpoints list to add discovered and parsed endpoints
+ */
+ public static void parseXmlRouteEndpoints(InputStream xml, String baseDir, String fullyQualifiedFileName,
+ List<CamelEndpointDetails> endpoints) throws Exception {
+
+ // find all the endpoints (currently only <endpoint> and within <route>)
+ // try parse it as dom
+ Document dom = null;
+ try {
+ dom = XmlLineNumberParser.parseXml(xml);
+ } catch (Exception e) {
+ // ignore as the xml file may not be valid at this point
+ }
+ if (dom != null) {
+ List<Node> nodes = CamelXmlHelper.findAllEndpoints(dom);
+ for (Node node : nodes) {
+ String uri = getSafeAttribute(node, "uri");
+ if (uri != null) {
+ // trim and remove whitespace noise
+ uri = trimEndpointUri(uri);
+ }
+ if (!Strings.isBlank(uri)) {
+ String id = getSafeAttribute(node, "id");
+ String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
+ String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
+
+ // we only want the relative dir name from the resource directory, eg META-INF/spring/foo.xml
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+
+ boolean consumerOnly = false;
+ boolean producerOnly = false;
+ String nodeName = node.getNodeName();
+ if ("from".equals(nodeName) || "pollEnrich".equals(nodeName)) {
+ consumerOnly = true;
+ } else if ("to".equals(nodeName) || "enrich".equals(nodeName) || "wireTap".equals(nodeName)) {
+ producerOnly = true;
+ }
+
+ CamelEndpointDetails detail = new CamelEndpointDetails();
+ detail.setFileName(fileName);
+ detail.setLineNumber(lineNumber);
+ detail.setLineNumberEnd(lineNumberEnd);
+ detail.setEndpointInstance(id);
+ detail.setEndpointUri(uri);
+ detail.setEndpointComponentName(endpointComponentName(uri));
+ detail.setConsumerOnly(consumerOnly);
+ detail.setProducerOnly(producerOnly);
+ endpoints.add(detail);
+ }
+ }
+ }
+ }
+
+ /**
+ * Parses the XML source to discover Camel endpoints.
+ *
+ * @param xml the xml file as input stream
+ * @param baseDir the base of the source code
+ * @param fullyQualifiedFileName the fully qualified source code file name
+ * @param simpleExpressions list to add discovered and parsed simple expressions
+ */
+ public static void parseXmlRouteSimpleExpressions(InputStream xml, String baseDir, String fullyQualifiedFileName,
+ List<CamelSimpleExpressionDetails> simpleExpressions) throws Exception {
+
+ // find all the simple expressions
+ // try parse it as dom
+ Document dom = null;
+ try {
+ dom = XmlLineNumberParser.parseXml(xml);
+ } catch (Exception e) {
+ // ignore as the xml file may not be valid at this point
+ }
+ if (dom != null) {
+ List<Node> nodes = CamelXmlHelper.findAllSimpleExpressions(dom);
+ for (Node node : nodes) {
+ String simple = node.getTextContent();
+ String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
+ String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
+
+ // we only want the relative dir name from the resource directory, eg META-INF/spring/foo.xml
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+
+ CamelSimpleExpressionDetails detail = new CamelSimpleExpressionDetails();
+ detail.setFileName(fileName);
+ detail.setLineNumber(lineNumber);
+ detail.setLineNumberEnd(lineNumberEnd);
+ detail.setSimple(simple);
+ simpleExpressions.add(detail);
+ }
+ }
+ }
+
+ private static String endpointComponentName(String uri) {
+ if (uri != null) {
+ int idx = uri.indexOf(":");
+ if (idx > 0) {
+ return uri.substring(0, idx);
+ }
+ }
+ return null;
+ }
+
+
+ private static String trimEndpointUri(String uri) {
+ uri = uri.trim();
+ // if the uri is using new-lines then remove whitespace noise before & and ? separator
+ uri = uri.replaceAll("(\\s+)(\\&)", "$2");
+ uri = uri.replaceAll("(\\&)(\\s+)", "$1");
+ uri = uri.replaceAll("(\\?)(\\s+)", "$1");
+ return uri;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
new file mode 100644
index 0000000..6df709a
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
@@ -0,0 +1,638 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.helper;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.roaster.AnonymousMethodSource;
+import org.apache.camel.parser.roaster.StatementFieldSource;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Block;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.BooleanLiteral;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ClassInstanceCreation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Expression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ExpressionStatement;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.FieldDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.InfixExpression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MemberValuePair;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodInvocation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NumberLiteral;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ParenthesizedExpression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.QualifiedName;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ReturnStatement;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleName;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleType;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SingleMemberAnnotation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Statement;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.StringLiteral;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Type;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclarationStatement;
+import org.jboss.forge.roaster.model.Annotation;
+import org.jboss.forge.roaster.model.source.AnnotationSource;
+import org.jboss.forge.roaster.model.source.FieldSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.jboss.forge.roaster.model.util.Strings;
+
+/**
+ * A Camel Java parser that only depends on the Roaster API.
+ * <p/>
+ * This implementation is lower level details. For a higher level parser see {@link RouteBuilderParser}.
+ */
+public final class CamelJavaParserHelper {
+
+ private CamelJavaParserHelper() {
+ // utility class
+ }
+
+ public static MethodSource<JavaClassSource> findConfigureMethod(JavaClassSource clazz) {
+ MethodSource<JavaClassSource> method = clazz.getMethod("configure");
+ // must be public void configure()
+ if (method != null && method.isPublic() && method.getParameters().isEmpty() && method.getReturnType().isType("void")) {
+ return method;
+ }
+
+ // maybe the route builder is from unit testing with camel-test as an anonymous inner class
+ // there is a bit of code to dig out this using the eclipse jdt api
+ method = findCreateRouteBuilderMethod(clazz);
+ if (method != null) {
+ return findConfigureMethodInCreateRouteBuilder(clazz, method);
+ }
+
+ return null;
+ }
+
+ public static List<MethodSource<JavaClassSource>> findInlinedConfigureMethods(JavaClassSource clazz) {
+ List<MethodSource<JavaClassSource>> answer = new ArrayList<>();
+
+ List<MethodSource<JavaClassSource>> methods = clazz.getMethods();
+ if (methods != null) {
+ for (MethodSource<JavaClassSource> method : methods) {
+ if (method.isPublic()
+ && (method.getParameters() == null || method.getParameters().isEmpty())
+ && (method.getReturnType() == null || method.getReturnType().isType("void"))) {
+ // maybe the method contains an inlined createRouteBuilder usually from an unit test method
+ MethodSource<JavaClassSource> builder = findConfigureMethodInCreateRouteBuilder(clazz, method);
+ if (builder != null) {
+ answer.add(builder);
+ }
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ private static MethodSource<JavaClassSource> findCreateRouteBuilderMethod(JavaClassSource clazz) {
+ MethodSource method = clazz.getMethod("createRouteBuilder");
+ if (method != null && (method.isPublic() || method.isProtected()) && method.getParameters().isEmpty()) {
+ return method;
+ }
+ return null;
+ }
+
+ private static MethodSource<JavaClassSource> findConfigureMethodInCreateRouteBuilder(JavaClassSource clazz, MethodSource<JavaClassSource> method) {
+ // find configure inside the code
+ MethodDeclaration md = (MethodDeclaration) method.getInternal();
+ Block block = md.getBody();
+ if (block != null) {
+ List statements = block.statements();
+ for (int i = 0; i < statements.size(); i++) {
+ Statement stmt = (Statement) statements.get(i);
+ Expression exp = null;
+ if (stmt instanceof ReturnStatement) {
+ ReturnStatement rs = (ReturnStatement) stmt;
+ exp = rs.getExpression();
+ } else if (stmt instanceof ExpressionStatement) {
+ ExpressionStatement es = (ExpressionStatement) stmt;
+ exp = es.getExpression();
+ if (exp instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) exp;
+ for (Object arg : mi.arguments()) {
+ if (arg instanceof ClassInstanceCreation) {
+ exp = (Expression) arg;
+ break;
+ }
+ }
+ }
+ }
+ if (exp != null && exp instanceof ClassInstanceCreation) {
+ ClassInstanceCreation cic = (ClassInstanceCreation) exp;
+ boolean isRouteBuilder = false;
+ if (cic.getType() instanceof SimpleType) {
+ SimpleType st = (SimpleType) cic.getType();
+ isRouteBuilder = "RouteBuilder".equals(st.getName().toString());
+ }
+ if (isRouteBuilder && cic.getAnonymousClassDeclaration() != null) {
+ List body = cic.getAnonymousClassDeclaration().bodyDeclarations();
+ for (int j = 0; j < body.size(); j++) {
+ Object line = body.get(j);
+ if (line instanceof MethodDeclaration) {
+ MethodDeclaration amd = (MethodDeclaration) line;
+ if ("configure".equals(amd.getName().toString())) {
+ return new AnonymousMethodSource(clazz, amd);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static List<ParserResult> parseCamelConsumerUris(MethodSource<JavaClassSource> method, boolean strings, boolean fields) {
+ return doParseCamelUris(method, true, false, strings, fields);
+ }
+
+ public static List<ParserResult> parseCamelProducerUris(MethodSource<JavaClassSource> method, boolean strings, boolean fields) {
+ return doParseCamelUris(method, false, true, strings, fields);
+ }
+
+ private static List<ParserResult> doParseCamelUris(MethodSource<JavaClassSource> method, boolean consumers, boolean producers,
+ boolean strings, boolean fields) {
+
+ List<ParserResult> answer = new ArrayList<ParserResult>();
+
+ if (method != null) {
+ MethodDeclaration md = (MethodDeclaration) method.getInternal();
+ Block block = md.getBody();
+ if (block != null) {
+ for (Object statement : md.getBody().statements()) {
+ // must be a method call expression
+ if (statement instanceof ExpressionStatement) {
+ ExpressionStatement es = (ExpressionStatement) statement;
+ Expression exp = es.getExpression();
+
+ List<ParserResult> uris = new ArrayList<ParserResult>();
+ parseExpression(method.getOrigin(), block, exp, uris, consumers, producers, strings, fields);
+ if (!uris.isEmpty()) {
+ // reverse the order as we will grab them from last->first
+ Collections.reverse(uris);
+ answer.addAll(uris);
+ }
+ }
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ private static void parseExpression(JavaClassSource clazz, Block block, Expression exp, List<ParserResult> uris,
+ boolean consumers, boolean producers, boolean strings, boolean fields) {
+ if (exp == null) {
+ return;
+ }
+ if (exp instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) exp;
+ doParseCamelUris(clazz, block, mi, uris, consumers, producers, strings, fields);
+ // if the method was called on another method, then recursive
+ exp = mi.getExpression();
+ parseExpression(clazz, block, exp, uris, consumers, producers, strings, fields);
+ }
+ }
+
+ private static void doParseCamelUris(JavaClassSource clazz, Block block, MethodInvocation mi, List<ParserResult> uris,
+ boolean consumers, boolean producers, boolean strings, boolean fields) {
+ String name = mi.getName().getIdentifier();
+
+ if (consumers) {
+ if ("from".equals(name)) {
+ List args = mi.arguments();
+ if (args != null) {
+ for (Object arg : args) {
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+ if ("fromF".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ if ("pollEnrich".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+
+ if (producers) {
+ if ("to".equals(name) || "toD".equals(name)) {
+ List args = mi.arguments();
+ if (args != null) {
+ for (Object arg : args) {
+ // skip if the arg is a boolean, ExchangePattern or Iterateable, type
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+ if ("toF".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ if ("enrich".equals(name) || "wireTap".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+ }
+
+ private static boolean isValidArgument(String node, Object arg) {
+ // skip boolean argument, as toD can accept a boolean value
+ if (arg instanceof BooleanLiteral) {
+ return false;
+ }
+ // skip ExchangePattern argument
+ if (arg instanceof QualifiedName) {
+ QualifiedName qn = (QualifiedName) arg;
+ String name = qn.getFullyQualifiedName();
+ if (name.startsWith("ExchangePattern")) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static void extractEndpointUriFromArgument(String node, JavaClassSource clazz, Block block, List<ParserResult> uris, Object arg, boolean strings, boolean fields) {
+ if (strings) {
+ String uri = getLiteralValue(clazz, block, (Expression) arg);
+ if (!Strings.isBlank(uri)) {
+ int position = ((Expression) arg).getStartPosition();
+
+ // if the node is fromF or toF, then replace all %s with {{%s}} as we cannot parse that value
+ if ("fromF".equals(node) || "toF".equals(node)) {
+ uri = uri.replaceAll("\\%s", "\\{\\{\\%s\\}\\}");
+ }
+
+ uris.add(new ParserResult(node, position, uri));
+ return;
+ }
+ }
+ if (fields && arg instanceof SimpleName) {
+ FieldSource field = getField(clazz, block, (SimpleName) arg);
+ if (field != null) {
+ // find the endpoint uri from the annotation
+ AnnotationSource annotation = field.getAnnotation("org.apache.camel.cdi.Uri");
+ if (annotation == null) {
+ annotation = field.getAnnotation("org.apache.camel.EndpointInject");
+ }
+ if (annotation != null) {
+ Expression exp = (Expression) annotation.getInternal();
+ if (exp instanceof SingleMemberAnnotation) {
+ exp = ((SingleMemberAnnotation) exp).getValue();
+ } else if (exp instanceof NormalAnnotation) {
+ List values = ((NormalAnnotation) exp).values();
+ for (Object value : values) {
+ MemberValuePair pair = (MemberValuePair) value;
+ if ("uri".equals(pair.getName().toString())) {
+ exp = pair.getValue();
+ break;
+ }
+ }
+ }
+ String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
+ if (!Strings.isBlank(uri)) {
+ int position = ((SimpleName) arg).getStartPosition();
+ uris.add(new ParserResult(node, position, uri));
+ }
+ } else {
+ // the field may be initialized using variables, so we need to evaluate those expressions
+ Object fi = field.getInternal();
+ if (fi instanceof VariableDeclaration) {
+ Expression exp = ((VariableDeclaration) fi).getInitializer();
+ String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
+ if (!Strings.isBlank(uri)) {
+ // we want the position of the field, and not in the route
+ int position = ((VariableDeclaration) fi).getStartPosition();
+ uris.add(new ParserResult(node, position, uri));
+ }
+ }
+ }
+ }
+ }
+
+ // cannot parse it so add a failure
+ uris.add(new ParserResult(node, -1, arg.toString(), false));
+ }
+
+ public static List<ParserResult> parseCamelSimpleExpressions(MethodSource<JavaClassSource> method) {
+ List<ParserResult> answer = new ArrayList<ParserResult>();
+
+ MethodDeclaration md = (MethodDeclaration) method.getInternal();
+ Block block = md.getBody();
+ if (block != null) {
+ for (Object statement : block.statements()) {
+ // must be a method call expression
+ if (statement instanceof ExpressionStatement) {
+ ExpressionStatement es = (ExpressionStatement) statement;
+ Expression exp = es.getExpression();
+
+ List<ParserResult> expressions = new ArrayList<ParserResult>();
+ parseExpression(null, method.getOrigin(), block, exp, expressions);
+ if (!expressions.isEmpty()) {
+ // reverse the order as we will grab them from last->first
+ Collections.reverse(expressions);
+ answer.addAll(expressions);
+ }
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ private static void parseExpression(String node, JavaClassSource clazz, Block block, Expression exp, List<ParserResult> expressions) {
+ if (exp == null) {
+ return;
+ }
+ if (exp instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) exp;
+ doParseCamelSimple(node, clazz, block, mi, expressions);
+ // if the method was called on another method, then recursive
+ exp = mi.getExpression();
+ parseExpression(node, clazz, block, exp, expressions);
+ }
+ }
+
+ private static void doParseCamelSimple(String node, JavaClassSource clazz, Block block, MethodInvocation mi, List<ParserResult> expressions) {
+ String name = mi.getName().getIdentifier();
+
+ if ("simple".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is a string parameter for the simple expression
+ if (args != null && args.size() >= 1) {
+ // it is a String type
+ Object arg = args.get(0);
+ String simple = getLiteralValue(clazz, block, (Expression) arg);
+ if (!Strings.isBlank(simple)) {
+ int position = ((Expression) arg).getStartPosition();
+ expressions.add(new ParserResult(node, position, simple));
+ }
+ }
+ }
+
+ // simple maybe be passed in as an argument
+ List args = mi.arguments();
+ if (args != null) {
+ for (Object arg : args) {
+ if (arg instanceof MethodInvocation) {
+ MethodInvocation ami = (MethodInvocation) arg;
+ doParseCamelSimple(node, clazz, block, ami, expressions);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static FieldSource<JavaClassSource> getField(JavaClassSource clazz, Block block, SimpleName ref) {
+ String fieldName = ref.getIdentifier();
+ if (fieldName != null) {
+ // find field in class
+ FieldSource field = clazz != null ? clazz.getField(fieldName) : null;
+ if (field == null) {
+ field = findFieldInBlock(clazz, block, fieldName);
+ }
+ return field;
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static FieldSource<JavaClassSource> findFieldInBlock(JavaClassSource clazz, Block block, String fieldName) {
+ for (Object statement : block.statements()) {
+ // try local statements first in the block
+ if (statement instanceof VariableDeclarationStatement) {
+ final Type type = ((VariableDeclarationStatement) statement).getType();
+ for (Object obj : ((VariableDeclarationStatement) statement).fragments()) {
+ if (obj instanceof VariableDeclarationFragment) {
+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
+ SimpleName name = fragment.getName();
+ if (name != null && fieldName.equals(name.getIdentifier())) {
+ return new StatementFieldSource(clazz, fragment, type);
+ }
+ }
+ }
+ }
+
+ // okay the field may be burried inside an anonymous inner class as a field declaration
+ // outside the configure method, so lets go back to the parent and see what we can find
+ ASTNode node = block.getParent();
+ if (node instanceof MethodDeclaration) {
+ node = node.getParent();
+ }
+ if (node instanceof AnonymousClassDeclaration) {
+ List declarations = ((AnonymousClassDeclaration) node).bodyDeclarations();
+ for (Object dec : declarations) {
+ if (dec instanceof FieldDeclaration) {
+ FieldDeclaration fd = (FieldDeclaration) dec;
+ final Type type = fd.getType();
+ for (Object obj : fd.fragments()) {
+ if (obj instanceof VariableDeclarationFragment) {
+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
+ SimpleName name = fragment.getName();
+ if (name != null && fieldName.equals(name.getIdentifier())) {
+ return new StatementFieldSource(clazz, fragment, type);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static String getLiteralValue(JavaClassSource clazz, Block block, Expression expression) {
+ // unwrap parenthesis
+ if (expression instanceof ParenthesizedExpression) {
+ expression = ((ParenthesizedExpression) expression).getExpression();
+ }
+
+ if (expression instanceof StringLiteral) {
+ return ((StringLiteral) expression).getLiteralValue();
+ } else if (expression instanceof BooleanLiteral) {
+ return "" + ((BooleanLiteral) expression).booleanValue();
+ } else if (expression instanceof NumberLiteral) {
+ return ((NumberLiteral) expression).getToken();
+ }
+
+ // if it a method invocation then add a dummy value assuming the method invocation will return a valid response
+ if (expression instanceof MethodInvocation) {
+ String name = ((MethodInvocation) expression).getName().getIdentifier();
+ return "{{" + name + "}}";
+ }
+
+ // if its a qualified name (usually a constant field in another class)
+ // then add a dummy value as we cannot find the field value in other classes and maybe even outside the
+ // source code we have access to
+ if (expression instanceof QualifiedName) {
+ QualifiedName qn = (QualifiedName) expression;
+ String name = qn.getFullyQualifiedName();
+ return "{{" + name + "}}";
+ }
+
+ if (expression instanceof SimpleName) {
+ FieldSource<JavaClassSource> field = getField(clazz, block, (SimpleName) expression);
+ if (field != null) {
+ // is the field annotated with a Camel endpoint
+ if (field.getAnnotations() != null) {
+ for (Annotation ann : field.getAnnotations()) {
+ boolean valid = "org.apache.camel.EndpointInject".equals(ann.getQualifiedName()) || "org.apache.camel.cdi.Uri".equals(ann.getQualifiedName());
+ if (valid) {
+ Expression exp = (Expression) ann.getInternal();
+ if (exp instanceof SingleMemberAnnotation) {
+ exp = ((SingleMemberAnnotation) exp).getValue();
+ } else if (exp instanceof NormalAnnotation) {
+ List values = ((NormalAnnotation) exp).values();
+ for (Object value : values) {
+ MemberValuePair pair = (MemberValuePair) value;
+ if ("uri".equals(pair.getName().toString())) {
+ exp = pair.getValue();
+ break;
+ }
+ }
+ }
+ if (exp != null) {
+ return getLiteralValue(clazz, block, exp);
+ }
+ }
+ }
+ }
+ // is the field an org.apache.camel.Endpoint type?
+ if ("Endpoint".equals(field.getType().getSimpleName())) {
+ // then grab the uri from the first argument
+ VariableDeclarationFragment vdf = (VariableDeclarationFragment) field.getInternal();
+ expression = vdf.getInitializer();
+ if (expression instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) expression;
+ List args = mi.arguments();
+ if (args != null && args.size() > 0) {
+ // the first argument has the endpoint uri
+ expression = (Expression) args.get(0);
+ return getLiteralValue(clazz, block, expression);
+ }
+ }
+ } else {
+ // no annotations so try its initializer
+ VariableDeclarationFragment vdf = (VariableDeclarationFragment) field.getInternal();
+ expression = vdf.getInitializer();
+ if (expression == null) {
+ // its a field which has no initializer, then add a dummy value assuming the field will be initialized at runtime
+ return "{{" + field.getName() + "}}";
+ } else {
+ return getLiteralValue(clazz, block, expression);
+ }
+ }
+ } else {
+ // we could not find the field in this class/method, so its maybe from some other super class, so insert a dummy value
+ final String fieldName = ((SimpleName) expression).getIdentifier();
+ return "{{" + fieldName + "}}";
+ }
+ } else if (expression instanceof InfixExpression) {
+ String answer = null;
+ // is it a string that is concat together?
+ InfixExpression ie = (InfixExpression) expression;
+ if (InfixExpression.Operator.PLUS.equals(ie.getOperator())) {
+
+ String val1 = getLiteralValue(clazz, block, ie.getLeftOperand());
+ String val2 = getLiteralValue(clazz, block, ie.getRightOperand());
+
+ // if numeric then we plus the values, otherwise we string concat
+ boolean numeric = isNumericOperator(clazz, block, ie.getLeftOperand()) && isNumericOperator(clazz, block, ie.getRightOperand());
+ if (numeric) {
+ Long num1 = val1 != null ? Long.valueOf(val1) : 0;
+ Long num2 = val2 != null ? Long.valueOf(val2) : 0;
+ answer = "" + (num1 + num2);
+ } else {
+ answer = (val1 != null ? val1 : "") + (val2 != null ? val2 : "");
+ }
+
+ if (!answer.isEmpty()) {
+ // include extended when we concat on 2 or more lines
+ List extended = ie.extendedOperands();
+ if (extended != null) {
+ for (Object ext : extended) {
+ String val3 = getLiteralValue(clazz, block, (Expression) ext);
+ if (numeric) {
+ Long num3 = val3 != null ? Long.valueOf(val3) : 0;
+ Long num = Long.valueOf(answer);
+ answer = "" + (num + num3);
+ } else {
+ answer += val3 != null ? val3 : "";
+ }
+ }
+ }
+ }
+ }
+ return answer;
+ }
+
+ return null;
+ }
+
+ private static boolean isNumericOperator(JavaClassSource clazz, Block block, Expression expression) {
+ if (expression instanceof NumberLiteral) {
+ return true;
+ } else if (expression instanceof SimpleName) {
+ FieldSource field = getField(clazz, block, (SimpleName) expression);
+ if (field != null) {
+ return field.getType().isType("int") || field.getType().isType("long")
+ || field.getType().isType("Integer") || field.getType().isType("Long");
+ }
+ }
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
new file mode 100644
index 0000000..53d4783
--- /dev/null
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
@@ -0,0 +1,268 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.helper;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.jboss.forge.roaster.model.util.Strings;
+
+/**
+ * Various XML helper methods used for parsing XML routes.
+ */
+public final class CamelXmlHelper {
+
+ private CamelXmlHelper() {
+ // utility class
+ }
+
+ public static String getSafeAttribute(Node node, String key) {
+ if (node != null) {
+ Node attr = node.getAttributes().getNamedItem(key);
+ if (attr != null) {
+ return attr.getNodeValue();
+ }
+ }
+ return null;
+ }
+
+ public static List<Node> findAllEndpoints(Document dom) {
+ List<Node> nodes = new ArrayList<>();
+
+ NodeList list = dom.getElementsByTagName("endpoint");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("endpoint".equals(child.getNodeName())) {
+ // it may not be a camel namespace, so skip those
+ String ns = child.getNamespaceURI();
+ if (ns == null) {
+ NamedNodeMap attrs = child.getAttributes();
+ if (attrs != null) {
+ Node node = attrs.getNamedItem("xmlns");
+ if (node != null) {
+ ns = node.getNodeValue();
+ }
+ }
+ }
+ // assume no namespace its for camel
+ if (ns == null || ns.contains("camel")) {
+ nodes.add(child);
+ }
+ }
+ }
+
+ list = dom.getElementsByTagName("onException");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("onCompletion");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("intercept");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("interceptFrom");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("interceptSendToEndpoint");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("rest");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("route".equals(child.getNodeName()) || "to".equals(child.getNodeName())) {
+ findAllUrisRecursive(child, nodes);
+ }
+ }
+ list = dom.getElementsByTagName("route");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("route".equals(child.getNodeName())) {
+ findAllUrisRecursive(child, nodes);
+ }
+ }
+
+ return nodes;
+ }
+
+ private static void findAllUrisRecursive(Node node, List<Node> nodes) {
+ // okay its a route so grab all uri attributes we can find
+ String url = getSafeAttribute(node, "uri");
+ if (url != null) {
+ nodes.add(node);
+ }
+
+ NodeList children = node.getChildNodes();
+ if (children != null) {
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ findAllUrisRecursive(child, nodes);
+ }
+ }
+ }
+ }
+
+ public static List<Node> findAllSimpleExpressions(Document dom) {
+ List<Node> nodes = new ArrayList<>();
+
+ NodeList list = dom.getElementsByTagName("route");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("route".equals(child.getNodeName())) {
+ findAllSimpleExpressionsRecursive(child, nodes);
+ }
+ }
+
+ return nodes;
+ }
+
+ private static void findAllSimpleExpressionsRecursive(Node node, List<Node> nodes) {
+ // okay its a route so grab if its <simple>
+ if ("simple".equals(node.getNodeName())) {
+ nodes.add(node);
+ }
+
+ NodeList children = node.getChildNodes();
+ if (children != null) {
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ findAllSimpleExpressionsRecursive(child, nodes);
+ }
+ }
+ }
+ }
+
+ public static Element getSelectedCamelElementNode(String key, InputStream resourceInputStream) throws Exception {
+ Document root = loadCamelXmlFileAsDom(resourceInputStream);
+ Element selectedElement = null;
+ if (root != null) {
+ Node selectedNode = findCamelNodeInDocument(root, key);
+ if (selectedNode instanceof Element) {
+ selectedElement = (Element) selectedNode;
+ }
+ }
+ return selectedElement;
+ }
+
+ private static Document loadCamelXmlFileAsDom(InputStream resourceInputStream) throws Exception {
+ // must enforce the namespace to be http://camel.apache.org/schema/spring which is what the camel-core JAXB model uses
+ Document root = XmlLineNumberParser.parseXml(resourceInputStream, "camelContext,routes,rests", "http://camel.apache.org/schema/spring");
+ return root;
+ }
+
+ private static Node findCamelNodeInDocument(Document root, String key) {
+ Node selectedNode = null;
+ if (root != null && !Strings.isBlank(key)) {
+ String[] paths = key.split("/");
+ NodeList camels = getCamelContextElements(root);
+ if (camels != null) {
+ Map<String, Integer> rootNodeCounts = new HashMap<>();
+ for (int i = 0, size = camels.getLength(); i < size; i++) {
+ Node node = camels.item(i);
+ boolean first = true;
+ for (String path : paths) {
+ if (first) {
+ first = false;
+ String actual = getIdOrIndex(node, rootNodeCounts);
+ if (!equal(actual, path)) {
+ node = null;
+ }
+ } else {
+ node = findCamelNodeForPath(node, path);
+ }
+ if (node == null) {
+ break;
+ }
+ }
+ if (node != null) {
+ return node;
+ }
+ }
+ }
+ }
+ return selectedNode;
+ }
+
+ private static Node findCamelNodeForPath(Node node, String path) {
+ NodeList childNodes = node.getChildNodes();
+ if (childNodes != null) {
+ Map<String, Integer> nodeCounts = new HashMap<>();
+ for (int i = 0, size = childNodes.getLength(); i < size; i++) {
+ Node child = childNodes.item(i);
+ if (child instanceof Element) {
+ String actual = getIdOrIndex(child, nodeCounts);
+ if (equal(actual, path)) {
+ return child;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private static String getIdOrIndex(Node node, Map<String, Integer> nodeCounts) {
+ String answer = null;
+ if (node instanceof Element) {
+ Element element = (Element) node;
+ String elementName = element.getTagName();
+ if ("routes".equals(elementName)) {
+ elementName = "camelContext";
+ }
+ Integer countObject = nodeCounts.get(elementName);
+ int count = countObject != null ? countObject.intValue() : 0;
+ nodeCounts.put(elementName, ++count);
+ answer = element.getAttribute("id");
+ if (Strings.isBlank(answer)) {
+ answer = "_" + elementName + count;
+ }
+ }
+ return answer;
+ }
+
+ private static NodeList getCamelContextElements(Document dom) {
+ NodeList camels = dom.getElementsByTagName("camelContext");
+ if (camels == null || camels.getLength() == 0) {
+ camels = dom.getElementsByTagName("routes");
+ }
+ return camels;
+ }
+
+ private static boolean equal(Object a, Object b) {
+ return a == b ? true : a != null && b != null && a.equals(b);
+ }
+
+}
[25/25] camel git commit: CAMEL-10559: maven plugin to validate using
the route parser. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: maven plugin to validate using the route parser. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/19e59f35
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/19e59f35
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/19e59f35
Branch: refs/heads/master
Commit: 19e59f35ada3d674a41d746a5e3cf8866c14e3a1
Parents: 7c4b41f
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 14:11:10 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:11:10 2016 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/camel/maven/ValidateMojo.java | 8 ++++++--
.../java/org/apache/camel/maven/helper/EndpointHelper.java | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/19e59f35/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
index c5ed912..2d5594b 100644
--- a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
+++ b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
@@ -162,6 +162,7 @@ public class ValidateMojo extends AbstractExecMojo {
*/
private boolean downloadVersion;
+ // CHECKSTYLE:OFF
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
CamelCatalog catalog = new DefaultCamelCatalog();
@@ -384,10 +385,12 @@ public class ValidateMojo extends AbstractExecMojo {
String endpointSummary;
if (endpointErrors == 0) {
int ok = endpoints.size() - endpointErrors - incapableErrors - unknownComponents;
- endpointSummary = String.format("Endpoint validation success: (%s = passed, %s = invalid, %s = incapable, %s = unknown components)", ok, endpointErrors, incapableErrors, unknownComponents);
+ endpointSummary = String.format("Endpoint validation success: (%s = passed, %s = invalid, %s = incapable, %s = unknown components)",
+ ok, endpointErrors, incapableErrors, unknownComponents);
} else {
int ok = endpoints.size() - endpointErrors - incapableErrors - unknownComponents;
- endpointSummary = String.format("Endpoint validation error: (%s = passed, %s = invalid, %s = incapable, %s = unknown components)", ok, endpointErrors, incapableErrors, unknownComponents);
+ endpointSummary = String.format("Endpoint validation error: (%s = passed, %s = invalid, %s = incapable, %s = unknown components)",
+ ok, endpointErrors, incapableErrors, unknownComponents);
}
if (endpointErrors > 0) {
@@ -484,6 +487,7 @@ public class ValidateMojo extends AbstractExecMojo {
getLog().info(simpleSummary);
}
}
+ // CHECKSTYLE:ON
private static String findCamelVersion(MavenProject project) {
Dependency candidate = null;
http://git-wip-us.apache.org/repos/asf/camel/blob/19e59f35/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/helper/EndpointHelper.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/helper/EndpointHelper.java b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/helper/EndpointHelper.java
index 94bed8c..486c2cf 100644
--- a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/helper/EndpointHelper.java
+++ b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/helper/EndpointHelper.java
@@ -20,6 +20,9 @@ import java.util.regex.PatternSyntaxException;
public final class EndpointHelper {
+ private EndpointHelper() {
+ }
+
/**
* Matches the name with the given pattern.
* <p/>
[15/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
new file mode 100644
index 0000000..6df709a
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelJavaParserHelper.java
@@ -0,0 +1,638 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.helper;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.roaster.AnonymousMethodSource;
+import org.apache.camel.parser.roaster.StatementFieldSource;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Block;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.BooleanLiteral;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ClassInstanceCreation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Expression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ExpressionStatement;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.FieldDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.InfixExpression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MemberValuePair;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodInvocation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NumberLiteral;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ParenthesizedExpression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.QualifiedName;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ReturnStatement;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleName;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleType;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SingleMemberAnnotation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Statement;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.StringLiteral;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Type;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclarationStatement;
+import org.jboss.forge.roaster.model.Annotation;
+import org.jboss.forge.roaster.model.source.AnnotationSource;
+import org.jboss.forge.roaster.model.source.FieldSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.jboss.forge.roaster.model.util.Strings;
+
+/**
+ * A Camel Java parser that only depends on the Roaster API.
+ * <p/>
+ * This implementation is lower level details. For a higher level parser see {@link RouteBuilderParser}.
+ */
+public final class CamelJavaParserHelper {
+
+ private CamelJavaParserHelper() {
+ // utility class
+ }
+
+ public static MethodSource<JavaClassSource> findConfigureMethod(JavaClassSource clazz) {
+ MethodSource<JavaClassSource> method = clazz.getMethod("configure");
+ // must be public void configure()
+ if (method != null && method.isPublic() && method.getParameters().isEmpty() && method.getReturnType().isType("void")) {
+ return method;
+ }
+
+ // maybe the route builder is from unit testing with camel-test as an anonymous inner class
+ // there is a bit of code to dig out this using the eclipse jdt api
+ method = findCreateRouteBuilderMethod(clazz);
+ if (method != null) {
+ return findConfigureMethodInCreateRouteBuilder(clazz, method);
+ }
+
+ return null;
+ }
+
+ public static List<MethodSource<JavaClassSource>> findInlinedConfigureMethods(JavaClassSource clazz) {
+ List<MethodSource<JavaClassSource>> answer = new ArrayList<>();
+
+ List<MethodSource<JavaClassSource>> methods = clazz.getMethods();
+ if (methods != null) {
+ for (MethodSource<JavaClassSource> method : methods) {
+ if (method.isPublic()
+ && (method.getParameters() == null || method.getParameters().isEmpty())
+ && (method.getReturnType() == null || method.getReturnType().isType("void"))) {
+ // maybe the method contains an inlined createRouteBuilder usually from an unit test method
+ MethodSource<JavaClassSource> builder = findConfigureMethodInCreateRouteBuilder(clazz, method);
+ if (builder != null) {
+ answer.add(builder);
+ }
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ private static MethodSource<JavaClassSource> findCreateRouteBuilderMethod(JavaClassSource clazz) {
+ MethodSource method = clazz.getMethod("createRouteBuilder");
+ if (method != null && (method.isPublic() || method.isProtected()) && method.getParameters().isEmpty()) {
+ return method;
+ }
+ return null;
+ }
+
+ private static MethodSource<JavaClassSource> findConfigureMethodInCreateRouteBuilder(JavaClassSource clazz, MethodSource<JavaClassSource> method) {
+ // find configure inside the code
+ MethodDeclaration md = (MethodDeclaration) method.getInternal();
+ Block block = md.getBody();
+ if (block != null) {
+ List statements = block.statements();
+ for (int i = 0; i < statements.size(); i++) {
+ Statement stmt = (Statement) statements.get(i);
+ Expression exp = null;
+ if (stmt instanceof ReturnStatement) {
+ ReturnStatement rs = (ReturnStatement) stmt;
+ exp = rs.getExpression();
+ } else if (stmt instanceof ExpressionStatement) {
+ ExpressionStatement es = (ExpressionStatement) stmt;
+ exp = es.getExpression();
+ if (exp instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) exp;
+ for (Object arg : mi.arguments()) {
+ if (arg instanceof ClassInstanceCreation) {
+ exp = (Expression) arg;
+ break;
+ }
+ }
+ }
+ }
+ if (exp != null && exp instanceof ClassInstanceCreation) {
+ ClassInstanceCreation cic = (ClassInstanceCreation) exp;
+ boolean isRouteBuilder = false;
+ if (cic.getType() instanceof SimpleType) {
+ SimpleType st = (SimpleType) cic.getType();
+ isRouteBuilder = "RouteBuilder".equals(st.getName().toString());
+ }
+ if (isRouteBuilder && cic.getAnonymousClassDeclaration() != null) {
+ List body = cic.getAnonymousClassDeclaration().bodyDeclarations();
+ for (int j = 0; j < body.size(); j++) {
+ Object line = body.get(j);
+ if (line instanceof MethodDeclaration) {
+ MethodDeclaration amd = (MethodDeclaration) line;
+ if ("configure".equals(amd.getName().toString())) {
+ return new AnonymousMethodSource(clazz, amd);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static List<ParserResult> parseCamelConsumerUris(MethodSource<JavaClassSource> method, boolean strings, boolean fields) {
+ return doParseCamelUris(method, true, false, strings, fields);
+ }
+
+ public static List<ParserResult> parseCamelProducerUris(MethodSource<JavaClassSource> method, boolean strings, boolean fields) {
+ return doParseCamelUris(method, false, true, strings, fields);
+ }
+
+ private static List<ParserResult> doParseCamelUris(MethodSource<JavaClassSource> method, boolean consumers, boolean producers,
+ boolean strings, boolean fields) {
+
+ List<ParserResult> answer = new ArrayList<ParserResult>();
+
+ if (method != null) {
+ MethodDeclaration md = (MethodDeclaration) method.getInternal();
+ Block block = md.getBody();
+ if (block != null) {
+ for (Object statement : md.getBody().statements()) {
+ // must be a method call expression
+ if (statement instanceof ExpressionStatement) {
+ ExpressionStatement es = (ExpressionStatement) statement;
+ Expression exp = es.getExpression();
+
+ List<ParserResult> uris = new ArrayList<ParserResult>();
+ parseExpression(method.getOrigin(), block, exp, uris, consumers, producers, strings, fields);
+ if (!uris.isEmpty()) {
+ // reverse the order as we will grab them from last->first
+ Collections.reverse(uris);
+ answer.addAll(uris);
+ }
+ }
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ private static void parseExpression(JavaClassSource clazz, Block block, Expression exp, List<ParserResult> uris,
+ boolean consumers, boolean producers, boolean strings, boolean fields) {
+ if (exp == null) {
+ return;
+ }
+ if (exp instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) exp;
+ doParseCamelUris(clazz, block, mi, uris, consumers, producers, strings, fields);
+ // if the method was called on another method, then recursive
+ exp = mi.getExpression();
+ parseExpression(clazz, block, exp, uris, consumers, producers, strings, fields);
+ }
+ }
+
+ private static void doParseCamelUris(JavaClassSource clazz, Block block, MethodInvocation mi, List<ParserResult> uris,
+ boolean consumers, boolean producers, boolean strings, boolean fields) {
+ String name = mi.getName().getIdentifier();
+
+ if (consumers) {
+ if ("from".equals(name)) {
+ List args = mi.arguments();
+ if (args != null) {
+ for (Object arg : args) {
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+ if ("fromF".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ if ("pollEnrich".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+
+ if (producers) {
+ if ("to".equals(name) || "toD".equals(name)) {
+ List args = mi.arguments();
+ if (args != null) {
+ for (Object arg : args) {
+ // skip if the arg is a boolean, ExchangePattern or Iterateable, type
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+ if ("toF".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ if ("enrich".equals(name) || "wireTap".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+ }
+
+ private static boolean isValidArgument(String node, Object arg) {
+ // skip boolean argument, as toD can accept a boolean value
+ if (arg instanceof BooleanLiteral) {
+ return false;
+ }
+ // skip ExchangePattern argument
+ if (arg instanceof QualifiedName) {
+ QualifiedName qn = (QualifiedName) arg;
+ String name = qn.getFullyQualifiedName();
+ if (name.startsWith("ExchangePattern")) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static void extractEndpointUriFromArgument(String node, JavaClassSource clazz, Block block, List<ParserResult> uris, Object arg, boolean strings, boolean fields) {
+ if (strings) {
+ String uri = getLiteralValue(clazz, block, (Expression) arg);
+ if (!Strings.isBlank(uri)) {
+ int position = ((Expression) arg).getStartPosition();
+
+ // if the node is fromF or toF, then replace all %s with {{%s}} as we cannot parse that value
+ if ("fromF".equals(node) || "toF".equals(node)) {
+ uri = uri.replaceAll("\\%s", "\\{\\{\\%s\\}\\}");
+ }
+
+ uris.add(new ParserResult(node, position, uri));
+ return;
+ }
+ }
+ if (fields && arg instanceof SimpleName) {
+ FieldSource field = getField(clazz, block, (SimpleName) arg);
+ if (field != null) {
+ // find the endpoint uri from the annotation
+ AnnotationSource annotation = field.getAnnotation("org.apache.camel.cdi.Uri");
+ if (annotation == null) {
+ annotation = field.getAnnotation("org.apache.camel.EndpointInject");
+ }
+ if (annotation != null) {
+ Expression exp = (Expression) annotation.getInternal();
+ if (exp instanceof SingleMemberAnnotation) {
+ exp = ((SingleMemberAnnotation) exp).getValue();
+ } else if (exp instanceof NormalAnnotation) {
+ List values = ((NormalAnnotation) exp).values();
+ for (Object value : values) {
+ MemberValuePair pair = (MemberValuePair) value;
+ if ("uri".equals(pair.getName().toString())) {
+ exp = pair.getValue();
+ break;
+ }
+ }
+ }
+ String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
+ if (!Strings.isBlank(uri)) {
+ int position = ((SimpleName) arg).getStartPosition();
+ uris.add(new ParserResult(node, position, uri));
+ }
+ } else {
+ // the field may be initialized using variables, so we need to evaluate those expressions
+ Object fi = field.getInternal();
+ if (fi instanceof VariableDeclaration) {
+ Expression exp = ((VariableDeclaration) fi).getInitializer();
+ String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
+ if (!Strings.isBlank(uri)) {
+ // we want the position of the field, and not in the route
+ int position = ((VariableDeclaration) fi).getStartPosition();
+ uris.add(new ParserResult(node, position, uri));
+ }
+ }
+ }
+ }
+ }
+
+ // cannot parse it so add a failure
+ uris.add(new ParserResult(node, -1, arg.toString(), false));
+ }
+
+ public static List<ParserResult> parseCamelSimpleExpressions(MethodSource<JavaClassSource> method) {
+ List<ParserResult> answer = new ArrayList<ParserResult>();
+
+ MethodDeclaration md = (MethodDeclaration) method.getInternal();
+ Block block = md.getBody();
+ if (block != null) {
+ for (Object statement : block.statements()) {
+ // must be a method call expression
+ if (statement instanceof ExpressionStatement) {
+ ExpressionStatement es = (ExpressionStatement) statement;
+ Expression exp = es.getExpression();
+
+ List<ParserResult> expressions = new ArrayList<ParserResult>();
+ parseExpression(null, method.getOrigin(), block, exp, expressions);
+ if (!expressions.isEmpty()) {
+ // reverse the order as we will grab them from last->first
+ Collections.reverse(expressions);
+ answer.addAll(expressions);
+ }
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ private static void parseExpression(String node, JavaClassSource clazz, Block block, Expression exp, List<ParserResult> expressions) {
+ if (exp == null) {
+ return;
+ }
+ if (exp instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) exp;
+ doParseCamelSimple(node, clazz, block, mi, expressions);
+ // if the method was called on another method, then recursive
+ exp = mi.getExpression();
+ parseExpression(node, clazz, block, exp, expressions);
+ }
+ }
+
+ private static void doParseCamelSimple(String node, JavaClassSource clazz, Block block, MethodInvocation mi, List<ParserResult> expressions) {
+ String name = mi.getName().getIdentifier();
+
+ if ("simple".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is a string parameter for the simple expression
+ if (args != null && args.size() >= 1) {
+ // it is a String type
+ Object arg = args.get(0);
+ String simple = getLiteralValue(clazz, block, (Expression) arg);
+ if (!Strings.isBlank(simple)) {
+ int position = ((Expression) arg).getStartPosition();
+ expressions.add(new ParserResult(node, position, simple));
+ }
+ }
+ }
+
+ // simple maybe be passed in as an argument
+ List args = mi.arguments();
+ if (args != null) {
+ for (Object arg : args) {
+ if (arg instanceof MethodInvocation) {
+ MethodInvocation ami = (MethodInvocation) arg;
+ doParseCamelSimple(node, clazz, block, ami, expressions);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static FieldSource<JavaClassSource> getField(JavaClassSource clazz, Block block, SimpleName ref) {
+ String fieldName = ref.getIdentifier();
+ if (fieldName != null) {
+ // find field in class
+ FieldSource field = clazz != null ? clazz.getField(fieldName) : null;
+ if (field == null) {
+ field = findFieldInBlock(clazz, block, fieldName);
+ }
+ return field;
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static FieldSource<JavaClassSource> findFieldInBlock(JavaClassSource clazz, Block block, String fieldName) {
+ for (Object statement : block.statements()) {
+ // try local statements first in the block
+ if (statement instanceof VariableDeclarationStatement) {
+ final Type type = ((VariableDeclarationStatement) statement).getType();
+ for (Object obj : ((VariableDeclarationStatement) statement).fragments()) {
+ if (obj instanceof VariableDeclarationFragment) {
+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
+ SimpleName name = fragment.getName();
+ if (name != null && fieldName.equals(name.getIdentifier())) {
+ return new StatementFieldSource(clazz, fragment, type);
+ }
+ }
+ }
+ }
+
+ // okay the field may be burried inside an anonymous inner class as a field declaration
+ // outside the configure method, so lets go back to the parent and see what we can find
+ ASTNode node = block.getParent();
+ if (node instanceof MethodDeclaration) {
+ node = node.getParent();
+ }
+ if (node instanceof AnonymousClassDeclaration) {
+ List declarations = ((AnonymousClassDeclaration) node).bodyDeclarations();
+ for (Object dec : declarations) {
+ if (dec instanceof FieldDeclaration) {
+ FieldDeclaration fd = (FieldDeclaration) dec;
+ final Type type = fd.getType();
+ for (Object obj : fd.fragments()) {
+ if (obj instanceof VariableDeclarationFragment) {
+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
+ SimpleName name = fragment.getName();
+ if (name != null && fieldName.equals(name.getIdentifier())) {
+ return new StatementFieldSource(clazz, fragment, type);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static String getLiteralValue(JavaClassSource clazz, Block block, Expression expression) {
+ // unwrap parenthesis
+ if (expression instanceof ParenthesizedExpression) {
+ expression = ((ParenthesizedExpression) expression).getExpression();
+ }
+
+ if (expression instanceof StringLiteral) {
+ return ((StringLiteral) expression).getLiteralValue();
+ } else if (expression instanceof BooleanLiteral) {
+ return "" + ((BooleanLiteral) expression).booleanValue();
+ } else if (expression instanceof NumberLiteral) {
+ return ((NumberLiteral) expression).getToken();
+ }
+
+ // if it a method invocation then add a dummy value assuming the method invocation will return a valid response
+ if (expression instanceof MethodInvocation) {
+ String name = ((MethodInvocation) expression).getName().getIdentifier();
+ return "{{" + name + "}}";
+ }
+
+ // if its a qualified name (usually a constant field in another class)
+ // then add a dummy value as we cannot find the field value in other classes and maybe even outside the
+ // source code we have access to
+ if (expression instanceof QualifiedName) {
+ QualifiedName qn = (QualifiedName) expression;
+ String name = qn.getFullyQualifiedName();
+ return "{{" + name + "}}";
+ }
+
+ if (expression instanceof SimpleName) {
+ FieldSource<JavaClassSource> field = getField(clazz, block, (SimpleName) expression);
+ if (field != null) {
+ // is the field annotated with a Camel endpoint
+ if (field.getAnnotations() != null) {
+ for (Annotation ann : field.getAnnotations()) {
+ boolean valid = "org.apache.camel.EndpointInject".equals(ann.getQualifiedName()) || "org.apache.camel.cdi.Uri".equals(ann.getQualifiedName());
+ if (valid) {
+ Expression exp = (Expression) ann.getInternal();
+ if (exp instanceof SingleMemberAnnotation) {
+ exp = ((SingleMemberAnnotation) exp).getValue();
+ } else if (exp instanceof NormalAnnotation) {
+ List values = ((NormalAnnotation) exp).values();
+ for (Object value : values) {
+ MemberValuePair pair = (MemberValuePair) value;
+ if ("uri".equals(pair.getName().toString())) {
+ exp = pair.getValue();
+ break;
+ }
+ }
+ }
+ if (exp != null) {
+ return getLiteralValue(clazz, block, exp);
+ }
+ }
+ }
+ }
+ // is the field an org.apache.camel.Endpoint type?
+ if ("Endpoint".equals(field.getType().getSimpleName())) {
+ // then grab the uri from the first argument
+ VariableDeclarationFragment vdf = (VariableDeclarationFragment) field.getInternal();
+ expression = vdf.getInitializer();
+ if (expression instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) expression;
+ List args = mi.arguments();
+ if (args != null && args.size() > 0) {
+ // the first argument has the endpoint uri
+ expression = (Expression) args.get(0);
+ return getLiteralValue(clazz, block, expression);
+ }
+ }
+ } else {
+ // no annotations so try its initializer
+ VariableDeclarationFragment vdf = (VariableDeclarationFragment) field.getInternal();
+ expression = vdf.getInitializer();
+ if (expression == null) {
+ // its a field which has no initializer, then add a dummy value assuming the field will be initialized at runtime
+ return "{{" + field.getName() + "}}";
+ } else {
+ return getLiteralValue(clazz, block, expression);
+ }
+ }
+ } else {
+ // we could not find the field in this class/method, so its maybe from some other super class, so insert a dummy value
+ final String fieldName = ((SimpleName) expression).getIdentifier();
+ return "{{" + fieldName + "}}";
+ }
+ } else if (expression instanceof InfixExpression) {
+ String answer = null;
+ // is it a string that is concat together?
+ InfixExpression ie = (InfixExpression) expression;
+ if (InfixExpression.Operator.PLUS.equals(ie.getOperator())) {
+
+ String val1 = getLiteralValue(clazz, block, ie.getLeftOperand());
+ String val2 = getLiteralValue(clazz, block, ie.getRightOperand());
+
+ // if numeric then we plus the values, otherwise we string concat
+ boolean numeric = isNumericOperator(clazz, block, ie.getLeftOperand()) && isNumericOperator(clazz, block, ie.getRightOperand());
+ if (numeric) {
+ Long num1 = val1 != null ? Long.valueOf(val1) : 0;
+ Long num2 = val2 != null ? Long.valueOf(val2) : 0;
+ answer = "" + (num1 + num2);
+ } else {
+ answer = (val1 != null ? val1 : "") + (val2 != null ? val2 : "");
+ }
+
+ if (!answer.isEmpty()) {
+ // include extended when we concat on 2 or more lines
+ List extended = ie.extendedOperands();
+ if (extended != null) {
+ for (Object ext : extended) {
+ String val3 = getLiteralValue(clazz, block, (Expression) ext);
+ if (numeric) {
+ Long num3 = val3 != null ? Long.valueOf(val3) : 0;
+ Long num = Long.valueOf(answer);
+ answer = "" + (num + num3);
+ } else {
+ answer += val3 != null ? val3 : "";
+ }
+ }
+ }
+ }
+ }
+ return answer;
+ }
+
+ return null;
+ }
+
+ private static boolean isNumericOperator(JavaClassSource clazz, Block block, Expression expression) {
+ if (expression instanceof NumberLiteral) {
+ return true;
+ } else if (expression instanceof SimpleName) {
+ FieldSource field = getField(clazz, block, (SimpleName) expression);
+ if (field != null) {
+ return field.getType().isType("int") || field.getType().isType("long")
+ || field.getType().isType("Integer") || field.getType().isType("Long");
+ }
+ }
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
new file mode 100644
index 0000000..53d4783
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/CamelXmlHelper.java
@@ -0,0 +1,268 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.helper;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.jboss.forge.roaster.model.util.Strings;
+
+/**
+ * Various XML helper methods used for parsing XML routes.
+ */
+public final class CamelXmlHelper {
+
+ private CamelXmlHelper() {
+ // utility class
+ }
+
+ public static String getSafeAttribute(Node node, String key) {
+ if (node != null) {
+ Node attr = node.getAttributes().getNamedItem(key);
+ if (attr != null) {
+ return attr.getNodeValue();
+ }
+ }
+ return null;
+ }
+
+ public static List<Node> findAllEndpoints(Document dom) {
+ List<Node> nodes = new ArrayList<>();
+
+ NodeList list = dom.getElementsByTagName("endpoint");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("endpoint".equals(child.getNodeName())) {
+ // it may not be a camel namespace, so skip those
+ String ns = child.getNamespaceURI();
+ if (ns == null) {
+ NamedNodeMap attrs = child.getAttributes();
+ if (attrs != null) {
+ Node node = attrs.getNamedItem("xmlns");
+ if (node != null) {
+ ns = node.getNodeValue();
+ }
+ }
+ }
+ // assume no namespace its for camel
+ if (ns == null || ns.contains("camel")) {
+ nodes.add(child);
+ }
+ }
+ }
+
+ list = dom.getElementsByTagName("onException");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("onCompletion");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("intercept");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("interceptFrom");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("interceptSendToEndpoint");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("rest");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("route".equals(child.getNodeName()) || "to".equals(child.getNodeName())) {
+ findAllUrisRecursive(child, nodes);
+ }
+ }
+ list = dom.getElementsByTagName("route");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("route".equals(child.getNodeName())) {
+ findAllUrisRecursive(child, nodes);
+ }
+ }
+
+ return nodes;
+ }
+
+ private static void findAllUrisRecursive(Node node, List<Node> nodes) {
+ // okay its a route so grab all uri attributes we can find
+ String url = getSafeAttribute(node, "uri");
+ if (url != null) {
+ nodes.add(node);
+ }
+
+ NodeList children = node.getChildNodes();
+ if (children != null) {
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ findAllUrisRecursive(child, nodes);
+ }
+ }
+ }
+ }
+
+ public static List<Node> findAllSimpleExpressions(Document dom) {
+ List<Node> nodes = new ArrayList<>();
+
+ NodeList list = dom.getElementsByTagName("route");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("route".equals(child.getNodeName())) {
+ findAllSimpleExpressionsRecursive(child, nodes);
+ }
+ }
+
+ return nodes;
+ }
+
+ private static void findAllSimpleExpressionsRecursive(Node node, List<Node> nodes) {
+ // okay its a route so grab if its <simple>
+ if ("simple".equals(node.getNodeName())) {
+ nodes.add(node);
+ }
+
+ NodeList children = node.getChildNodes();
+ if (children != null) {
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ findAllSimpleExpressionsRecursive(child, nodes);
+ }
+ }
+ }
+ }
+
+ public static Element getSelectedCamelElementNode(String key, InputStream resourceInputStream) throws Exception {
+ Document root = loadCamelXmlFileAsDom(resourceInputStream);
+ Element selectedElement = null;
+ if (root != null) {
+ Node selectedNode = findCamelNodeInDocument(root, key);
+ if (selectedNode instanceof Element) {
+ selectedElement = (Element) selectedNode;
+ }
+ }
+ return selectedElement;
+ }
+
+ private static Document loadCamelXmlFileAsDom(InputStream resourceInputStream) throws Exception {
+ // must enforce the namespace to be http://camel.apache.org/schema/spring which is what the camel-core JAXB model uses
+ Document root = XmlLineNumberParser.parseXml(resourceInputStream, "camelContext,routes,rests", "http://camel.apache.org/schema/spring");
+ return root;
+ }
+
+ private static Node findCamelNodeInDocument(Document root, String key) {
+ Node selectedNode = null;
+ if (root != null && !Strings.isBlank(key)) {
+ String[] paths = key.split("/");
+ NodeList camels = getCamelContextElements(root);
+ if (camels != null) {
+ Map<String, Integer> rootNodeCounts = new HashMap<>();
+ for (int i = 0, size = camels.getLength(); i < size; i++) {
+ Node node = camels.item(i);
+ boolean first = true;
+ for (String path : paths) {
+ if (first) {
+ first = false;
+ String actual = getIdOrIndex(node, rootNodeCounts);
+ if (!equal(actual, path)) {
+ node = null;
+ }
+ } else {
+ node = findCamelNodeForPath(node, path);
+ }
+ if (node == null) {
+ break;
+ }
+ }
+ if (node != null) {
+ return node;
+ }
+ }
+ }
+ }
+ return selectedNode;
+ }
+
+ private static Node findCamelNodeForPath(Node node, String path) {
+ NodeList childNodes = node.getChildNodes();
+ if (childNodes != null) {
+ Map<String, Integer> nodeCounts = new HashMap<>();
+ for (int i = 0, size = childNodes.getLength(); i < size; i++) {
+ Node child = childNodes.item(i);
+ if (child instanceof Element) {
+ String actual = getIdOrIndex(child, nodeCounts);
+ if (equal(actual, path)) {
+ return child;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private static String getIdOrIndex(Node node, Map<String, Integer> nodeCounts) {
+ String answer = null;
+ if (node instanceof Element) {
+ Element element = (Element) node;
+ String elementName = element.getTagName();
+ if ("routes".equals(elementName)) {
+ elementName = "camelContext";
+ }
+ Integer countObject = nodeCounts.get(elementName);
+ int count = countObject != null ? countObject.intValue() : 0;
+ nodeCounts.put(elementName, ++count);
+ answer = element.getAttribute("id");
+ if (Strings.isBlank(answer)) {
+ answer = "_" + elementName + count;
+ }
+ }
+ return answer;
+ }
+
+ private static NodeList getCamelContextElements(Document dom) {
+ NodeList camels = dom.getElementsByTagName("camelContext");
+ if (camels == null || camels.getLength() == 0) {
+ camels = dom.getElementsByTagName("routes");
+ }
+ return camels;
+ }
+
+ private static boolean equal(Object a, Object b) {
+ return a == b ? true : a != null && b != null && a.equals(b);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
new file mode 100644
index 0000000..b214b1e
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
@@ -0,0 +1,197 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.helper;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.Stack;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * An XML parser that uses SAX to include line and column number for each XML element in the parsed Document.
+ * <p/>
+ * The line number and column number can be obtained from a Node/Element using
+ * <pre>
+ * String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
+ * String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
+ * String columnNumber = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER);
+ * String columnNumberEnd = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER_END);
+ * </pre>
+ */
+public final class XmlLineNumberParser {
+
+ public static final String LINE_NUMBER = "lineNumber";
+ public static final String COLUMN_NUMBER = "colNumber";
+ public static final String LINE_NUMBER_END = "lineNumberEnd";
+ public static final String COLUMN_NUMBER_END = "colNumberEnd";
+
+ private XmlLineNumberParser() {
+ }
+
+ /**
+ * Parses the XML.
+ *
+ * @param is the XML content as an input stream
+ * @return the DOM model
+ * @throws Exception is thrown if error parsing
+ */
+ public static Document parseXml(final InputStream is) throws Exception {
+ return parseXml(is, null, null);
+ }
+
+ /**
+ * Parses the XML.
+ *
+ * @param is the XML content as an input stream
+ * @param rootNames one or more root names that is used as baseline for beginning the parsing, for example camelContext to start parsing
+ * when Camel is discovered. Multiple names can be defined separated by comma
+ * @param forceNamespace an optional namespace to force assign to each node. This may be needed for JAXB unmarshalling from XML -> POJO.
+ * @return the DOM model
+ * @throws Exception is thrown if error parsing
+ */
+ public static Document parseXml(final InputStream is, final String rootNames, final String forceNamespace) throws Exception {
+ final Document doc;
+ SAXParser parser;
+ final SAXParserFactory factory = SAXParserFactory.newInstance();
+ parser = factory.newSAXParser();
+ final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ // turn off validator and loading external dtd
+ dbf.setValidating(false);
+ dbf.setNamespaceAware(true);
+ dbf.setFeature("http://xml.org/sax/features/namespaces", false);
+ dbf.setFeature("http://xml.org/sax/features/validation", false);
+ dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
+ dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ final DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ doc = docBuilder.newDocument();
+
+ final Stack<Element> elementStack = new Stack<Element>();
+ final StringBuilder textBuffer = new StringBuilder();
+ final DefaultHandler handler = new DefaultHandler() {
+ private Locator locator;
+ private boolean found;
+
+ @Override
+ public void setDocumentLocator(final Locator locator) {
+ this.locator = locator; // Save the locator, so that it can be used later for line tracking when traversing nodes.
+ this.found = rootNames == null;
+ }
+
+ private boolean isRootName(String qName) {
+ for (String root : rootNames.split(",")) {
+ if (qName.equals(root)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException {
+ addTextIfNeeded();
+
+ if (rootNames != null && !found) {
+ if (isRootName(qName)) {
+ found = true;
+ }
+ }
+
+ if (found) {
+ Element el;
+ if (forceNamespace != null) {
+ el = doc.createElementNS(forceNamespace, qName);
+ } else {
+ el = doc.createElement(qName);
+ }
+
+ for (int i = 0; i < attributes.getLength(); i++) {
+ el.setAttribute(attributes.getQName(i), attributes.getValue(i));
+ }
+
+ el.setUserData(LINE_NUMBER, String.valueOf(this.locator.getLineNumber()), null);
+ el.setUserData(COLUMN_NUMBER, String.valueOf(this.locator.getColumnNumber()), null);
+ elementStack.push(el);
+ }
+ }
+
+ @Override
+ public void endElement(final String uri, final String localName, final String qName) {
+ if (!found) {
+ return;
+ }
+
+ addTextIfNeeded();
+
+ final Element closedEl = elementStack.isEmpty() ? null : elementStack.pop();
+ if (closedEl != null) {
+ if (elementStack.isEmpty()) {
+ // Is this the root element?
+ doc.appendChild(closedEl);
+ } else {
+ final Element parentEl = elementStack.peek();
+ parentEl.appendChild(closedEl);
+ }
+
+ closedEl.setUserData(LINE_NUMBER_END, String.valueOf(this.locator.getLineNumber()), null);
+ closedEl.setUserData(COLUMN_NUMBER_END, String.valueOf(this.locator.getColumnNumber()), null);
+ }
+ }
+
+ @Override
+ public void characters(final char ch[], final int start, final int length) throws SAXException {
+ textBuffer.append(ch, start, length);
+ }
+
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException {
+ // do not resolve external dtd
+ return new InputSource(new StringReader(""));
+ }
+
+ // Outputs text accumulated under the current node
+ private void addTextIfNeeded() {
+ if (textBuffer.length() > 0) {
+ final Element el = elementStack.isEmpty() ? null : elementStack.peek();
+ if (el != null) {
+ final Node textNode = doc.createTextNode(textBuffer.toString());
+ el.appendChild(textNode);
+ textBuffer.delete(0, textBuffer.length());
+ }
+ }
+ }
+ };
+ parser.parse(is, handler);
+
+ return doc;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
index 9b03710..3b112a4 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.parser.model;
+/**
+ * Details about a parsed and discovered Camel endpoint.
+ */
public class CamelEndpointDetails {
private String fileName;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleDetails.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleDetails.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleDetails.java
deleted file mode 100644
index 058111d..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleDetails.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.model;
-
-public class CamelSimpleDetails {
-
- private String fileName;
- private String lineNumber;
- private String lineNumberEnd;
- private String className;
- private String methodName;
- private String simple;
- private boolean predicate;
- private boolean expression;
-
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- public String getLineNumber() {
- return lineNumber;
- }
-
- public void setLineNumber(String lineNumber) {
- this.lineNumber = lineNumber;
- }
-
- public String getLineNumberEnd() {
- return lineNumberEnd;
- }
-
- public void setLineNumberEnd(String lineNumberEnd) {
- this.lineNumberEnd = lineNumberEnd;
- }
-
- public String getClassName() {
- return className;
- }
-
- public void setClassName(String className) {
- this.className = className;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public void setMethodName(String methodName) {
- this.methodName = methodName;
- }
-
- public String getSimple() {
- return simple;
- }
-
- public void setSimple(String simple) {
- this.simple = simple;
- }
-
- public boolean isPredicate() {
- return predicate;
- }
-
- public void setPredicate(boolean predicate) {
- this.predicate = predicate;
- }
-
- public boolean isExpression() {
- return expression;
- }
-
- public void setExpression(boolean expression) {
- this.expression = expression;
- }
-
- @Override
- public String toString() {
- return simple;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java
new file mode 100644
index 0000000..9d6db11
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleExpressionDetails.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.model;
+
+/**
+ * Details about a parsed and discovered Camel simple expression.
+ */
+public class CamelSimpleExpressionDetails {
+
+ private String fileName;
+ private String lineNumber;
+ private String lineNumberEnd;
+ private String className;
+ private String methodName;
+ private String simple;
+ private boolean predicate;
+ private boolean expression;
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getLineNumber() {
+ return lineNumber;
+ }
+
+ public void setLineNumber(String lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ public String getLineNumberEnd() {
+ return lineNumberEnd;
+ }
+
+ public void setLineNumberEnd(String lineNumberEnd) {
+ this.lineNumberEnd = lineNumberEnd;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+ public String getSimple() {
+ return simple;
+ }
+
+ public void setSimple(String simple) {
+ this.simple = simple;
+ }
+
+ public boolean isPredicate() {
+ return predicate;
+ }
+
+ public void setPredicate(boolean predicate) {
+ this.predicate = predicate;
+ }
+
+ public boolean isExpression() {
+ return expression;
+ }
+
+ public void setExpression(boolean expression) {
+ this.expression = expression;
+ }
+
+ @Override
+ public String toString() {
+ return simple;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java
new file mode 100644
index 0000000..234082a
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/AnonymousMethodSource.java
@@ -0,0 +1,426 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.roaster;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+import org.jboss.forge.roaster.model.JavaType;
+import org.jboss.forge.roaster.model.Type;
+import org.jboss.forge.roaster.model.TypeVariable;
+import org.jboss.forge.roaster.model.Visibility;
+import org.jboss.forge.roaster.model.source.AnnotationSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.JavaDocSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.jboss.forge.roaster.model.source.ParameterSource;
+import org.jboss.forge.roaster.model.source.TypeVariableSource;
+
+/**
+ * In use when we have discovered a RouteBuilder being as anonymous inner class
+ */
+public class AnonymousMethodSource implements MethodSource<JavaClassSource> {
+
+ // this implementation should only implement the needed logic to support the parser
+
+ private final JavaClassSource origin;
+ private final Object internal;
+
+ public AnonymousMethodSource(JavaClassSource origin, Object internal) {
+ this.origin = origin;
+ this.internal = internal;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setDefault(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setSynchronized(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setNative(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(Class<?> aClass) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(JavaType<?> javaType) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnTypeVoid() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setBody(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setConstructor(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setParameters(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> addThrows(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> addThrows(Class<? extends Exception> aClass) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeThrows(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeThrows(Class<? extends Exception> aClass) {
+ return null;
+ }
+
+ @Override
+ public boolean isSynchronized() {
+ return false;
+ }
+
+ @Override
+ public boolean isNative() {
+ return false;
+ }
+
+ @Override
+ public String getBody() {
+ return null;
+ }
+
+ @Override
+ public boolean isConstructor() {
+ return false;
+ }
+
+ @Override
+ public Type<JavaClassSource> getReturnType() {
+ return null;
+ }
+
+ @Override
+ public boolean isReturnTypeVoid() {
+ return false;
+ }
+
+ @Override
+ public List<ParameterSource<JavaClassSource>> getParameters() {
+ return null;
+ }
+
+ @Override
+ public String toSignature() {
+ return null;
+ }
+
+ @Override
+ public List<String> getThrownExceptions() {
+ return null;
+ }
+
+ @Override
+ public boolean isDefault() {
+ return false;
+ }
+
+ @Override
+ public ParameterSource<JavaClassSource> addParameter(Class<?> aClass, String s) {
+ return null;
+ }
+
+ @Override
+ public ParameterSource<JavaClassSource> addParameter(String s, String s1) {
+ return null;
+ }
+
+ @Override
+ public ParameterSource<JavaClassSource> addParameter(JavaType<?> javaType, String s) {
+ return null;
+ }
+
+ @Override
+ public void removeAllAnnotations() {
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(ParameterSource<JavaClassSource> parameterSource) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(Class<?> aClass, String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(String s, String s1) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(JavaType<?> javaType, String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setAbstract(boolean b) {
+ return null;
+ }
+
+ @Override
+ public List<AnnotationSource<JavaClassSource>> getAnnotations() {
+ return null;
+ }
+
+ @Override
+ public boolean hasAnnotation(Class<? extends Annotation> aClass) {
+ return false;
+ }
+
+ @Override
+ public boolean hasAnnotation(String s) {
+ return false;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> getAnnotation(Class<? extends Annotation> aClass) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> getAnnotation(String s) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> addAnnotation() {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> addAnnotation(Class<? extends Annotation> aClass) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> addAnnotation(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeAnnotation(org.jboss.forge.roaster.model.Annotation<JavaClassSource> annotation) {
+ return null;
+ }
+
+ @Override
+ public List<TypeVariableSource<JavaClassSource>> getTypeVariables() {
+ return null;
+ }
+
+ @Override
+ public TypeVariableSource<JavaClassSource> getTypeVariable(String s) {
+ return null;
+ }
+
+ @Override
+ public TypeVariableSource<JavaClassSource> addTypeVariable() {
+ return null;
+ }
+
+ @Override
+ public TypeVariableSource<JavaClassSource> addTypeVariable(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeTypeVariable(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeTypeVariable(TypeVariable<?> typeVariable) {
+ return null;
+ }
+
+ @Override
+ public boolean hasJavaDoc() {
+ return false;
+ }
+
+ @Override
+ public boolean isAbstract() {
+ return false;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setFinal(boolean b) {
+ return null;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return false;
+ }
+
+ @Override
+ public Object getInternal() {
+ return internal;
+ }
+
+ @Override
+ public JavaDocSource<MethodSource<JavaClassSource>> getJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setName(String s) {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public JavaClassSource getOrigin() {
+ return origin;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setStatic(boolean b) {
+ return null;
+ }
+
+ @Override
+ public boolean isStatic() {
+ return false;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setPackagePrivate() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setPublic() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setPrivate() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setProtected() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setVisibility(Visibility visibility) {
+ return null;
+ }
+
+ @Override
+ public boolean isPackagePrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isPublic() {
+ return false;
+ }
+
+ @Override
+ public boolean isPrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isProtected() {
+ return false;
+ }
+
+ @Override
+ public Visibility getVisibility() {
+ return null;
+ }
+
+ @Override
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ @Override
+ public int getStartPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getEndPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getLineNumber() {
+ return 0;
+ }
+
+ @Override
+ public boolean hasTypeVariable(String arg0) {
+ return false;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(Type<?> arg0) {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java
new file mode 100644
index 0000000..cbfcedc
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/roaster/StatementFieldSource.java
@@ -0,0 +1,278 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.roaster;
+
+import java.util.List;
+
+import org.jboss.forge.roaster.model.Annotation;
+import org.jboss.forge.roaster.model.JavaType;
+import org.jboss.forge.roaster.model.Type;
+import org.jboss.forge.roaster.model.Visibility;
+import org.jboss.forge.roaster.model.impl.TypeImpl;
+import org.jboss.forge.roaster.model.source.AnnotationSource;
+import org.jboss.forge.roaster.model.source.FieldSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.JavaDocSource;
+
+public class StatementFieldSource implements FieldSource {
+
+ // this implementation should only implement the needed logic to support the parser
+
+ private final JavaClassSource origin;
+ private final Object internal;
+ private final Type type;
+
+ public StatementFieldSource(JavaClassSource origin, Object internal, Object typeInternal) {
+ this.origin = origin;
+ this.internal = internal;
+ this.type = new TypeImpl(origin, typeInternal);
+ }
+
+ @Override
+ public FieldSource setType(Class clazz) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setType(String type) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setLiteralInitializer(String value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setStringInitializer(String value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setTransient(boolean value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setVolatile(boolean value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setType(JavaType entity) {
+ return null;
+ }
+
+ @Override
+ public List<AnnotationSource> getAnnotations() {
+ return null;
+ }
+
+ @Override
+ public boolean hasAnnotation(String type) {
+ return false;
+ }
+
+ @Override
+ public boolean hasAnnotation(Class type) {
+ return false;
+ }
+
+ @Override
+ public AnnotationSource getAnnotation(String type) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource addAnnotation() {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource addAnnotation(String className) {
+ return null;
+ }
+
+ @Override
+ public void removeAllAnnotations() {
+ }
+
+ @Override
+ public Object removeAnnotation(Annotation annotation) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource addAnnotation(Class type) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource getAnnotation(Class type) {
+ return null;
+ }
+
+ @Override
+ public Type getType() {
+ return type;
+ }
+
+ @Override
+ public String getStringInitializer() {
+ return null;
+ }
+
+ @Override
+ public String getLiteralInitializer() {
+ return null;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return false;
+ }
+
+ @Override
+ public boolean isVolatile() {
+ return false;
+ }
+
+ @Override
+ public Object setFinal(boolean finl) {
+ return null;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return false;
+ }
+
+ @Override
+ public Object getInternal() {
+ return internal;
+ }
+
+ @Override
+ public JavaDocSource getJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public boolean hasJavaDoc() {
+ return false;
+ }
+
+ @Override
+ public Object removeJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public Object setName(String name) {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public Object getOrigin() {
+ return origin;
+ }
+
+ @Override
+ public Object setStatic(boolean value) {
+ return null;
+ }
+
+ @Override
+ public boolean isStatic() {
+ return false;
+ }
+
+ @Override
+ public Object setPackagePrivate() {
+ return null;
+ }
+
+ @Override
+ public Object setPublic() {
+ return null;
+ }
+
+ @Override
+ public Object setPrivate() {
+ return null;
+ }
+
+ @Override
+ public Object setProtected() {
+ return null;
+ }
+
+ @Override
+ public Object setVisibility(Visibility scope) {
+ return null;
+ }
+
+ @Override
+ public boolean isPackagePrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isPublic() {
+ return false;
+ }
+
+ @Override
+ public boolean isPrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isProtected() {
+ return false;
+ }
+
+ @Override
+ public Visibility getVisibility() {
+ return null;
+ }
+
+ @Override
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ @Override
+ public int getStartPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getEndPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getLineNumber() {
+ return 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
index 0bd7fb1..326d599 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
index 16e01da..6cb2492 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
index 9cd8f11..099ea7b 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
index a239789..c432183 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
@@ -20,7 +20,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.apache.camel.parser.RouteBuilderParser;
import org.apache.camel.parser.model.CamelEndpointDetails;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
index 75c6781..53495e9 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
index 24cec20..c7ca922 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
index a715ca3..951a4cb 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
index 4c80879..89f9544 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
index 99e288a..9dc1687 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
index b6b8ca0..a4fc1fb 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/cf41dadd/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
index 6e40043..b7cb3d6 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.CamelJavaParserHelper;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
[11/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: route parser for java and xml to parse source code. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/86cb3922
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/86cb3922
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/86cb3922
Branch: refs/heads/master
Commit: 86cb39220c28f700e23fb2d48d5640915e489d22
Parents: b925366
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 12:17:06 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
.../org/apache/camel/parser/CamelXmlHelper.java | 260 +++++++++++++++++++
.../apache/camel/parser/RouteBuilderParser.java | 1 -
.../camel/parser/XmlLineNumberParser.java | 194 ++++++++++++++
.../org/apache/camel/parser/XmlRouteParser.java | 141 ++++++++++
.../parser/xml/FindElementInRoutesTest.java | 44 ++++
.../parser/xml/XmlOnExceptionRouteTest.java | 55 ++++
.../apache/camel/parser/xml/XmlRouteTest.java | 51 ++++
.../camel/parser/xml/mycamel-onexception.xml | 33 +++
.../org/apache/camel/parser/xml/mycamel.xml | 26 ++
.../org/apache/camel/parser/xml/myroutes.xml | 19 ++
10 files changed, 823 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/86cb3922/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java
new file mode 100644
index 0000000..b4a7848
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelXmlHelper.java
@@ -0,0 +1,260 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.forge.roaster.model.util.Strings;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class CamelXmlHelper {
+
+ public static String getSafeAttribute(Node node, String key) {
+ if (node != null) {
+ Node attr = node.getAttributes().getNamedItem(key);
+ if (attr != null) {
+ return attr.getNodeValue();
+ }
+ }
+ return null;
+ }
+
+ public static List<Node> findAllEndpoints(Document dom) {
+ List<Node> nodes = new ArrayList<>();
+
+ NodeList list = dom.getElementsByTagName("endpoint");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("endpoint".equals(child.getNodeName())) {
+ // it may not be a camel namespace, so skip those
+ String ns = child.getNamespaceURI();
+ if (ns == null) {
+ NamedNodeMap attrs = child.getAttributes();
+ if (attrs != null) {
+ Node node = attrs.getNamedItem("xmlns");
+ if (node != null) {
+ ns = node.getNodeValue();
+ }
+ }
+ }
+ // assume no namespace its for camel
+ if (ns == null || ns.contains("camel")) {
+ nodes.add(child);
+ }
+ }
+ }
+
+ list = dom.getElementsByTagName("onException");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("onCompletion");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("intercept");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("interceptFrom");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("interceptSendToEndpoint");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ findAllUrisRecursive(child, nodes);
+ }
+ list = dom.getElementsByTagName("rest");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("route".equals(child.getNodeName()) || "to".equals(child.getNodeName())) {
+ findAllUrisRecursive(child, nodes);
+ }
+ }
+ list = dom.getElementsByTagName("route");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("route".equals(child.getNodeName())) {
+ findAllUrisRecursive(child, nodes);
+ }
+ }
+
+ return nodes;
+ }
+
+ private static void findAllUrisRecursive(Node node, List<Node> nodes) {
+ // okay its a route so grab all uri attributes we can find
+ String url = getSafeAttribute(node, "uri");
+ if (url != null) {
+ nodes.add(node);
+ }
+
+ NodeList children = node.getChildNodes();
+ if (children != null) {
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ findAllUrisRecursive(child, nodes);
+ }
+ }
+ }
+ }
+
+ public static List<Node> findAllSimpleExpressions(Document dom) {
+ List<Node> nodes = new ArrayList<>();
+
+ NodeList list = dom.getElementsByTagName("route");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if ("route".equals(child.getNodeName())) {
+ findAllSimpleExpressionsRecursive(child, nodes);
+ }
+ }
+
+ return nodes;
+ }
+
+ private static void findAllSimpleExpressionsRecursive(Node node, List<Node> nodes) {
+ // okay its a route so grab if its <simple>
+ if ("simple".equals(node.getNodeName())) {
+ nodes.add(node);
+ }
+
+ NodeList children = node.getChildNodes();
+ if (children != null) {
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ findAllSimpleExpressionsRecursive(child, nodes);
+ }
+ }
+ }
+ }
+
+ public static Element getSelectedCamelElementNode(String key, InputStream resourceInputStream) throws Exception {
+ Document root = loadCamelXmlFileAsDom(resourceInputStream);
+ Element selectedElement = null;
+ if (root != null) {
+ Node selectedNode = findCamelNodeInDocument(root, key);
+ if (selectedNode instanceof Element) {
+ selectedElement = (Element) selectedNode;
+ }
+ }
+ return selectedElement;
+ }
+
+ private static Document loadCamelXmlFileAsDom(InputStream resourceInputStream) throws Exception {
+ // TODO:
+ Document root = XmlLineNumberParser.parseXml(resourceInputStream, "camelContext,routes,rests", "http://camel.apache.org/schema/spring");
+ return root;
+ }
+
+ private static Node findCamelNodeInDocument(Document root, String key) {
+ Node selectedNode = null;
+ if (root != null && !Strings.isBlank(key)) {
+ String[] paths = key.split("/");
+ NodeList camels = getCamelContextElements(root);
+ if (camels != null) {
+ Map<String, Integer> rootNodeCounts = new HashMap<>();
+ for (int i = 0, size = camels.getLength(); i < size; i++) {
+ Node node = camels.item(i);
+ boolean first = true;
+ for (String path : paths) {
+ if (first) {
+ first = false;
+ String actual = getIdOrIndex(node, rootNodeCounts);
+ if (!equal(actual, path)) {
+ node = null;
+ }
+ } else {
+ node = findCamelNodeForPath(node, path);
+ }
+ if (node == null) {
+ break;
+ }
+ }
+ if (node != null) {
+ return node;
+ }
+ }
+ }
+ }
+ return selectedNode;
+ }
+
+ private static Node findCamelNodeForPath(Node node, String path) {
+ NodeList childNodes = node.getChildNodes();
+ if (childNodes != null) {
+ Map<String, Integer> nodeCounts = new HashMap<>();
+ for (int i = 0, size = childNodes.getLength(); i < size; i++) {
+ Node child = childNodes.item(i);
+ if (child instanceof Element) {
+ String actual = getIdOrIndex(child, nodeCounts);
+ if (equal(actual, path)) {
+ return child;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private static String getIdOrIndex(Node node, Map<String, Integer> nodeCounts) {
+ String answer = null;
+ if (node instanceof Element) {
+ Element element = (Element) node;
+ String elementName = element.getTagName();
+ if ("routes".equals(elementName)) {
+ elementName = "camelContext";
+ }
+ Integer countObject = nodeCounts.get(elementName);
+ int count = countObject != null ? countObject.intValue() : 0;
+ nodeCounts.put(elementName, ++count);
+ answer = element.getAttribute("id");
+ if (Strings.isBlank(answer)) {
+ answer = "_" + elementName + count;
+ }
+ }
+ return answer;
+ }
+
+ private static NodeList getCamelContextElements(Document dom) {
+ NodeList camels = dom.getElementsByTagName("camelContext");
+ if (camels == null || camels.getLength() == 0) {
+ camels = dom.getElementsByTagName("routes");
+ }
+ return camels;
+ }
+
+ private static boolean equal(Object a, Object b) {
+ return a == b?true:a != null && b != null && a.equals(b);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/86cb3922/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
index 2327ae1..b84888a 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
@@ -277,5 +277,4 @@ public class RouteBuilderParser {
return null;
}
-
}
http://git-wip-us.apache.org/repos/asf/camel/blob/86cb3922/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java
new file mode 100644
index 0000000..c2fffce
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlLineNumberParser.java
@@ -0,0 +1,194 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.Stack;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * An XML parser that uses SAX to include line and column number for each XML element in the parsed Document.
+ * <p/>
+ * The line number and column number can be obtained from a Node/Element using
+ * <pre>
+ * String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
+ * String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
+ * String columnNumber = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER);
+ * String columnNumberEnd = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER_END);
+ * </pre>
+ */
+public final class XmlLineNumberParser {
+
+ public static final String LINE_NUMBER = "lineNumber";
+ public static final String COLUMN_NUMBER = "colNumber";
+ public static final String LINE_NUMBER_END = "lineNumberEnd";
+ public static final String COLUMN_NUMBER_END = "colNumberEnd";
+
+ /**
+ * Parses the XML.
+ *
+ * @param is the XML content as an input stream
+ * @return the DOM model
+ * @throws Exception is thrown if error parsing
+ */
+ public static Document parseXml(final InputStream is) throws Exception {
+ return parseXml(is, null, null);
+ }
+
+ /**
+ * Parses the XML.
+ *
+ * @param is the XML content as an input stream
+ * @param rootNames one or more root names that is used as baseline for beginning the parsing, for example camelContext to start parsing
+ * when Camel is discovered. Multiple names can be defined separated by comma
+ * @param forceNamespace an optional namespace to force assign to each node. This may be needed for JAXB unmarshalling from XML -> POJO.
+ * @return the DOM model
+ * @throws Exception is thrown if error parsing
+ */
+ public static Document parseXml(final InputStream is, final String rootNames, final String forceNamespace) throws Exception {
+ final Document doc;
+ SAXParser parser;
+ final SAXParserFactory factory = SAXParserFactory.newInstance();
+ parser = factory.newSAXParser();
+ final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ // turn off validator and loading external dtd
+ dbf.setValidating(false);
+ dbf.setNamespaceAware(true);
+ dbf.setFeature("http://xml.org/sax/features/namespaces", false);
+ dbf.setFeature("http://xml.org/sax/features/validation", false);
+ dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
+ dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ final DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ doc = docBuilder.newDocument();
+
+ final Stack<Element> elementStack = new Stack<Element>();
+ final StringBuilder textBuffer = new StringBuilder();
+ final DefaultHandler handler = new DefaultHandler() {
+ private Locator locator;
+ private boolean found;
+
+ @Override
+ public void setDocumentLocator(final Locator locator) {
+ this.locator = locator; // Save the locator, so that it can be used later for line tracking when traversing nodes.
+ this.found = rootNames == null;
+ }
+
+ private boolean isRootName(String qName) {
+ for (String root : rootNames.split(",")) {
+ if (qName.equals(root)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException {
+ addTextIfNeeded();
+
+ if (rootNames != null && !found) {
+ if (isRootName(qName)) {
+ found = true;
+ }
+ }
+
+ if (found) {
+ Element el;
+ if (forceNamespace != null) {
+ el = doc.createElementNS(forceNamespace, qName);
+ } else {
+ el = doc.createElement(qName);
+ }
+
+ for (int i = 0; i < attributes.getLength(); i++) {
+ el.setAttribute(attributes.getQName(i), attributes.getValue(i));
+ }
+
+ el.setUserData(LINE_NUMBER, String.valueOf(this.locator.getLineNumber()), null);
+ el.setUserData(COLUMN_NUMBER, String.valueOf(this.locator.getColumnNumber()), null);
+ elementStack.push(el);
+ }
+ }
+
+ @Override
+ public void endElement(final String uri, final String localName, final String qName) {
+ if (!found) {
+ return;
+ }
+
+ addTextIfNeeded();
+
+ final Element closedEl = elementStack.isEmpty() ? null : elementStack.pop();
+ if (closedEl != null) {
+ if (elementStack.isEmpty()) {
+ // Is this the root element?
+ doc.appendChild(closedEl);
+ } else {
+ final Element parentEl = elementStack.peek();
+ parentEl.appendChild(closedEl);
+ }
+
+ closedEl.setUserData(LINE_NUMBER_END, String.valueOf(this.locator.getLineNumber()), null);
+ closedEl.setUserData(COLUMN_NUMBER_END, String.valueOf(this.locator.getColumnNumber()), null);
+ }
+ }
+
+ @Override
+ public void characters(final char ch[], final int start, final int length) throws SAXException {
+ textBuffer.append(ch, start, length);
+ }
+
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException {
+ // do not resolve external dtd
+ return new InputSource(new StringReader(""));
+ }
+
+ // Outputs text accumulated under the current node
+ private void addTextIfNeeded() {
+ if (textBuffer.length() > 0) {
+ final Element el = elementStack.isEmpty() ? null : elementStack.peek();
+ if (el != null) {
+ final Node textNode = doc.createTextNode(textBuffer.toString());
+ el.appendChild(textNode);
+ textBuffer.delete(0, textBuffer.length());
+ }
+ }
+ }
+ };
+ parser.parse(is, handler);
+
+ return doc;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/86cb3922/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
new file mode 100644
index 0000000..1b206cb
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.apache.camel.parser.model.CamelSimpleDetails;
+import org.jboss.forge.roaster.model.util.Strings;
+
+import static org.apache.camel.parser.CamelXmlHelper.getSafeAttribute;
+
+public class XmlRouteParser {
+
+ public static void parseXmlRouteEndpoints(InputStream xml, String baseDir, String fullyQualifiedFileName,
+ List<CamelEndpointDetails> endpoints) throws Exception {
+
+ // find all the endpoints (currently only <endpoint> and within <route>)
+ // try parse it as dom
+ Document dom = null;
+ try {
+ dom = XmlLineNumberParser.parseXml(xml);
+ } catch (Exception e) {
+ // ignore as the xml file may not be valid at this point
+ }
+ if (dom != null) {
+ List<Node> nodes = CamelXmlHelper.findAllEndpoints(dom);
+ for (Node node : nodes) {
+ String uri = getSafeAttribute(node, "uri");
+ if (uri != null) {
+ // trim and remove whitespace noise
+ uri = trimEndpointUri(uri);
+ }
+ if (!Strings.isBlank(uri)) {
+ String id = getSafeAttribute(node, "id");
+ String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
+ String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
+
+ // we only want the relative dir name from the resource directory, eg META-INF/spring/foo.xml
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+
+ boolean consumerOnly = false;
+ boolean producerOnly = false;
+ String nodeName = node.getNodeName();
+ if ("from".equals(nodeName) || "pollEnrich".equals(nodeName)) {
+ consumerOnly = true;
+ } else if ("to".equals(nodeName) || "enrich".equals(nodeName) || "wireTap".equals(nodeName)) {
+ producerOnly = true;
+ }
+
+ CamelEndpointDetails detail = new CamelEndpointDetails();
+ detail.setFileName(fileName);
+ detail.setLineNumber(lineNumber);
+ detail.setLineNumberEnd(lineNumberEnd);
+ detail.setEndpointInstance(id);
+ detail.setEndpointUri(uri);
+ detail.setEndpointComponentName(endpointComponentName(uri));
+ detail.setConsumerOnly(consumerOnly);
+ detail.setProducerOnly(producerOnly);
+ endpoints.add(detail);
+ }
+ }
+ }
+ }
+
+ public static void parseXmlRouteSimpleExpressions(InputStream xml, String baseDir, String fullyQualifiedFileName,
+ List<CamelSimpleDetails> simpleExpressions) throws Exception {
+
+ // find all the simple expressions
+ // try parse it as dom
+ Document dom = null;
+ try {
+ dom = XmlLineNumberParser.parseXml(xml);
+ } catch (Exception e) {
+ // ignore as the xml file may not be valid at this point
+ }
+ if (dom != null) {
+ List<Node> nodes = CamelXmlHelper.findAllSimpleExpressions(dom);
+ for (Node node : nodes) {
+ String simple = node.getTextContent();
+ String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
+ String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
+
+ // we only want the relative dir name from the resource directory, eg META-INF/spring/foo.xml
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+
+ CamelSimpleDetails detail = new CamelSimpleDetails();
+ detail.setFileName(fileName);
+ detail.setLineNumber(lineNumber);
+ detail.setLineNumberEnd(lineNumberEnd);
+ detail.setSimple(simple);
+ simpleExpressions.add(detail);
+ }
+ }
+ }
+
+ private static String endpointComponentName(String uri) {
+ if (uri != null) {
+ int idx = uri.indexOf(":");
+ if (idx > 0) {
+ return uri.substring(0, idx);
+ }
+ }
+ return null;
+ }
+
+
+ private static String trimEndpointUri(String uri) {
+ uri = uri.trim();
+ // if the uri is using new-lines then remove whitespace noise before & and ? separator
+ uri = uri.replaceAll("(\\s+)(\\&)", "$2");
+ uri = uri.replaceAll("(\\&)(\\s+)", "$1");
+ uri = uri.replaceAll("(\\?)(\\s+)", "$1");
+ return uri;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/86cb3922/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
new file mode 100644
index 0000000..b39fc2d
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.xml;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.camel.parser.CamelXmlHelper;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+
+import static org.junit.Assert.assertNotNull;
+
+public class FindElementInRoutesTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FindElementInRoutesTest.class);
+
+ @Test
+ public void testXml() throws Exception {
+ InputStream is = new FileInputStream("src/test/resources/org/apache/camel/parser/xml/myroutes.xml");
+ String key = "_camelContext1/cbr-route/_from1";
+ Element element = CamelXmlHelper.getSelectedCamelElementNode(key, is);
+ assertNotNull("Could not find Element for key " + key, element);
+
+ LOG.info("Found element " + element.getTagName());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/86cb3922/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java
new file mode 100644
index 0000000..6f8aeb6
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.xml;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.XmlRouteParser;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class XmlOnExceptionRouteTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(XmlOnExceptionRouteTest.class);
+
+ @Test
+ public void testXml() throws Exception {
+ List<CamelEndpointDetails> endpoints = new ArrayList<>();
+
+ InputStream is = new FileInputStream("src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml");
+ String fqn = "src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml";
+ String baseDir = "src/test/resources";
+ XmlRouteParser.parseXmlRouteEndpoints(is, baseDir, fqn, endpoints);
+
+ for (CamelEndpointDetails detail : endpoints) {
+ LOG.info(detail.getEndpointUri());
+ }
+
+ Assert.assertEquals("log:all", endpoints.get(0).getEndpointUri());
+ Assert.assertEquals("mock:dead", endpoints.get(1).getEndpointUri());
+ Assert.assertEquals("log:done", endpoints.get(2).getEndpointUri());
+ Assert.assertEquals("stream:in?promptMessage=Enter something:", endpoints.get(3).getEndpointUri());
+ Assert.assertEquals("stream:out", endpoints.get(4).getEndpointUri());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/86cb3922/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java
new file mode 100644
index 0000000..05be852
--- /dev/null
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.xml;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.XmlRouteParser;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class XmlRouteTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(XmlRouteTest.class);
+
+ @Test
+ public void testXml() throws Exception {
+ List<CamelEndpointDetails> endpoints = new ArrayList<>();
+
+ InputStream is = new FileInputStream("src/test/resources/org/apache/camel/parser/xml/mycamel.xml");
+ String fqn = "src/test/resources/org/apache/camel/camel/parser/xml/mycamel.xml";
+ String baseDir = "src/test/resources";
+ XmlRouteParser.parseXmlRouteEndpoints(is, baseDir, fqn, endpoints);
+
+ for (CamelEndpointDetails detail : endpoints) {
+ LOG.info(detail.getEndpointUri());
+ }
+ Assert.assertEquals("stream:in?promptMessage=Enter something:", endpoints.get(0).getEndpointUri());
+ Assert.assertEquals("stream:out", endpoints.get(1).getEndpointUri());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/86cb3922/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml b/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml
new file mode 100644
index 0000000..14a370f
--- /dev/null
+++ b/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+ <endpoint id="logger" uri="log:all"/>
+
+ <onException>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
+ <to uri="mock:dead"/>
+ </onException>
+
+ <onCompletion>
+ <to uri="log:done"/>
+ </onCompletion>
+
+ <route>
+ <from uri="stream:in?promptMessage=Enter something: "/>
+ <transform>
+ <simple>Hello ${body.toUpperCase()}</simple>
+ </transform>
+ <to uri="stream:out"/>
+ </route>
+ </camelContext>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/86cb3922/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml b/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml
new file mode 100644
index 0000000..f243369
--- /dev/null
+++ b/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <!-- START SNIPPET: e1 -->
+ <!-- camelContext is the Camel runtime, where we can host Camel routes -->
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <!-- read input from the console using the stream component -->
+ <from
+ uri="stream:in?promptMessage=Enter something: "/>
+ <!-- transform the input to upper case using the simple language -->
+ <!-- you can also use other languages such as groovy, ognl, mvel, javascript etc. -->
+ <transform>
+ <simple>Hello ${body.toUpperCase()}</simple>
+ </transform>
+ <!-- and then print to the console -->
+ <to uri="stream:out"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: e1 -->
+
+</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/86cb3922/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml b/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml
new file mode 100644
index 0000000..c132e34
--- /dev/null
+++ b/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<routes xmlns="http://camel.apache.org/schema/spring">
+ <route id="cbr-route">
+ <from uri="timer:foo?period=5000"/>
+ <!-- generate random number message, using a 3 digit number -->
+ <transform>
+ <method bean="myTransformer"/>
+ </transform>
+ <choice>
+ <when>
+ <simple>${body} > 500</simple>
+ <log message="High priority message : ${body}"/>
+ </when>
+ <otherwise>
+ <log message="Low priority message : ${body}"/>
+ </otherwise>
+ </choice>
+ </route>
+</routes>
[17/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
deleted file mode 100644
index 603d96f..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterMyNettyTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterMyNettyTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyNettyTest.java"));
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
-
- List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Consumer: " + result.getElement());
- }
- Assert.assertEquals("netty-http:http://0.0.0.0:{{port}}/foo", list.get(0).getElement());
- Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
-
- list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
- for (ParserResult result : list) {
- LOG.info("Producer: " + result.getElement());
- }
- Assert.assertEquals("mock:input1", list.get(0).getElement());
- Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
- Assert.assertEquals("mock:input2", list.get(2).getElement());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
deleted file mode 100644
index 3b7cb69..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterNewLineConstRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterNewLineConstRouteBuilderConfigureTest.class);
-
- @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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
deleted file mode 100644
index eeb320f..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterNewLineRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterNewLineRouteBuilderConfigureTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
deleted file mode 100644
index 9760f66..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterRouteBuilderCamelTestSupportTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderCamelTestSupportTest.class);
-
- @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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
deleted file mode 100644
index af9cb2e..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderConfigureTest.class);
-
- @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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
deleted file mode 100644
index 3d97c65..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterRouteBuilderEmptyUriTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderEmptyUriTest.class);
-
- @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());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
deleted file mode 100644
index c83d89a..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.RouteBuilderParser;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterSimpleProcessorTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleProcessorTest.class);
-
- @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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
deleted file mode 100644
index 14d63af..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterSimpleRouteBuilderConfigureTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleRouteBuilderConfigureTest.class);
-
- @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(27, findLineNumber(list.get(0).getPosition()));
- Assert.assertEquals("${body} > 200", list.get(1).getElement());
- Assert.assertEquals(30, findLineNumber(list.get(1).getPosition()));
- }
-
- public static int findLineNumber(int pos) throws Exception {
- int lines = 0;
- int current = 0;
- File file = new File("src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java");
- try (BufferedReader br = new BufferedReader(new FileReader(file))) {
- String line;
- while ((line = br.readLine()) != null) {
- lines++;
- current += line.length();
- if (current > pos) {
- return lines;
- }
- }
- }
- return -1;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
deleted file mode 100644
index aeea6cf..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.RouteBuilderParser;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterSimpleToDTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleToDTest.class);
-
- @Test
- public void parse() throws Exception {
- JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java"));
- MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
-
- List<CamelEndpointDetails> details = new ArrayList<>();
- RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.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("toD", list.get(0).getNode());
- Assert.assertEquals("log:a", list.get(0).getElement());
- Assert.assertEquals("to", list.get(1).getNode());
- Assert.assertEquals("log:b", list.get(1).getElement());
- Assert.assertEquals("to", list.get(2).getNode());
- Assert.assertEquals("log:c", list.get(2).getElement());
- Assert.assertEquals(3, list.size());
-
- Assert.assertEquals(4, details.size());
- Assert.assertEquals("direct:start", details.get(0).getEndpointUri());
- Assert.assertEquals("log:a", details.get(1).getEndpointUri());
- Assert.assertEquals("log:b", details.get(2).getEndpointUri());
- Assert.assertEquals("log:c", details.get(3).getEndpointUri());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
deleted file mode 100644
index 82d9f75..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.RouteBuilderParser;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterSimpleToFTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleToFTest.class);
-
- @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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
deleted file mode 100644
index ef8bde8..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.ParserResult;
-import org.apache.camel.parser.RouteBuilderParser;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.jboss.forge.roaster.Roaster;
-import org.jboss.forge.roaster.model.source.JavaClassSource;
-import org.jboss.forge.roaster.model.source.MethodSource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RoasterSplitTokenizeTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(RoasterSplitTokenizeTest.class);
-
- @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());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
deleted file mode 100644
index de37bf8..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-
-public class SimpleProcessorTest extends CamelTestSupport {
-
- public void testProcess() throws Exception {
- String out = template.requestBody("direct:start", "Hello World", String.class);
- assertEquals("Bye World", out);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start").process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getOut().setBody("Bye World");
- }
- });
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
deleted file mode 100644
index 4243dff..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.java;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-
-public class SplitTokenizeTest extends CamelTestSupport {
-
- public void testSplitTokenizerA() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("Claus", "James", "Willem");
-
- template.sendBody("direct:a", "Claus,James,Willem");
-
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerB() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("Claus", "James", "Willem");
-
- template.sendBodyAndHeader("direct:b", "Hello World", "myHeader", "Claus,James,Willem");
-
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerC() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("Claus", "James", "Willem");
-
- template.sendBody("direct:c", "Claus James Willem");
-
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerD() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("[Claus]", "[James]", "[Willem]");
-
- template.sendBody("direct:d", "[Claus][James][Willem]");
-
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerE() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("<person>Claus</person>", "<person>James</person>", "<person>Willem</person>");
-
- String xml = "<persons><person>Claus</person><person>James</person><person>Willem</person></persons>";
- template.sendBody("direct:e", xml);
-
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerEWithSlash() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- String xml = "<persons><person attr='/' /></persons>";
- mock.expectedBodiesReceived("<person attr='/' />");
- template.sendBody("direct:e", xml);
- mock.assertIsSatisfied();
- assertMockEndpointsSatisfied();
- }
-
- public void testSplitTokenizerF() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:split");
- mock.expectedBodiesReceived("<person name=\"Claus\"/>", "<person>James</person>", "<person>Willem</person>");
-
- String xml = "<persons><person/><person name=\"Claus\"/><person>James</person><person>Willem</person></persons>";
- template.sendBody("direct:f", xml);
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
-
- from("direct:a")
- .split().tokenize(",")
- .to("mock:split");
-
- from("direct:b")
- .split().tokenize(",", "myHeader")
- .to("mock:split");
-
- from("direct:c")
- .split().tokenize("(\\W+)\\s*", null, true)
- .to("mock:split");
-
- from("direct:d")
- .split().tokenizePair("[", "]", true)
- .to("mock:split");
-
- from("direct:e")
- .split().tokenizeXML("person")
- .to("mock:split");
-
- from("direct:f")
- .split().xpath("//person")
- // To test the body is not empty
- // it will call the ObjectHelper.evaluateValuePredicate()
- .filter().simple("${body}")
- .to("mock:split");
-
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
deleted file mode 100644
index f15dd0e..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.xml;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-
-import org.w3c.dom.Element;
-
-import org.apache.camel.parser.helper.CamelXmlHelper;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertNotNull;
-
-public class FindElementInRoutesTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(FindElementInRoutesTest.class);
-
- @Test
- public void testXml() throws Exception {
- InputStream is = new FileInputStream("src/test/resources/org/apache/camel/parser/xml/myroutes.xml");
- String key = "_camelContext1/cbr-route/_from1";
- Element element = CamelXmlHelper.getSelectedCamelElementNode(key, is);
- assertNotNull("Could not find Element for key " + key, element);
-
- LOG.info("Found element " + element.getTagName());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java
deleted file mode 100644
index 6f8aeb6..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.xml;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.XmlRouteParser;
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class XmlOnExceptionRouteTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(XmlOnExceptionRouteTest.class);
-
- @Test
- public void testXml() throws Exception {
- List<CamelEndpointDetails> endpoints = new ArrayList<>();
-
- InputStream is = new FileInputStream("src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml");
- String fqn = "src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml";
- String baseDir = "src/test/resources";
- XmlRouteParser.parseXmlRouteEndpoints(is, baseDir, fqn, endpoints);
-
- for (CamelEndpointDetails detail : endpoints) {
- LOG.info(detail.getEndpointUri());
- }
-
- Assert.assertEquals("log:all", endpoints.get(0).getEndpointUri());
- Assert.assertEquals("mock:dead", endpoints.get(1).getEndpointUri());
- Assert.assertEquals("log:done", endpoints.get(2).getEndpointUri());
- Assert.assertEquals("stream:in?promptMessage=Enter something:", endpoints.get(3).getEndpointUri());
- Assert.assertEquals("stream:out", endpoints.get(4).getEndpointUri());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java
deleted file mode 100644
index 05be852..0000000
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser.xml;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.parser.XmlRouteParser;
-import org.apache.camel.parser.model.CamelEndpointDetails;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class XmlRouteTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(XmlRouteTest.class);
-
- @Test
- public void testXml() throws Exception {
- List<CamelEndpointDetails> endpoints = new ArrayList<>();
-
- InputStream is = new FileInputStream("src/test/resources/org/apache/camel/parser/xml/mycamel.xml");
- String fqn = "src/test/resources/org/apache/camel/camel/parser/xml/mycamel.xml";
- String baseDir = "src/test/resources";
- XmlRouteParser.parseXmlRouteEndpoints(is, baseDir, fqn, endpoints);
-
- for (CamelEndpointDetails detail : endpoints) {
- LOG.info(detail.getEndpointUri());
- }
- Assert.assertEquals("stream:in?promptMessage=Enter something:", endpoints.get(0).getEndpointUri());
- Assert.assertEquals("stream:out", endpoints.get(1).getEndpointUri());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/resources/log4j2.properties b/tooling/route-parser/src/test/resources/log4j2.properties
deleted file mode 100644
index 2f66eb5..0000000
--- a/tooling/route-parser/src/test/resources/log4j2.properties
+++ /dev/null
@@ -1,30 +0,0 @@
-## ---------------------------------------------------------------------------
-## Licensed to the Apache Software Foundation (ASF) under one or more
-## contributor license agreements. See the NOTICE file distributed with
-## this work for additional information regarding copyright ownership.
-## The ASF licenses this file to You under the Apache License, Version 2.0
-## (the "License"); you may not use this file except in compliance with
-## the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-## ---------------------------------------------------------------------------
-
-appender.file.type = File
-appender.file.name = file
-appender.file.fileName = target/route-parser-test.log
-appender.file.layout.type = PatternLayout
-appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
-appender.out.type = Console
-appender.out.name = out
-appender.out.layout.type = PatternLayout
-appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
-logger.parser.name = org.apache.camel.parser
-logger.parser.level = DEBUG
-rootLogger.level = INFO
-rootLogger.appenderRef.file.ref = file
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml b/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml
deleted file mode 100644
index 14a370f..0000000
--- a/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
-
- <camelContext xmlns="http://camel.apache.org/schema/spring">
-
- <endpoint id="logger" uri="log:all"/>
-
- <onException>
- <exception>java.lang.Exception</exception>
- <handled>
- <constant>true</constant>
- </handled>
- <to uri="mock:dead"/>
- </onException>
-
- <onCompletion>
- <to uri="log:done"/>
- </onCompletion>
-
- <route>
- <from uri="stream:in?promptMessage=Enter something: "/>
- <transform>
- <simple>Hello ${body.toUpperCase()}</simple>
- </transform>
- <to uri="stream:out"/>
- </route>
- </camelContext>
-
-</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml b/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml
deleted file mode 100644
index f243369..0000000
--- a/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
-
- <!-- START SNIPPET: e1 -->
- <!-- camelContext is the Camel runtime, where we can host Camel routes -->
- <camelContext xmlns="http://camel.apache.org/schema/spring">
- <route>
- <!-- read input from the console using the stream component -->
- <from
- uri="stream:in?promptMessage=Enter something: "/>
- <!-- transform the input to upper case using the simple language -->
- <!-- you can also use other languages such as groovy, ognl, mvel, javascript etc. -->
- <transform>
- <simple>Hello ${body.toUpperCase()}</simple>
- </transform>
- <!-- and then print to the console -->
- <to uri="stream:out"/>
- </route>
- </camelContext>
- <!-- END SNIPPET: e1 -->
-
-</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml b/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml
deleted file mode 100644
index c132e34..0000000
--- a/tooling/route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<routes xmlns="http://camel.apache.org/schema/spring">
- <route id="cbr-route">
- <from uri="timer:foo?period=5000"/>
- <!-- generate random number message, using a 3 digit number -->
- <transform>
- <method bean="myTransformer"/>
- </transform>
- <choice>
- <when>
- <simple>${body} > 500</simple>
- <log message="High priority message : ${body}"/>
- </when>
- <otherwise>
- <log message="Low priority message : ${body}"/>
- </otherwise>
- </choice>
- </route>
-</routes>
[23/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: route parser for java and xml to parse source code. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b9e7ea84
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b9e7ea84
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b9e7ea84
Branch: refs/heads/master
Commit: b9e7ea8414bf98fef0fc5c9dea5ac6184c8c9cd9
Parents: 30daaea
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 12:27:55 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
.../apache/camel/parser/java/RoasterEndpointInjectTest.java | 6 +++---
.../parser/java/RoasterSimpleRouteBuilderConfigureTest.java | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b9e7ea84/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
index 121605a..a239789 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
@@ -46,13 +46,13 @@ public class RoasterEndpointInjectTest {
LOG.info("{}", details);
Assert.assertEquals("timer:foo?period=4999", details.get(0).getEndpointUri());
- Assert.assertEquals("27", details.get(0).getLineNumber());
+ Assert.assertEquals("28", details.get(0).getLineNumber());
Assert.assertEquals("log:a", details.get(1).getEndpointUri());
- Assert.assertEquals("31", details.get(1).getLineNumber());
+ Assert.assertEquals("32", details.get(1).getLineNumber());
Assert.assertEquals("netty4-http:http:someserver:80/hello", details.get(2).getEndpointUri());
- Assert.assertEquals("35", details.get(2).getLineNumber());
+ Assert.assertEquals("36", details.get(2).getLineNumber());
List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
for (ParserResult result : list) {
http://git-wip-us.apache.org/repos/asf/camel/blob/b9e7ea84/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
index 313cef5..5ea3a0a 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
@@ -46,9 +46,9 @@ public class RoasterSimpleRouteBuilderConfigureTest {
LOG.info(" Line: " + findLineNumber(simple.getPosition()));
}
Assert.assertEquals("${body} > 100", list.get(0).getElement());
- Assert.assertEquals(26, findLineNumber(list.get(0).getPosition()));
+ Assert.assertEquals(27, findLineNumber(list.get(0).getPosition()));
Assert.assertEquals("${body} > 200", list.get(1).getElement());
- Assert.assertEquals(29, findLineNumber(list.get(1).getPosition()));
+ Assert.assertEquals(30, findLineNumber(list.get(1).getPosition()));
}
public static int findLineNumber(int pos) throws Exception {
[05/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: route parser for java and xml to parse source code. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/42e4d973
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/42e4d973
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/42e4d973
Branch: refs/heads/master
Commit: 42e4d9733fab7082b90b5d16f90d4e8b4b4a3a85
Parents: 1d23b62
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 11:41:11 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
tooling/pom.xml | 1 +
tooling/route-parser/pom.xml | 43 ++
.../camel/parser/AnonymousMethodSource.java | 426 +++++++++++++
.../camel/parser/CamelJavaParserHelper.java | 630 +++++++++++++++++++
.../org/apache/camel/parser/ParserResult.java | 68 ++
.../apache/camel/parser/RouteBuilderParser.java | 281 +++++++++
.../camel/parser/StatementFieldSource.java | 278 ++++++++
.../parser/model/CamelEndpointDetails.java | 157 +++++
.../camel/parser/model/CamelSimpleDetails.java | 98 +++
.../src/main/resources/META-INF/LICENSE.txt | 203 ++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
11 files changed, 2196 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/pom.xml b/tooling/pom.xml
index b205a45..10e460d 100644
--- a/tooling/pom.xml
+++ b/tooling/pom.xml
@@ -39,6 +39,7 @@
<module>parent</module>
<module>spi-annotations</module>
<module>apt</module>
+ <module>route-parser</module>
<module>maven</module>
<module>archetypes</module>
<module>camel-manual</module>
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/route-parser/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/pom.xml b/tooling/route-parser/pom.xml
new file mode 100644
index 0000000..b6f51a0
--- /dev/null
+++ b/tooling/route-parser/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>tooling</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>route-parser</artifactId>
+ <name>Camel :: Tooling :: Route Parser</name>
+ <description>Java and XML source code parser for Camel routes</description>
+
+ <properties>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.forge.roaster</groupId>
+ <artifactId>roaster-jdt</artifactId>
+ <version>${roaster-version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/route-parser/src/main/java/org/apache/camel/parser/AnonymousMethodSource.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/AnonymousMethodSource.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/AnonymousMethodSource.java
new file mode 100644
index 0000000..777d34e
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/AnonymousMethodSource.java
@@ -0,0 +1,426 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+import org.jboss.forge.roaster.model.JavaType;
+import org.jboss.forge.roaster.model.Type;
+import org.jboss.forge.roaster.model.TypeVariable;
+import org.jboss.forge.roaster.model.Visibility;
+import org.jboss.forge.roaster.model.source.AnnotationSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.JavaDocSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.jboss.forge.roaster.model.source.ParameterSource;
+import org.jboss.forge.roaster.model.source.TypeVariableSource;
+
+/**
+ * In use when we have discovered a RouteBuilder being as anonymous inner class
+ */
+public class AnonymousMethodSource implements MethodSource<JavaClassSource> {
+
+ // this implementation should only implement the needed logic to support the parser
+
+ private final JavaClassSource origin;
+ private final Object internal;
+
+ public AnonymousMethodSource(JavaClassSource origin, Object internal) {
+ this.origin = origin;
+ this.internal = internal;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setDefault(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setSynchronized(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setNative(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(Class<?> aClass) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(JavaType<?> javaType) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnTypeVoid() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setBody(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setConstructor(boolean b) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setParameters(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> addThrows(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> addThrows(Class<? extends Exception> aClass) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeThrows(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeThrows(Class<? extends Exception> aClass) {
+ return null;
+ }
+
+ @Override
+ public boolean isSynchronized() {
+ return false;
+ }
+
+ @Override
+ public boolean isNative() {
+ return false;
+ }
+
+ @Override
+ public String getBody() {
+ return null;
+ }
+
+ @Override
+ public boolean isConstructor() {
+ return false;
+ }
+
+ @Override
+ public Type<JavaClassSource> getReturnType() {
+ return null;
+ }
+
+ @Override
+ public boolean isReturnTypeVoid() {
+ return false;
+ }
+
+ @Override
+ public List<ParameterSource<JavaClassSource>> getParameters() {
+ return null;
+ }
+
+ @Override
+ public String toSignature() {
+ return null;
+ }
+
+ @Override
+ public List<String> getThrownExceptions() {
+ return null;
+ }
+
+ @Override
+ public boolean isDefault() {
+ return false;
+ }
+
+ @Override
+ public ParameterSource<JavaClassSource> addParameter(Class<?> aClass, String s) {
+ return null;
+ }
+
+ @Override
+ public ParameterSource<JavaClassSource> addParameter(String s, String s1) {
+ return null;
+ }
+
+ @Override
+ public ParameterSource<JavaClassSource> addParameter(JavaType<?> javaType, String s) {
+ return null;
+ }
+
+ @Override
+ public void removeAllAnnotations() {
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(ParameterSource<JavaClassSource> parameterSource) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(Class<?> aClass, String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(String s, String s1) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeParameter(JavaType<?> javaType, String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setAbstract(boolean b) {
+ return null;
+ }
+
+ @Override
+ public List<AnnotationSource<JavaClassSource>> getAnnotations() {
+ return null;
+ }
+
+ @Override
+ public boolean hasAnnotation(Class<? extends Annotation> aClass) {
+ return false;
+ }
+
+ @Override
+ public boolean hasAnnotation(String s) {
+ return false;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> getAnnotation(Class<? extends Annotation> aClass) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> getAnnotation(String s) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> addAnnotation() {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> addAnnotation(Class<? extends Annotation> aClass) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource<JavaClassSource> addAnnotation(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeAnnotation(org.jboss.forge.roaster.model.Annotation<JavaClassSource> annotation) {
+ return null;
+ }
+
+ @Override
+ public List<TypeVariableSource<JavaClassSource>> getTypeVariables() {
+ return null;
+ }
+
+ @Override
+ public TypeVariableSource<JavaClassSource> getTypeVariable(String s) {
+ return null;
+ }
+
+ @Override
+ public TypeVariableSource<JavaClassSource> addTypeVariable() {
+ return null;
+ }
+
+ @Override
+ public TypeVariableSource<JavaClassSource> addTypeVariable(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeTypeVariable(String s) {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeTypeVariable(TypeVariable<?> typeVariable) {
+ return null;
+ }
+
+ @Override
+ public boolean hasJavaDoc() {
+ return false;
+ }
+
+ @Override
+ public boolean isAbstract() {
+ return false;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setFinal(boolean b) {
+ return null;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return false;
+ }
+
+ @Override
+ public Object getInternal() {
+ return internal;
+ }
+
+ @Override
+ public JavaDocSource<MethodSource<JavaClassSource>> getJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> removeJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setName(String s) {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public JavaClassSource getOrigin() {
+ return origin;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setStatic(boolean b) {
+ return null;
+ }
+
+ @Override
+ public boolean isStatic() {
+ return false;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setPackagePrivate() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setPublic() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setPrivate() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setProtected() {
+ return null;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setVisibility(Visibility visibility) {
+ return null;
+ }
+
+ @Override
+ public boolean isPackagePrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isPublic() {
+ return false;
+ }
+
+ @Override
+ public boolean isPrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isProtected() {
+ return false;
+ }
+
+ @Override
+ public Visibility getVisibility() {
+ return null;
+ }
+
+ @Override
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ @Override
+ public int getStartPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getEndPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getLineNumber() {
+ return 0;
+ }
+
+ @Override
+ public boolean hasTypeVariable(String arg0) {
+ return false;
+ }
+
+ @Override
+ public MethodSource<JavaClassSource> setReturnType(Type<?> arg0) {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
new file mode 100644
index 0000000..71d442d
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/CamelJavaParserHelper.java
@@ -0,0 +1,630 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Block;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.BooleanLiteral;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ClassInstanceCreation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Expression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ExpressionStatement;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.FieldDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.InfixExpression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MemberValuePair;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MethodInvocation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NumberLiteral;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ParenthesizedExpression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.QualifiedName;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ReturnStatement;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleName;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SimpleType;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SingleMemberAnnotation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Statement;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.StringLiteral;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Type;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclaration;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.VariableDeclarationStatement;
+import org.jboss.forge.roaster.model.Annotation;
+import org.jboss.forge.roaster.model.source.AnnotationSource;
+import org.jboss.forge.roaster.model.source.FieldSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.jboss.forge.roaster.model.util.Strings;
+
+/**
+ * A Camel Java parser that only depends on the Roaster API.
+ * <p/>
+ * This implementation is lower level details. For a higher level parser see {@link RouteBuilderParser}.
+ */
+public class CamelJavaParserHelper {
+
+ public static MethodSource<JavaClassSource> findConfigureMethod(JavaClassSource clazz) {
+ MethodSource<JavaClassSource> method = clazz.getMethod("configure");
+ // must be public void configure()
+ if (method != null && method.isPublic() && method.getParameters().isEmpty() && method.getReturnType().isType("void")) {
+ return method;
+ }
+
+ // maybe the route builder is from unit testing with camel-test as an anonymous inner class
+ // there is a bit of code to dig out this using the eclipse jdt api
+ method = findCreateRouteBuilderMethod(clazz);
+ if (method != null) {
+ return findConfigureMethodInCreateRouteBuilder(clazz, method);
+ }
+
+ return null;
+ }
+
+ public static List<MethodSource<JavaClassSource>> findInlinedConfigureMethods(JavaClassSource clazz) {
+ List<MethodSource<JavaClassSource>> answer = new ArrayList<>();
+
+ List<MethodSource<JavaClassSource>> methods = clazz.getMethods();
+ if (methods != null) {
+ for (MethodSource<JavaClassSource> method : methods) {
+ if (method.isPublic()
+ && (method.getParameters() == null || method.getParameters().isEmpty())
+ && (method.getReturnType() == null || method.getReturnType().isType("void"))) {
+ // maybe the method contains an inlined createRouteBuilder usually from an unit test method
+ MethodSource<JavaClassSource> builder = findConfigureMethodInCreateRouteBuilder(clazz, method);
+ if (builder != null) {
+ answer.add(builder);
+ }
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ private static MethodSource<JavaClassSource> findCreateRouteBuilderMethod(JavaClassSource clazz) {
+ MethodSource method = clazz.getMethod("createRouteBuilder");
+ if (method != null && (method.isPublic() || method.isProtected()) && method.getParameters().isEmpty()) {
+ return method;
+ }
+ return null;
+ }
+
+ private static MethodSource<JavaClassSource> findConfigureMethodInCreateRouteBuilder(JavaClassSource clazz, MethodSource<JavaClassSource> method) {
+ // find configure inside the code
+ MethodDeclaration md = (MethodDeclaration) method.getInternal();
+ Block block = md.getBody();
+ if (block != null) {
+ List statements = block.statements();
+ for (int i = 0; i < statements.size(); i++) {
+ Statement stmt = (Statement) statements.get(i);
+ Expression exp = null;
+ if (stmt instanceof ReturnStatement) {
+ ReturnStatement rs = (ReturnStatement) stmt;
+ exp = rs.getExpression();
+ } else if (stmt instanceof ExpressionStatement) {
+ ExpressionStatement es = (ExpressionStatement) stmt;
+ exp = es.getExpression();
+ if (exp instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) exp;
+ for (Object arg : mi.arguments()) {
+ if (arg instanceof ClassInstanceCreation) {
+ exp = (Expression) arg;
+ break;
+ }
+ }
+ }
+ }
+ if (exp != null && exp instanceof ClassInstanceCreation) {
+ ClassInstanceCreation cic = (ClassInstanceCreation) exp;
+ boolean isRouteBuilder = false;
+ if (cic.getType() instanceof SimpleType) {
+ SimpleType st = (SimpleType) cic.getType();
+ isRouteBuilder = "RouteBuilder".equals(st.getName().toString());
+ }
+ if (isRouteBuilder && cic.getAnonymousClassDeclaration() != null) {
+ List body = cic.getAnonymousClassDeclaration().bodyDeclarations();
+ for (int j = 0; j < body.size(); j++) {
+ Object line = body.get(j);
+ if (line instanceof MethodDeclaration) {
+ MethodDeclaration amd = (MethodDeclaration) line;
+ if ("configure".equals(amd.getName().toString())) {
+ return new AnonymousMethodSource(clazz, amd);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static List<ParserResult> parseCamelConsumerUris(MethodSource<JavaClassSource> method, boolean strings, boolean fields) {
+ return doParseCamelUris(method, true, false, strings, fields);
+ }
+
+ public static List<ParserResult> parseCamelProducerUris(MethodSource<JavaClassSource> method, boolean strings, boolean fields) {
+ return doParseCamelUris(method, false, true, strings, fields);
+ }
+
+ private static List<ParserResult> doParseCamelUris(MethodSource<JavaClassSource> method, boolean consumers, boolean producers,
+ boolean strings, boolean fields) {
+
+ List<ParserResult> answer = new ArrayList<ParserResult>();
+
+ if (method != null) {
+ MethodDeclaration md = (MethodDeclaration) method.getInternal();
+ Block block = md.getBody();
+ if (block != null) {
+ for (Object statement : md.getBody().statements()) {
+ // must be a method call expression
+ if (statement instanceof ExpressionStatement) {
+ ExpressionStatement es = (ExpressionStatement) statement;
+ Expression exp = es.getExpression();
+
+ List<ParserResult> uris = new ArrayList<ParserResult>();
+ parseExpression(method.getOrigin(), block, exp, uris, consumers, producers, strings, fields);
+ if (!uris.isEmpty()) {
+ // reverse the order as we will grab them from last->first
+ Collections.reverse(uris);
+ answer.addAll(uris);
+ }
+ }
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ private static void parseExpression(JavaClassSource clazz, Block block, Expression exp, List<ParserResult> uris,
+ boolean consumers, boolean producers, boolean strings, boolean fields) {
+ if (exp == null) {
+ return;
+ }
+ if (exp instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) exp;
+ doParseCamelUris(clazz, block, mi, uris, consumers, producers, strings, fields);
+ // if the method was called on another method, then recursive
+ exp = mi.getExpression();
+ parseExpression(clazz, block, exp, uris, consumers, producers, strings, fields);
+ }
+ }
+
+ private static void doParseCamelUris(JavaClassSource clazz, Block block, MethodInvocation mi, List<ParserResult> uris,
+ boolean consumers, boolean producers, boolean strings, boolean fields) {
+ String name = mi.getName().getIdentifier();
+
+ if (consumers) {
+ if ("from".equals(name)) {
+ List args = mi.arguments();
+ if (args != null) {
+ for (Object arg : args) {
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+ if ("fromF".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ if ("pollEnrich".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+
+ if (producers) {
+ if ("to".equals(name) || "toD".equals(name)) {
+ List args = mi.arguments();
+ if (args != null) {
+ for (Object arg : args) {
+ // skip if the arg is a boolean, ExchangePattern or Iterateable, type
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+ if ("toF".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ if ("enrich".equals(name) || "wireTap".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is where the uri is
+ if (args != null && args.size() >= 1) {
+ Object arg = args.get(0);
+ if (isValidArgument(name, arg)) {
+ extractEndpointUriFromArgument(name, clazz, block, uris, arg, strings, fields);
+ }
+ }
+ }
+ }
+ }
+
+ private static boolean isValidArgument(String node, Object arg) {
+ // skip boolean argument, as toD can accept a boolean value
+ if (arg instanceof BooleanLiteral) {
+ return false;
+ }
+ // skip ExchangePattern argument
+ if (arg instanceof QualifiedName) {
+ QualifiedName qn = (QualifiedName) arg;
+ String name = qn.getFullyQualifiedName();
+ if (name.startsWith("ExchangePattern")) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static void extractEndpointUriFromArgument(String node, JavaClassSource clazz, Block block, List<ParserResult> uris, Object arg, boolean strings, boolean fields) {
+ if (strings) {
+ String uri = getLiteralValue(clazz, block, (Expression) arg);
+ if (!Strings.isBlank(uri)) {
+ int position = ((Expression) arg).getStartPosition();
+
+ // if the node is fromF or toF, then replace all %s with {{%s}} as we cannot parse that value
+ if ("fromF".equals(node) || "toF".equals(node)) {
+ uri = uri.replaceAll("\\%s", "\\{\\{\\%s\\}\\}");
+ }
+
+ uris.add(new ParserResult(node, position, uri));
+ return;
+ }
+ }
+ if (fields && arg instanceof SimpleName) {
+ FieldSource field = getField(clazz, block, (SimpleName) arg);
+ if (field != null) {
+ // find the endpoint uri from the annotation
+ AnnotationSource annotation = field.getAnnotation("org.apache.camel.cdi.Uri");
+ if (annotation == null) {
+ annotation = field.getAnnotation("org.apache.camel.EndpointInject");
+ }
+ if (annotation != null) {
+ Expression exp = (Expression) annotation.getInternal();
+ if (exp instanceof SingleMemberAnnotation) {
+ exp = ((SingleMemberAnnotation) exp).getValue();
+ } else if (exp instanceof NormalAnnotation) {
+ List values = ((NormalAnnotation) exp).values();
+ for (Object value : values) {
+ MemberValuePair pair = (MemberValuePair) value;
+ if ("uri".equals(pair.getName().toString())) {
+ exp = pair.getValue();
+ break;
+ }
+ }
+ }
+ String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
+ if (!Strings.isBlank(uri)) {
+ int position = ((SimpleName) arg).getStartPosition();
+ uris.add(new ParserResult(node, position, uri));
+ }
+ } else {
+ // the field may be initialized using variables, so we need to evaluate those expressions
+ Object fi = field.getInternal();
+ if (fi instanceof VariableDeclaration) {
+ Expression exp = ((VariableDeclaration) fi).getInitializer();
+ String uri = CamelJavaParserHelper.getLiteralValue(clazz, block, exp);
+ if (!Strings.isBlank(uri)) {
+ // we want the position of the field, and not in the route
+ int position = ((VariableDeclaration) fi).getStartPosition();
+ uris.add(new ParserResult(node, position, uri));
+ }
+ }
+ }
+ }
+ }
+
+ // cannot parse it so add a failure
+ uris.add(new ParserResult(node, -1, arg.toString(), false));
+ }
+
+ public static List<ParserResult> parseCamelSimpleExpressions(MethodSource<JavaClassSource> method) {
+ List<ParserResult> answer = new ArrayList<ParserResult>();
+
+ MethodDeclaration md = (MethodDeclaration) method.getInternal();
+ Block block = md.getBody();
+ if (block != null) {
+ for (Object statement : block.statements()) {
+ // must be a method call expression
+ if (statement instanceof ExpressionStatement) {
+ ExpressionStatement es = (ExpressionStatement) statement;
+ Expression exp = es.getExpression();
+
+ List<ParserResult> expressions = new ArrayList<ParserResult>();
+ parseExpression(null, method.getOrigin(), block, exp, expressions);
+ if (!expressions.isEmpty()) {
+ // reverse the order as we will grab them from last->first
+ Collections.reverse(expressions);
+ answer.addAll(expressions);
+ }
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ private static void parseExpression(String node, JavaClassSource clazz, Block block, Expression exp, List<ParserResult> expressions) {
+ if (exp == null) {
+ return;
+ }
+ if (exp instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) exp;
+ doParseCamelSimple(node, clazz, block, mi, expressions);
+ // if the method was called on another method, then recursive
+ exp = mi.getExpression();
+ parseExpression(node, clazz, block, exp, expressions);
+ }
+ }
+
+ private static void doParseCamelSimple(String node, JavaClassSource clazz, Block block, MethodInvocation mi, List<ParserResult> expressions) {
+ String name = mi.getName().getIdentifier();
+
+ if ("simple".equals(name)) {
+ List args = mi.arguments();
+ // the first argument is a string parameter for the simple expression
+ if (args != null && args.size() >= 1) {
+ // it is a String type
+ Object arg = args.get(0);
+ String simple = getLiteralValue(clazz, block, (Expression) arg);
+ if (!Strings.isBlank(simple)) {
+ int position = ((Expression) arg).getStartPosition();
+ expressions.add(new ParserResult(node, position, simple));
+ }
+ }
+ }
+
+ // simple maybe be passed in as an argument
+ List args = mi.arguments();
+ if (args != null) {
+ for (Object arg : args) {
+ if (arg instanceof MethodInvocation) {
+ MethodInvocation ami = (MethodInvocation) arg;
+ doParseCamelSimple(node, clazz, block, ami, expressions);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static FieldSource<JavaClassSource> getField(JavaClassSource clazz, Block block, SimpleName ref) {
+ String fieldName = ref.getIdentifier();
+ if (fieldName != null) {
+ // find field in class
+ FieldSource field = clazz != null ? clazz.getField(fieldName) : null;
+ if (field == null) {
+ field = findFieldInBlock(clazz, block, fieldName);
+ }
+ return field;
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static FieldSource<JavaClassSource> findFieldInBlock(JavaClassSource clazz, Block block, String fieldName) {
+ for (Object statement : block.statements()) {
+ // try local statements first in the block
+ if (statement instanceof VariableDeclarationStatement) {
+ final Type type = ((VariableDeclarationStatement) statement).getType();
+ for (Object obj : ((VariableDeclarationStatement) statement).fragments()) {
+ if (obj instanceof VariableDeclarationFragment) {
+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
+ SimpleName name = fragment.getName();
+ if (name != null && fieldName.equals(name.getIdentifier())) {
+ return new StatementFieldSource(clazz, fragment, type);
+ }
+ }
+ }
+ }
+
+ // okay the field may be burried inside an anonymous inner class as a field declaration
+ // outside the configure method, so lets go back to the parent and see what we can find
+ ASTNode node = block.getParent();
+ if (node instanceof MethodDeclaration) {
+ node = node.getParent();
+ }
+ if (node instanceof AnonymousClassDeclaration) {
+ List declarations = ((AnonymousClassDeclaration) node).bodyDeclarations();
+ for (Object dec : declarations) {
+ if (dec instanceof FieldDeclaration) {
+ FieldDeclaration fd = (FieldDeclaration) dec;
+ final Type type = fd.getType();
+ for (Object obj : fd.fragments()) {
+ if (obj instanceof VariableDeclarationFragment) {
+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
+ SimpleName name = fragment.getName();
+ if (name != null && fieldName.equals(name.getIdentifier())) {
+ return new StatementFieldSource(clazz, fragment, type);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static String getLiteralValue(JavaClassSource clazz, Block block, Expression expression) {
+ // unwrap parenthesis
+ if (expression instanceof ParenthesizedExpression) {
+ expression = ((ParenthesizedExpression) expression).getExpression();
+ }
+
+ if (expression instanceof StringLiteral) {
+ return ((StringLiteral) expression).getLiteralValue();
+ } else if (expression instanceof BooleanLiteral) {
+ return "" + ((BooleanLiteral) expression).booleanValue();
+ } else if (expression instanceof NumberLiteral) {
+ return ((NumberLiteral) expression).getToken();
+ }
+
+ // if it a method invocation then add a dummy value assuming the method invocation will return a valid response
+ if (expression instanceof MethodInvocation) {
+ String name = ((MethodInvocation) expression).getName().getIdentifier();
+ return "{{" + name + "}}";
+ }
+
+ // if its a qualified name (usually a constant field in another class)
+ // then add a dummy value as we cannot find the field value in other classes and maybe even outside the
+ // source code we have access to
+ if (expression instanceof QualifiedName) {
+ QualifiedName qn = (QualifiedName) expression;
+ String name = qn.getFullyQualifiedName();
+ return "{{" + name + "}}";
+ }
+
+ if (expression instanceof SimpleName) {
+ FieldSource<JavaClassSource> field = getField(clazz, block, (SimpleName) expression);
+ if (field != null) {
+ // is the field annotated with a Camel endpoint
+ if (field.getAnnotations() != null) {
+ for (Annotation ann : field.getAnnotations()) {
+ boolean valid = "org.apache.camel.EndpointInject".equals(ann.getQualifiedName()) || "org.apache.camel.cdi.Uri".equals(ann.getQualifiedName());
+ if (valid) {
+ Expression exp = (Expression) ann.getInternal();
+ if (exp instanceof SingleMemberAnnotation) {
+ exp = ((SingleMemberAnnotation) exp).getValue();
+ } else if (exp instanceof NormalAnnotation) {
+ List values = ((NormalAnnotation) exp).values();
+ for (Object value : values) {
+ MemberValuePair pair = (MemberValuePair) value;
+ if ("uri".equals(pair.getName().toString())) {
+ exp = pair.getValue();
+ break;
+ }
+ }
+ }
+ if (exp != null) {
+ return getLiteralValue(clazz, block, exp);
+ }
+ }
+ }
+ }
+ // is the field an org.apache.camel.Endpoint type?
+ if ("Endpoint".equals(field.getType().getSimpleName())) {
+ // then grab the uri from the first argument
+ VariableDeclarationFragment vdf = (VariableDeclarationFragment) field.getInternal();
+ expression = vdf.getInitializer();
+ if (expression instanceof MethodInvocation) {
+ MethodInvocation mi = (MethodInvocation) expression;
+ List args = mi.arguments();
+ if (args != null && args.size() > 0) {
+ // the first argument has the endpoint uri
+ expression = (Expression) args.get(0);
+ return getLiteralValue(clazz, block, expression);
+ }
+ }
+ } else {
+ // no annotations so try its initializer
+ VariableDeclarationFragment vdf = (VariableDeclarationFragment) field.getInternal();
+ expression = vdf.getInitializer();
+ if (expression == null) {
+ // its a field which has no initializer, then add a dummy value assuming the field will be initialized at runtime
+ return "{{" + field.getName() + "}}";
+ } else {
+ return getLiteralValue(clazz, block, expression);
+ }
+ }
+ } else {
+ // we could not find the field in this class/method, so its maybe from some other super class, so insert a dummy value
+ final String fieldName = ((SimpleName) expression).getIdentifier();
+ return "{{" + fieldName + "}}";
+ }
+ } else if (expression instanceof InfixExpression) {
+ String answer = null;
+ // is it a string that is concat together?
+ InfixExpression ie = (InfixExpression) expression;
+ if (InfixExpression.Operator.PLUS.equals(ie.getOperator())) {
+
+ String val1 = getLiteralValue(clazz, block, ie.getLeftOperand());
+ String val2 = getLiteralValue(clazz, block, ie.getRightOperand());
+
+ // if numeric then we plus the values, otherwise we string concat
+ boolean numeric = isNumericOperator(clazz, block, ie.getLeftOperand()) && isNumericOperator(clazz, block, ie.getRightOperand());
+ if (numeric) {
+ Long num1 = (val1 != null ? Long.valueOf(val1) : 0);
+ Long num2 = (val2 != null ? Long.valueOf(val2) : 0);
+ answer = "" + (num1 + num2);
+ } else {
+ answer = (val1 != null ? val1 : "") + (val2 != null ? val2 : "");
+ }
+
+ if (!answer.isEmpty()) {
+ // include extended when we concat on 2 or more lines
+ List extended = ie.extendedOperands();
+ if (extended != null) {
+ for (Object ext : extended) {
+ String val3 = getLiteralValue(clazz, block, (Expression) ext);
+ if (numeric) {
+ Long num3 = (val3 != null ? Long.valueOf(val3) : 0);
+ Long num = Long.valueOf(answer);
+ answer = "" + (num + num3);
+ } else {
+ answer += val3 != null ? val3 : "";
+ }
+ }
+ }
+ }
+ }
+ return answer;
+ }
+
+ return null;
+ }
+
+ private static boolean isNumericOperator(JavaClassSource clazz, Block block, Expression expression) {
+ if (expression instanceof NumberLiteral) {
+ return true;
+ } else if (expression instanceof SimpleName) {
+ FieldSource field = getField(clazz, block, (SimpleName) expression);
+ if (field != null) {
+ return field.getType().isType("int") || field.getType().isType("long")
+ || field.getType().isType("Integer") || field.getType().isType("Long");
+ }
+ }
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
new file mode 100644
index 0000000..445147d
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+public class ParserResult {
+
+ private final String node;
+ private boolean parsed;
+ private int position;
+ private String element;
+
+ public ParserResult(String node, int position, String element) {
+ this(node, position, element, true);
+ }
+
+ public ParserResult(String node, int position, String element, boolean parsed) {
+ this.node = node;
+ this.position = position;
+ this.element = element;
+ this.parsed = parsed;
+ }
+
+ public int getPosition() {
+ return position;
+ }
+
+ public void setPosition(int position) {
+ this.position = position;
+ }
+
+ public String getElement() {
+ return element;
+ }
+
+ public void setElement(String element) {
+ this.element = element;
+ }
+
+ public boolean isParsed() {
+ return parsed;
+ }
+
+ public void setParsed(boolean parsed) {
+ this.parsed = parsed;
+ }
+
+ public String getNode() {
+ return node;
+ }
+
+ public String toString() {
+ return element;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
new file mode 100644
index 0000000..2327ae1
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
@@ -0,0 +1,281 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.apache.camel.parser.model.CamelSimpleDetails;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Expression;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.MemberValuePair;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.SingleMemberAnnotation;
+import org.jboss.forge.roaster.model.Annotation;
+import org.jboss.forge.roaster.model.source.FieldSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.jboss.forge.roaster.model.util.Strings;
+
+/**
+ * A Camel RouteBuilder parser that parses Camel Java routes source code.
+ * <p/>
+ * This implementation is higher level details, and uses the lower level parser {@link CamelJavaParserHelper}.
+ */
+public class RouteBuilderParser {
+
+ public static void parseRouteBuilderEndpoints(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
+ List<CamelEndpointDetails> endpoints) {
+ parseRouteBuilderEndpoints(clazz, baseDir, fullyQualifiedFileName, endpoints, null, false);
+ }
+
+ public static void parseRouteBuilderEndpoints(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
+ List<CamelEndpointDetails> endpoints, List<String> unparsable, boolean includeInlinedRouteBuilders) {
+
+ // look for fields which are not used in the route
+ for (FieldSource<JavaClassSource> field : clazz.getFields()) {
+
+ // is the field annotated with a Camel endpoint
+ String uri = null;
+ Expression exp = null;
+ for (Annotation ann : field.getAnnotations()) {
+ boolean valid = "org.apache.camel.EndpointInject".equals(ann.getQualifiedName()) || "org.apache.camel.cdi.Uri".equals(ann.getQualifiedName());
+ if (valid) {
+ exp = (Expression) ann.getInternal();
+ if (exp instanceof SingleMemberAnnotation) {
+ exp = ((SingleMemberAnnotation) exp).getValue();
+ } else if (exp instanceof NormalAnnotation) {
+ List values = ((NormalAnnotation) exp).values();
+ for (Object value : values) {
+ MemberValuePair pair = (MemberValuePair) value;
+ if ("uri".equals(pair.getName().toString())) {
+ exp = pair.getValue();
+ break;
+ }
+ }
+ }
+ uri = CamelJavaParserHelper.getLiteralValue(clazz, null, exp);
+ }
+ }
+
+ // we only want to add fields which are not used in the route
+ if (!Strings.isBlank(uri) && findEndpointByUri(endpoints, uri) == null) {
+
+ // we only want the relative dir name from the
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+ String id = field.getName();
+
+ CamelEndpointDetails detail = new CamelEndpointDetails();
+ detail.setFileName(fileName);
+ detail.setClassName(clazz.getQualifiedName());
+ detail.setEndpointInstance(id);
+ detail.setEndpointUri(uri);
+ detail.setEndpointComponentName(endpointComponentName(uri));
+
+ // favor the position of the expression which had the actual uri
+ Object internal = exp != null ? exp : field.getInternal();
+
+ // find position of field/expression
+ if (internal instanceof ASTNode) {
+ int pos = ((ASTNode) internal).getStartPosition();
+ int line = findLineNumber(fullyQualifiedFileName, pos);
+ if (line > -1) {
+ detail.setLineNumber("" + line);
+ }
+ }
+ // we do not know if this field is used as consumer or producer only, but we try
+ // to find out by scanning the route in the configure method below
+ endpoints.add(detail);
+ }
+ }
+
+ // find all the configure methods
+ List<MethodSource<JavaClassSource>> methods = new ArrayList<>();
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+ if (method != null) {
+ methods.add(method);
+ }
+ if (includeInlinedRouteBuilders) {
+ List<MethodSource<JavaClassSource>> inlinedMethods = CamelJavaParserHelper.findInlinedConfigureMethods(clazz);
+ if (!inlinedMethods.isEmpty()) {
+ methods.addAll(inlinedMethods);
+ }
+ }
+
+ // look if any of these fields are used in the route only as consumer or producer, as then we can
+ // determine this to ensure when we edit the endpoint we should only the options accordingly
+ for (MethodSource<JavaClassSource> configureMethod : methods) {
+ // consumers only
+ List<ParserResult> uris = CamelJavaParserHelper.parseCamelConsumerUris(configureMethod, true, true);
+ for (ParserResult result : uris) {
+ if (!result.isParsed()) {
+ if (unparsable != null) {
+ unparsable.add(result.getElement());
+ }
+ } else {
+ CamelEndpointDetails detail = findEndpointByUri(endpoints, result.getElement());
+ if (detail != null) {
+ // its a consumer only
+ detail.setConsumerOnly(true);
+ } else {
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+
+ detail = new CamelEndpointDetails();
+ detail.setFileName(fileName);
+ detail.setClassName(clazz.getQualifiedName());
+ detail.setMethodName(configureMethod.getName());
+ detail.setEndpointInstance(null);
+ detail.setEndpointUri(result.getElement());
+ int line = findLineNumber(fullyQualifiedFileName, result.getPosition());
+ if (line > -1) {
+ detail.setLineNumber("" + line);
+ }
+ detail.setEndpointComponentName(endpointComponentName(result.getElement()));
+ detail.setConsumerOnly(true);
+ detail.setProducerOnly(false);
+ endpoints.add(detail);
+ }
+ }
+ }
+ // producer only
+ uris = CamelJavaParserHelper.parseCamelProducerUris(configureMethod, true, true);
+ for (ParserResult result : uris) {
+ if (!result.isParsed()) {
+ if (unparsable != null) {
+ unparsable.add(result.getElement());
+ }
+ } else {
+ CamelEndpointDetails detail = findEndpointByUri(endpoints, result.getElement());
+ if (detail != null) {
+ if (detail.isConsumerOnly()) {
+ // its both a consumer and producer
+ detail.setConsumerOnly(false);
+ detail.setProducerOnly(false);
+ } else {
+ // its a producer only
+ detail.setProducerOnly(true);
+ }
+ }
+ // the same endpoint uri may be used in multiple places in the same route
+ // so we should maybe add all of them
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+
+ detail = new CamelEndpointDetails();
+ detail.setFileName(fileName);
+ detail.setClassName(clazz.getQualifiedName());
+ detail.setMethodName(configureMethod.getName());
+ detail.setEndpointInstance(null);
+ detail.setEndpointUri(result.getElement());
+ int line = findLineNumber(fullyQualifiedFileName, result.getPosition());
+ if (line > -1) {
+ detail.setLineNumber("" + line);
+ }
+ detail.setEndpointComponentName(endpointComponentName(result.getElement()));
+ detail.setConsumerOnly(false);
+ detail.setProducerOnly(true);
+ endpoints.add(detail);
+ }
+ }
+ }
+ }
+
+ private static CamelEndpointDetails findEndpointByUri(List<CamelEndpointDetails> endpoints, String uri) {
+ for (CamelEndpointDetails detail : endpoints) {
+ if (uri.equals(detail.getEndpointUri())) {
+ return detail;
+ }
+ }
+ return null;
+ }
+
+ public static void parseRouteBuilderSimpleExpressions(JavaClassSource clazz, String baseDir, String fullyQualifiedFileName,
+ List<CamelSimpleDetails> simpleExpressions) {
+
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+ if (method != null) {
+ List<ParserResult> expressions = CamelJavaParserHelper.parseCamelSimpleExpressions(method);
+ for (ParserResult result : expressions) {
+ if (result.isParsed()) {
+ String fileName = fullyQualifiedFileName;
+ if (fileName.startsWith(baseDir)) {
+ fileName = fileName.substring(baseDir.length() + 1);
+ }
+
+ CamelSimpleDetails details = new CamelSimpleDetails();
+ details.setFileName(fileName);
+ details.setClassName(clazz.getQualifiedName());
+ details.setMethodName("configure");
+ int line = findLineNumber(fullyQualifiedFileName, result.getPosition());
+ if (line > -1) {
+ details.setLineNumber("" + line);
+ }
+ details.setSimple(result.getElement());
+
+ simpleExpressions.add(details);
+ }
+ }
+ }
+ }
+
+ private static int findLineNumber(String fullyQualifiedFileName, int position) {
+ int lines = 0;
+
+ try {
+ int current = 0;
+ try (BufferedReader br = new BufferedReader(new FileReader(new File(fullyQualifiedFileName)))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ lines++;
+ current += line.length() + 1; // add 1 for line feed
+ if (current >= position) {
+ return lines;
+ }
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ return -1;
+ }
+
+ return lines;
+ }
+
+ private static String endpointComponentName(String uri) {
+ if (uri != null) {
+ int idx = uri.indexOf(":");
+ if (idx > 0) {
+ return uri.substring(0, idx);
+ }
+ }
+ return null;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/route-parser/src/main/java/org/apache/camel/parser/StatementFieldSource.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/StatementFieldSource.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/StatementFieldSource.java
new file mode 100644
index 0000000..1daa85d
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/StatementFieldSource.java
@@ -0,0 +1,278 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser;
+
+import java.util.List;
+
+import org.jboss.forge.roaster.model.Annotation;
+import org.jboss.forge.roaster.model.JavaType;
+import org.jboss.forge.roaster.model.Type;
+import org.jboss.forge.roaster.model.Visibility;
+import org.jboss.forge.roaster.model.impl.TypeImpl;
+import org.jboss.forge.roaster.model.source.AnnotationSource;
+import org.jboss.forge.roaster.model.source.FieldSource;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.JavaDocSource;
+
+public class StatementFieldSource implements FieldSource {
+
+ // this implementation should only implement the needed logic to support the parser
+
+ private final JavaClassSource origin;
+ private final Object internal;
+ private final Type type;
+
+ public StatementFieldSource(JavaClassSource origin, Object internal, Object typeInternal) {
+ this.origin = origin;
+ this.internal = internal;
+ this.type = new TypeImpl(origin, typeInternal);
+ }
+
+ @Override
+ public FieldSource setType(Class clazz) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setType(String type) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setLiteralInitializer(String value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setStringInitializer(String value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setTransient(boolean value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setVolatile(boolean value) {
+ return null;
+ }
+
+ @Override
+ public FieldSource setType(JavaType entity) {
+ return null;
+ }
+
+ @Override
+ public List<AnnotationSource> getAnnotations() {
+ return null;
+ }
+
+ @Override
+ public boolean hasAnnotation(String type) {
+ return false;
+ }
+
+ @Override
+ public boolean hasAnnotation(Class type) {
+ return false;
+ }
+
+ @Override
+ public AnnotationSource getAnnotation(String type) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource addAnnotation() {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource addAnnotation(String className) {
+ return null;
+ }
+
+ @Override
+ public void removeAllAnnotations() {
+ }
+
+ @Override
+ public Object removeAnnotation(Annotation annotation) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource addAnnotation(Class type) {
+ return null;
+ }
+
+ @Override
+ public AnnotationSource getAnnotation(Class type) {
+ return null;
+ }
+
+ @Override
+ public Type getType() {
+ return type;
+ }
+
+ @Override
+ public String getStringInitializer() {
+ return null;
+ }
+
+ @Override
+ public String getLiteralInitializer() {
+ return null;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return false;
+ }
+
+ @Override
+ public boolean isVolatile() {
+ return false;
+ }
+
+ @Override
+ public Object setFinal(boolean finl) {
+ return null;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return false;
+ }
+
+ @Override
+ public Object getInternal() {
+ return internal;
+ }
+
+ @Override
+ public JavaDocSource getJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public boolean hasJavaDoc() {
+ return false;
+ }
+
+ @Override
+ public Object removeJavaDoc() {
+ return null;
+ }
+
+ @Override
+ public Object setName(String name) {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public Object getOrigin() {
+ return origin;
+ }
+
+ @Override
+ public Object setStatic(boolean value) {
+ return null;
+ }
+
+ @Override
+ public boolean isStatic() {
+ return false;
+ }
+
+ @Override
+ public Object setPackagePrivate() {
+ return null;
+ }
+
+ @Override
+ public Object setPublic() {
+ return null;
+ }
+
+ @Override
+ public Object setPrivate() {
+ return null;
+ }
+
+ @Override
+ public Object setProtected() {
+ return null;
+ }
+
+ @Override
+ public Object setVisibility(Visibility scope) {
+ return null;
+ }
+
+ @Override
+ public boolean isPackagePrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isPublic() {
+ return false;
+ }
+
+ @Override
+ public boolean isPrivate() {
+ return false;
+ }
+
+ @Override
+ public boolean isProtected() {
+ return false;
+ }
+
+ @Override
+ public Visibility getVisibility() {
+ return null;
+ }
+
+ @Override
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ @Override
+ public int getStartPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getEndPosition() {
+ return 0;
+ }
+
+ @Override
+ public int getLineNumber() {
+ return 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
new file mode 100644
index 0000000..2255c1d
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelEndpointDetails.java
@@ -0,0 +1,157 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.model;
+
+public class CamelEndpointDetails {
+
+ private String fileName;
+ private String lineNumber;
+ private String lineNumberEnd;
+ private String className;
+ private String methodName;
+ private String endpointComponentName;
+ private String endpointInstance;
+ private String endpointUri;
+ private boolean consumerOnly;
+ private boolean producerOnly;
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getLineNumber() {
+ return lineNumber;
+ }
+
+ public void setLineNumber(String lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ public String getLineNumberEnd() {
+ return lineNumberEnd;
+ }
+
+ public void setLineNumberEnd(String lineNumberEnd) {
+ this.lineNumberEnd = lineNumberEnd;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+ public String getEndpointComponentName() {
+ return endpointComponentName;
+ }
+
+ public void setEndpointComponentName(String endpointComponentName) {
+ this.endpointComponentName = endpointComponentName;
+ }
+
+ public String getEndpointInstance() {
+ return endpointInstance;
+ }
+
+ public void setEndpointInstance(String endpointInstance) {
+ this.endpointInstance = endpointInstance;
+ }
+
+ public String getEndpointUri() {
+ return endpointUri;
+ }
+
+ public void setEndpointUri(String endpointUri) {
+ this.endpointUri = endpointUri;
+ }
+
+ public boolean isConsumerOnly() {
+ return consumerOnly;
+ }
+
+ public void setConsumerOnly(boolean consumerOnly) {
+ this.consumerOnly = consumerOnly;
+ }
+
+ public boolean isProducerOnly() {
+ return producerOnly;
+ }
+
+ public void setProducerOnly(boolean producerOnly) {
+ this.producerOnly = producerOnly;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ CamelEndpointDetails that = (CamelEndpointDetails) o;
+
+ if (!fileName.equals(that.fileName)) return false;
+ if (lineNumber != null ? !lineNumber.equals(that.lineNumber) : that.lineNumber != null) return false;
+ if (lineNumberEnd != null ? !lineNumberEnd.equals(that.lineNumberEnd) : that.lineNumberEnd != null) return false;
+ if (!className.equals(that.className)) return false;
+ if (methodName != null ? !methodName.equals(that.methodName) : that.methodName != null) return false;
+ if (endpointInstance != null ? !endpointInstance.equals(that.endpointInstance) : that.endpointInstance != null)
+ return false;
+ return endpointUri.equals(that.endpointUri);
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = fileName.hashCode();
+ result = 31 * result + (lineNumber != null ? lineNumber.hashCode() : 0);
+ result = 31 * result + (lineNumberEnd != null ? lineNumberEnd.hashCode() : 0);
+ result = 31 * result + className.hashCode();
+ result = 31 * result + (methodName != null ? methodName.hashCode() : 0);
+ result = 31 * result + (endpointInstance != null ? endpointInstance.hashCode() : 0);
+ result = 31 * result + endpointUri.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "CamelEndpointDetails[" +
+ "fileName='" + fileName + '\'' +
+ ", lineNumber='" + lineNumber + '\'' +
+ ", lineNumberEnd='" + lineNumberEnd + '\'' +
+ ", className='" + className + '\'' +
+ ", methodName='" + methodName + '\'' +
+ ", endpointComponentName='" + endpointComponentName + '\'' +
+ ", endpointInstance='" + endpointInstance + '\'' +
+ ", endpointUri='" + endpointUri + '\'' +
+ ", consumerOnly=" + consumerOnly +
+ ", producerOnly=" + producerOnly +
+ ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42e4d973/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleDetails.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleDetails.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleDetails.java
new file mode 100644
index 0000000..058111d
--- /dev/null
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/model/CamelSimpleDetails.java
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.model;
+
+public class CamelSimpleDetails {
+
+ private String fileName;
+ private String lineNumber;
+ private String lineNumberEnd;
+ private String className;
+ private String methodName;
+ private String simple;
+ private boolean predicate;
+ private boolean expression;
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getLineNumber() {
+ return lineNumber;
+ }
+
+ public void setLineNumber(String lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ public String getLineNumberEnd() {
+ return lineNumberEnd;
+ }
+
+ public void setLineNumberEnd(String lineNumberEnd) {
+ this.lineNumberEnd = lineNumberEnd;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+ public String getSimple() {
+ return simple;
+ }
+
+ public void setSimple(String simple) {
+ this.simple = simple;
+ }
+
+ public boolean isPredicate() {
+ return predicate;
+ }
+
+ public void setPredicate(boolean predicate) {
+ this.predicate = predicate;
+ }
+
+ public boolean isExpression() {
+ return expression;
+ }
+
+ public void setExpression(boolean expression) {
+ this.expression = expression;
+ }
+
+ @Override
+ public String toString() {
+ return simple;
+ }
+}
[20/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..a57ce23
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterConcatFieldRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterConcatFieldRouteBuilderConfigureTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
new file mode 100644
index 0000000..8ffb23b
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterEndpointInjectTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterEndpointInjectTest.class);
+
+ @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 = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<CamelEndpointDetails> details = new ArrayList<>();
+ RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/java/MyCdiRouteBuilder.java", details);
+ LOG.info("{}", details);
+
+ Assert.assertEquals("timer:foo?period=4999", details.get(0).getEndpointUri());
+ Assert.assertEquals("28", details.get(0).getLineNumber());
+
+ Assert.assertEquals("log:a", details.get(1).getEndpointUri());
+ Assert.assertEquals("32", details.get(1).getLineNumber());
+
+ Assert.assertEquals("netty4-http:http:someserver:80/hello", details.get(2).getEndpointUri());
+ Assert.assertEquals("36", details.get(2).getLineNumber());
+
+ 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(2, list.size());
+
+ Assert.assertEquals(5, details.size());
+ Assert.assertEquals("log:a", details.get(3).getEndpointUri());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..5b16bd3
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterFieldRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterFieldRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyFieldRouteBuilder.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", list.get(0).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("file:output?fileExist=Override", list.get(0).getElement());
+ Assert.assertEquals("log:b", list.get(1).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..00a8623
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMethodCallRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMethodCallRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyMethodCallRouteBuilder.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", list.get(0).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("file:output?fileExist={{whatToDoWhenExists}}", list.get(0).getElement());
+ Assert.assertEquals("log:b", list.get(1).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..44b4539
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMyFieldMethodCallRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMyFieldMethodCallRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyFieldMethodCallRouteBuilder.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("netty-http:http://0.0.0.0:{{port}}/foo", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("mock:input1", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+ Assert.assertEquals("mock:input2", list.get(2).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
new file mode 100644
index 0000000..9b1495e
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMyLocalAddRouteBuilderTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMyLocalAddRouteBuilderTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyLocalAddRouteBuilderTest.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+ Assert.assertNull(method);
+
+ List<MethodSource<JavaClassSource>> methods = CamelJavaParserHelper.findInlinedConfigureMethods(clazz);
+ Assert.assertEquals(1, methods.size());
+ method = methods.get(0);
+
+ List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Consumer: " + result.getElement());
+ }
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
new file mode 100644
index 0000000..603d96f
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterMyNettyTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterMyNettyTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyNettyTest.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<ParserResult> list = CamelJavaParserHelper.parseCamelConsumerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Consumer: " + result.getElement());
+ }
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{port}}/foo", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+
+ list = CamelJavaParserHelper.parseCamelProducerUris(method, true, true);
+ for (ParserResult result : list) {
+ LOG.info("Producer: " + result.getElement());
+ }
+ Assert.assertEquals("mock:input1", list.get(0).getElement());
+ Assert.assertEquals("netty-http:http://0.0.0.0:{{getNextPort}}/bar", list.get(1).getElement());
+ Assert.assertEquals("mock:input2", list.get(2).getElement());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..3b7cb69
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterNewLineConstRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterNewLineConstRouteBuilderConfigureTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..eeb320f
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterNewLineRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterNewLineRouteBuilderConfigureTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MyNewLineRouteBuilder.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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
new file mode 100644
index 0000000..9760f66
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterRouteBuilderCamelTestSupportTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderCamelTestSupportTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..af9cb2e
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderConfigureTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
new file mode 100644
index 0000000..3d97c65
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterRouteBuilderEmptyUriTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterRouteBuilderEmptyUriTest.class);
+
+ @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());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
new file mode 100644
index 0000000..c83d89a
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleProcessorTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleProcessorTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
new file mode 100644
index 0000000..14d63af
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleRouteBuilderConfigureTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleRouteBuilderConfigureTest.class);
+
+ @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(27, findLineNumber(list.get(0).getPosition()));
+ Assert.assertEquals("${body} > 200", list.get(1).getElement());
+ Assert.assertEquals(30, findLineNumber(list.get(1).getPosition()));
+ }
+
+ public static int findLineNumber(int pos) throws Exception {
+ int lines = 0;
+ int current = 0;
+ File file = new File("src/test/java/org/apache/camel/parser/java/MySimpleRouteBuilder.java");
+ try (BufferedReader br = new BufferedReader(new FileReader(file))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ lines++;
+ current += line.length();
+ if (current > pos) {
+ return lines;
+ }
+ }
+ }
+ return -1;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
new file mode 100644
index 0000000..aeea6cf
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleToDTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleToDTest.class);
+
+ @Test
+ public void parse() throws Exception {
+ JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.java"));
+ MethodSource<JavaClassSource> method = CamelJavaParserHelper.findConfigureMethod(clazz);
+
+ List<CamelEndpointDetails> details = new ArrayList<>();
+ RouteBuilderParser.parseRouteBuilderEndpoints(clazz, ".", "src/test/java/org/apache/camel/parser/java/MySimpleToDRoute.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("toD", list.get(0).getNode());
+ Assert.assertEquals("log:a", list.get(0).getElement());
+ Assert.assertEquals("to", list.get(1).getNode());
+ Assert.assertEquals("log:b", list.get(1).getElement());
+ Assert.assertEquals("to", list.get(2).getNode());
+ Assert.assertEquals("log:c", list.get(2).getElement());
+ Assert.assertEquals(3, list.size());
+
+ Assert.assertEquals(4, details.size());
+ Assert.assertEquals("direct:start", details.get(0).getEndpointUri());
+ Assert.assertEquals("log:a", details.get(1).getEndpointUri());
+ Assert.assertEquals("log:b", details.get(2).getEndpointUri());
+ Assert.assertEquals("log:c", details.get(3).getEndpointUri());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
new file mode 100644
index 0000000..82d9f75
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSimpleToFTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSimpleToFTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
new file mode 100644
index 0000000..ef8bde8
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RoasterSplitTokenizeTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoasterSplitTokenizeTest.class);
+
+ @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());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
new file mode 100644
index 0000000..de37bf8
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+public class SimpleProcessorTest extends CamelTestSupport {
+
+ public void testProcess() throws Exception {
+ String out = template.requestBody("direct:start", "Hello World", String.class);
+ assertEquals("Bye World", out);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ exchange.getOut().setBody("Bye World");
+ }
+ });
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
new file mode 100644
index 0000000..4243dff
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
@@ -0,0 +1,126 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.java;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+public class SplitTokenizeTest extends CamelTestSupport {
+
+ public void testSplitTokenizerA() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("Claus", "James", "Willem");
+
+ template.sendBody("direct:a", "Claus,James,Willem");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerB() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("Claus", "James", "Willem");
+
+ template.sendBodyAndHeader("direct:b", "Hello World", "myHeader", "Claus,James,Willem");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerC() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("Claus", "James", "Willem");
+
+ template.sendBody("direct:c", "Claus James Willem");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerD() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("[Claus]", "[James]", "[Willem]");
+
+ template.sendBody("direct:d", "[Claus][James][Willem]");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerE() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("<person>Claus</person>", "<person>James</person>", "<person>Willem</person>");
+
+ String xml = "<persons><person>Claus</person><person>James</person><person>Willem</person></persons>";
+ template.sendBody("direct:e", xml);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerEWithSlash() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ String xml = "<persons><person attr='/' /></persons>";
+ mock.expectedBodiesReceived("<person attr='/' />");
+ template.sendBody("direct:e", xml);
+ mock.assertIsSatisfied();
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testSplitTokenizerF() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:split");
+ mock.expectedBodiesReceived("<person name=\"Claus\"/>", "<person>James</person>", "<person>Willem</person>");
+
+ String xml = "<persons><person/><person name=\"Claus\"/><person>James</person><person>Willem</person></persons>";
+ template.sendBody("direct:f", xml);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ from("direct:a")
+ .split().tokenize(",")
+ .to("mock:split");
+
+ from("direct:b")
+ .split().tokenize(",", "myHeader")
+ .to("mock:split");
+
+ from("direct:c")
+ .split().tokenize("(\\W+)\\s*", null, true)
+ .to("mock:split");
+
+ from("direct:d")
+ .split().tokenizePair("[", "]", true)
+ .to("mock:split");
+
+ from("direct:e")
+ .split().tokenizeXML("person")
+ .to("mock:split");
+
+ from("direct:f")
+ .split().xpath("//person")
+ // To test the body is not empty
+ // it will call the ObjectHelper.evaluateValuePredicate()
+ .filter().simple("${body}")
+ .to("mock:split");
+
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
new file mode 100644
index 0000000..f15dd0e
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/FindElementInRoutesTest.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.xml;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.w3c.dom.Element;
+
+import org.apache.camel.parser.helper.CamelXmlHelper;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertNotNull;
+
+public class FindElementInRoutesTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FindElementInRoutesTest.class);
+
+ @Test
+ public void testXml() throws Exception {
+ InputStream is = new FileInputStream("src/test/resources/org/apache/camel/parser/xml/myroutes.xml");
+ String key = "_camelContext1/cbr-route/_from1";
+ Element element = CamelXmlHelper.getSelectedCamelElementNode(key, is);
+ assertNotNull("Could not find Element for key " + key, element);
+
+ LOG.info("Found element " + element.getTagName());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java
new file mode 100644
index 0000000..6f8aeb6
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/XmlOnExceptionRouteTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.xml;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.XmlRouteParser;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class XmlOnExceptionRouteTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(XmlOnExceptionRouteTest.class);
+
+ @Test
+ public void testXml() throws Exception {
+ List<CamelEndpointDetails> endpoints = new ArrayList<>();
+
+ InputStream is = new FileInputStream("src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml");
+ String fqn = "src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml";
+ String baseDir = "src/test/resources";
+ XmlRouteParser.parseXmlRouteEndpoints(is, baseDir, fqn, endpoints);
+
+ for (CamelEndpointDetails detail : endpoints) {
+ LOG.info(detail.getEndpointUri());
+ }
+
+ Assert.assertEquals("log:all", endpoints.get(0).getEndpointUri());
+ Assert.assertEquals("mock:dead", endpoints.get(1).getEndpointUri());
+ Assert.assertEquals("log:done", endpoints.get(2).getEndpointUri());
+ Assert.assertEquals("stream:in?promptMessage=Enter something:", endpoints.get(3).getEndpointUri());
+ Assert.assertEquals("stream:out", endpoints.get(4).getEndpointUri());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java
new file mode 100644
index 0000000..05be852
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/xml/XmlRouteTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.parser.xml;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.parser.XmlRouteParser;
+import org.apache.camel.parser.model.CamelEndpointDetails;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class XmlRouteTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(XmlRouteTest.class);
+
+ @Test
+ public void testXml() throws Exception {
+ List<CamelEndpointDetails> endpoints = new ArrayList<>();
+
+ InputStream is = new FileInputStream("src/test/resources/org/apache/camel/parser/xml/mycamel.xml");
+ String fqn = "src/test/resources/org/apache/camel/camel/parser/xml/mycamel.xml";
+ String baseDir = "src/test/resources";
+ XmlRouteParser.parseXmlRouteEndpoints(is, baseDir, fqn, endpoints);
+
+ for (CamelEndpointDetails detail : endpoints) {
+ LOG.info(detail.getEndpointUri());
+ }
+ Assert.assertEquals("stream:in?promptMessage=Enter something:", endpoints.get(0).getEndpointUri());
+ Assert.assertEquals("stream:out", endpoints.get(1).getEndpointUri());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/resources/log4j2.properties b/tooling/camel-route-parser/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..2f66eb5
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/resources/log4j2.properties
@@ -0,0 +1,30 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/route-parser-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+logger.parser.name = org.apache.camel.parser
+logger.parser.level = DEBUG
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml b/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml
new file mode 100644
index 0000000..14a370f
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel-onexception.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+ <endpoint id="logger" uri="log:all"/>
+
+ <onException>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
+ <to uri="mock:dead"/>
+ </onException>
+
+ <onCompletion>
+ <to uri="log:done"/>
+ </onCompletion>
+
+ <route>
+ <from uri="stream:in?promptMessage=Enter something: "/>
+ <transform>
+ <simple>Hello ${body.toUpperCase()}</simple>
+ </transform>
+ <to uri="stream:out"/>
+ </route>
+ </camelContext>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml b/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml
new file mode 100644
index 0000000..f243369
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/mycamel.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <!-- START SNIPPET: e1 -->
+ <!-- camelContext is the Camel runtime, where we can host Camel routes -->
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <!-- read input from the console using the stream component -->
+ <from
+ uri="stream:in?promptMessage=Enter something: "/>
+ <!-- transform the input to upper case using the simple language -->
+ <!-- you can also use other languages such as groovy, ognl, mvel, javascript etc. -->
+ <transform>
+ <simple>Hello ${body.toUpperCase()}</simple>
+ </transform>
+ <!-- and then print to the console -->
+ <to uri="stream:out"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: e1 -->
+
+</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml
----------------------------------------------------------------------
diff --git a/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml b/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml
new file mode 100644
index 0000000..c132e34
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/resources/org/apache/camel/parser/xml/myroutes.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<routes xmlns="http://camel.apache.org/schema/spring">
+ <route id="cbr-route">
+ <from uri="timer:foo?period=5000"/>
+ <!-- generate random number message, using a 3 digit number -->
+ <transform>
+ <method bean="myTransformer"/>
+ </transform>
+ <choice>
+ <when>
+ <simple>${body} > 500</simple>
+ <log message="High priority message : ${body}"/>
+ </when>
+ <otherwise>
+ <log message="Low priority message : ${body}"/>
+ </otherwise>
+ </choice>
+ </route>
+</routes>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/pom.xml b/tooling/pom.xml
index 10e460d..4a58b4f 100644
--- a/tooling/pom.xml
+++ b/tooling/pom.xml
@@ -39,7 +39,7 @@
<module>parent</module>
<module>spi-annotations</module>
<module>apt</module>
- <module>route-parser</module>
+ <module>camel-route-parser</module>
<module>maven</module>
<module>archetypes</module>
<module>camel-manual</module>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/pom.xml b/tooling/route-parser/pom.xml
deleted file mode 100644
index f81ad38..0000000
--- a/tooling/route-parser/pom.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.camel</groupId>
- <artifactId>tooling</artifactId>
- <version>2.19.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>route-parser</artifactId>
- <name>Camel :: Tooling :: Route Parser</name>
- <description>Java and XML source code parser for Camel routes</description>
-
- <dependencies>
-
- <!-- the roaster-jdt is set as provided as different runtimes may have it out of the box -->
- <dependency>
- <groupId>org.jboss.forge.roaster</groupId>
- <artifactId>roaster-jdt</artifactId>
- <version>${roaster-version}</version>
- <scope>provided</scope>
- </dependency>
-
- <!-- only test scopes for camel as we have no runtime dependency on camel -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-cdi</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test-cdi</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/88ba9063/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
deleted file mode 100644
index 4ef2fc4..0000000
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/ParserResult.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.parser;
-
-/**
- * Result of parsing Camel RouteBuilder or XML routes from the source code.
- */
-public class ParserResult {
-
- private final String node;
- private boolean parsed;
- private int position;
- private String element;
-
- public ParserResult(String node, int position, String element) {
- this(node, position, element, true);
- }
-
- public ParserResult(String node, int position, String element, boolean parsed) {
- this.node = node;
- this.position = position;
- this.element = element;
- this.parsed = parsed;
- }
-
- /**
- * Character based position in the source code (not line based).
- */
- public int getPosition() {
- return position;
- }
-
- /**
- * The element such as a Camel endpoint uri
- */
- public String getElement() {
- return element;
- }
-
- /**
- * Whether the element was successfully parsed. If the parser cannot parse
- * the element for whatever reason this will return <tt>false</tt>.
- */
- public boolean isParsed() {
- return parsed;
- }
-
- /**
- * The node which is typically a Camel EIP name such as <tt>to</tt>, <tt>wireTap</tt> etc.
- */
- public String getNode() {
- return node;
- }
-
- public String toString() {
- return element;
- }
-}
[24/25] camel git commit: CAMEL-10559: route parser for java and xml
to parse source code. Donated from fabric8 project.
Posted by da...@apache.org.
CAMEL-10559: route parser for java and xml to parse source code. Donated from fabric8 project.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/96e946e6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/96e946e6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/96e946e6
Branch: refs/heads/master
Commit: 96e946e6c650ca0aef010ef4d780e3646d53844a
Parents: cf41dad
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Dec 5 13:18:45 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Dec 5 14:04:48 2016 +0100
----------------------------------------------------------------------
tooling/route-parser/pom.xml | 4 +---
.../main/java/org/apache/camel/parser/RouteBuilderParser.java | 6 +++---
.../src/main/java/org/apache/camel/parser/XmlRouteParser.java | 5 +++--
.../parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java | 2 +-
.../camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java | 2 +-
.../java/RoasterConcatFieldRouteBuilderConfigureTest.java | 2 +-
.../apache/camel/parser/java/RoasterEndpointInjectTest.java | 2 +-
.../parser/java/RoasterFieldRouteBuilderConfigureTest.java | 2 +-
.../java/RoasterMethodCallRouteBuilderConfigureTest.java | 2 +-
.../RoasterMyFieldMethodCallRouteBuilderConfigureTest.java | 2 +-
.../camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java | 2 +-
.../java/org/apache/camel/parser/java/RoasterMyNettyTest.java | 2 +-
.../java/RoasterNewLineConstRouteBuilderConfigureTest.java | 2 +-
.../parser/java/RoasterNewLineRouteBuilderConfigureTest.java | 2 +-
.../parser/java/RoasterRouteBuilderCamelTestSupportTest.java | 2 +-
.../camel/parser/java/RoasterRouteBuilderConfigureTest.java | 2 +-
.../camel/parser/java/RoasterRouteBuilderEmptyUriTest.java | 2 +-
.../apache/camel/parser/java/RoasterSimpleProcessorTest.java | 2 +-
.../parser/java/RoasterSimpleRouteBuilderConfigureTest.java | 2 +-
.../org/apache/camel/parser/java/RoasterSimpleToDTest.java | 2 +-
.../org/apache/camel/parser/java/RoasterSimpleToFTest.java | 2 +-
.../org/apache/camel/parser/java/RoasterSplitTokenizeTest.java | 2 +-
22 files changed, 26 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/route-parser/pom.xml b/tooling/route-parser/pom.xml
index 7d038dd..f81ad38 100644
--- a/tooling/route-parser/pom.xml
+++ b/tooling/route-parser/pom.xml
@@ -30,9 +30,6 @@
<name>Camel :: Tooling :: Route Parser</name>
<description>Java and XML source code parser for Camel routes</description>
- <properties>
- </properties>
-
<dependencies>
<!-- the roaster-jdt is set as provided as different runtimes may have it out of the box -->
@@ -43,6 +40,7 @@
<scope>provided</scope>
</dependency>
+ <!-- only test scopes for camel as we have no runtime dependency on camel -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
index 1bba303..36fc443 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/RouteBuilderParser.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
index 67cbbde..2cca9df 100644
--- a/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
+++ b/tooling/route-parser/src/main/java/org/apache/camel/parser/XmlRouteParser.java
@@ -19,11 +19,12 @@ package org.apache.camel.parser;
import java.io.InputStream;
import java.util.List;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.helper.CamelXmlHelper;
import org.apache.camel.parser.helper.XmlLineNumberParser;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
import org.apache.camel.parser.model.CamelEndpointDetails;
import org.apache.camel.parser.model.CamelSimpleExpressionDetails;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
index 326d599..7d9abe4 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiConcatRouteBuilderConfigureTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
index 6cb2492..6abd424 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterCdiRouteBuilderConfigureTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
index 099ea7b..a57ce23 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterConcatFieldRouteBuilderConfigureTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
index c432183..8ffb23b 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterEndpointInjectTest.java
@@ -20,9 +20,9 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.model.CamelEndpointDetails;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
index 53495e9..5b16bd3 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterFieldRouteBuilderConfigureTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
index c7ca922..00a8623 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMethodCallRouteBuilderConfigureTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
index 951a4cb..44b4539 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyFieldMethodCallRouteBuilderConfigureTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
index 89f9544..9b1495e 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyLocalAddRouteBuilderTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
index 9dc1687..603d96f 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterMyNettyTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
index a4fc1fb..3b7cb69 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineConstRouteBuilderConfigureTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
index b7cb3d6..eeb320f 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterNewLineRouteBuilderConfigureTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
index f096713..9760f66 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderCamelTestSupportTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
index 2449e39..af9cb2e 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderConfigureTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
index 90e7ff9..3d97c65 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterRouteBuilderEmptyUriTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.parser.java;
import java.io.File;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
index 0d92c2a..c83d89a 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleProcessorTest.java
@@ -20,9 +20,9 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.model.CamelEndpointDetails;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
index 51a47b2..14d63af 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleRouteBuilderConfigureTest.java
@@ -21,8 +21,8 @@ import java.io.File;
import java.io.FileReader;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
index 63f3388..aeea6cf 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToDTest.java
@@ -20,9 +20,9 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.model.CamelEndpointDetails;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
index 877a892..82d9f75 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSimpleToFTest.java
@@ -20,9 +20,9 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.model.CamelEndpointDetails;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/96e946e6/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
----------------------------------------------------------------------
diff --git a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
index 03aea83..ef8bde8 100644
--- a/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
+++ b/tooling/route-parser/src/test/java/org/apache/camel/parser/java/RoasterSplitTokenizeTest.java
@@ -20,9 +20,9 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.ParserResult;
import org.apache.camel.parser.RouteBuilderParser;
+import org.apache.camel.parser.helper.CamelJavaParserHelper;
import org.apache.camel.parser.model.CamelEndpointDetails;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;