camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-11523: Bridge properties parser should support default values as well. Thanks to Ronny Aerts for sample project to reproduce this issue.
Date Wed, 06 Sep 2017 07:42:45 GMT
Repository: camel
Updated Branches:
  refs/heads/master 137bae33c -> a38ff2587


CAMEL-11523: Bridge properties parser should support default values as well. Thanks to Ronny
Aerts for sample project to reproduce this issue.


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

Branch: refs/heads/master
Commit: a38ff25873d473fafd7a8e8bf4b9d4fcac3075d9
Parents: 137bae3
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Sep 6 09:41:26 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Sep 6 09:42:38 2017 +0200

----------------------------------------------------------------------
 .../BridgePropertyPlaceholderConfigurer.java    | 26 +++++++++++++++++++-
 ...BridgePropertyPlaceholderConfigurerTest.java | 10 ++++++--
 .../spi/bridgePropertyPlaceholderConfigurer.xml |  9 ++++++-
 3 files changed, 41 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a38ff258/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 58939ca..81e3d2d 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
@@ -245,7 +245,7 @@ public class BridgePropertyPlaceholderConfigurer extends PropertyPlaceholderConf
         }
     }
 
-    private final class BridgePropertiesParser implements PropertiesParser {
+    private final class BridgePropertiesParser implements PropertiesParser, AugmentedPropertyNameAwarePropertiesParser
{
 
         private final PropertiesParser delegate;
         private final PropertiesParser parser;
@@ -256,6 +256,30 @@ public class BridgePropertyPlaceholderConfigurer extends PropertyPlaceholderConf
         }
 
         @Override
+        public String parseUri(String text, Properties properties, String prefixToken, String
suffixToken, String propertyPrefix, String propertySuffix,
+                               boolean fallbackToUnaugmentedProperty, boolean defaultFallbackEnabled)
throws IllegalArgumentException {
+            String answer = null;
+            if (delegate != null) {
+                if (delegate instanceof AugmentedPropertyNameAwarePropertiesParser) {
+                    answer = ((AugmentedPropertyNameAwarePropertiesParser)this.delegate).parseUri(text,
properties,
+                        prefixToken, suffixToken, propertyPrefix, propertySuffix, fallbackToUnaugmentedProperty,
defaultFallbackEnabled);
+                } else {
+                    answer = delegate.parseUri(text, properties, prefixToken, suffixToken);
+                }
+            }
+            if (answer != null) {
+                text = answer;
+            }
+            if (parser instanceof AugmentedPropertyNameAwarePropertiesParser) {
+                answer = ((AugmentedPropertyNameAwarePropertiesParser)this.parser).parseUri(text,
properties,
+                    prefixToken, suffixToken, propertyPrefix, propertySuffix, fallbackToUnaugmentedProperty,
defaultFallbackEnabled);
+            } else {
+                answer = parser.parseUri(text, properties, prefixToken, suffixToken);
+            }
+            return answer;
+        }
+
+        @Override
         public String parseUri(String text, Properties properties, String prefixToken, String
suffixToken) throws IllegalArgumentException {
             String answer = null;
             if (delegate != null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/a38ff258/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
index f219525..d4bb126 100644
--- 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
@@ -29,12 +29,18 @@ public class BridgePropertyPlaceholderConfigurerTest extends SpringTestSupport
{
         return new ClassPathXmlApplicationContext("org/apache/camel/spring/spi/bridgePropertyPlaceholderConfigurer.xml");
  
     }
     
-    
-    public void testIgnore() throws Exception {
+    public void testProperty() throws Exception {
         MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.class);
         result.expectedBodiesReceived(CONSTANT);
         template.sendBody("direct:start", "Test");
         result.assertIsSatisfied();
     }
 
+    public void testPropertyDefault() throws Exception {
+        MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.class);
+        result.expectedBodiesReceived("myDefaultValue");
+        template.sendBody("direct:start2", "Test");
+        result.assertIsSatisfied();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/a38ff258/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
index 2d94743..0ef85eb 100644
--- 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
@@ -51,6 +51,13 @@
       </camel:setBody>
       <camel:to uri="mock:result" />
     </camel:route>
-   </camel:camelContext>   
+    <camel:route>
+      <camel:from uri="direct:start2" />
+      <camel:setBody>
+        <camel:simple>{{unknown:myDefaultValue}}</camel:simple>
+      </camel:setBody>
+      <camel:to uri="mock:result" />
+    </camel:route>
+   </camel:camelContext>
     
 </beans>
\ No newline at end of file


Mime
View raw message