This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 8be2376 CAMEL-15006: Allow to configure camel-main's properties
locations using system properties and env vars
8be2376 is described below
commit 8be2376ba1ff984a20fbc5bfefa762c3508289dd
Author: lburgazzoli <[email protected]>
AuthorDate: Mon May 4 15:23:03 2020 +0200
CAMEL-15006: Allow to configure camel-main's properties locations using
system properties and env vars
---
core/camel-main/pom.xml | 18 ++
.../org/apache/camel/main/BaseMainSupport.java | 82 ++++-----
.../java/org/apache/camel/main/MainHelper.java | 63 +++++++
...sTest.java => MainPropertyPlaceholderTest.java} | 2 +-
.../main/MainPropertyPlaceholderWithEnvTest.java | 193 +++++++++++++++++++++
.../MainPropertyPlaceholderWithSystemTest.java | 119 +++++++++++++
.../src/test/resources/default.properties | 3 +-
.../{default.properties => initial.properties} | 3 +-
.../{default.properties => override.properties} | 2 +-
.../{default.properties => user.properties} | 3 +-
parent/pom.xml | 1 +
11 files changed, 445 insertions(+), 44 deletions(-)
diff --git a/core/camel-main/pom.xml b/core/camel-main/pom.xml
index d4b464d..6393811 100644
--- a/core/camel-main/pom.xml
+++ b/core/camel-main/pom.xml
@@ -116,6 +116,24 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>${mockito-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>${powermock-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <version>${powermock-version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git
a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index bcd9481..460e05f 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -61,6 +62,7 @@ import org.apache.camel.spi.RestConfiguration;
import org.apache.camel.support.CamelContextHelper;
import org.apache.camel.support.LifecycleStrategySupport;
import org.apache.camel.support.PropertyBindingSupport;
+import org.apache.camel.support.ResourceHelper;
import org.apache.camel.support.service.BaseService;
import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.util.FileUtil;
@@ -73,7 +75,8 @@ import
org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+import static org.apache.camel.main.MainHelper.lookupPropertyFromSysOrEnv;
+import static
org.apache.camel.main.MainHelper.loadEnvironmentVariablesAsProperties;
import static org.apache.camel.support.ObjectHelper.invokeMethod;
import static org.apache.camel.util.ReflectionHelper.findMethod;
import static org.apache.camel.util.StringHelper.matches;
@@ -82,6 +85,10 @@ import static org.apache.camel.util.StringHelper.matches;
* Base class for main implementations to allow bootstrapping Camel in
standalone mode.
*/
public abstract class BaseMainSupport extends BaseService {
+ public static final String DEFAULT_PROPERTY_PLACEHOLDER_LOCATION =
"classpath:application.properties;optional=true";
+ public static final String INITIAL_PROPERTIES_LOCATION =
"camel.main.initial-properties-location";
+ public static final String OVERRIDE_PROPERTIES_LOCATION =
"camel.main.override-properties-location";
+ public static final String PROPERTY_PLACEHOLDER_LOCATION =
"camel.main.property-placeholder-location";
private static final Logger LOG =
LoggerFactory.getLogger(BaseMainSupport.class);
@@ -103,31 +110,10 @@ public abstract class BaseMainSupport extends BaseService
{
protected List<Object> configurations = new ArrayList<>();
protected String configurationClasses;
protected String propertyPlaceholderLocations;
- protected String defaultPropertyPlaceholderLocation =
"classpath:application.properties;optional=true";
+ protected String defaultPropertyPlaceholderLocation =
DEFAULT_PROPERTY_PLACEHOLDER_LOCATION;
protected Properties initialProperties;
protected Properties overrideProperties;
- protected static Properties loadEnvironmentVariablesAsProperties(String[]
prefixes) {
- Properties answer = new OrderedProperties();
- if (prefixes == null || prefixes.length == 0) {
- return answer;
- }
-
- for (String prefix : prefixes) {
- final String pk =
prefix.toUpperCase(Locale.US).replaceAll("[^\\w]", "-");
- final String pk2 = pk.replace('-', '_');
- System.getenv().forEach((k, v) -> {
- k = k.toUpperCase(Locale.US);
- if (k.startsWith(pk) || k.startsWith(pk2)) {
- String key = k.toLowerCase(Locale.ENGLISH).replace('_',
'.');
- answer.put(key, v);
- }
- });
- }
-
- return answer;
- }
-
protected static String optionKey(String key) {
// as we ignore case for property names we should use keys in same
case and without dashes
key = StringHelper.dashToCamelCase(key);
@@ -515,26 +501,44 @@ public abstract class BaseMainSupport extends BaseService
{
}
protected void configurePropertiesService(CamelContext camelContext)
throws Exception {
- if (propertyPlaceholderLocations != null) {
- PropertiesComponent pc = camelContext.getPropertiesComponent();
- pc.addLocation(propertyPlaceholderLocations);
- LOG.info("Using properties from: {}",
propertyPlaceholderLocations);
- } else if (ObjectHelper.isNotEmpty(defaultPropertyPlaceholderLocation)
&& !ObjectHelper.equal("false", defaultPropertyPlaceholderLocation)) {
- // lets default to defaultPropertyPlaceholderLocation if
- // there are no existing locations configured
- PropertiesComponent pc = camelContext.getPropertiesComponent();
- if (pc.getLocations().isEmpty()) {
- pc.addLocation(defaultPropertyPlaceholderLocation);
+ PropertiesComponent pc = camelContext.getPropertiesComponent();
+ if (pc.getLocations().isEmpty()) {
+ String locations = propertyPlaceholderLocations;
+ if (locations == null) {
+ locations =
lookupPropertyFromSysOrEnv(PROPERTY_PLACEHOLDER_LOCATION).orElse(defaultPropertyPlaceholderLocation);
+ }
+ if (!Objects.equals(locations, "false")) {
+ pc.addLocation(locations);
+ LOG.info("Using properties from: {}",
propertyPlaceholderLocations);
}
- LOG.info("Using properties from {}",
defaultPropertyPlaceholderLocation);
}
- PropertiesComponent pc = camelContext.getPropertiesComponent();
- if (initialProperties != null) {
- pc.setInitialProperties(initialProperties);
+ Properties ip = initialProperties;
+ if (ip == null || ip.isEmpty()) {
+ Optional<String> location =
lookupPropertyFromSysOrEnv(INITIAL_PROPERTIES_LOCATION);
+ if (location.isPresent()) {
+ try (InputStream is =
ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext,
location.get())) {
+ ip = new Properties();
+ ip.load(is);
+ }
+ }
+ }
+ if (ip != null) {
+ pc.setInitialProperties(ip);
+ }
+
+ Properties op = overrideProperties;
+ if (op == null || op.isEmpty()) {
+ Optional<String> location =
lookupPropertyFromSysOrEnv(OVERRIDE_PROPERTIES_LOCATION);
+ if (location.isPresent()) {
+ try (InputStream is =
ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext,
location.get())) {
+ op = new Properties();
+ op.load(is);
+ }
+ }
}
- if (overrideProperties != null) {
- pc.setOverrideProperties(overrideProperties);
+ if (op != null) {
+ pc.setOverrideProperties(op);
}
}
diff --git
a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
new file mode 100644
index 0000000..a8ff18e
--- /dev/null
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
@@ -0,0 +1,63 @@
+/*
+ * 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.main;
+
+import java.util.Locale;
+import java.util.Optional;
+import java.util.Properties;
+
+import org.apache.camel.util.OrderedProperties;
+
+public final class MainHelper {
+ private MainHelper() {
+ }
+
+ public static String toEnvVar(String name) {
+ return name.toUpperCase(Locale.US).replaceAll("[^\\w]",
"-").replace('-', '_');
+ }
+
+ public static Optional<String> lookupPropertyFromSysOrEnv(String name) {
+ String answer = System.getProperty(name);
+ if (answer == null) {
+ answer = System.getenv(toEnvVar(name));
+ }
+
+ return Optional.ofNullable(answer);
+ }
+
+ public static Properties loadEnvironmentVariablesAsProperties(String[]
prefixes) {
+ Properties answer = new OrderedProperties();
+ if (prefixes == null || prefixes.length == 0) {
+ return answer;
+ }
+
+ for (String prefix : prefixes) {
+ final String pk =
prefix.toUpperCase(Locale.US).replaceAll("[^\\w]", "-");
+ final String pk2 = pk.replace('-', '_');
+ System.getenv().forEach((k, v) -> {
+ k = k.toUpperCase(Locale.US);
+ if (k.startsWith(pk) || k.startsWith(pk2)) {
+ String key = k.toLowerCase(Locale.ENGLISH).replace('_',
'.');
+ answer.put(key, v);
+ }
+ });
+ }
+
+ return answer;
+ }
+
+}
diff --git
a/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderLocationsTest.java
b/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderTest.java
similarity index 96%
rename from
core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderLocationsTest.java
rename to
core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderTest.java
index fb74aee..a065a49 100644
---
a/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderLocationsTest.java
+++
b/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.main;
import org.junit.Assert;
import org.junit.Test;
-public class MainPropertyPlaceholderLocationsTest extends Assert {
+public class MainPropertyPlaceholderTest extends Assert {
@Test(expected = IllegalArgumentException.class)
public void testDefaultPropertyPlaceholderLocationDisabled() {
Main main = new Main();
diff --git
a/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderWithEnvTest.java
b/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderWithEnvTest.java
new file mode 100644
index 0000000..9f1b6a6
--- /dev/null
+++
b/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderWithEnvTest.java
@@ -0,0 +1,193 @@
+/*
+ * 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.main;
+
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockIgnore({"javax.management.*", "javax.script.*"})
+@PrepareForTest(MainHelper.class)
+public class MainPropertyPlaceholderWithEnvTest {
+ public static final String ENV_PROPERTY_PLACEHOLDER_LOCATION =
MainHelper.toEnvVar(Main.PROPERTY_PLACEHOLDER_LOCATION);
+ public static final String ENV_INITIAL_PROPERTIES_LOCATION =
MainHelper.toEnvVar(Main.INITIAL_PROPERTIES_LOCATION);
+ public static final String ENV_OVERRIDE_PROPERTIES_LOCATION =
MainHelper.toEnvVar(Main.OVERRIDE_PROPERTIES_LOCATION);
+
+ @Before
+ public void setUp() {
+ PowerMockito.mockStatic(System.class);
+ }
+
+ @Test
+ public void testPropertyPlaceholderLocation() {
+ when(System.getenv(ENV_PROPERTY_PLACEHOLDER_LOCATION))
+ .thenReturn("classpath:default.properties");
+
+ Main main = new Main();
+ try {
+ main.start();
+ assertEquals("default",
main.getCamelContext().resolvePropertyPlaceholders("{{hello}}"));
+ } finally {
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testPropertyPlaceholderOrdering() {
+
when(System.getenv(MainHelper.toEnvVar(Main.PROPERTY_PLACEHOLDER_LOCATION)))
+ .thenReturn("classpath:default.properties");
+ when(System.getProperty(Main.PROPERTY_PLACEHOLDER_LOCATION))
+ .thenReturn("classpath:user.properties");
+
+ Main main = new Main();
+ try {
+ main.start();
+ assertEquals("user",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testInitialProperties() {
+ when(System.getenv(ENV_INITIAL_PROPERTIES_LOCATION))
+ .thenReturn("classpath:initial.properties");
+
+ Main main = new Main();
+ try {
+ main.start();
+ assertEquals("initial",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testInitialPropertiesOrdering() {
+ when(System.getenv(ENV_INITIAL_PROPERTIES_LOCATION))
+ .thenReturn("classpath:default.properties");
+ when(System.getProperty(Main.INITIAL_PROPERTIES_LOCATION))
+ .thenReturn("classpath:user.properties");
+
+ Main main = new Main();
+ try {
+ main.start();
+ assertEquals("user",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testInstanceInitialPropertiesOrdering() {
+ when(System.getenv(ENV_INITIAL_PROPERTIES_LOCATION))
+ .thenReturn("classpath:initial.properties");
+
+ Main main = new Main();
+ try {
+ Properties properties = new Properties();
+ properties.setProperty("type", "custom");
+
+ main.setInitialProperties(properties);
+ main.start();
+ assertEquals("custom",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testOverrideProperties() {
+ when(System.getenv(ENV_OVERRIDE_PROPERTIES_LOCATION))
+ .thenReturn("classpath:override.properties");
+
+ Main main = new Main();
+ try {
+ main.start();
+ assertEquals("override",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testInstanceOverridePropertiesOrdering() {
+ when(System.getenv(ENV_OVERRIDE_PROPERTIES_LOCATION))
+ .thenReturn("classpath:override.properties");
+
+ Main main = new Main();
+ try {
+ Properties properties = new Properties();
+ properties.setProperty("type", "custom");
+
+ main.setOverrideProperties(properties);
+ main.start();
+ assertEquals("custom",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testOverridePropertiesOrdering() {
+ when(System.getenv(ENV_OVERRIDE_PROPERTIES_LOCATION))
+ .thenReturn("classpath:default.properties");
+ when(System.getProperty(Main.OVERRIDE_PROPERTIES_LOCATION))
+ .thenReturn("classpath:user.properties");
+
+ Main main = new Main();
+ try {
+ main.start();
+ assertEquals("user",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ main.stop();
+ }
+ }
+
+
+ @Test
+ public void testAll() {
+ when(System.getenv(ENV_INITIAL_PROPERTIES_LOCATION))
+ .thenReturn("classpath:initial.properties");
+ when(System.getenv(ENV_OVERRIDE_PROPERTIES_LOCATION))
+ .thenReturn("classpath:override.properties");
+ when(System.getenv(ENV_PROPERTY_PLACEHOLDER_LOCATION))
+
.thenReturn("classpath:default.properties,classpath:user.properties");
+
+ Main main = new Main();
+ try {
+ main.start();
+
+ assertEquals("default",
main.getCamelContext().resolvePropertyPlaceholders("{{hello}}"));
+ assertEquals("override",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ assertEquals("user-value",
main.getCamelContext().resolvePropertyPlaceholders("{{user-key}}"));
+ assertEquals("initial-value",
main.getCamelContext().resolvePropertyPlaceholders("{{initial-key}}"));
+ } finally {
+ main.stop();
+ }
+ }
+}
diff --git
a/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderWithSystemTest.java
b/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderWithSystemTest.java
new file mode 100644
index 0000000..98365d7
--- /dev/null
+++
b/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderWithSystemTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.main;
+
+import java.util.Properties;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MainPropertyPlaceholderWithSystemTest extends Assert {
+ @Test
+ public void testCustomPropertyPlaceholderLocation() {
+ Main main = new Main();
+ try {
+ System.setProperty(Main.PROPERTY_PLACEHOLDER_LOCATION,
"classpath:default.properties");
+ main.start();
+ assertEquals("default",
main.getCamelContext().resolvePropertyPlaceholders("{{hello}}"));
+ } finally {
+ System.clearProperty(Main.PROPERTY_PLACEHOLDER_LOCATION);
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testInitialProperties() {
+ Main main = new Main();
+ try {
+ System.setProperty(Main.INITIAL_PROPERTIES_LOCATION,
"classpath:initial.properties");
+ main.start();
+ assertEquals("initial",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ System.clearProperty(Main.INITIAL_PROPERTIES_LOCATION);
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testInstanceInitialPropertiesOrdering() {
+ Main main = new Main();
+ try {
+ Properties properties = new Properties();
+ properties.setProperty("type", "custom");
+
+ System.setProperty(Main.INITIAL_PROPERTIES_LOCATION,
"classpath:initial.properties");
+ main.setInitialProperties(properties);
+ main.start();
+ assertEquals("custom",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ System.clearProperty(Main.INITIAL_PROPERTIES_LOCATION);
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testOverrideProperties() {
+ Main main = new Main();
+ try {
+ System.setProperty(Main.OVERRIDE_PROPERTIES_LOCATION,
"classpath:override.properties");
+ main.start();
+ assertEquals("override",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ System.clearProperty(Main.OVERRIDE_PROPERTIES_LOCATION);
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testInstanceOverridePropertiesOrdering() {
+ Main main = new Main();
+ try {
+ Properties properties = new Properties();
+ properties.setProperty("type", "custom");
+
+ System.setProperty(Main.OVERRIDE_PROPERTIES_LOCATION,
"classpath:override.properties");
+ main.setOverrideProperties(properties);
+ main.start();
+ assertEquals("custom",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ } finally {
+ System.clearProperty(Main.OVERRIDE_PROPERTIES_LOCATION);
+ main.stop();
+ }
+ }
+
+ @Test
+ public void testAll() {
+ Main main = new Main();
+ try {
+ System.setProperty(Main.INITIAL_PROPERTIES_LOCATION,
"classpath:initial.properties");
+ System.setProperty(Main.OVERRIDE_PROPERTIES_LOCATION,
"classpath:override.properties");
+ System.setProperty(Main.PROPERTY_PLACEHOLDER_LOCATION,
"classpath:default.properties,classpath:user.properties");
+
+ main.start();
+
+ assertEquals("default",
main.getCamelContext().resolvePropertyPlaceholders("{{hello}}"));
+ assertEquals("override",
main.getCamelContext().resolvePropertyPlaceholders("{{type}}"));
+ assertEquals("user-value",
main.getCamelContext().resolvePropertyPlaceholders("{{user-key}}"));
+ assertEquals("initial-value",
main.getCamelContext().resolvePropertyPlaceholders("{{initial-key}}"));
+ } finally {
+ System.clearProperty(Main.INITIAL_PROPERTIES_LOCATION);
+ System.clearProperty(Main.OVERRIDE_PROPERTIES_LOCATION);
+ System.clearProperty(Main.PROPERTY_PLACEHOLDER_LOCATION);
+ main.stop();
+ }
+ }
+}
diff --git a/core/camel-main/src/test/resources/default.properties
b/core/camel-main/src/test/resources/default.properties
index 02cf755..b92a205 100644
--- a/core/camel-main/src/test/resources/default.properties
+++ b/core/camel-main/src/test/resources/default.properties
@@ -14,4 +14,5 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
-hello=default
\ No newline at end of file
+hello=default
+type=default
\ No newline at end of file
diff --git a/core/camel-main/src/test/resources/default.properties
b/core/camel-main/src/test/resources/initial.properties
similarity index 96%
copy from core/camel-main/src/test/resources/default.properties
copy to core/camel-main/src/test/resources/initial.properties
index 02cf755..c280a0f 100644
--- a/core/camel-main/src/test/resources/default.properties
+++ b/core/camel-main/src/test/resources/initial.properties
@@ -14,4 +14,5 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
-hello=default
\ No newline at end of file
+type=initial
+initial-key=initial-value
\ No newline at end of file
diff --git a/core/camel-main/src/test/resources/default.properties
b/core/camel-main/src/test/resources/override.properties
similarity index 98%
copy from core/camel-main/src/test/resources/default.properties
copy to core/camel-main/src/test/resources/override.properties
index 02cf755..ef3582a 100644
--- a/core/camel-main/src/test/resources/default.properties
+++ b/core/camel-main/src/test/resources/override.properties
@@ -14,4 +14,4 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
-hello=default
\ No newline at end of file
+type=override
\ No newline at end of file
diff --git a/core/camel-main/src/test/resources/default.properties
b/core/camel-main/src/test/resources/user.properties
similarity index 97%
copy from core/camel-main/src/test/resources/default.properties
copy to core/camel-main/src/test/resources/user.properties
index 02cf755..8711a73 100644
--- a/core/camel-main/src/test/resources/default.properties
+++ b/core/camel-main/src/test/resources/user.properties
@@ -14,4 +14,5 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
-hello=default
\ No newline at end of file
+type=user
+user-key=user-value
\ No newline at end of file
diff --git a/parent/pom.xml b/parent/pom.xml
index ea47917..eba8ae7 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -450,6 +450,7 @@
<pdfbox-version>2.0.19</pdfbox-version>
<pgjdbc-driver-version>42.2.6</pgjdbc-driver-version>
<pgjdbc-ng-driver-version>0.8.3</pgjdbc-ng-driver-version>
+ <powermock-version>2.0.7</powermock-version>
<properties-maven-plugin-version>1.0-alpha-2</properties-maven-plugin-version>
<protobuf-version>3.11.1</protobuf-version>
<protobuf-maven-plugin-version>0.6.1</protobuf-maven-plugin-version>