commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1095797 - in /commons/proper/configuration/trunk: conf/testDigesterConfiguration3.xml src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java
Date Thu, 21 Apr 2011 19:34:32 GMT
Author: oheger
Date: Thu Apr 21 19:34:32 2011
New Revision: 1095797

URL: http://svn.apache.org/viewvc?rev=1095797&view=rev
Log:
[CONFIGURATION-447] Added support for environment properties to DefaultConfigurationBuilder.
Thanks to Fabien Nisol for the proposal.

Modified:
    commons/proper/configuration/trunk/conf/testDigesterConfiguration3.xml
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
    commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java

Modified: commons/proper/configuration/trunk/conf/testDigesterConfiguration3.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/conf/testDigesterConfiguration3.xml?rev=1095797&r1=1095796&r2=1095797&view=diff
==============================================================================
--- commons/proper/configuration/trunk/conf/testDigesterConfiguration3.xml (original)
+++ commons/proper/configuration/trunk/conf/testDigesterConfiguration3.xml Thu Apr 21 19:34:32
2011
@@ -9,5 +9,6 @@
     <properties fileName="testDigesterConfigurationInclude2.properties" at="mail"/>
     <jndi prefix=""/>
     <ini fileName="test.ini"/>
+    <env at="env"/>
   </additional>
 </configuration>

Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java?rev=1095797&r1=1095796&r2=1095797&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
Thu Apr 21 19:34:32 2011
@@ -383,6 +383,10 @@ public class DefaultConfigurationBuilder
     private static final ConfigurationProvider INI_PROVIDER =
             new FileConfigurationProvider(HierarchicalINIConfiguration.class);
 
+    /** Constant for the provider for environment properties. */
+    private static final ConfigurationProvider ENV_PROVIDER =
+            new ConfigurationProvider(EnvironmentConfiguration.class);
+
     /** Constant for the provider for plist files. */
     private static final ConfigurationProvider PLIST_PROVIDER = new FileExtensionConfigurationProvider(
             "org.apache.commons.configuration.plist.XMLPropertyListConfiguration",
@@ -395,13 +399,15 @@ public class DefaultConfigurationBuilder
     /** An array with the names of the default tags. */
     private static final String[] DEFAULT_TAGS = {
             "properties", "xml", "hierarchicalXml", "jndi", "system", "plist",
-            "configuration", "ini"
+            "configuration", "ini", "env"
     };
 
     /** An array with the providers for the default tags. */
-    private static final ConfigurationProvider[] DEFAULT_PROVIDERS =
-    {PROPERTIES_PROVIDER, XML_PROVIDER, XML_PROVIDER, JNDI_PROVIDER,
-            SYSTEM_PROVIDER, PLIST_PROVIDER, BUILDER_PROVIDER, INI_PROVIDER};
+    private static final ConfigurationProvider[] DEFAULT_PROVIDERS = {
+            PROPERTIES_PROVIDER, XML_PROVIDER, XML_PROVIDER, JNDI_PROVIDER,
+            SYSTEM_PROVIDER, PLIST_PROVIDER, BUILDER_PROVIDER, INI_PROVIDER,
+            ENV_PROVIDER
+    };
 
     /**
      * The serial version UID.

Modified: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java?rev=1095797&r1=1095796&r2=1095797&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java
Thu Apr 21 19:34:32 2011
@@ -666,6 +666,16 @@ public class TestDefaultConfigurationBui
         // test INIConfiguration
         assertEquals("Property from ini file not found", "yes",
                 config.getString("testini.loaded"));
+
+        // test environment configuration
+        EnvironmentConfiguration envConf = new EnvironmentConfiguration();
+        for (Iterator it = envConf.getKeys(); it.hasNext();)
+        {
+            String key = (String) it.next();
+            String combinedKey = "env." + key;
+            assertEquals("Wrong value for env property " + key,
+                    envConf.getString(key), config.getString(combinedKey));
+        }
     }
 
     /**



Mime
View raw message