henning     2002/12/10 15:39:41

  Modified:    configuration/src/test/org/apache/commons/configuration
                        TestPropertiesConfiguration.java
  Added:       configuration/conf README include.properties test.properties
  Removed:     configuration/src/test/org/apache/commons/configuration
                        include.properties test.properties
  Log:
  Fix up the test case for the PropertiesConfiguration to actually work. :-)
  
  Move the tested properties file from the test source tree into a conf
  subdirectory.
  
  commons-configuration should now build under maven and ant (gump).
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/configuration/conf/README
  
  Index: README
  ===================================================================
  DO NOT DELETE THESE FILES! 
  
  They're used for testing the PropertiesLoader in
  the TestPropertiesConfiguration class
  
  
  
  1.1                  jakarta-commons-sandbox/configuration/conf/include.properties
  
  Index: include.properties
  ===================================================================
  include.loaded = true
  
  packages = packageb, packagec
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/configuration/conf/test.properties
  
  Index: test.properties
  ===================================================================
  configuration.loaded = true
  
  packages = packagea
  
  include = include.properties
  
  
  
  
  1.3       +36 -55    
jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
  
  Index: TestPropertiesConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestPropertiesConfiguration.java  3 Dec 2002 14:03:54 -0000       1.2
  +++ TestPropertiesConfiguration.java  10 Dec 2002 23:39:41 -0000      1.3
  @@ -54,19 +54,26 @@
    * <http://www.apache.org/>.
    */
   
  -import junit.framework.*;
  -import java.io.*;
  +import java.io.File;
  +import java.io.InputStream;
  +
   import java.util.Vector;
   
  +import junit.framework.TestCase;
   
   /**
  - * test foir loading and saving properties files
  + * test for loading and saving properties files
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Poeschl</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Henning P. Schmiedehausen</a>
    * @version $Id$
    */
  -public class TestPropertiesConfiguration extends TestCase
  +public class TestPropertiesConfiguration
  +    extends TestCase
   {
  +    /** The File that we test with */
  +    private String testProperties = 
  +        new File("conf/test.properties").getAbsolutePath();
   
       public TestPropertiesConfiguration(String s)
       {
  @@ -74,64 +81,44 @@
       }
   
       public void testLoad()
  +        throws Exception
       {
  -        PropertiesConfiguration conf = new PropertiesConfiguration();
  -        InputStream input = this.getClass().getResourceAsStream(
  -                "/org/apache/commons/configuration/test.properties");
  -        try
  -        {
  -            conf.load(input);
  -            String loaded = conf.getString("configuration.loaded");
  -            assertEquals("true", loaded);
  -        }
  -        catch (Exception e)
  -        {
  -            System.err.println("Exception thrown:  " + e);
  -        }
  +        PropertiesConfiguration conf =
  +            new PropertiesConfiguration(testProperties);
  +
  +        String loaded = conf.getString("configuration.loaded");
  +        assertEquals("true", loaded);
       }
   
       /**
  -     * test if includes properites get loaded too
  +     * test if includes properties get loaded too
        */
       public void testLoadInclude()
  +        throws Exception
       {
  -        PropertiesConfiguration conf = new PropertiesConfiguration();
  -        InputStream input = this.getClass().getResourceAsStream(
  -                "/org/apache/commons/configuration/test.properties");
  -        try
  -        {
  -            conf.load(input);
  -            String loaded = conf.getString("include.loaded");
  -            assertEquals("true", loaded);
  -        }
  -        catch (Exception e)
  -        {
  -            System.err.println("Exception thrown:  " + e);
  -        }
  +        PropertiesConfiguration conf =
  +            new PropertiesConfiguration(testProperties);
  +
  +        String loaded = conf.getString("include.loaded");
  +        assertEquals("true", loaded);
       }
   
       /**
  -     * test if includes properites get loaded too
  +     * test if includes properties get loaded too
        */
       public void testVector()
  +        throws Exception
       {
  -        PropertiesConfiguration conf = new PropertiesConfiguration();
  -        InputStream input = this.getClass().getResourceAsStream(
  -                "/org/apache/commons/configuration/test.properties");
  -        try
  -        {
  -            conf.load(input);
  -            Vector loaded = conf.getVector("packages");
  -            // we should get 3 packages here
  -            assertEquals(3, loaded.size());
  -        }
  -        catch (Exception e)
  -        {
  -            System.err.println("Exception thrown:  " + e);
  -        }
  +        PropertiesConfiguration conf =
  +            new PropertiesConfiguration(testProperties);
  +
  +        Vector loaded = conf.getVector("packages");
  +        // we should get 3 packages here
  +        assertEquals(3, loaded.size());
       }
   
       public void testSave()
  +        throws Exception
       {
           PropertiesConfiguration conf = new PropertiesConfiguration();
           conf.addProperty("string", "value1");
  @@ -142,13 +129,7 @@
           }
           conf.addProperty("array", vec);
           String filename = "STRING0";
  -        try
  -        {
  -            conf.save(filename);
  -        }
  -        catch (Exception e)
  -        {
  -            System.err.println("Exception thrown:  " + e);
  -        }
  +
  +        conf.save(filename);
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to