camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject [1/4] git commit: Added a test based on a user-forum question.
Date Sun, 13 Oct 2013 19:05:00 GMT
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 <bvahdat@apache.org>
Authored: Wed Oct 2 22:55:12 2013 +0200
Committer: Babak Vahdat <bvahdat@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


Mime
View raw message