commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henn...@apache.org
Subject cvs commit: jakarta-commons/configuration/xdocs changes.xml
Date Mon, 16 Aug 2004 22:16:34 GMT
henning     2004/08/16 15:16:33

  Modified:    configuration project.xml
               configuration/src/java/org/apache/commons/configuration
                        AbstractConfiguration.java
                        CompositeConfiguration.java Configuration.java
               configuration/src/test/org/apache/commons/configuration
                        BaseNonStringProperties.java
                        NonStringTestHolder.java TestBaseConfiguration.java
                        TestBasePropertiesConfiguration.java
                        TestCompositeConfiguration.java
                        TestConfigurationConverter.java
                        TestDatabaseConfiguration.java
                        TestEqualBehaviour.java
                        TestSubsetConfiguration.java
                        TestXMLConfiguration.java
               configuration/xdocs changes.xml
  Log:
  bring back the getVector() methods in the Configuration interface,
  making it possible to use 1.0-rc1 and beyond as drop-in replacement
  for older commons-configuration snapshots as used by e.g. Turbine-2.3
  and Torque-3.1
  
  Without this patch, these fail miserably due to missing method errors.
  
  The methods are deprecated and should be removed in 1.1
  
  Unit tests and change message are included.
  
  Revision  Changes    Path
  1.26      +2 -1      jakarta-commons/configuration/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/project.xml,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- project.xml	14 Aug 2004 12:22:50 -0000	1.25
  +++ project.xml	16 Aug 2004 22:16:30 -0000	1.26
  @@ -116,6 +116,7 @@
         <id>henning</id>
         <email>hps@intermeta.de</email>
         <organization>INTERMETA - Gesellschaft fuer Mehrwertdienste mbH</organization>
  +      <timezone>2</timezone>
       </developer>
   
       <developer>
  
  
  
  1.20      +51 -1     jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java
  
  Index: AbstractConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- AbstractConfiguration.java	12 Aug 2004 15:45:58 -0000	1.19
  +++ AbstractConfiguration.java	16 Aug 2004 22:16:30 -0000	1.20
  @@ -25,6 +25,7 @@
   import java.util.NoSuchElementException;
   import java.util.Properties;
   import java.util.StringTokenizer;
  +import java.util.Vector;
   
   import org.apache.commons.collections.Predicate;
   import org.apache.commons.collections.iterators.FilterIterator;
  @@ -37,6 +38,7 @@
    *
    * @author <a href="mailto:ksh@scand.com">Konstantin Shaposhnikov</a>
    * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
  + * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
   public abstract class AbstractConfiguration implements Configuration
  @@ -991,6 +993,54 @@
                       + value.getClass().getName());
           }
           return list;
  +    }
  +
  +    /**
  +     * {@inheritDoc}
  +     */
  +    public Vector getVector(String key)
  +    {
  +        return getVector(key, new Vector());
  +    }
  +
  +    /**
  +     * {@inheritDoc}
  +     */
  +    public Vector getVector(String key, Vector defaultValue)
  +    {
  +        Object value = getPropertyDirect(key);
  +        Vector vector = null;
  +
  +        if (value instanceof String)
  +        {
  +            vector = new Vector(1);
  +            vector.add(value);
  +        }
  +        else if (value instanceof List)
  +        {
  +            vector = new Vector(((List) value).size());
  +
  +            for (Iterator it = ((List) value).iterator(); it.hasNext(); )
  +            {
  +                Object obj = it.next();
  +                vector.add(obj);
  +            }
  +        }
  +        else if (value == null)
  +        {
  +            vector = defaultValue;
  +        }
  +        else
  +        {
  +            throw new ConversionException(
  +                '\''
  +                    + key
  +                    + "' doesn't map to a Vector object: "
  +                    + value
  +                    + ", a "
  +                    + value.getClass().getName());
  +        }
  +        return vector;
       }
   
       /**
  
  
  
  1.17      +18 -1     jakarta-commons/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java
  
  Index: CompositeConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- CompositeConfiguration.java	24 Jun 2004 14:01:03 -0000	1.16
  +++ CompositeConfiguration.java	16 Aug 2004 22:16:31 -0000	1.17
  @@ -20,6 +20,7 @@
   import java.util.Iterator;
   import java.util.LinkedList;
   import java.util.List;
  +import java.util.Vector;
   
   /**
    * This Configuration class allows you to add multiple different types of Configuration
  @@ -298,6 +299,22 @@
           }
   
           return list;
  +    }
  +
  +    /**
  +     * {@inheritDoc}
  +     */
  +    public Vector getVector(String key, Vector defaultValue)
  +    {
  +        List list = getList(key, defaultValue);
  +        Vector vector = new Vector(list.size());
  +
  +        for (Iterator it = list.iterator(); it.hasNext();)
  +        {
  +            vector.add(it.next());
  +        }
  +
  +        return vector;
       }
   
       /**
  
  
  
  1.10      +34 -1     jakarta-commons/configuration/src/java/org/apache/commons/configuration/Configuration.java
  
  Index: Configuration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/Configuration.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Configuration.java	24 Jul 2004 15:38:39 -0000	1.9
  +++ Configuration.java	16 Aug 2004 22:16:31 -0000	1.10
  @@ -21,6 +21,7 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Properties;
  +import java.util.Vector;
   
   /**
    * Configuration interface.
  @@ -536,4 +537,36 @@
        *         object that is not a List.
        */
       List getList(String key, List defaultValue);
  +
  +    /**
  +     * Get a Vector of strings associated with the given configuration key.
  +     * If the key doesn't map to an existing object an empty Vector is returned.
  +     *
  +     * @param key The configuration key.
  +     * @return The associated Vector.
  +     *
  +     * @deprecated This method is for compatibility with applications that
  +     * use the pre-1.0 versions of commons-configuration. It will be removed
  +     * post 1.0
  +     *
  +     * @throws ConversionException is thrown if the key maps to an
  +     *         object that is not a Vector.
  +     */
  +    Vector getVector(String key);
  +
  +    /**
  +     * Get a Vector of strings associated with the given configuration key.
  +     *
  +     * @param key The configuration key.
  +     * @param defaultValue The default value.
  +     * @return The associated Vector.
  +     *
  +     * @deprecated This method is for compatibility with applications that
  +     * use the pre-1.0 versions of commons-configuration. It will be removed
  +     * post 1.0
  +     *
  +     * @throws ConversionException is thrown if the key maps to an
  +     *         object that is not a Vector.
  +     */
  +    Vector getVector(String key, Vector defaultValue);
   }
  
  
  
  1.6       +13 -1     jakarta-commons/configuration/src/test/org/apache/commons/configuration/BaseNonStringProperties.java
  
  Index: BaseNonStringProperties.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/BaseNonStringProperties.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BaseNonStringProperties.java	27 Feb 2004 17:41:34 -0000	1.5
  +++ BaseNonStringProperties.java	16 Aug 2004 22:16:31 -0000	1.6
  @@ -46,6 +46,7 @@
           boolean booleanValue = conf.getBoolean("test.boolean");
           assertEquals(true, booleanValue);
           assertEquals(2, conf.getList("test.boolean.array").size());
  +        assertEquals(2, conf.getVector("test.boolean.array").size());
       }
   
       public void testByte() throws Exception
  @@ -59,6 +60,7 @@
           byte byteValue = conf.getByte("test.byte");
           assertEquals(testValue, byteValue);
           assertEquals(2, conf.getList("test.byte.array").size());
  +        assertEquals(2, conf.getVector("test.byte.array").size());
       }
   
       public void testDouble() throws Exception
  @@ -77,6 +79,7 @@
           double doubleValue = conf.getDouble("test.double");
           assertEquals(testValue, doubleValue, 0.01);
           assertEquals(2, conf.getList("test.double.array").size());
  +        assertEquals(2, conf.getVector("test.double.array").size());
       }
   
       public void testFloat() throws Exception
  @@ -96,6 +99,7 @@
           float floatValue = conf.getFloat("test.float");
           assertEquals(testValue, floatValue, 0.01);
           assertEquals(2, conf.getList("test.float.array").size());
  +        assertEquals(2, conf.getVector("test.float.array").size());
       }
   
       public void testInteger() throws Exception
  @@ -113,6 +117,7 @@
           int intValue = conf.getInt("test.integer");
           assertEquals(10, intValue);
           assertEquals(2, conf.getList("test.integer.array").size());
  +        assertEquals(2, conf.getVector("test.integer.array").size());
       }
   
       public void testLong() throws Exception
  @@ -128,6 +133,7 @@
           long longValue = conf.getLong("test.long");
           assertEquals(1000000, longValue);
           assertEquals(2, conf.getList("test.long.array").size());
  +        assertEquals(2, conf.getVector("test.long.array").size());
       }
   
       public void testShort() throws Exception
  @@ -144,11 +150,17 @@
           short shortValue = conf.getShort("test.short");
           assertEquals(1, shortValue);
           assertEquals(2, conf.getList("test.short.array").size());
  +        assertEquals(2, conf.getVector("test.short.array").size());
       }
   
       public void testListMissing() throws Exception
       {
           nonStringTestHolder.testListMissing();
  +    }
  +
  +    public void testVectorMissing() throws Exception
  +    {
  +        nonStringTestHolder.testVectorMissing();
       }
   
       public void testSubset() throws Exception
  
  
  
  1.8       +15 -1     jakarta-commons/configuration/src/test/org/apache/commons/configuration/NonStringTestHolder.java
  
  Index: NonStringTestHolder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/NonStringTestHolder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- NonStringTestHolder.java	12 Jul 2004 12:14:38 -0000	1.7
  +++ NonStringTestHolder.java	16 Aug 2004 22:16:31 -0000	1.8
  @@ -18,6 +18,7 @@
   
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Vector;
   
   import junit.framework.Assert;
   
  @@ -41,6 +42,7 @@
           boolean booleanValue = configuration.getBoolean("test.boolean");
           Assert.assertEquals(true, booleanValue);
           Assert.assertEquals(1, configuration.getList("test.boolean").size());
  +        Assert.assertEquals(1, configuration.getVector("test.boolean").size());
       }
   
       public void testBooleanDefaultValue() throws Exception
  @@ -58,6 +60,7 @@
           byte byteValue = configuration.getByte("test.byte");
           Assert.assertEquals(testValue, byteValue);
           Assert.assertEquals(1, configuration.getList("test.byte").size());
  +        Assert.assertEquals(1, configuration.getVector("test.byte").size());
       }
   
       public void testDouble() throws Exception
  @@ -66,6 +69,7 @@
           double doubleValue = configuration.getDouble("test.double");
           Assert.assertEquals(testValue, doubleValue, 0.01);
           Assert.assertEquals(1, configuration.getList("test.double").size());
  +        Assert.assertEquals(1, configuration.getVector("test.double").size());
       }
   
       public void testDoubleDefaultValue() throws Exception
  @@ -82,6 +86,7 @@
           float floatValue = configuration.getFloat("test.float");
           Assert.assertEquals(testValue, floatValue, 0.01);
           Assert.assertEquals(1, configuration.getList("test.float").size());
  +        Assert.assertEquals(1, configuration.getVector("test.float").size());
       }
   
       public void testFloatDefaultValue() throws Exception
  @@ -96,6 +101,7 @@
           int intValue = configuration.getInt("test.integer");
           Assert.assertEquals(10, intValue);
           Assert.assertEquals(1, configuration.getList("test.integer").size());
  +        Assert.assertEquals(1, configuration.getVector("test.integer").size());
       }
   
       public void testIntegerDefaultValue() throws Exception
  @@ -109,6 +115,7 @@
           long longValue = configuration.getLong("test.long");
           Assert.assertEquals(1000000, longValue);
           Assert.assertEquals(1, configuration.getList("test.long").size());
  +        Assert.assertEquals(1, configuration.getVector("test.long").size());
       }
       public void testLongDefaultValue() throws Exception
       {
  @@ -121,6 +128,7 @@
           short shortValue = configuration.getShort("test.short");
           Assert.assertEquals(1, shortValue);
           Assert.assertEquals(1, configuration.getList("test.short").size());
  +        Assert.assertEquals(1, configuration.getVector("test.short").size());
       }
   
       public void testShortDefaultValue() throws Exception
  @@ -133,6 +141,12 @@
       {
           List list = configuration.getList("missing.list");
           Assert.assertTrue("'missing.list' is not empty", list.isEmpty());
  +    }
  +
  +    public void testVectorMissing() throws Exception
  +    {
  +        Vector vector = configuration.getVector("missing.list");
  +        Assert.assertTrue("'missing.list' is not empty", vector.isEmpty());
       }
   
       public void testSubset() throws Exception
  
  
  
  1.14      +26 -1     jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestBaseConfiguration.java
  
  Index: TestBaseConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestBaseConfiguration.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestBaseConfiguration.java	21 Jun 2004 13:49:24 -0000	1.13
  +++ TestBaseConfiguration.java	16 Aug 2004 22:16:31 -0000	1.14
  @@ -22,6 +22,7 @@
   import java.util.List;
   import java.util.NoSuchElementException;
   import java.util.Properties;
  +import java.util.Vector;
   
   import junit.framework.TestCase;
   import junitx.framework.ObjectAssert;
  @@ -317,6 +318,30 @@
   		/*
   		 *  now test dan's new fix where we get the first scalar
   		 *  when we access a list valued property
  +		 */
  +		try
  +		{
  +			config.getString("number");
  +		}
  +		catch (NoSuchElementException nsse)
  +		{
  +			fail("Should return a string");
  +		}
  +	}
  +
  +	public void testGetVector()
  +	{
  +		config.addProperty("number", "1");
  +		config.addProperty("number", "2");
  +		Vector vector = config.getVector("number");
  +		assertNotNull("The vector is null", vector);
  +		assertEquals("Vector size", 2, vector.size());
  +		assertTrue("The number 1 is missing from the vector", vector.contains("1"));
  +		assertTrue("The number 2 is missing from the vector", vector.contains("2"));
  +
  +		/*
  +		 *  now test dan's new fix where we get the first scalar
  +		 *  when we access a vector valued property
   		 */
   		try
   		{
  
  
  
  1.5       +12 -1     jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestBasePropertiesConfiguration.java
  
  Index: TestBasePropertiesConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestBasePropertiesConfiguration.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestBasePropertiesConfiguration.java	27 Feb 2004 17:41:34 -0000	1.4
  +++ TestBasePropertiesConfiguration.java	16 Aug 2004 22:16:31 -0000	1.5
  @@ -17,6 +17,7 @@
    */
   
   import java.util.List;
  +import java.util.Vector;
   
   import junit.framework.TestCase;
   
  @@ -78,6 +79,16 @@
       public void testList() throws Exception
       {
           List packages = conf.getList("packages");
  +        // we should get 3 packages here
  +        assertEquals(3, packages.size());
  +    }
  +
  +    /**
  +     * Tests <code>Vector</code> parsing.
  +     */
  +    public void testVector() throws Exception
  +    {
  +        Vector packages = conf.getVector("packages");
           // we should get 3 packages here
           assertEquals(3, packages.size());
       }
  
  
  
  1.10      +65 -1     jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java
  
  Index: TestCompositeConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestCompositeConfiguration.java	12 Jul 2004 12:14:38 -0000	1.9
  +++ TestCompositeConfiguration.java	16 Aug 2004 22:16:31 -0000	1.10
  @@ -21,6 +21,7 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.NoSuchElementException;
  +import java.util.Vector;
   
   import junit.framework.TestCase;
   
  @@ -69,6 +70,9 @@
           cc.addConfiguration(conf2);
           List l = cc.getList("packages");
           assertTrue(l.contains("packagea"));
  +
  +        Vector v = cc.getVector("packages");
  +        assertTrue(v.contains("packagea"));
       }
       
       public void testGetProperty() throws Exception
  @@ -251,6 +255,10 @@
           // we should get 3 packages here
           assertEquals(3, packages.size());
   
  +        Vector vpackages = cc.getVector("packages");
  +        // we should get 3 packages here
  +        assertEquals(3, vpackages.size());
  +
           List defaultList = new ArrayList();
           defaultList.add("1");
           defaultList.add("2");
  @@ -258,6 +266,14 @@
           packages = cc.getList("packages.which.dont.exist", defaultList);
           // we should get 2 packages here
           assertEquals(2, packages.size());
  +
  +        Vector defaultVector = new Vector();
  +        defaultVector.add("1");
  +        defaultVector.add("2");
  +
  +        vpackages = cc.getVector("packages.which.dont.exist", defaultVector);
  +        // we should get 2 packages here
  +        assertEquals(2, vpackages.size());
       }
   
       /**
  @@ -307,6 +323,54 @@
           assertTrue("'value1' not found in the list", list.contains("value1"));
           assertTrue("'value2' not found in the list", list.contains("value2"));
           assertTrue("'value5' not found in the list", list.contains("value5"));
  +    }
  +
  +    public void testGetVector()
  +    {
  +        Configuration conf1 = new BaseConfiguration();
  +        conf1.addProperty("array", "value1");
  +        conf1.addProperty("array", "value2");
  +
  +        Configuration conf2 = new BaseConfiguration();
  +        conf2.addProperty("array", "value3");
  +        conf2.addProperty("array", "value4");
  +
  +        cc.addConfiguration(conf1);
  +        cc.addConfiguration(conf2);
  +
  +        // check the composite 'array' property
  +        Vector vector = cc.getVector("array");
  +        assertNotNull("null vector", vector);
  +        assertEquals("vector size", 2, vector.size());
  +        assertTrue("'value1' not found in the vector", vector.contains("value1"));
  +        assertTrue("'value2' not found in the vector", vector.contains("value2"));
  +
  +        // add an element to the vector in the composite configuration
  +        cc.addProperty("array", "value5");
  +
  +        List list = cc.getList("array");
  +        
  +        for (Iterator it = list.iterator(); it.hasNext(); )
  +        {
  +            Object value = it.next();
  +            System.out.println(value.getClass().getName() + " -> " + value);
  +        }
  +
  +        Vector lVector = cc.getVector("array");
  +        
  +        for (Iterator it = lVector.iterator(); it.hasNext(); )
  +        {
  +            Object value = it.next();
  +            System.out.println(value.getClass().getName() + " -> " + value);
  +        }
  +
  +        // test the new vector
  +        vector = cc.getVector("array");
  +        assertNotNull("null vector", vector);
  +        assertEquals("vector size", 3, vector.size());
  +        assertTrue("'value1' not found in the vector", vector.contains("value1"));
  +        assertTrue("'value2' not found in the vector", vector.contains("value2"));
  +        assertTrue("'value5' not found in the vector", vector.contains("value5"));
       }
   
       /**
  
  
  
  1.6       +10 -1     jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationConverter.java
  
  Index: TestConfigurationConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationConverter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestConfigurationConverter.java	16 Jun 2004 15:17:09 -0000	1.5
  +++ TestConfigurationConverter.java	16 Aug 2004 22:16:31 -0000	1.6
  @@ -18,6 +18,7 @@
   
   import java.util.List;
   import java.util.Properties;
  +import java.util.Vector;
   
   import junit.framework.TestCase;
   import org.apache.commons.collections.ExtendedProperties;
  @@ -44,6 +45,10 @@
           assertEquals("This returns 'teststring'", config.getString("string"), "teststring");
           List item1 = config.getList("list");
           assertEquals("This returns 'item 1'", (String) item1.get(0), "item 1");
  +
  +        Vector item2 = config.getVector("list");
  +        assertEquals("This returns 'item 1'", (String) item2.get(0), "item 1");
  +
           assertEquals("This returns 123", config.getInt("int"), 123);
       }
   
  @@ -59,6 +64,10 @@
           assertEquals("This returns 'teststring'", config.getString("string"), "teststring");
           List item1 = config.getList("list");
           assertEquals("This returns 'item 1'", (String) item1.get(0), "item 1");
  +
  +        Vector item2 = config.getVector("list");
  +        assertEquals("This returns 'item 1'", (String) item2.get(0), "item 1");
  +
           assertEquals("This returns 123", config.getInt("int"), 123);
       }
   
  
  
  
  1.7       +9 -1      jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java
  
  Index: TestDatabaseConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestDatabaseConfiguration.java	24 Jul 2004 16:26:10 -0000	1.6
  +++ TestDatabaseConfiguration.java	16 Aug 2004 22:16:31 -0000	1.7
  @@ -20,6 +20,7 @@
   import java.sql.SQLException;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Vector;
   
   import javax.sql.DataSource;
   
  @@ -182,6 +183,13 @@
           DatabaseConfiguration config1 = new DatabaseConfiguration(datasource, "configurationList",
"key", "value");
           List list = config1.getList("key3");
           assertEquals(3,list.size());
  +    }    
  +    
  +    public void testGetVector()
  +    {
  +        DatabaseConfiguration config1 = new DatabaseConfiguration(datasource, "configurationList",
"key", "value");
  +        Vector vector = config1.getVector("key3");
  +        assertEquals(3,vector.size());
       }    
       
       public void testGetKeys()
  
  
  
  1.5       +31 -1     jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestEqualBehaviour.java
  
  Index: TestEqualBehaviour.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestEqualBehaviour.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestEqualBehaviour.java	27 Feb 2004 17:41:34 -0000	1.4
  +++ TestEqualBehaviour.java	16 Aug 2004 22:16:31 -0000	1.5
  @@ -20,6 +20,7 @@
   
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Vector;
   
   import junit.framework.TestCase;
   
  @@ -95,6 +96,35 @@
               String val1 = (String) it1.next();
               String val2 = (String) it2.next();
               assertEquals(msg + ", List: ", val1, val2);
  +        }
  +        assertEquals(msg + ", Iterator End: ", it1.hasNext(), it2.hasNext());
  +    }
  +
  +    private void checkSameKeyVector(String msg, String key, Configuration c1, Configuration
c2)
  +    {
  +        String [] s1 = c1.getStringArray(key);
  +        String [] s2 = c2.getStringArray(key);
  +
  +        assertEquals(msg + ", length: ", s1.length, s2.length);
  +
  +        for (int i = 0; i < s1.length ; i++)
  +        {
  +            assertEquals(msg + ", String Array: ", s1[i], s2[i]);
  +        }
  +
  +        Vector vector1 = c1.getVector(key);
  +        Vector vector2 = c2.getVector(key);
  +
  +        assertEquals(msg + ", Size: ", vector1.size(), vector2.size());
  +
  +        Iterator it1 = vector1.iterator();
  +        Iterator it2 = vector2.iterator();
  +
  +        while(it1.hasNext() && it2.hasNext())
  +        {
  +            String val1 = (String) it1.next();
  +            String val2 = (String) it2.next();
  +            assertEquals(msg + ", Vector: ", val1, val2);
           }
           assertEquals(msg + ", Iterator End: ", it1.hasNext(), it2.hasNext());
       }
  
  
  
  1.3       +13 -1     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestSubsetConfiguration.java	4 May 2004 22:27:10 -0000	1.2
  +++ TestSubsetConfiguration.java	16 Aug 2004 22:16:31 -0000	1.3
  @@ -21,6 +21,7 @@
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Vector;
   
   /**
    * Test case for the {@link SubsetConfiguration} class.
  @@ -117,4 +118,15 @@
           List list = subset.getList("abc", new ArrayList());
           assertEquals(3, list.size());
       }
  +
  +    public void testGetVector() {
  +        BaseConfiguration conf = new BaseConfiguration();
  +        conf.setProperty("test.abc", "value0,value1");
  +        conf.addProperty("test.abc","value3");
  +
  +        Configuration subset = new SubsetConfiguration(conf, "test", ".");
  +        Vector vector = subset.getVector("abc", new Vector());
  +        assertEquals(3, vector.size());
  +    }
  +
   }
  
  
  
  1.8       +25 -1     jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
  
  Index: TestXMLConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestXMLConfiguration.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestXMLConfiguration.java	14 Aug 2004 11:21:27 -0000	1.7
  +++ TestXMLConfiguration.java	16 Aug 2004 22:16:31 -0000	1.8
  @@ -20,6 +20,7 @@
   import java.io.IOException;
   import java.util.List;
   import java.util.Iterator;
  +import java.util.Vector;
   
   import junit.framework.TestCase;
   import junitx.framework.ArrayAssert;
  @@ -238,6 +239,17 @@
           assertEquals("list size", 2, list.size());
       }
   
  +    public void testAddVectorAttribute() throws Exception
  +    {
  +        conf.addProperty("element3[@name]", "bar");
  +
  +        Vector vector = conf.getVector("element3[@name]");
  +        assertNotNull("null vector", vector);
  +        assertTrue("'foo' element missing", vector.contains("foo"));
  +        assertTrue("'bar' element missing", vector.contains("bar"));
  +        assertEquals("vector size", 2, vector.size());
  +    }
  +
       public void testAddList() throws Exception
       {
           conf.addProperty("test.array", "value1");
  @@ -248,6 +260,18 @@
           assertTrue("'value1' element missing", list.contains("value1"));
           assertTrue("'value2' element missing", list.contains("value2"));
           assertEquals("list size", 2, list.size());
  +    }
  +
  +    public void testAddVector() throws Exception
  +    {
  +        conf.addProperty("test.array", "value1");
  +        conf.addProperty("test.array", "value2");
  +
  +        Vector vector = conf.getVector("test.array");
  +        assertNotNull("null vector", vector);
  +        assertTrue("'value1' element missing", vector.contains("value1"));
  +        assertTrue("'value2' element missing", vector.contains("value2"));
  +        assertEquals("vector size", 2, vector.size());
       }
   
       public void testGetComplexProperty() throws Exception
  
  
  
  1.35      +5 -0      jakarta-commons/configuration/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- changes.xml	14 Aug 2004 13:06:13 -0000	1.34
  +++ changes.xml	16 Aug 2004 22:16:33 -0000	1.35
  @@ -6,6 +6,11 @@
     </properties>
   
     <body>
  +    <release version="1.0-rc2" date="in CVS">
  +      <action dev="henning" type="add">Bring back the getVector() methods in the
Configuration interface. These methods are needed for &quot;drop-on&quot; replacement
  +                                     of the various pre-1.0 commons-configuration snapshots
and are already deprecated. These methods will be removed for 1.1
  +      </action>
  +    </release>
       <release version="1.0-rc1" date="2004-08-14">
         <action dev="epugh" type="add" due-to="Oliver Heger" issue="30597">HierarchicalConfigurationXMLReader
stores comments as text nodes</action>        
         <action dev="epugh" type="add" due-to="Ricardo Gladwell" issue="30648">project.xml
contains bad dependencies</action>        
  
  
  

---------------------------------------------------------------------
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