You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/06/11 10:54:51 UTC

[1/2] git commit: CAMEL-7488 Added an unit test to show how to wire the util:constant with BridgePropertyPlaceholderConfigurer

Repository: camel
Updated Branches:
  refs/heads/master 686ff1f3d -> 6a02d8ebc


CAMEL-7488 Added an unit test to show how to wire the util:constant with BridgePropertyPlaceholderConfigurer


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

Branch: refs/heads/master
Commit: 6a02d8ebce2a798a335864ff4e1830b6f0c5654c
Parents: 47a9298
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Jun 11 16:53:17 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Jun 11 16:54:21 2014 +0800

----------------------------------------------------------------------
 ...BridgePropertyPlaceholderConfigurerTest.java | 40 +++++++++++++++
 .../spi/bridgePropertyPlaceholderConfigurer.xml | 54 ++++++++++++++++++++
 2 files changed, 94 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6a02d8eb/components/camel-spring/src/test/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurerTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurerTest.java
new file mode 100644
index 0000000..f219525
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurerTest.java
@@ -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.spring.spi;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class BridgePropertyPlaceholderConfigurerTest extends SpringTestSupport {
+    public static final String CONSTANT = "This is the test property.";
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/spi/bridgePropertyPlaceholderConfigurer.xml");   
+    }
+    
+    
+    public void testIgnore() throws Exception {
+        MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.class);
+        result.expectedBodiesReceived(CONSTANT);
+        template.sendBody("direct:start", "Test");
+        result.assertIsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/6a02d8eb/components/camel-spring/src/test/resources/org/apache/camel/spring/spi/bridgePropertyPlaceholderConfigurer.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/spi/bridgePropertyPlaceholderConfigurer.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/spi/bridgePropertyPlaceholderConfigurer.xml
new file mode 100644
index 0000000..99db40f
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/spi/bridgePropertyPlaceholderConfigurer.xml
@@ -0,0 +1,54 @@
+<?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"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       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
+       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
+    ">
+    <util:constant id="test" static-field="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurerTest.CONSTANT"/>  
+    
+    <bean id="bridgePropertyPlaceHolder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
+      <property name="properties">
+         <props>
+           <!-- reference the constant value in a property-->
+           <prop key="testProperty">#{test}</prop>
+         </props>
+      </property>
+      <property name="ignoreResourceNotFound" value="true"/>
+      <property name="locations">
+        <list>
+          <value>classpath:someplaceToOverride</value>
+        </list>
+      </property>
+   </bean>
+
+   <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
+    <camel:route>
+      <camel:from uri="direct:start" />
+      <camel:setBody>
+        <camel:simple>{{testProperty}}</camel:simple>
+      </camel:setBody>
+      <camel:to uri="mock:result" />
+    </camel:route>
+   </camel:camelContext>   
+    
+</beans>
\ No newline at end of file


[2/2] git commit: CAMEL-7496 BridgePropertyPlaceholderConfigurer should take ignoreResourceNotFound into consideration when it loads the property files

Posted by ni...@apache.org.
CAMEL-7496 BridgePropertyPlaceholderConfigurer should take ignoreResourceNotFound into consideration when it loads the property files


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

Branch: refs/heads/master
Commit: 47a9298faa4edc1152649e742fce9b811c5e80f6
Parents: 686ff1f
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Jun 11 16:51:40 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Jun 11 16:54:21 2014 +0800

----------------------------------------------------------------------
 .../spi/BridgePropertyPlaceholderConfigurer.java      | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/47a9298f/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurer.java b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurer.java
index 17b4b1f..3108acf 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurer.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurer.java
@@ -49,6 +49,7 @@ public class BridgePropertyPlaceholderConfigurer extends PropertyPlaceholderConf
     private String configuredValueSeparator;
     private Boolean configuredIgnoreUnresolvablePlaceholders;
     private int systemPropertiesMode = SYSTEM_PROPERTIES_MODE_FALLBACK;
+    private Boolean ignoreResourceNotFound;
 
     @Override
     protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException {
@@ -105,6 +106,12 @@ public class BridgePropertyPlaceholderConfigurer extends PropertyPlaceholderConf
         super.setIgnoreUnresolvablePlaceholders(ignoreUnresolvablePlaceholders);
         this.configuredIgnoreUnresolvablePlaceholders = ignoreUnresolvablePlaceholders;
     }
+    
+    @Override
+    public void setIgnoreResourceNotFound(boolean ignoreResourceNotFound) {
+        super.setIgnoreResourceNotFound(ignoreResourceNotFound);
+        this.ignoreResourceNotFound = ignoreResourceNotFound;
+    }
 
     @Override
     public Properties resolveProperties(CamelContext context, boolean ignoreMissingLocation, String... uri) throws Exception {
@@ -115,7 +122,12 @@ public class BridgePropertyPlaceholderConfigurer extends PropertyPlaceholderConf
             if (ref.equals(u)) {
                 answer.putAll(properties);
             } else if (resolver != null) {
-                Properties p = resolver.resolveProperties(context, ignoreMissingLocation, u);
+                boolean flag = ignoreMissingLocation;
+                // Override the setting by using ignoreResourceNotFound
+                if (ignoreResourceNotFound != null) {
+                    flag = ignoreResourceNotFound;
+                }
+                Properties p = resolver.resolveProperties(context, flag, u);
                 if (p != null) {
                     answer.putAll(p);
                 }