You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2016/11/04 16:02:34 UTC
[3/3] camel git commit: CAMEL-10417: camel-properties: Support adding
location using child nodes of propertyPlaceholder element
CAMEL-10417: camel-properties: Support adding location using child nodes of propertyPlaceholder element
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/610c5db0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/610c5db0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/610c5db0
Branch: refs/heads/master
Commit: 610c5db0a02804f64ced39581ab7cbf0b2b786dc
Parents: a4e94f0
Author: lburgazzoli <lb...@gmail.com>
Authored: Fri Oct 28 19:12:11 2016 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Fri Nov 4 16:44:44 2016 +0100
----------------------------------------------------------------------
.../src/main/docs/properties-component.adoc | 2 +-
.../properties/PropertiesComponent.java | 13 +++-
.../PropertiesComponentConfiguration.java | 5 +-
.../blueprint/BlueprintPropertiesResolver.java | 3 +-
.../blueprint/CamelContextFactoryBean.java | 11 ++--
.../xml/AbstractCamelContextFactoryBean.java | 15 ++++-
.../xml/CamelPropertyPlaceholderDefinition.java | 15 ++++-
...elPropertyPlaceholderFunctionDefinition.java | 1 -
...elPropertyPlaceholderLocationDefinition.java | 62 +++++++++++++++++++
...ntPropertiesLocationElementImplicitTest.java | 49 +++++++++++++++
.../BlueprintPropertiesLocationElementTest.java | 48 +++++++++++++++
.../properties-location-element-1.properties | 17 +++++
.../properties-location-element-2.properties | 17 +++++
...roperties-location-element-implicit-test.xml | 55 +++++++++++++++++
.../properties-location-element-test.xml | 55 +++++++++++++++++
...amelSpringPropertiesLocationElementTest.java | 65 ++++++++++++++++++++
...ingPropertiesLocationElementTest-context.xml | 46 ++++++++++++++
.../properties-location-element-1.properties | 17 +++++
.../properties-location-element-2.properties | 17 +++++
.../properties-location-element-3.properties | 17 +++++
20 files changed, 515 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/camel-core/src/main/docs/properties-component.adoc
----------------------------------------------------------------------
diff --git a/camel-core/src/main/docs/properties-component.adoc b/camel-core/src/main/docs/properties-component.adoc
index b68d26d..8ba8bf4 100644
--- a/camel-core/src/main/docs/properties-component.adoc
+++ b/camel-core/src/main/docs/properties-component.adoc
@@ -28,7 +28,7 @@ The Properties component supports 16 options which are listed below.
[width="100%",cols="2,1m,7",options="header"]
|=======================================================================
| Name | Java Type | Description
-| locations | String[] | A list of locations to load properties. You can use comma to separate multiple locations. This option will override any default locations and only use the locations from this option.
+| locations | String[] | A list of locations to load properties. This option will override any default locations and only use the locations from this option.
| location | String | A list of locations to load properties. You can use comma to separate multiple locations. This option will override any default locations and only use the locations from this option.
| encoding | String | Encoding to use when loading properties file from the file system or classpath. If no encoding has been set then the properties files is loaded using ISO-8859-1 encoding (latin-1) as documented by link java.util.Propertiesload(java.io.InputStream)
| propertiesResolver | PropertiesResolver | To use a custom PropertiesResolver
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java b/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
index 82020f6..3ad3067 100644
--- a/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.properties;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -229,7 +230,7 @@ public class PropertiesComponent extends UriEndpointComponent {
}
/**
- * A list of locations to load properties. You can use comma to separate multiple locations.
+ * A list of locations to load properties.
* This option will override any default locations and only use the locations from this option.
*/
public void setLocations(String[] locations) {
@@ -246,6 +247,16 @@ public class PropertiesComponent extends UriEndpointComponent {
}
/**
+ * A list of locations to load properties.
+ * This option will override any default locations and only use the locations from this option.
+ */
+ public void setLocations(Collection<String> locations) {
+ if (locations != null && !locations.isEmpty()) {
+ setLocations(locations.toArray(new String[locations.size()]));
+ }
+ }
+
+ /**
* A list of locations to load properties. You can use comma to separate multiple locations.
* This option will override any default locations and only use the locations from this option.
*/
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java b/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java
index 9a360bc..8eab06c 100644
--- a/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java
+++ b/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java
@@ -32,9 +32,8 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
public class PropertiesComponentConfiguration {
/**
- * A list of locations to load properties. You can use comma to separate
- * multiple locations. This option will override any default locations and
- * only use the locations from this option.
+ * A list of locations to load properties. This option will override any
+ * default locations and only use the locations from this option.
*/
private String[] locations;
/**
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesResolver.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesResolver.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesResolver.java
index dc2bd8d..aa36d1f 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesResolver.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesResolver.java
@@ -60,8 +60,7 @@ public class BlueprintPropertiesResolver implements PropertiesResolver {
if (!explicit) {
// auto lookup blueprint property placeholders to use if none explicit was configured
// this is convention over configuration
- String[] ids = blueprint.lookupPropertyPlaceholderIds();
- for (String id : ids) {
+ for (String id : blueprint.lookupPropertyPlaceholderIds()) {
blueprint.addPropertyPlaceholder(id);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
index 4961bee..6802312 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
@@ -270,14 +270,15 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
// no locations has been set, so its a default component
if (pc.getLocations() == null) {
- StringBuilder sb = new StringBuilder();
String[] ids = parser.lookupPropertyPlaceholderIds();
- for (String id : ids) {
- sb.append("blueprint:").append(id).append(",");
+ for (int i = 0; i < ids.length; i++) {
+ if (!ids[i].startsWith( "blueprint:")) {
+ ids[i] = "blueprint:" + ids[i];
+ }
}
- if (sb.length() > 0) {
+ if (ids.length > 0) {
// location supports multiple separated by comma
- pc.setLocation(sb.toString());
+ pc.setLocations(ids);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index d26449b..a2b5e3f 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -567,8 +567,21 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
if (getCamelPropertyPlaceholder() != null) {
CamelPropertyPlaceholderDefinition def = getCamelPropertyPlaceholder();
+ List<String> locations = new ArrayList<>();
+
+ if (def.getLocation() != null) {
+ ObjectHelper.createIterable(def.getLocation()).forEach(
+ location -> locations.add((String) location)
+ );
+ }
+ if (def.getLocations() != null) {
+ def.getLocations().forEach(
+ definition -> locations.add(definition.getPath())
+ );
+ }
+
PropertiesComponent pc = new PropertiesComponent();
- pc.setLocation(def.getLocation());
+ pc.setLocations(locations);
pc.setEncoding(def.getEncoding());
if (def.isCache() != null) {
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java
index 6e3d638..c626836 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java
@@ -36,7 +36,7 @@ import org.apache.camel.spi.Metadata;
@XmlAccessorType(XmlAccessType.FIELD)
public class CamelPropertyPlaceholderDefinition extends IdentifiedType {
- @XmlAttribute(required = true)
+ @XmlAttribute
private String location;
@XmlAttribute
private String encoding;
@@ -62,6 +62,8 @@ public class CamelPropertyPlaceholderDefinition extends IdentifiedType {
private String suffixToken;
@XmlElement(name = "propertiesFunction")
private List<CamelPropertyPlaceholderFunctionDefinition> functions;
+ @XmlElement(name = "propertiesLocation")
+ private List<CamelPropertyPlaceholderLocationDefinition> locations;
public String getLocation() {
return location;
@@ -212,4 +214,15 @@ public class CamelPropertyPlaceholderDefinition extends IdentifiedType {
public void setFunctions(List<CamelPropertyPlaceholderFunctionDefinition> functions) {
this.functions = functions;
}
+
+ public List<CamelPropertyPlaceholderLocationDefinition> getLocations() {
+ return locations;
+ }
+
+ /**
+ * List of property locations to use.
+ */
+ public void setLocations(List<CamelPropertyPlaceholderLocationDefinition> locations) {
+ this.locations = locations;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderFunctionDefinition.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderFunctionDefinition.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderFunctionDefinition.java
index 6256798..0dbebef 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderFunctionDefinition.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderFunctionDefinition.java
@@ -28,7 +28,6 @@ import org.apache.camel.spi.Metadata;
@Metadata(label = "spring,configuration")
@XmlRootElement(name = "propertiesFunction")
public class CamelPropertyPlaceholderFunctionDefinition extends IdentifiedType {
-
@XmlAttribute(required = true)
private String ref;
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderLocationDefinition.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderLocationDefinition.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderLocationDefinition.java
new file mode 100644
index 0000000..4923684
--- /dev/null
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderLocationDefinition.java
@@ -0,0 +1,62 @@
+/**
+ * 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.core.xml;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.model.IdentifiedType;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Properties to use with properties placeholder
+ */
+@Metadata(label = "spring,configuration")
+@XmlRootElement(name = "propertiesLocation")
+public class CamelPropertyPlaceholderLocationDefinition extends IdentifiedType {
+ @XmlAttribute(required = true)
+ public String path;
+ @XmlAttribute
+ public String resolver;
+
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * Property locations to use.
+ */
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getResolver() {
+ return resolver;
+ }
+
+ /**
+ * The resolver to use to locate the location
+ */
+ public void setResolver(String resolver) {
+ this.resolver = resolver;
+ }
+
+ public String getLocation() {
+ return ObjectHelper.isEmpty(resolver) ? path : resolver + path;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesLocationElementImplicitTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesLocationElementImplicitTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesLocationElementImplicitTest.java
new file mode 100644
index 0000000..89a7451
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesLocationElementImplicitTest.java
@@ -0,0 +1,49 @@
+/**
+ * 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.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.junit.Test;
+
+public class BlueprintPropertiesLocationElementImplicitTest extends CamelBlueprintTestSupport {
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/blueprint/properties-location-element-implicit-test.xml";
+ }
+
+ @Test
+ public void testPropertiesLocationElement() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedHeaderReceived("property-1", "property-value-1");
+ mock.expectedHeaderReceived("property-2", "property-value-2");
+ mock.expectedHeaderReceived("cm", "cm-value");
+
+ PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
+ assertNotNull("Properties component not defined", pc);
+
+ String[] locations = pc.getLocations();
+
+ assertNotNull(locations);
+ assertEquals("Properties locations", 2, locations.length);
+
+ template.sendBody("direct:start", null);
+
+ mock.assertIsSatisfied();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesLocationElementTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesLocationElementTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesLocationElementTest.java
new file mode 100644
index 0000000..d05ce78
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesLocationElementTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.junit.Test;
+
+public class BlueprintPropertiesLocationElementTest extends CamelBlueprintTestSupport {
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/blueprint/properties-location-element-test.xml";
+ }
+
+ @Test
+ public void testPropertiesLocationElement() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedHeaderReceived("property-1", "property-value-1");
+ mock.expectedHeaderReceived("property-2", "property-value-2");
+ mock.expectedHeaderReceived("cm", "cm-value");
+
+ PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
+ assertNotNull("Properties component not defined", pc);
+
+ String[] locations = pc.getLocations();
+
+ assertNotNull(locations);
+ assertEquals("Properties locations", 3, locations.length);
+
+ template.sendBody("direct:start", null);
+
+ mock.assertIsSatisfied();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-1.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-1.properties b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-1.properties
new file mode 100644
index 0000000..23b2f2f
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-1.properties
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+property-key-1 = property-value-1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-2.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-2.properties b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-2.properties
new file mode 100644
index 0000000..0732a17
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-2.properties
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+property-key-2 = property-value-2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-implicit-test.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-implicit-test.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-implicit-test.xml
new file mode 100644
index 0000000..ffe6986
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-implicit-test.xml
@@ -0,0 +1,55 @@
+<?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.1.0
+ http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
+ http://www.osgi.org/xmlns/blueprint/v1.0.0
+ http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <cm:property-placeholder id="properties-element" persistent-id="properties.element">
+ <cm:default-properties>
+ <cm:property name="cm-key" value="cm-value" />
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+ <propertyPlaceholder id="property-placeholder-camel">
+ <propertiesLocation path="classpath:org/apache/camel/test/blueprint/properties-location-element-1.properties"/>
+ <propertiesLocation resolver="classpath" path="org/apache/camel/test/blueprint/properties-location-element-2.properties"/>
+ </propertyPlaceholder>
+
+ <route>
+ <from uri="direct:start"/>
+ <setHeader headerName="property-1">
+ <constant>{{property-key-1}}</constant>
+ </setHeader>
+ <setHeader headerName="property-2">
+ <constant>{{property-key-2}}</constant>
+ </setHeader>
+ <setHeader headerName="cm">
+ <constant>{{cm-key}}</constant>
+ </setHeader>
+ <to uri="mock:result"/>
+ </route>
+
+ </camelContext>
+
+</blueprint>
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-test.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-test.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-test.xml
new file mode 100644
index 0000000..9c81873
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/properties-location-element-test.xml
@@ -0,0 +1,55 @@
+<?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.1.0
+ http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
+ http://www.osgi.org/xmlns/blueprint/v1.0.0
+ http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <cm:property-placeholder id="properties-element" persistent-id="properties.element">
+ <cm:default-properties>
+ <cm:property name="cm-key" value="cm-value" />
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+ <propertyPlaceholder id="property-placeholder-camel" location="blueprint:properties-element">
+ <propertiesLocation path="classpath:org/apache/camel/test/blueprint/properties-location-element-1.properties"/>
+ <propertiesLocation resolver="classpath" path="org/apache/camel/test/blueprint/properties-location-element-2.properties"/>
+ </propertyPlaceholder>
+
+ <route>
+ <from uri="direct:start"/>
+ <setHeader headerName="property-1">
+ <constant>{{property-key-1}}</constant>
+ </setHeader>
+ <setHeader headerName="property-2">
+ <constant>{{property-key-2}}</constant>
+ </setHeader>
+ <setHeader headerName="cm">
+ <constant>{{cm-key}}</constant>
+ </setHeader>
+ <to uri="mock:result"/>
+ </route>
+
+ </camelContext>
+
+</blueprint>
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringPropertiesLocationElementTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringPropertiesLocationElementTest.java b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringPropertiesLocationElementTest.java
new file mode 100644
index 0000000..89a5186
--- /dev/null
+++ b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringPropertiesLocationElementTest.java
@@ -0,0 +1,65 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.BootstrapWith;
+import org.springframework.test.context.ContextConfiguration;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(CamelSpringRunner.class)
+@BootstrapWith(CamelTestContextBootstrapper.class)
+@ContextConfiguration()
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
+public class CamelSpringPropertiesLocationElementTest {
+ @Autowired
+ protected CamelContext context;
+ @Produce
+ private ProducerTemplate producer;
+ @EndpointInject(uri = "mock:result")
+ private MockEndpoint mock;
+
+ @Test
+ public void testPropertiesLocationElement() throws Exception {
+ mock.expectedHeaderReceived("property-1", "property-value-1");
+ mock.expectedHeaderReceived("property-2", "property-value-2");
+ mock.expectedHeaderReceived("property-3", "property-value-3");
+
+ PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
+ assertNotNull("Properties component not defined", pc);
+
+ String[] locations = pc.getLocations();
+
+ assertNotNull(locations);
+ assertEquals("Properties locations", 3, locations.length);
+
+ producer.sendBody("direct:start", null);
+
+ mock.assertIsSatisfied();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringPropertiesLocationElementTest-context.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringPropertiesLocationElementTest-context.xml b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringPropertiesLocationElementTest-context.xml
new file mode 100644
index 0000000..247b551
--- /dev/null
+++ b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringPropertiesLocationElementTest-context.xml
@@ -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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <propertyPlaceholder id="property-placeholder-camel" location="classpath:org/apache/camel/test/spring/properties-location-element-3.properties">
+ <propertiesLocation path="classpath:org/apache/camel/test/spring/properties-location-element-1.properties"/>
+ <propertiesLocation resolver="classpath" path="org/apache/camel/test/spring/properties-location-element-2.properties"/>
+ </propertyPlaceholder>
+
+ <route>
+ <from uri="direct:start"/>
+ <setHeader headerName="property-1">
+ <constant>{{property-key-1}}</constant>
+ </setHeader>
+ <setHeader headerName="property-2">
+ <constant>{{property-key-2}}</constant>
+ </setHeader>
+ <setHeader headerName="property-3">
+ <constant>{{property-key-3}}</constant>
+ </setHeader>
+ <to uri="mock:result"/>
+ </route>
+
+ </camelContext>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-1.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-1.properties b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-1.properties
new file mode 100644
index 0000000..23b2f2f
--- /dev/null
+++ b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-1.properties
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+property-key-1 = property-value-1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-2.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-2.properties b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-2.properties
new file mode 100644
index 0000000..0732a17
--- /dev/null
+++ b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-2.properties
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+property-key-2 = property-value-2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/610c5db0/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-3.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-3.properties b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-3.properties
new file mode 100644
index 0000000..aac5c21
--- /dev/null
+++ b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/properties-location-element-3.properties
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+property-key-3 = property-value-3
\ No newline at end of file