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 2014/02/18 18:35:59 UTC

[1/5] git commit: CAMEL-7219: Fixed language component to be able to load resources from classpath.

Repository: camel
Updated Branches:
  refs/heads/camel-2.11.x 827b0b027 -> 0c872dc03
  refs/heads/camel-2.12.x f02b9bec7 -> 7b415b426
  refs/heads/master 9640e23f1 -> fdf9871fb


CAMEL-7219: Fixed language component to be able to load resources from classpath.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/80c7935d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/80c7935d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/80c7935d

Branch: refs/heads/master
Commit: 80c7935dd5462aede67ba97e8b83639a3dde4280
Parents: 9640e23
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Feb 18 17:54:22 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 18 17:54:34 2014 +0100

----------------------------------------------------------------------
 .../component/language/LanguageComponent.java   |  4 ++
 ...geResourceLoadConstantFromClasspathTest.java | 46 ++++++++++++++++++++
 .../apache/camel/component/language/hello.txt   |  1 +
 3 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/80c7935d/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java b/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
index 24a9e07..2942ae3 100644
--- a/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
@@ -61,9 +61,13 @@ public class LanguageComponent extends UriEndpointComponent {
             if (ResourceHelper.hasScheme(resource)) {
                 // the script is a uri for a resource
                 resourceUri = resource;
+                // then the script should be null
+                script = null;
             } else {
                 // the script is provided as text in the uri, so decode to utf-8
                 script = URLDecoder.decode(script, "UTF-8");
+                // then the resource should be null
+                resourceUri = null;
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/80c7935d/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.java b/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.java
new file mode 100644
index 0000000..aa98835
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.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.component.language;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version 
+ */
+public class LanguageResourceLoadConstantFromClasspathTest extends ContextTestSupport {
+
+    public void testLanguage() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello this is some text.");
+
+        template.sendBody("direct:start", "World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("language:constant:resource:classpath:org/apache/camel/component/language/hello.txt")
+                    .to("mock:result");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/80c7935d/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt
----------------------------------------------------------------------
diff --git a/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt b/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt
new file mode 100644
index 0000000..b75dc3d
--- /dev/null
+++ b/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt
@@ -0,0 +1 @@
+Hello this is some text.
\ No newline at end of file


[3/5] git commit: CAMEL-7219: Fixed language component to be able to load resources from classpath.

Posted by da...@apache.org.
CAMEL-7219: Fixed language component to be able to load resources from classpath.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/66d30bfd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/66d30bfd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/66d30bfd

Branch: refs/heads/camel-2.12.x
Commit: 66d30bfd306322d06941502424475e2be442406d
Parents: f02b9be
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Feb 18 17:54:22 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 18 18:35:19 2014 +0100

----------------------------------------------------------------------
 .../component/language/LanguageComponent.java   |  4 ++
 ...geResourceLoadConstantFromClasspathTest.java | 46 ++++++++++++++++++++
 .../apache/camel/component/language/hello.txt   |  1 +
 3 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/66d30bfd/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java b/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
index 24a9e07..2942ae3 100644
--- a/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
@@ -61,9 +61,13 @@ public class LanguageComponent extends UriEndpointComponent {
             if (ResourceHelper.hasScheme(resource)) {
                 // the script is a uri for a resource
                 resourceUri = resource;
+                // then the script should be null
+                script = null;
             } else {
                 // the script is provided as text in the uri, so decode to utf-8
                 script = URLDecoder.decode(script, "UTF-8");
+                // then the resource should be null
+                resourceUri = null;
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/66d30bfd/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.java b/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.java
new file mode 100644
index 0000000..aa98835
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.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.component.language;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version 
+ */
+public class LanguageResourceLoadConstantFromClasspathTest extends ContextTestSupport {
+
+    public void testLanguage() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello this is some text.");
+
+        template.sendBody("direct:start", "World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("language:constant:resource:classpath:org/apache/camel/component/language/hello.txt")
+                    .to("mock:result");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/66d30bfd/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt
----------------------------------------------------------------------
diff --git a/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt b/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt
new file mode 100644
index 0000000..b75dc3d
--- /dev/null
+++ b/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt
@@ -0,0 +1 @@
+Hello this is some text.
\ No newline at end of file


[5/5] git commit: CAMEL-7219: Fixed language component to be able to load resources from classpath.

Posted by da...@apache.org.
CAMEL-7219: Fixed language component to be able to load resources from classpath.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0c872dc0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0c872dc0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0c872dc0

Branch: refs/heads/camel-2.11.x
Commit: 0c872dc03b052352e8f3cbc1b034e7102f476f48
Parents: 827b0b0
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Feb 18 17:54:22 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 18 18:36:01 2014 +0100

----------------------------------------------------------------------
 .../component/language/LanguageComponent.java   |  4 ++
 ...geResourceLoadConstantFromClasspathTest.java | 46 ++++++++++++++++++++
 .../apache/camel/component/language/hello.txt   |  1 +
 3 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0c872dc0/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java b/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
index 2127256..07366db 100644
--- a/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/language/LanguageComponent.java
@@ -57,9 +57,13 @@ public class LanguageComponent extends DefaultComponent {
             if (ResourceHelper.hasScheme(resource)) {
                 // the script is a uri for a resource
                 resourceUri = resource;
+                // then the script should be null
+                script = null;
             } else {
                 // the script is provided as text in the uri, so decode to utf-8
                 script = URLDecoder.decode(script, "UTF-8");
+                // then the resource should be null
+                resourceUri = null;
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0c872dc0/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.java b/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.java
new file mode 100644
index 0000000..aa98835
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadConstantFromClasspathTest.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.component.language;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version 
+ */
+public class LanguageResourceLoadConstantFromClasspathTest extends ContextTestSupport {
+
+    public void testLanguage() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello this is some text.");
+
+        template.sendBody("direct:start", "World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("language:constant:resource:classpath:org/apache/camel/component/language/hello.txt")
+                    .to("mock:result");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c872dc0/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt
----------------------------------------------------------------------
diff --git a/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt b/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt
new file mode 100644
index 0000000..b75dc3d
--- /dev/null
+++ b/camel-core/src/test/resources/org/apache/camel/component/language/hello.txt
@@ -0,0 +1 @@
+Hello this is some text.
\ No newline at end of file


[2/5] git commit: CAMEL-7155 Fixed the issue of StringHelper

Posted by da...@apache.org.
CAMEL-7155 Fixed the issue of StringHelper


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fdf9871f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fdf9871f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fdf9871f

Branch: refs/heads/master
Commit: fdf9871fbd3101e6c2ac77c99a49e233f6b2d748
Parents: 80c7935
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Feb 18 18:19:35 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 18 18:19:35 2014 +0100

----------------------------------------------------------------------
 .../src/test/java/org/apache/camel/util/StringHelperTest.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fdf9871f/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java b/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
index 2618e94..e9c5ed2 100644
--- a/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
@@ -87,12 +87,13 @@ public class StringHelperTest extends TestCase {
         assertEquals(false, StringHelper.hasStartToken("Hello World", null));
         assertEquals(false, StringHelper.hasStartToken("Hello World", "simple"));
 
-        assertEquals(true, StringHelper.hasStartToken("${body}", null));
+        assertEquals(false, StringHelper.hasStartToken("${body}", null));
         assertEquals(true, StringHelper.hasStartToken("${body}", "simple"));
         assertEquals(true, StringHelper.hasStartToken("$simple{body}", "simple"));
 
-        assertEquals(true, StringHelper.hasStartToken("${body}", null));
-        assertEquals(true, StringHelper.hasStartToken("${body}", "foo"));
+        assertEquals(false, StringHelper.hasStartToken("${body}", null));
+        assertEquals(false, StringHelper.hasStartToken("${body}", "foo"));
+        // $foo{ is valid because its foo language
         assertEquals(true, StringHelper.hasStartToken("$foo{body}", "foo"));
     }
     


[4/5] git commit: CAMEL-7155 Fixed the issue of StringHelper

Posted by da...@apache.org.
CAMEL-7155 Fixed the issue of StringHelper


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7b415b42
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7b415b42
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7b415b42

Branch: refs/heads/camel-2.12.x
Commit: 7b415b426736638a0b9fdd66e7e3136d0f23f4ff
Parents: 66d30bf
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Feb 18 18:19:35 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 18 18:35:26 2014 +0100

----------------------------------------------------------------------
 .../src/test/java/org/apache/camel/util/StringHelperTest.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7b415b42/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java b/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
index 2618e94..e9c5ed2 100644
--- a/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
@@ -87,12 +87,13 @@ public class StringHelperTest extends TestCase {
         assertEquals(false, StringHelper.hasStartToken("Hello World", null));
         assertEquals(false, StringHelper.hasStartToken("Hello World", "simple"));
 
-        assertEquals(true, StringHelper.hasStartToken("${body}", null));
+        assertEquals(false, StringHelper.hasStartToken("${body}", null));
         assertEquals(true, StringHelper.hasStartToken("${body}", "simple"));
         assertEquals(true, StringHelper.hasStartToken("$simple{body}", "simple"));
 
-        assertEquals(true, StringHelper.hasStartToken("${body}", null));
-        assertEquals(true, StringHelper.hasStartToken("${body}", "foo"));
+        assertEquals(false, StringHelper.hasStartToken("${body}", null));
+        assertEquals(false, StringHelper.hasStartToken("${body}", "foo"));
+        // $foo{ is valid because its foo language
         assertEquals(true, StringHelper.hasStartToken("$foo{body}", "foo"));
     }