Repository: camel
Updated Branches:
  refs/heads/master d36d2e520 -> 1153beb5b


[CAMEL-10038] added unit test for BlueprintPropertiesParser 
fallbackToUnaugmentedProperty=false behavior


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

Branch: refs/heads/master
Commit: 1153beb5b5fedbc533a099866b15dd1a380eb99a
Parents: 55ee517
Author: Grzegorz Grzybek <gr.grzy...@gmail.com>
Authored: Thu Jul 21 08:52:30 2016 +0200
Committer: Grzegorz Grzybek <gr.grzy...@gmail.com>
Committed: Thu Jul 21 08:53:26 2016 +0200

----------------------------------------------------------------------
 ...eprintAugmentedPropertiesNoFallbackTest.java | 53 ++++++++++++++++++++
 .../resources/etc/augmented.no.fallback.cfg     | 23 +++++++++
 .../augmented-properties-no-fallback.xml        | 48 ++++++++++++++++++
 3 files changed, 124 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1153beb5/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintAugmentedPropertiesNoFallbackTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintAugmentedPropertiesNoFallbackTest.java
 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintAugmentedPropertiesNoFallbackTest.java
new file mode 100644
index 0000000..4474b7d
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintAugmentedPropertiesNoFallbackTest.java
@@ -0,0 +1,53 @@
+/**
+ * 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.test.blueprint;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+
+/**
+ * A test showing that Blueprint XML property placeholders work correctly with
+ * augmented property names and fallback behavior.
+ */
+public class BlueprintAugmentedPropertiesNoFallbackTest extends 
CamelBlueprintTestSupport {
+
+    @Override
+    public void setUp() throws Exception {
+        try {
+            super.setUp();
+            fail("Should fail, because Blueprint XML uses property 
placeholders, but we didn't resolve the placeholder");
+        } catch (Exception e) {
+            assertThat(e.getCause().getCause().getCause().getMessage(), 
equalTo("Property with key [TESTYYY.source] not found in properties from text: 
{{source}}"));
+        }
+    }
+
+    @Override
+    protected String getBlueprintDescriptor() {
+        return 
"org/apache/camel/test/blueprint/augmented-properties-no-fallback.xml";
+    }
+
+    @Override
+    protected String[] loadConfigAdminConfigurationFile() {
+        return new String[] 
{"src/test/resources/etc/augmented.no.fallback.cfg", "augmented.no.fallback"};
+    }
+
+    @Test
+    public void testFallbackToUnaugmentedProperty() throws Exception {
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1153beb5/components/camel-test-blueprint/src/test/resources/etc/augmented.no.fallback.cfg
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/resources/etc/augmented.no.fallback.cfg
 
b/components/camel-test-blueprint/src/test/resources/etc/augmented.no.fallback.cfg
new file mode 100644
index 0000000..4dba59a
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/resources/etc/augmented.no.fallback.cfg
@@ -0,0 +1,23 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+source = direct:from-here
+TESTXXX.source = direct:not-from-here
+
+# augmented TEST.destination should fall back to this
+destination = mock:result
+

http://git-wip-us.apache.org/repos/asf/camel/blob/1153beb5/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/augmented-properties-no-fallback.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/augmented-properties-no-fallback.xml
 
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/augmented-properties-no-fallback.xml
new file mode 100644
index 0000000..5949cd5
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/augmented-properties-no-fallback.xml
@@ -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.1.0";
+           xsi:schemaLocation="
+             http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";>
+
+  <!-- blueprint property placeholders -->
+  <cm:property-placeholder id="test-property-placeholder"
+                           persistent-id="augmented.no.fallback"/>
+
+  <camelContext xmlns="http://camel.apache.org/schema/blueprint";
+                id="test-camelContext"
+                useBlueprintPropertyResolver="true">
+
+    <propertyPlaceholder id="test-propertyPlaceholder"
+                         location="blueprint:test-property-placeholder"
+                         propertyPrefix="TESTYYY."
+                         fallbackToUnaugmentedProperty="false"/>
+
+    <route>
+      <from uri="{{source}}"/>
+      <transform>
+        <simple>fallbackToUnaugmentedProperty is working</simple>
+      </transform>
+      <to uri="{{destination}}"/>
+    </route>
+
+  </camelContext>
+
+</blueprint>

Reply via email to