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/02 22:55:25 UTC
git commit: Added a test based on a user-forum question.
Updated Branches:
refs/heads/master d4aabe11b -> 17f9678a6
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/17f9678a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/17f9678a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/17f9678a
Branch: refs/heads/master
Commit: 17f9678a6881ad269fe0eb8728082b53c8296e87
Parents: d4aabe1
Author: Babak Vahdat <bv...@apache.org>
Authored: Wed Oct 2 22:55:12 2013 +0200
Committer: Babak Vahdat <bv...@apache.org>
Committed: Wed Oct 2 22:55:12 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/17f9678a/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/17f9678a/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/17f9678a/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