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 12:29:02 UTC
[4/6] camel git commit: CAMEL-10559: route parser for java and xml to
parse source code. Donated from fabric8 project.
http://git-wip-us.apache.org/repos/asf/camel/blob/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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/550186e9/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;
- }
-}