commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestSubsetConfiguration.java TestHierarchicalConfiguration.java
Date Sat, 13 Nov 2004 17:03:18 GMT
oheger      2004/11/13 09:03:18

  Modified:    configuration/src/test/org/apache/commons/configuration
                        TestSubsetConfiguration.java
                        TestHierarchicalConfiguration.java
  Log:
  Fix for Bug 31745, Unit tests
  
  Revision  Changes    Path
  1.8       +27 -2     jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestSubsetConfiguration.java
  
  Index: TestSubsetConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestSubsetConfiguration.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestSubsetConfiguration.java	18 Oct 2004 21:38:45 -0000	1.7
  +++ TestSubsetConfiguration.java	13 Nov 2004 17:03:18 -0000	1.8
  @@ -16,10 +16,13 @@
   
   package org.apache.commons.configuration;
   
  +import java.io.File;
   import java.util.ArrayList;
  +import java.util.HashSet;
   import java.util.Iterator;
   import java.util.List;
   import java.util.NoSuchElementException;
  +import java.util.Set;
   
   import junit.framework.TestCase;
   
  @@ -31,6 +34,8 @@
    */
   public class TestSubsetConfiguration extends TestCase
   {
  +    static final String TEST_DIR = "conf";
  +    static final String TEST_FILE = "testDigesterConfiguration2.xml";
   
       public void testGetProperty()
       {
  @@ -185,5 +190,25 @@
           }
       }
   
  -
  +    public void testNested() throws Exception
  +    {
  +        ConfigurationFactory factory = new ConfigurationFactory();
  +        File src = new File(new File(TEST_DIR), TEST_FILE);
  +        factory.setConfigurationURL(src.toURL());
  +        Configuration config = factory.getConfiguration();
  +        Configuration subConf = config.subset("tables.table(0)");
  +        assertTrue(subConf.getKeys().hasNext());
  +        Configuration subSubConf = subConf.subset("fields.field(1)");
  +        Iterator itKeys = subSubConf.getKeys();
  +        Set keys = new HashSet();
  +        keys.add("name");
  +        keys.add("type");
  +        while(itKeys.hasNext())
  +        {
  +            String k = (String) itKeys.next();
  +            assertTrue(keys.contains(k));
  +            keys.remove(k);
  +        }
  +        assertTrue(keys.isEmpty());
  +    }
   }
  
  
  
  1.7       +2 -2      jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestHierarchicalConfiguration.java
  
  Index: TestHierarchicalConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestHierarchicalConfiguration.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestHierarchicalConfiguration.java	18 Oct 2004 10:19:27 -0000	1.6
  +++ TestHierarchicalConfiguration.java	13 Nov 2004 17:03:18 -0000	1.7
  @@ -281,7 +281,7 @@
           Set values = new HashSet();
           for(int i = 0; i < expected.length; i++)
           {
  -            values.add(expected[i]);
  +            values.add(prefix + "." + expected[i]);
           }
           
           Iterator itKeys = config.getKeys(prefix);
  
  
  

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


Mime
View raw message