Permalink
Browse files

CAMEL-5973: Fixed property placeholder with blueprint and delegate no…

…t working such as when using jasypt.

git-svn-id: https://svn.apache.org/repos/asf/camel/trunk@1433519 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 5582a0e commit 8627c04be867aa81dcd5e2a4d0802e4f6b6fb75d @davsclaus davsclaus committed Jan 15, 2013
@@ -52,6 +52,11 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring</artifactId>
<scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-blueprint</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -0,0 +1,40 @@
+/**
+ * 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.jasypt;
+
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.junit.Test;
+
+/**
+ * @version
+ */
+public class BlueprintJasyptProperties2Test extends CamelBlueprintTestSupport {
+
+ @Test
+ public void testJasyptProperties() throws Exception {
+ getMockEndpoint("mock:tiger").expectedBodiesReceived("Hello World");
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/component/jasypt/BlueprintJasyptProperties2Test.xml";
+ }
+}
@@ -0,0 +1,40 @@
+/**
+ * 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.jasypt;
+
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.junit.Test;
+
+/**
+ * @version
+ */
+public class BlueprintJasyptProperties3Test extends CamelBlueprintTestSupport {
+
+ @Test
+ public void testJasyptProperties() throws Exception {
+ getMockEndpoint("mock:tiger").expectedBodiesReceived("Hello World");
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/component/jasypt/BlueprintJasyptProperties3Test.xml";
+ }
+}
@@ -0,0 +1,40 @@
+/**
+ * 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.jasypt;
+
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.junit.Test;
+
+/**
+ * @version
+ */
+public class BlueprintJasyptPropertiesTest extends CamelBlueprintTestSupport {
+
+ @Test
+ public void testJasyptProperties() throws Exception {
+ getMockEndpoint("mock:tiger").expectedBodiesReceived("Hello World");
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/component/jasypt/BlueprintJasyptPropertiesTest.xml";
+ }
+}
@@ -0,0 +1,40 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <!-- define the jasypt properties parser with the given password to be used -->
+ <bean id="jasypt" class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
+ <property name="password" value="secret"/>
+ </bean>
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+ <!-- define the camel properties placeholder, and let it leverage jasypt -->
+ <propertyPlaceholder id="properties"
+ location="classpath:org/apache/camel/component/jasypt/myproperties.properties"
+ propertiesParserRef="jasypt"/>
+ <route>
+ <from uri="direct:start"/>
+ <to uri="{{cool.result}}"/>
+ </route>
+ </camelContext>
+
+</blueprint>
@@ -0,0 +1,48 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <cm:property-placeholder id="myblue" persistent-id="mypersistent">
+ <!-- list some properties for this test -->
+ <cm:default-properties>
+ <cm:property name="cool.result" value="mock:{{cool.password}}"/>
+ <cm:property name="cool.password" value="ENC(bsW9uV37gQ0QHFu7KO03Ww==)"/>
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <!-- define the jasypt properties parser with the given password to be used -->
+ <bean id="jasypt" class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
+ <property name="password" value="secret"/>
+ </bean>
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+ <!-- define the camel properties placeholder, and let it leverage jasypt -->
+ <propertyPlaceholder id="properties"
+ location="blueprint:myblue"
+ propertiesParserRef="jasypt"/>
+ <route>
+ <from uri="direct:start"/>
+ <to uri="{{cool.result}}"/>
+ </route>
+ </camelContext>
+
+</blueprint>
@@ -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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <!-- START SNIPPET: e1 -->
+ <!-- define the jasypt properties parser with the given password to be used -->
+ <bean id="jasypt" class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
+ <property name="password" value="secret"/>
+ </bean>
+
+ <!-- define the camel properties component -->
+ <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
+ <!-- the properties file is in the classpath -->
+ <property name="location" value="classpath:org/apache/camel/component/jasypt/myproperties.properties"/>
+ <!-- and let it leverage the jasypt parser -->
+ <property name="propertiesParser" ref="jasypt"/>
+ </bean>
+ <!-- END SNIPPET: e1 -->
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+ <route>
+ <from uri="direct:start"/>
+ <to uri="{{cool.result}}"/>
+ </route>
+ </camelContext>
+
+</blueprint>

0 comments on commit 8627c04

Please sign in to comment.