camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggrzy...@apache.org
Subject [3/4] camel git commit: CAMEL-10038: added unit test for BlueprintPropertiesParser fallbackToUnaugmentedProperty behavior
Date Thu, 21 Jul 2016 06:55:41 GMT
CAMEL-10038: added unit test for BlueprintPropertiesParser fallbackToUnaugmentedProperty behavior

(cherry picked from commit da85e4c86fc7fdb6156b00aafbaac8c35a0168ca)


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

Branch: refs/heads/master
Commit: 55ee517f05515cf3bb257e67930db8be10c26c90
Parents: 8137499
Author: Matthew Zipay <mattz@ninthtest.net>
Authored: Wed Jul 20 11:54:27 2016 -0400
Committer: Grzegorz Grzybek <gr.grzybek@gmail.com>
Committed: Thu Jul 21 08:53:26 2016 +0200

----------------------------------------------------------------------
 ...lueprintAugmentedPropertiesFallbackTest.java | 50 ++++++++++++++++++++
 .../test/resources/etc/augmented.fallback.cfg   | 23 +++++++++
 .../blueprint/augmented-properties-fallback.xml | 48 +++++++++++++++++++
 3 files changed, 121 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/55ee517f/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintAugmentedPropertiesFallbackTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintAugmentedPropertiesFallbackTest.java
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintAugmentedPropertiesFallbackTest.java
new file mode 100644
index 0000000..fa12e13
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintAugmentedPropertiesFallbackTest.java
@@ -0,0 +1,50 @@
+/**
+ * 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;
+
+/**
+ * A test showing that Blueprint XML property placeholders work correctly with
+ * augmented property names and fallback behavior.
+ */
+public class BlueprintAugmentedPropertiesFallbackTest extends CamelBlueprintTestSupport {
+
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "org/apache/camel/test/blueprint/augmented-properties-fallback.xml";
+    }
+
+    @Override
+    protected String[] loadConfigAdminConfigurationFile() {
+        return new String[] {"src/test/resources/etc/augmented.fallback.cfg", "augmented.fallback"};
+    }
+
+    @Test
+    public void testFallbackToUnaugmentedProperty() throws Exception {
+        /*
+         * mock:result only gets the expected body if BlueprintPropertiesParser
+         * correctly fell back from "TEST.destination" to "destination"
+         */
+        getMockEndpoint("mock:result").expectedBodiesReceived("fallbackToUnaugmentedProperty
is working");
+
+        template.sendBody("direct:start", null);
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/55ee517f/components/camel-test-blueprint/src/test/resources/etc/augmented.fallback.cfg
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/etc/augmented.fallback.cfg
b/components/camel-test-blueprint/src/test/resources/etc/augmented.fallback.cfg
new file mode 100644
index 0000000..f6ada0a
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/etc/augmented.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:not-from-here
+TEST.source = direct:start
+
+# augmented TEST.destination should fall back to this
+destination = mock:result
+

http://git-wip-us.apache.org/repos/asf/camel/blob/55ee517f/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/augmented-properties-fallback.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/augmented-properties-fallback.xml
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/augmented-properties-fallback.xml
new file mode 100644
index 0000000..d26d6b9
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/augmented-properties-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.fallback"/>
+
+  <camelContext xmlns="http://camel.apache.org/schema/blueprint"
+                id="test-camelContext"
+                useBlueprintPropertyResolver="true">
+
+    <propertyPlaceholder id="test-propertyPlaceholder"
+                         location="blueprint:test-property-placeholder"
+                         propertyPrefix="TEST."
+                         fallbackToUnaugmentedProperty="true"/>
+
+    <route>
+      <from uri="{{source}}"/>
+      <transform>
+        <simple>fallbackToUnaugmentedProperty is working</simple>
+      </transform>
+      <to uri="{{destination}}"/>
+    </route>
+
+  </camelContext>
+
+</blueprint>


Mime
View raw message