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:36:03 UTC
[5/5] git commit: CAMEL-7219: Fixed language component to be able to
load resources from classpath.
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