ebourg      2004/11/18 17:56:30

  Modified:    configuration/xdocs changes.xml
               configuration/src/java/org/apache/commons/configuration
                        ConfigurationUtils.java
               configuration/conf resources.jar
               configuration/src/test/org/apache/commons/configuration
                        TestConfigurationFactory.java
  Log:
  ConfigurationUtils.locate() now checks if the URL based ressources exist.
  
  Revision  Changes    Path
  1.70      +14 -9     jakarta-commons/configuration/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- changes.xml       14 Nov 2004 19:06:32 -0000      1.69
  +++ changes.xml       19 Nov 2004 01:56:30 -0000      1.70
  @@ -9,6 +9,20 @@
   
       <release version="1.1-dev" date="in CVS">
         <action dev="ebourg" type="fix">
  +        ConfigurationUtils.locate() now checks if the URL based ressources 
exist.
  +        This fixes a bug preventing configuration files from being found if
  +        the configuration descriptor is in a JAR file (reported by Grant 
Ingersoll).
  +      </action>
  +       <action dev="oheger" type="fix" issue="32236">
  +             Fixed NPE that where caused in the constructors of file based
  +             configurations if an invalid file name was specified.
  +       </action>
  +       <action dev="oheger" type="add" issue="31797">
  +             Added support for optional configuration sources in definition 
files for
  +             ConfigurationFactory. A new required attribute allows to 
specify whether a
  +             configuration source is mandatory or optional.
  +       </action>
  +      <action dev="ebourg" type="fix">
           JNDIConfiguration.getKeys() now returns an empty iterator instead of
           throwing a ConfigurationRuntimeException when a NamingException 
occurs.
           The NamingExceptions are now logged.
  @@ -71,15 +85,6 @@
           AppletConfiguration, ServletConfiguration, 
ServletContextConfiguration,
           ServletRequestConfiguration, ServletFilterConfiguration.
         </action>
  -       <action dev="oheger" type="fix" issue="32236">
  -             Fixed NPE that where caused in the constructors of file based
  -             configurations if an invalid file name was specified.
  -       </action>
  -       <action dev="oheger" type="add" issue="31797">
  -             Added support for optional configuration sources in definition 
files for
  -             ConfigurationFactory. A new required attribute allows to 
specify whether a
  -             configuration source is mandatory or optional.
  -       </action>
       </release>
   
       <release version="1.0.1-dev" date="in CVS">
  
  
  
  1.12      +18 -8     
jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationUtils.java
  
  Index: ConfigurationUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationUtils.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ConfigurationUtils.java   17 Nov 2004 00:14:03 -0000      1.11
  +++ ConfigurationUtils.java   19 Nov 2004 01:56:30 -0000      1.12
  @@ -16,11 +16,7 @@
   
   package org.apache.commons.configuration;
   
  -import java.io.File;
  -import java.io.IOException;
  -import java.io.PrintStream;
  -import java.io.PrintWriter;
  -import java.io.StringWriter;
  +import java.io.*;
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.util.Iterator;
  @@ -264,13 +260,27 @@
               {
                   URL baseURL = new URL(base);
                   url = new URL(baseURL, name);
  +
  +                // check if the file exists
  +                InputStream in = null;
  +                try
  +                {
  +                    in = url.openStream();
  +                }
  +                finally
  +                {
  +                    if (in != null)
  +                    {
  +                        in.close();
  +                    }
  +                }
               }
   
               log.debug("Configuration loaded from the URL " + url);
           }
  -        catch (MalformedURLException e)
  +        catch (IOException e)
           {
  -
  +            url = null;
           }
   
           // attempt to load from an absolute path
  
  
  
  1.2       +4 -1      jakarta-commons/configuration/conf/resources.jar
  
        <<Binary file>>
  
  
  1.18      +12 -1     
jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationFactory.java
  
  Index: TestConfigurationFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationFactory.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- TestConfigurationFactory.java     14 Nov 2004 19:06:32 -0000      1.17
  +++ TestConfigurationFactory.java     19 Nov 2004 01:56:30 -0000      1.18
  @@ -18,6 +18,7 @@
   
   import java.io.File;
   import java.util.Collection;
  +import java.net.URL;
   
   import junit.framework.TestCase;
   
  @@ -194,6 +195,16 @@
       {
           factory.setConfigurationURL(testDigesterFileEnhanced.toURL());
           checkUnionConfig();
  +    }
  +
  +    public void testLoadingFromJAR() throws Exception
  +    {
  +        URL url = 
Thread.currentThread().getContextClassLoader().getResource("config-jar.xml");
  +        assertNotNull("config-jar.xml not found on the classpath", url);
  +        factory.setConfigurationURL(url);
  +
  +        Configuration conf = factory.getConfiguration();
  +        assertFalse("The configuration is empty", conf.isEmpty());
       }
   
       public void testThrowingConfigurationInitializationException() throws 
Exception
  
  
  

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

Reply via email to