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-cactus/org/apache/commons/configuration TestConfigurationFactoryWithJNDI.java TestJNDIAndCompositeConfiguration.java
Date Wed, 19 Mar 2003 10:33:00 GMT
epugh       2003/03/19 02:33:00

  Modified:    configuration/src/test-cactus/org/apache/commons/configuration
                        TestConfigurationFactoryWithJNDI.java
                        TestJNDIAndCompositeConfiguration.java
  Log:
  Test cases for fixes to support being able to setProperties and clearProperties.
  
  Revision  Changes    Path
  1.2       +5 -5      jakarta-commons-sandbox/configuration/src/test-cactus/org/apache/commons/configuration/TestConfigurationFactoryWithJNDI.java
  
  Index: TestConfigurationFactoryWithJNDI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/test-cactus/org/apache/commons/configuration/TestConfigurationFactoryWithJNDI.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestConfigurationFactoryWithJNDI.java	18 Mar 2003 21:44:56 -0000	1.1
  +++ TestConfigurationFactoryWithJNDI.java	19 Mar 2003 10:33:00 -0000	1.2
  @@ -85,12 +85,12 @@
   		cf.setConfigurationFileName(testDigesterFile.toString());
   		CompositeConfiguration compositeConfiguration = (CompositeConfiguration)cf.getConfiguration();
   
  -		assertEquals("Verify how many configs", 3, compositeConfiguration.getNumberOfConfigurations());
  +		assertEquals("Verify how many configs", 4, compositeConfiguration.getNumberOfConfigurations());
   		
  -		assertEquals(JNDIConfiguration.class, compositeConfiguration.getConfiguration(0).getClass());
  -		assertEquals(PropertiesConfiguration.class, compositeConfiguration.getConfiguration(1).getClass());
  -		assertEquals(DOM4JConfiguration.class, compositeConfiguration.getConfiguration(2).getClass());
  -		PropertiesConfiguration pc = (PropertiesConfiguration) compositeConfiguration.getConfiguration(1);
  +		assertEquals(JNDIConfiguration.class, compositeConfiguration.getConfiguration(1).getClass());
  +		assertEquals(PropertiesConfiguration.class, compositeConfiguration.getConfiguration(2).getClass());
  +		assertEquals(DOM4JConfiguration.class, compositeConfiguration.getConfiguration(3).getClass());
  +		PropertiesConfiguration pc = (PropertiesConfiguration) compositeConfiguration.getConfiguration(2);
   
   		assertNotNull("Make sure we have a fileName:" + pc.getFileName(), pc.getFileName());
   		
  
  
  
  1.2       +73 -29    jakarta-commons-sandbox/configuration/src/test-cactus/org/apache/commons/configuration/TestJNDIAndCompositeConfiguration.java
  
  Index: TestJNDIAndCompositeConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/test-cactus/org/apache/commons/configuration/TestJNDIAndCompositeConfiguration.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestJNDIAndCompositeConfiguration.java	28 Feb 2003 20:28:08 -0000	1.1
  +++ TestJNDIAndCompositeConfiguration.java	19 Mar 2003 10:33:00 -0000	1.2
  @@ -59,33 +59,77 @@
   import org.apache.cactus.ServletTestCase;
   import java.io.File;
   
  -public class TestJNDIAndCompositeConfiguration extends ServletTestCase {
  -	private String testProperties =
  -		new File("conf/test.properties").getAbsolutePath();
  -		
  -	private CompositeConfiguration cc;
  -	private PropertiesConfiguration conf1;
  -	public TestJNDIAndCompositeConfiguration(String testName) {
  -		super(testName);
  -	}
  -
  -	public void testSimpleGet() throws Exception {
  -		JNDIConfiguration jndiConf = new JNDIConfiguration();
  -		jndiConf.setPrefix("java:comp/env");
  -
  -		cc = new CompositeConfiguration();
  -		conf1 = new PropertiesConfiguration(testProperties);
  -		
  -		cc.addConfiguration(jndiConf);
  -		cc.addConfiguration(conf1);
  -		String s = cc.getString("test.short");
  -		assertEquals("80",s);
  -		
  -		cc.clear();
  -		cc.addConfiguration(conf1);
  -		cc.addConfiguration(jndiConf);
  -		assertEquals("1",cc.getString("test.short"));
  -		
  -	}
  +public class TestJNDIAndCompositeConfiguration extends ServletTestCase
  +{
  +    private String testProperties =
  +        new File("conf/test.properties").getAbsolutePath();
   
  -}
  +    private CompositeConfiguration cc;
  +    private PropertiesConfiguration conf1;
  +    private JNDIConfiguration jndiConf;
  +    public TestJNDIAndCompositeConfiguration(String testName)
  +    {
  +        super(testName);
  +    }
  +
  +    public void setUp() throws Exception
  +    {
  +        jndiConf = new JNDIConfiguration();
  +        jndiConf.setPrefix("java:comp/env");
  +
  +        cc = new CompositeConfiguration();
  +        conf1 = new PropertiesConfiguration(testProperties);
  +
  +        cc.addConfiguration(jndiConf);
  +        cc.addConfiguration(conf1);
  +
  +    }
  +
  +    public void testSimpleGet() throws Exception
  +    {
  +        String s = cc.getString("test.short");
  +        assertEquals("80", s);
  +
  +        cc.clear();
  +        cc.addConfiguration(conf1);
  +        cc.addConfiguration(jndiConf);
  +        assertEquals("1", cc.getString("test.short"));
  +
  +    }
  +
  +    /**
  +     * Tests setting values.  These are set in memory mode only!
  +     */
  +    public void testClearingProperty() throws Exception
  +    {
  +
  +        cc.clearProperty("test.short");
  +        assertTrue(
  +            "Make sure test.short is gone!",
  +            !cc.containsKey("test.short"));
  +    }
  +
  +    /**
  +     * Tests adding values.  Make sure they override any other properties!
  +     */
  +    public void testAddingProperty() throws Exception
  +    {
  +
  +        cc.addProperty("test.short", "88");
  +        assertEquals(
  +            "Make sure test.short is overridden!",
  +            "88",
  +            cc.getString("test.short"));
  +    }
  +
  +    /**
  +     * Tests setting values.  These are set in memory mode only!
  +     */
  +    public void testSettingMissingProperty() throws Exception
  +    {
  +
  +        cc.setProperty("my.new.property", "supernew");
  +        assertEquals("supernew", cc.getString("my.new.property"));
  +
  +    }
  +}
  \ No newline at end of file
  
  
  

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