commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject cvs commit: jakarta-commons/configuration/xdocs changes.xml
Date Mon, 04 Oct 2004 21:45:11 GMT
ebourg      2004/10/04 14:45:11

  Modified:    configuration/src/java/org/apache/commons/configuration
                        AbstractFileConfiguration.java
               configuration/src/test/org/apache/commons/configuration
                        TestXMLConfiguration.java
               configuration/xdocs changes.xml
  Added:       configuration/src/test/org/apache/commons/configuration
                        TestFileConfiguration.java
  Log:
  Removed "file:" at the beginning of the base path when calling setFile() on a FileConfiguration.
This prevented auto saving an XMLConfiguration loaded from a File (issue reported by Mark
Roth).
  
  Revision  Changes    Path
  1.4       +5 -1      jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java
  
  Index: AbstractFileConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractFileConfiguration.java	23 Sep 2004 11:49:45 -0000	1.3
  +++ AbstractFileConfiguration.java	4 Oct 2004 21:45:10 -0000	1.4
  @@ -423,6 +423,10 @@
   
           // update the base path
           basePath = ConfigurationUtils.getBasePath(url);
  +        if (basePath != null && basePath.startsWith("file:"))
  +        {
  +            basePath = basePath.substring(5);
  +        }
   
           // update the file name
           fileName = ConfigurationUtils.getFileName(url);
  
  
  
  1.13      +13 -2     jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
  
  Index: TestXMLConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestXMLConfiguration.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TestXMLConfiguration.java	4 Oct 2004 18:14:59 -0000	1.12
  +++ TestXMLConfiguration.java	4 Oct 2004 21:45:11 -0000	1.13
  @@ -18,8 +18,8 @@
   
   import java.io.File;
   import java.io.IOException;
  -import java.util.List;
   import java.util.Iterator;
  +import java.util.List;
   import java.util.Vector;
   
   import junit.framework.TestCase;
  @@ -394,6 +394,17 @@
           	assertTrue("The saved configuration doesn't contain the key '" + key + "'", checkConfig.containsKey(key));
           	assertEquals("Value of the '" + key + "' property", conf.getProperty(key), checkConfig.getProperty(key));
           }
  +    }
  +
  +    public void testAutoSave() throws Exception
  +    {
  +        conf.setFile(new File("target/testsave.xml"));
  +        conf.setAutoSave(true);
  +        conf.setProperty("autosave", "ok");
  +
  +        // reload the configuration
  +        XMLConfiguration conf2 = new XMLConfiguration(conf.getFile());
  +        assertEquals("'autosave' property", "ok", conf2.getString("autosave"));
       }
   
       public void testParseElementsNames()
  
  
  
  1.1                  jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestFileConfiguration.java
  
  Index: TestFileConfiguration.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License")
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.commons.configuration;
  
  import java.net.URL;
  
  import junit.framework.TestCase;
  
  /**
   * @author Emmanuel Bourg
   * @version $Revision: 1.1 $, $Date: 2004/10/04 21:45:11 $
   */
  public class TestFileConfiguration extends TestCase
  {
      public void testSetURL() throws Exception
      {
          // http URL
          FileConfiguration config = new PropertiesConfiguration();
          config.setURL(new URL("http://jakarta.apache.org/commons/configuration/index.html"));
  
          assertEquals("base path", "http://jakarta.apache.org/commons/configuration/", config.getBasePath());
          assertEquals("file name", "index.html", config.getFileName());
  
          // file URL
          config.setURL(new URL("file:/temp/test.properties"));
          assertEquals("base path", "/temp/", config.getBasePath());
          assertEquals("file name", "test.properties", config.getFileName());
      }
  }
  
  
  
  1.51      +5 -0      jakarta-commons/configuration/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- changes.xml	4 Oct 2004 20:06:09 -0000	1.50
  +++ changes.xml	4 Oct 2004 21:45:11 -0000	1.51
  @@ -7,6 +7,11 @@
   
     <body>
       <release version="1.0" date="IN CVS">
  +      <action dev="ebourg" type="fix">
  +        Removed "file:" at the beginning of the base path when calling
  +        setFile() on a FileConfiguration. This prevented auto saving an
  +        XMLConfiguration loaded from a File (issue reported by Mark Roth).
  +      </action>
         <action dev="ebourg" type="update">
           All NamingEnumerations in JNDIConfiguraiton are now properly closed (Suggested
           by Eric Jung).
  
  
  

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