You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/07/12 23:45:48 UTC

[commons-configuration] branch master updated: CONFIGURATION-834 Update ConfigurationPropertySource to so resolved values are returned. (#309)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-configuration.git


The following commit(s) were added to refs/heads/master by this push:
     new 9243c8c0 CONFIGURATION-834 Update ConfigurationPropertySource to so resolved values are returned. (#309)
9243c8c0 is described below

commit 9243c8c0d4bc5fd2519f6d000089e5ed5c4ef567
Author: kbarlowgw <13...@users.noreply.github.com>
AuthorDate: Wed Jul 12 19:45:42 2023 -0400

    CONFIGURATION-834 Update ConfigurationPropertySource to so resolved values are returned. (#309)
---
 .../spring/ConfigurationPropertySource.java        |  2 +-
 .../spring/TestConfigurationPropertySource.java    | 23 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java b/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java
index 200f5a52..beeba6bc 100644
--- a/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java
+++ b/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java
@@ -49,6 +49,6 @@ public class ConfigurationPropertySource extends EnumerablePropertySource<Config
 
     @Override
     public Object getProperty(final String name) {
-        return source.getProperty(name);
+        return source.getString(name);
     }
 }
diff --git a/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertySource.java b/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertySource.java
index aa194752..c37eb43e 100644
--- a/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertySource.java
+++ b/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertySource.java
@@ -20,6 +20,8 @@ package org.apache.commons.configuration2.spring;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.apache.commons.configuration2.PropertiesConfiguration;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.springframework.beans.factory.annotation.Value;
@@ -55,19 +57,40 @@ public class TestConfigurationPropertySource {
     }
     private static final String TEST_PROPERTY = "test.property";
 
+    private static final String TEST_SYSTEM_PROPERTY = "test.system.property";
+
     private static final String TEST_VALUE = "testVALUE";
 
+
     private static ConfigurationPropertySource createConfigPropertySource() {
         final PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
         propertiesConfiguration.addProperty(TEST_PROPERTY, TEST_VALUE);
+        propertiesConfiguration.addProperty(TEST_SYSTEM_PROPERTY, "${sys:" + TEST_SYSTEM_PROPERTY + "}");
         return new ConfigurationPropertySource("test configuration", propertiesConfiguration);
     }
 
+    @BeforeAll
+    public static void setUp() {
+        System.setProperty(TEST_SYSTEM_PROPERTY, TEST_VALUE);
+    }
+
+    @AfterAll
+    public static void tearDown() {
+        System.clearProperty(TEST_SYSTEM_PROPERTY);
+    }
+
     @Value("${" + TEST_PROPERTY + "}")
     private String value;
 
+    @Value("${" + TEST_SYSTEM_PROPERTY + "}")
+    private String systemPropertyValue;
+
     @Test
     public void testValueInjection() {
         assertEquals(TEST_VALUE, value);
     }
+
+    @Test
+    public void testSystemPropertyValueInjection() { assertEquals(TEST_VALUE, systemPropertyValue); }
+
 }