commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: jakarta-commons-sandbox/configuration project.xml build.xml
Date Mon, 13 Jan 2003 23:08:13 GMT
dlr         2003/01/13 15:08:13

  Modified:    configuration/src/java/org/apache/commons/configuration
                        BaseConfiguration.java
               configuration/src/test/org/apache/commons/configuration
                        TestBaseConfiguration.java
               configuration project.xml build.xml
  Log:
  * src/java/org/apache/commons/configuration/BaseConfiguration.java
    Changed implementation of getProperties(String) to pass null rather
    than a new java.util.Properties object to its overload,
    getProperties(String, Properties).
  
    Changed getProperties(String, Properties) to handle a null defaults
    Properties object, and to not barf on empty values.
  
  * src/test/org/apache/commons/configuration/TestBaseConfiguration.java
    Added unit tests for Configuration's getProperties() API in
    testRetrieve(), including new empty property value handling in base
    impl.
  
  * build.xml
  * project.xml
    Bumped version number from 0.8.0 to 0.8.1 -- new CVS tag
    forthcoming.
  
  Revision  Changes    Path
  1.7       +13 -3     jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/BaseConfiguration.java
  
  Index: BaseConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/BaseConfiguration.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- BaseConfiguration.java	21 Dec 2002 17:11:30 -0000	1.6
  +++ BaseConfiguration.java	13 Jan 2003 23:08:13 -0000	1.7
  @@ -488,10 +488,11 @@
        * object that is not a String/Vector.
        * @exception IllegalArgumentException if one of the tokens is
        * malformed (does not contain an equals sign).
  +     * @see #getProperties(String, Properties)
        */
       public Properties getProperties(String key)
       {
  -        return getProperties(key, new Properties());
  +        return getProperties(key, null);
       }
   
       /**
  @@ -499,6 +500,8 @@
        * configuration key.
        *
        * @param key The configuration key.
  +     * @param defaults Any default values for the returned
  +     * <code>Properties</code> object.  Ignored if <code>null</code>.
        * @return The associated properties if key is found.
        * @exception ClassCastException is thrown if the key maps to an
        * object that is not a String/Vector of Strings.
  @@ -515,7 +518,8 @@
           /*
            * Each token is of the form 'key=value'.
            */
  -        Properties props = new Properties(defaults);
  +        Properties props =
  +            (defaults == null ? new Properties() : new Properties(defaults));
           for (int i = 0; i < tokens.length; i++)
           {
               String token = tokens[i];
  @@ -525,6 +529,12 @@
                   String pkey = token.substring(0, equalSign).trim();
                   String pvalue = token.substring(equalSign + 1).trim();
                   props.put(pkey, pvalue);
  +            }
  +            else if (tokens.length == 1 && "".equals(token))
  +            {
  +                // Semantically equivalent to an empty Properties
  +                // object.
  +                break;
               }
               else
               {
  
  
  
  1.4       +22 -3     jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestBaseConfiguration.java
  
  Index: TestBaseConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestBaseConfiguration.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- TestBaseConfiguration.java	7 Jan 2003 22:53:52 -0000	1.3
  +++ TestBaseConfiguration.java	13 Jan 2003 23:08:13 -0000	1.4
  @@ -54,6 +54,8 @@
    * <http://www.apache.org/>.
    */
   
  +import java.util.Properties;
  +
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  @@ -63,6 +65,7 @@
    *
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
  + * @author <a href="mailto:dlr@apache.org">Daniel Rall</a>
    * @version $Id$
    */
   public class TestBaseConfiguration extends TestCase
  @@ -209,9 +212,25 @@
           assertTrue("This returns string", ( eprop.getString("prop.string")
                   instanceof java.lang.String) );
   
  +        // Test Properties access.
  +        eprop.clearProperty("prop.properties");
  +        eprop.setProperty("prop.properties", "");
  +        assertEquals("This returns an empty Properties object",
  +                     eprop.getProperties("prop.properties"),
  +                     new Properties());
  +        eprop.clearProperty("prop.properties");
  +        eprop.setProperty("prop.properties", "foo=bar, baz=moo, seal=clubber");
  +        Properties p = new Properties();
  +        p.setProperty("foo", "bar");
  +        p.setProperty("baz", "moo");
  +        p.setProperty("seal", "clubber");
  +        assertEquals("This returns a filled in Properties object",
  +                     eprop.getProperties("prop.properties"),
  +                     p);
  +
           /*
  -         * test subset : we want to make sure that the EP doesn't reprocess the
  -         * data elements when generating the subset
  +         * test subset : assure we don't reprocess the data elements
  +         * when generating the subset
            */
   
           Configuration subEprop = eprop.subset("prop");
  
  
  
  1.19      +2 -2      jakarta-commons-sandbox/configuration/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/project.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -u -r1.18 -r1.19
  --- project.xml	13 Jan 2003 21:17:55 -0000	1.18
  +++ project.xml	13 Jan 2003 23:08:13 -0000	1.19
  @@ -10,7 +10,7 @@
     <pomVersion>3</pomVersion>
     <name>commons-configuration</name>
     <id>commons-configuration</id>
  -  <currentVersion>0.8.0</currentVersion>
  +  <currentVersion>0.8.1</currentVersion>
     <organization>
       <name>Apache Software Foundation</name>
       <url>http://jakarta.apache.org/</url>
  
  
  
  1.9       +2 -2      jakarta-commons-sandbox/configuration/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/build.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -u -r1.8 -r1.9
  --- build.xml	13 Jan 2003 21:17:55 -0000	1.8
  +++ build.xml	13 Jan 2003 23:08:13 -0000	1.9
  @@ -14,7 +14,7 @@
     <property name="testreportdir" value="target/test-reports"/>
     <property name="distdir" value="dist"/>
     <property name="javadocdir" value="target/docs/apidocs"/>
  -  <property name="final.name" value="commons-configuration-0.8.0"/>
  +  <property name="final.name" value="commons-configuration-0.8.1"/>
   
     <target name="init" description="o Initializes some properties">
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message