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 maven.xml project.xml
Date Sat, 21 Jun 2003 22:11:04 GMT
epugh       2003/06/21 15:11:04

  Modified:    configuration/xdocs tasks.xml
               configuration/src/test/org/apache/commons/configuration
                        TestClassPropertiesConfiguration.java
                        TestBasePropertiesConfiguration.java
               configuration/src/java/org/apache/commons/configuration
                        ClassPropertiesConfiguration.java
               configuration maven.xml project.xml
  Added:       configuration/xdocs changes.xml
  Log:
  Adding fix from Brian Dunbar for ClassPropertiesConfiguration.  Thanks Brian!
  Also tweaked documentation to add an explicit changes.xml file to record
  changes.
  
  Revision  Changes    Path
  1.6       +5 -19     jakarta-commons-sandbox/configuration/xdocs/tasks.xml
  
  Index: tasks.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/xdocs/tasks.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- tasks.xml	20 Jun 2003 01:12:49 -0000	1.5
  +++ tasks.xml	21 Jun 2003 22:11:03 -0000	1.6
  @@ -41,29 +41,15 @@
                 Need to be able to retrieve configuration values from Avalon,
                 and pass them into Avalon.
             </li>
  +          <li>
  +              <strong>JDBC Integration</strong>
  +              Need to be able to retrieve configuration values from JDBC 
  +              datasource.
  +          </li>
          </ul>
       </subsection>
       
       <subsection name="Low priority"> 
  -    </subsection>
  -</section>
  -<section name='Completed'>
  -    <subsection name="Since Last Release"> 
  -       <ul>
  -          <li>
  -              <strong>CompositeConfiguration.getKeys() Fix</strong>
  -			  The CompositeConfiguration.getKeys() method was returning an
  -			  unordered list of configuration values.  However, many apps
  -			  expect the order that keys are returned to be the order they
  -			  are added into the properties file.
  -          </li>
  -          <li>
  -              <strong>JNDIConfiguration.getKeys() Addition</strong>
  -			  The JNDIConfiguration.getKeys() method was returning an unsupported
  -			  operation error.  However, this is an important method to have 
  -			  supported.
  -          </li>
  -       </ul>
       </subsection>
   </section>
     </body>
  
  
  
  1.1                  jakarta-commons-sandbox/configuration/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  <?xml version="1.0"?>
  <document>
    <properties>
      <title>Changes</title>
      <author email="epugh@upstate.com">Eric Pugh</author>
    </properties>
  
    <body>
      <release version="1.0-dev-4" date="">
  
       <action dev="bdunbar" type="fix">
  	     <strong>ClassPropertiesConfiguration Additions</strong>
  	     <ul>
  	      	<li>Use the classloader of class that is provided by the constructor.</li>
  			<li>Add a constructor that indicates whether to use relative or absolute.</li>
  			<li>Change getPropertyStream to utilize the relative or absolute flag.</li>
  			<li>Add a test case that checks that absolute paths work.</li>
  		  </ul>
       </action>    
       <action dev="epugh" type="fix">
        	<strong>JNDIConfiguration.getKeys() Addition</strong>
  	  	The JNDIConfiguration.getKeys() method was returning an unsupported
  	  	operation error.  However, this is an important method to have 
  	 	supported.
       </action>    
       <action dev="epugh" type="fix">
        	<strong>CompositeConfiguration.getKeys() Fix</strong>
  	  	The CompositeConfiguration.getKeys() method was returning an
  	  	unordered list of configuration values.  However, many apps
  	  	expect the order that keys are returned to be the order they
  	  	are added into the properties file.
       </action>         
      </release>
  
    </body>
  </document>
  
  
  
  
  1.6       +17 -3     jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestClassPropertiesConfiguration.java
  
  Index: TestClassPropertiesConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestClassPropertiesConfiguration.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestClassPropertiesConfiguration.java	11 Mar 2003 17:39:33 -0000	1.5
  +++ TestClassPropertiesConfiguration.java	21 Jun 2003 22:11:04 -0000	1.6
  @@ -68,7 +68,11 @@
       extends TestBasePropertiesConfiguration
   {
       /** The File that we test with */
  -    private static final String TEST_PROPERTIES = "test.properties";
  +    private static final String[] TEST_FILE_NAMES = 
  +    {
  +        "/testClasspath.properties", "test.properties", "./test.properties",
  +        "/org/apache/commons/configuration/test.properties"
  +     };
   
       public TestClassPropertiesConfiguration(String s)
       {
  @@ -78,6 +82,16 @@
       protected void setUp()
           throws Exception
       {
  -        conf = new ClassPropertiesConfiguration(getClass(), TEST_PROPERTIES);
  +        conf = new ClassPropertiesConfiguration(getClass(), TEST_FILE_NAMES[0]);
  +    }
  +    
  +    /** Test that loading from the classpath in various path formats works */
  +    public void testClasspathLoading() throws Exception
  +    {
  +      for (int i=0; i<TEST_FILE_NAMES.length; i++) 
  +      {
  +        conf = new ClassPropertiesConfiguration(getClass(), TEST_FILE_NAMES[i]);
  +        testLoad();
  +      }
       }
   }
  
  
  
  1.3       +10 -1     jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestBasePropertiesConfiguration.java
  
  Index: TestBasePropertiesConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestBasePropertiesConfiguration.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestBasePropertiesConfiguration.java	13 Jan 2003 19:29:38 -0000	1.2
  +++ TestBasePropertiesConfiguration.java	21 Jun 2003 22:11:04 -0000	1.3
  @@ -106,6 +106,15 @@
       }
   
       /**
  +     * Tests that references to other properties work
  +     */
  +    public void testReference()
  +      throws Exception
  +    {
  +		assertEquals("baseextra", conf.getString("base.reference"));
  +	}
  +
  +    /**
        * test if includes properties get loaded too
        */
       public void testLoadInclude()
  
  
  
  1.4       +16 -35    jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/ClassPropertiesConfiguration.java
  
  Index: ClassPropertiesConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/ClassPropertiesConfiguration.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ClassPropertiesConfiguration.java	7 Jun 2003 19:30:43 -0000	1.3
  +++ ClassPropertiesConfiguration.java	21 Jun 2003 22:11:04 -0000	1.4
  @@ -61,9 +61,10 @@
   import org.apache.commons.lang.StringUtils;
   
   /**
  - * Loads the configuration from a class resource. The included
  - * properties files are relative to the class or absolute class
  - * references. All files are loaded from the class loader.
  + * Loads the configuration from the classpath utilizing a specified class to get
  + * the classloader from. The properties file will be attempted to be loaded 
  + * first from the classes package directory and then from the class path in 
  + * general.
    * <p>
    * This class does not support an empty constructor and saving of a
    * synthesized properties file. Use PropertiesConfiguration for this.
  @@ -148,8 +149,7 @@
   
       /**
        * Gets a resource relative to the supplied base class or
  -     * from the class loader if its an absolute reference (starting
  -     * with a "/").
  +     * from the class loader if it is not found from the supplied base class.
        *
        * @param resourceName The resource Name
        * @return An Input Stream
  @@ -159,38 +159,19 @@
           throws IOException
       {
           InputStream resource = null;
  -
  -        // JavaDocs say, that Resource Names always start with "/"
  -        if (resourceName.startsWith("/"))
  -        {
  -            resource = classLoader.getResourceAsStream(resourceName);
  -        }
  -        else
  -        {
  -            // Relative reference
  -            StringBuffer classPath = new StringBuffer();
  -            // Javadocs say "/" separated...
  -            classPath.append(baseClass.getPackage()
  -                             .getName().replace('.', '/'));
  -            classPath.append("/");
  -                             
  -            /*
  -             * We have a relative path, and we have
  -             * two possible forms here. If we have the
  -             * "./" form then just strip that off first
  -             * before continuing.
  -             */
  -            
  +        //For backwards compatibility with earlier versions, 
  +        //strip a leading "./" from the 
               if (resourceName.startsWith("./"))
               {
  -                classPath.append(resourceName.substring(2));
  -            }
  -            else
  -            {
  -                classPath.append(resourceName);
  +                //classPath.append(resourceName.substring(2));
               }
  -
  -            resource = classLoader.getResourceAsStream(classPath.toString());
  +        
  +        //First try to load from within the package of the provided class
  +        resource = baseClass.getResourceAsStream(resourceName);
  +        
  +        if (resource == null)
  +        {
  +          resource = classLoader.getResourceAsStream(resourceName);
           }
   
           if (resource == null)
  
  
  
  1.4       +10 -7     jakarta-commons-sandbox/configuration/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/maven.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- maven.xml	7 Feb 2003 00:21:50 -0000	1.3
  +++ maven.xml	21 Jun 2003 22:11:04 -0000	1.4
  @@ -7,13 +7,16 @@
   <!-- ===================================================================== -->
   
   <project default="java:jar">
  -
  -  <postGoal name="test:compile">
  -    <copy todir="${maven.build.dest}/org/apache/commons/configuration">
  -      <fileset dir="${maven.conf.dir}" includes="*.properties"/>
  +  <!-- NonStringTestHolder.java contains tests shared by JUnit and Cactus
  +  tests.  This ugly hack moves the src from /src/test to /src/test-cactus
  +  so the Cactus tests will compile.  Not sure what is worse, this hack, or
  +  just duplicating the code!
  +  -->
  +  <preGoal name="cactus:compile">
  +    <copy todir="${basedir}/src/test-cactus/org/apache/commons/configuration">
  +        <fileset dir="${basedir}/src/test/" includes="**/NonStringTestHolder.java"/>
       </copy>
  -  </postGoal>
  -
  +  </preGoal>
   </project>
   
   
  
  
  
  1.29      +19 -2     jakarta-commons-sandbox/configuration/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/project.xml,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- project.xml	20 Jun 2003 07:50:47 -0000	1.28
  +++ project.xml	21 Jun 2003 22:11:04 -0000	1.29
  @@ -96,6 +96,12 @@
         <organization>upstate.com</organization>
       </developer>
   
  +    <developer>
  +      <name>Brian E. Dunbar</name>
  +      <id>bdunbar</id>
  +      <email>bdunbar@dunbarconsulting.org</email>
  +      <organization>dunbarconsulting.org</organization>
  +    </developer>
     </developers>
   
     <dependencies>
  @@ -185,15 +191,26 @@
         </includes>
         <excludes>
           <exclude>**/TestBasePropertiesConfiguration.java</exclude>
  -        <exclude>**/TestClassPropertiesConfiguration.java</exclude>
           <exclude>**/NonStringTestHolder.java</exclude>
         </excludes>
         <resources>
           <resource>
             <directory>conf</directory>
             <includes>
  +            <include>testClasspath.properties</include>
  +          </includes>
  +        </resource>
  +      </resources>
  +      <resources>
  +        <resource>
  +          <directory>conf</directory>
  +          <targetPath>org/apache/commons/configuration</targetPath> 
  +          <includes>
               <include>*.properties</include>
             </includes>
  +          <excludes>
  +            <exclude>testClasspath.properties</exclude>
  +          </excludes>          
           </resource>
         </resources>
       </unitTest>
  
  
  

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