You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2013/10/13 21:05:00 UTC

[1/4] git commit: Added a test based on a user-forum question.

Updated Branches:
  refs/heads/camel-2.12.x b0f74f6da -> 9bfeed7cd


Added a test based on a user-forum question.


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

Branch: refs/heads/camel-2.12.x
Commit: 003b37e444e045d960508ac9af55e36c7a946d28
Parents: b0f74f6
Author: Babak Vahdat <bv...@apache.org>
Authored: Wed Oct 2 22:55:12 2013 +0200
Committer: Babak Vahdat <bv...@apache.org>
Committed: Sun Oct 13 20:49:08 2013 +0200

----------------------------------------------------------------------
 ...pringPropertyPlaceholderConfigurer3Test.java | 66 ++++++++++++++++++++
 ...SpringPropertyPlaceholderConfigurer3Test.xml | 46 ++++++++++++++
 .../component/properties/cheese.properties      |  2 +
 3 files changed, 114 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/003b37e4/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java b/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
new file mode 100644
index 0000000..a9084dd
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
@@ -0,0 +1,66 @@
+/**
+ * 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.properties;
+
+import java.util.Properties;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.SpringTestSupport;
+import org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer;
+
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ *
+ */
+public class CamelSpringPropertyPlaceholderConfigurer3Test extends SpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml");
+    }
+
+    public void testCamelSpringPropertyPlaceholderConfigurerTest() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Guten Tag Camel");
+
+        template.sendBody("direct:bar", "Camel");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @SuppressWarnings("unused")
+    private static class MyBridgePropertyPlaceholderConfigurer extends BridgePropertyPlaceholderConfigurer {
+
+        @Override
+        public Properties resolveProperties(CamelContext context, boolean ignoreMissingLocation, String... uri) throws Exception {
+            Properties answer = super.resolveProperties(context, ignoreMissingLocation, uri);
+
+            // add the additional properties we need to provide so that the uri ""{{scheme}}{{separator}}{{authority}}""
+            // inside the route can be resolved. please note that in this simple test we just add these properties
+            // hard-coded below but of course the mechanism to retrieve these extra properties can be anything else,
+            // e.g. through the entries inside a database table etc.
+            answer.put("scheme", "mock");
+            answer.put("separator", ":");
+            answer.put("authority", "result");
+                
+            return answer;
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/003b37e4/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
new file mode 100644
index 0000000..680814a
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
@@ -0,0 +1,46 @@
+<?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.
+-->
+<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">
+
+  <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
+    <property name="propertiesResolver" ref="myBridgePropertyPlaceholder"/>
+  </bean>
+
+  <bean id="myBridgePropertyPlaceholder" class="org.apache.camel.component.properties.CamelSpringPropertyPlaceholderConfigurer3Test$MyBridgePropertyPlaceholderConfigurer">
+    <property name="location" value="classpath:org/apache/camel/component/properties/cheese.properties"/>
+  </bean>
+
+  <!-- a bean that uses Spring property placeholder -->
+  <!-- the ${hi2} is a spring property placeholder -->
+  <bean id="hello" class="org.apache.camel.component.properties.HelloBean">
+    <property name="greeting" value="${hi2}"/>
+  </bean>
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+    <!-- in this route we use Camels property placeholder {{ }} style -->
+    <route>
+      <from uri="direct:{{cool.bar}}"/>
+      <bean ref="hello"/>
+      <to uri="{{scheme}}{{separator}}{{authority}}"/>
+    </route>
+  </camelContext>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/003b37e4/components/camel-spring/src/test/resources/org/apache/camel/component/properties/cheese.properties
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/cheese.properties b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/cheese.properties
index 1603168..25c1573 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/cheese.properties
+++ b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/cheese.properties
@@ -26,4 +26,6 @@ max=3
 
 hi=Bonjour
 
+hi2=Guten Tag
+
 autoStartup=true


[3/4] git commit: Extended the test to show the user how to properly make use of the Spring PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_XYZ setting.

Posted by bv...@apache.org.
Extended the test to show the user how to properly make use of the Spring PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_XYZ setting.


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

Branch: refs/heads/camel-2.12.x
Commit: c6b751b91bcd2642d09773e3045e2da60b9646bd
Parents: 2654c81
Author: Babak Vahdat <bv...@apache.org>
Authored: Tue Oct 8 10:20:49 2013 +0200
Committer: Babak Vahdat <bv...@apache.org>
Committed: Sun Oct 13 20:49:46 2013 +0200

----------------------------------------------------------------------
 ...pringPropertyPlaceholderConfigurer3Test.java | 24 ++++++++++++++++++--
 ...SpringPropertyPlaceholderConfigurer3Test.xml |  1 +
 2 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c6b751b9/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java b/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
index b22037d..dcf02dc 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
@@ -21,7 +21,6 @@ import java.util.Properties;
 import org.apache.camel.CamelContext;
 import org.apache.camel.spring.SpringTestSupport;
 import org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer;
-
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
@@ -31,12 +30,33 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
 public class CamelSpringPropertyPlaceholderConfigurer3Test extends SpringTestSupport {
 
     @Override
+    protected void setUp() throws Exception {
+        // inside the used properties file (cheese.properties) we've defined the following key/value mapping:
+        // hi2=Guten Tag
+        // however as we make use of the PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE mode
+        // (which is NOT the default mode) we expect that setting the system property below should override
+        // the mapping being defined above. that's we expect the following key/value mapping taking effect:
+        // hi2=Gute Nacht
+        System.setProperty("hi2", "Gute Nacht");
+
+        super.setUp();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        // clear the property properly to avoid any side effect by the other tests
+        System.clearProperty("hi2");
+
+        super.tearDown();
+    }
+
+    @Override
     protected AbstractXmlApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml");
     }
 
     public void testCamelSpringPropertyPlaceholderConfigurerTest() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived("Guten Tag Camel");
+        getMockEndpoint("mock:result").expectedBodiesReceived("Gute Nacht Camel");
 
         template.sendBody("direct:bar", "Camel");
 

http://git-wip-us.apache.org/repos/asf/camel/blob/c6b751b9/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
index b95b2d8..ae5a476 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
@@ -26,6 +26,7 @@
 
   <bean id="myBridgePropertyPlaceholder" class="org.apache.camel.component.properties.CamelSpringPropertyPlaceholderConfigurer3Test$MyBridgePropertyPlaceholderConfigurer">
     <property name="location" value="classpath:org/apache/camel/component/properties/cheese.properties"/>
+    <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
   </bean>
 
   <!-- a bean that uses Spring property placeholder -->


[2/4] git commit: Modified the test so that it better matches to the given use-case by the user-forum.

Posted by bv...@apache.org.
Modified the test so that it better matches to the given use-case by the user-forum.


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

Branch: refs/heads/camel-2.12.x
Commit: 2654c816a1938452b921bef1b6d788aababa2c89
Parents: 003b37e
Author: Babak Vahdat <bv...@apache.org>
Authored: Thu Oct 3 08:10:42 2013 +0200
Committer: Babak Vahdat <bv...@apache.org>
Committed: Sun Oct 13 20:49:33 2013 +0200

----------------------------------------------------------------------
 .../CamelSpringPropertyPlaceholderConfigurer3Test.java  | 12 +++++++-----
 .../CamelSpringPropertyPlaceholderConfigurer3Test.xml   |  4 ++--
 2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2654c816/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java b/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
index a9084dd..b22037d 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
@@ -50,13 +50,15 @@ public class CamelSpringPropertyPlaceholderConfigurer3Test extends SpringTestSup
         public Properties resolveProperties(CamelContext context, boolean ignoreMissingLocation, String... uri) throws Exception {
             Properties answer = super.resolveProperties(context, ignoreMissingLocation, uri);
 
-            // add the additional properties we need to provide so that the uri ""{{scheme}}{{separator}}{{authority}}""
-            // inside the route can be resolved. please note that in this simple test we just add these properties
-            // hard-coded below but of course the mechanism to retrieve these extra properties can be anything else,
-            // e.g. through the entries inside a database table etc.
+            // define the additional properties we need to provide so that the uri "direct:{{foo}}" by the "from" clause
+            // as well as "{{scheme}}{{separator}}{{context-path}}" by the "to" clause can be properly resolved. please
+            // note that in this simple test we just add these properties hard-coded below but of course the mechanism to
+            // retrieve these extra properties can be anything else, e.g. through the entries inside a database table etc.
+            answer.put("foo", "bar");
+
             answer.put("scheme", "mock");
             answer.put("separator", ":");
-            answer.put("authority", "result");
+            answer.put("context-path", "result");
                 
             return answer;
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/2654c816/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
index 680814a..b95b2d8 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml
@@ -37,9 +37,9 @@
   <camelContext xmlns="http://camel.apache.org/schema/spring">
     <!-- in this route we use Camels property placeholder {{ }} style -->
     <route>
-      <from uri="direct:{{cool.bar}}"/>
+      <from uri="direct:{{foo}}"/>
       <bean ref="hello"/>
-      <to uri="{{scheme}}{{separator}}{{authority}}"/>
+      <to uri="{{scheme}}{{separator}}{{context-path}}"/>
     </route>
   </camelContext>
 


[4/4] git commit: Put back the line feed being unintentionally removed by the previous commit.

Posted by bv...@apache.org.
Put back the line feed being unintentionally removed by the previous commit.


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

Branch: refs/heads/camel-2.12.x
Commit: 9bfeed7cd23e0b94541eec59d088c7710b16efea
Parents: c6b751b
Author: Babak Vahdat <bv...@apache.org>
Authored: Tue Oct 8 11:23:16 2013 +0200
Committer: Babak Vahdat <bv...@apache.org>
Committed: Sun Oct 13 20:50:00 2013 +0200

----------------------------------------------------------------------
 .../properties/CamelSpringPropertyPlaceholderConfigurer3Test.java   | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9bfeed7c/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java b/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
index dcf02dc..9305d53 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java
@@ -21,6 +21,7 @@ import java.util.Properties;
 import org.apache.camel.CamelContext;
 import org.apache.camel.spring.SpringTestSupport;
 import org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer;
+
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;