commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ep...@apache.org
Subject cvs commit: jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration BaseNonStringProperties.java TestNonStringProperties.java
Date Tue, 11 Mar 2003 18:04:20 GMT
epugh       2003/03/11 10:04:20

  Modified:    configuration/src/test/org/apache/commons/configuration
                        BaseNonStringProperties.java
                        TestNonStringProperties.java
  Log:
  Added more tests for defaultValues to verify infinite loop bug fixed!
  
  Revision  Changes    Path
  1.2       +158 -132  jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/BaseNonStringProperties.java
  
  Index: BaseNonStringProperties.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/BaseNonStringProperties.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseNonStringProperties.java	11 Mar 2003 17:40:20 -0000	1.1
  +++ BaseNonStringProperties.java	11 Mar 2003 18:04:20 -0000	1.2
  @@ -62,136 +62,162 @@
    * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
  -public abstract class BaseNonStringProperties
  -    extends TestCase
  +public abstract class BaseNonStringProperties extends TestCase
   {
  -    
  -    public abstract void setUp() throws Exception;
  -    
  -    public Configuration conf = null;
  -
  -    public BaseNonStringProperties(String s)
  -      throws Exception
  -    {
  -        super(s);
  -        
  -    }
  -
  -    public void testBoolean()
  -      throws Exception
  -    {
  -        boolean booleanValue = conf.getBoolean("test.boolean");
  -        assertEquals(true, booleanValue);
  -        assertEquals(1, conf.getVector("test.boolean").size());
  -    }
  -
  -    public void testBooleanArrayValue()
  -      throws Exception
  -    {
  -        boolean booleanValue = conf.getBoolean("test.boolean.array");
  -        assertEquals(false, booleanValue);
  -        assertEquals(2, conf.getVector("test.boolean.array").size());
  -    }
  -
  -    public void testByte()
  -      throws Exception
  -    {
  -        byte testValue = 10;
  -        byte byteValue = conf.getByte("test.byte");
  -        assertEquals(testValue, byteValue);
  -        assertEquals(1, conf.getVector("test.byte").size());
  -    }
  -
  -    public void testByteArrayValue()
  -      throws Exception
  -    {
  -        byte testValue = 20;
  -        byte byteValue = conf.getByte("test.byte.array");
  -        assertEquals(testValue, byteValue);
  -        assertEquals(2, conf.getVector("test.byte.array").size());
  -    }
  -
  -    public void testDouble()
  -      throws Exception
  -    {
  -        double testValue = 10.25;
  -        double doubleValue = conf.getDouble("test.double");
  -        assertEquals(testValue, doubleValue, 0.01);
  -        assertEquals(1, conf.getVector("test.double").size());
  -    }
  -
  -    public void testDoubleArrayValue()
  -      throws Exception
  -    {
  -        double testValue = 20.35;
  -        double doubleValue = conf.getDouble("test.double.array");
  -        assertEquals(testValue, doubleValue, 0.01);
  -        assertEquals(2, conf.getVector("test.double.array").size());
  -    }
  -
  -    public void testFloat()
  -      throws Exception
  -    {
  -        float testValue = (float) 20.25;
  -        float floatValue = conf.getFloat("test.float");
  -        assertEquals(testValue, floatValue, 0.01);
  -        assertEquals(1, conf.getVector("test.float").size());
  -    }
  -
  -    public void testFloatArrayValue()
  -      throws Exception
  -    {
  -        float testValue = (float) 30.35;
  -        float floatValue = conf.getFloat("test.float.array");
  -        assertEquals(testValue, floatValue, 0.01);
  -        assertEquals(2, conf.getVector("test.float.array").size());
  -    }
  -
  -    public void testInteger()
  -      throws Exception
  -    {
  -        int intValue = conf.getInt("test.integer");
  -        assertEquals(10, intValue);
  -        assertEquals(1, conf.getVector("test.integer").size());
  -    }
  -
  -    public void testIntegerArrayValue()
  -      throws Exception
  -    {
  -        int intValue = conf.getInt("test.integer.array");
  -        assertEquals(20, intValue);
  -        assertEquals(2, conf.getVector("test.integer.array").size());
  -    }
  -
  -    public void testLong()
  -      throws Exception
  -    {
  -        long longValue = conf.getLong("test.long");
  -        assertEquals(1000000, longValue);
  -        assertEquals(1, conf.getVector("test.long").size());
  -    }
  -
  -    public void testLongArrayValue()
  -      throws Exception
  -    {
  -        long longValue = conf.getLong("test.long.array");
  -        assertEquals(2000000, longValue);
  -        assertEquals(2, conf.getVector("test.long.array").size());
  -    }
  -
  -    public void testShort()
  -      throws Exception
  -    {
  -        short shortValue = conf.getShort("test.short");
  -        assertEquals(1, shortValue);
  -        assertEquals(1, conf.getVector("test.short").size());
  -    }
  -
  -    public void testShortArrayValue()
  -      throws Exception
  -    {
  -        short shortValue = conf.getShort("test.short.array");
  -        assertEquals(2, shortValue);
  -        assertEquals(2, conf.getVector("test.short.array").size());
  -    }
  +
  +	public abstract void setUp() throws Exception;
  +
  +	public Configuration conf = null;
  +
  +	public BaseNonStringProperties(String s) throws Exception
  +	{
  +		super(s);
  +
  +	}
  +
  +	public void testBoolean() throws Exception
  +	{
  +		boolean booleanValue = conf.getBoolean("test.boolean");
  +		assertEquals(true, booleanValue);
  +		assertEquals(1, conf.getVector("test.boolean").size());
  +	}
  +
  +	public void testBooleanDefaultValue() throws Exception
  +	{
  +		boolean booleanValue = conf.getBoolean("test.boolean.missing", true);
  +		assertEquals(true, booleanValue);
  +
  +		Boolean booleanObject =
  +			conf.getBoolean("test.boolean.missing", new Boolean(true));
  +		assertEquals(new Boolean(true), booleanObject);
  +	}
  +
  +	public void testBooleanArrayValue() throws Exception
  +	{
  +		boolean booleanValue = conf.getBoolean("test.boolean.array");
  +		assertEquals(false, booleanValue);
  +		assertEquals(2, conf.getVector("test.boolean.array").size());
  +	}
  +
  +	public void testByte() throws Exception
  +	{
  +		byte testValue = 10;
  +		byte byteValue = conf.getByte("test.byte");
  +		assertEquals(testValue, byteValue);
  +		assertEquals(1, conf.getVector("test.byte").size());
  +	}
  +
  +	public void testByteArrayValue() throws Exception
  +	{
  +		byte testValue = 20;
  +		byte byteValue = conf.getByte("test.byte.array");
  +		assertEquals(testValue, byteValue);
  +		assertEquals(2, conf.getVector("test.byte.array").size());
  +	}
  +
  +	public void testDouble() throws Exception
  +	{
  +		double testValue = 10.25;
  +		double doubleValue = conf.getDouble("test.double");
  +		assertEquals(testValue, doubleValue, 0.01);
  +		assertEquals(1, conf.getVector("test.double").size());
  +	}
  +
  +	public void testDoubleDefaultValue() throws Exception
  +		{
  +			double testValue = 10.25;
  +			double doubleValue = conf.getDouble("test.double.missing",10.25);
  +					
  +			
  +			assertEquals(testValue, doubleValue, 0.01);
  +		}
  +		
  +	public void testDoubleArrayValue() throws Exception
  +	{
  +		double testValue = 20.35;
  +		double doubleValue = conf.getDouble("test.double.array");
  +		assertEquals(testValue, doubleValue, 0.01);
  +		assertEquals(2, conf.getVector("test.double.array").size());
  +	}
  +
  +	public void testFloat() throws Exception
  +	{
  +		float testValue = (float) 20.25;
  +		float floatValue = conf.getFloat("test.float");
  +		assertEquals(testValue, floatValue, 0.01);
  +		assertEquals(1, conf.getVector("test.float").size());
  +	}
  +	
  +	public void testFloatDefualtFalue() throws Exception
  +	{
  +		float testValue = (float) 20.25;
  +		float floatValue = conf.getFloat("test.float.missing",testValue);
  +		assertEquals(testValue, floatValue, 0.01);
  +
  +	}
  +
  +	public void testFloatArrayValue() throws Exception
  +	{
  +		float testValue = (float) 30.35;
  +		float floatValue = conf.getFloat("test.float.array");
  +		assertEquals(testValue, floatValue, 0.01);
  +		assertEquals(2, conf.getVector("test.float.array").size());
  +	}
  +
  +	public void testInteger() throws Exception
  +	{
  +		int intValue = conf.getInt("test.integer");
  +		assertEquals(10, intValue);
  +		assertEquals(1, conf.getVector("test.integer").size());
  +	}
  +	
  +	public void testIntegerDefaultValue() throws Exception
  +	{
  +		int intValue = conf.getInt("test.integer.missing",10);
  +		assertEquals(10, intValue);
  +	}	
  +
  +	public void testIntegerArrayValue() throws Exception
  +	{
  +		int intValue = conf.getInt("test.integer.array");
  +		assertEquals(20, intValue);
  +		assertEquals(2, conf.getVector("test.integer.array").size());
  +	}
  +
  +	public void testLong() throws Exception
  +	{
  +		long longValue = conf.getLong("test.long");
  +		assertEquals(1000000, longValue);
  +		assertEquals(1, conf.getVector("test.long").size());
  +	}
  +	public void testLongDefaultValue() throws Exception
  +	{
  +		long longValue = conf.getLong("test.long.missing",1000000);
  +		assertEquals(1000000, longValue);
  +	}
  +	public void testLongArrayValue() throws Exception
  +	{
  +		long longValue = conf.getLong("test.long.array");
  +		assertEquals(2000000, longValue);
  +		assertEquals(2, conf.getVector("test.long.array").size());
  +	}
  +
  +	public void testShort() throws Exception
  +	{
  +		short shortValue = conf.getShort("test.short");
  +		assertEquals(1, shortValue);
  +		assertEquals(1, conf.getVector("test.short").size());
  +	}
  +
  +	public void testShortDefaultValue() throws Exception
  +	{
  +		short shortValue = conf.getShort("test.short.missing",(short)1);
  +		assertEquals(1, shortValue);
  +	}
  +	public void testShortArrayValue() throws Exception
  +	{
  +		short shortValue = conf.getShort("test.short.array");
  +		assertEquals(2, shortValue);
  +		assertEquals(2, conf.getVector("test.short.array").size());
  +	}
   }
  
  
  
  1.4       +3 -120    jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestNonStringProperties.java
  
  Index: TestNonStringProperties.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestNonStringProperties.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestNonStringProperties.java	11 Mar 2003 17:40:20 -0000	1.3
  +++ TestNonStringProperties.java	11 Mar 2003 18:04:20 -0000	1.4
  @@ -69,8 +69,7 @@
       private String testProperties = 
           new File("conf/test.properties").getAbsolutePath();
   
  -    /** Our Properties configuration */
  -    private PropertiesConfiguration conf = null;
  +    
   
       public TestNonStringProperties(String s)
         throws Exception
  @@ -83,121 +82,5 @@
   		conf = new PropertiesConfiguration(testProperties);
       }
   
  -    public void testBoolean()
  -      throws Exception
  -    {
  -        boolean booleanValue = conf.getBoolean("test.boolean");
  -        assertEquals(true, booleanValue);
  -        assertEquals(1, conf.getVector("test.boolean").size());
  -    }
  -
  -    public void testBooleanArrayValue()
  -      throws Exception
  -    {
  -        boolean booleanValue = conf.getBoolean("test.boolean.array");
  -        assertEquals(false, booleanValue);
  -        assertEquals(2, conf.getVector("test.boolean.array").size());
  -    }
  -
  -    public void testByte()
  -      throws Exception
  -    {
  -        byte testValue = 10;
  -        byte byteValue = conf.getByte("test.byte");
  -        assertEquals(testValue, byteValue);
  -        assertEquals(1, conf.getVector("test.byte").size());
  -    }
  -
  -    public void testByteArrayValue()
  -      throws Exception
  -    {
  -        byte testValue = 20;
  -        byte byteValue = conf.getByte("test.byte.array");
  -        assertEquals(testValue, byteValue);
  -        assertEquals(2, conf.getVector("test.byte.array").size());
  -    }
  -
  -    public void testDouble()
  -      throws Exception
  -    {
  -        double testValue = 10.25;
  -        double doubleValue = conf.getDouble("test.double");
  -        assertEquals(testValue, doubleValue, 0.01);
  -        assertEquals(1, conf.getVector("test.double").size());
  -    }
  -
  -    public void testDoubleArrayValue()
  -      throws Exception
  -    {
  -        double testValue = 20.35;
  -        double doubleValue = conf.getDouble("test.double.array");
  -        assertEquals(testValue, doubleValue, 0.01);
  -        assertEquals(2, conf.getVector("test.double.array").size());
  -    }
  -
  -    public void testFloat()
  -      throws Exception
  -    {
  -        float testValue = (float) 20.25;
  -        float floatValue = conf.getFloat("test.float");
  -        assertEquals(testValue, floatValue, 0.01);
  -        assertEquals(1, conf.getVector("test.float").size());
  -    }
  -
  -    public void testFloatArrayValue()
  -      throws Exception
  -    {
  -        float testValue = (float) 30.35;
  -        float floatValue = conf.getFloat("test.float.array");
  -        assertEquals(testValue, floatValue, 0.01);
  -        assertEquals(2, conf.getVector("test.float.array").size());
  -    }
  -
  -    public void testInteger()
  -      throws Exception
  -    {
  -        int intValue = conf.getInt("test.integer");
  -        assertEquals(10, intValue);
  -        assertEquals(1, conf.getVector("test.integer").size());
  -    }
  -
  -    public void testIntegerArrayValue()
  -      throws Exception
  -    {
  -        int intValue = conf.getInt("test.integer.array");
  -        assertEquals(20, intValue);
  -        assertEquals(2, conf.getVector("test.integer.array").size());
  -    }
  -
  -    public void testLong()
  -      throws Exception
  -    {
  -        long longValue = conf.getLong("test.long");
  -        assertEquals(1000000, longValue);
  -        assertEquals(1, conf.getVector("test.long").size());
  -    }
  -
  -    public void testLongArrayValue()
  -      throws Exception
  -    {
  -        long longValue = conf.getLong("test.long.array");
  -        assertEquals(2000000, longValue);
  -        assertEquals(2, conf.getVector("test.long.array").size());
  -    }
  -
  -    public void testShort()
  -      throws Exception
  -    {
  -        short shortValue = conf.getShort("test.short");
  -        assertEquals(1, shortValue);
  -        assertEquals(1, conf.getVector("test.short").size());
  -    }
  -
  -    public void testShortArrayValue()
  -      throws Exception
  -    {
  -        short shortValue = conf.getShort("test.short.array");
  -        assertEquals(2, shortValue);
  -        assertEquals(2, conf.getVector("test.short.array").size());
  -    }
  +   
   }
  
  
  

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