commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r628577 - in /commons/proper/configuration/branches/configuration2_experimental/src: main/java/org/apache/commons/configuration2/ test/java/org/apache/commons/configuration2/
Date Sun, 17 Feb 2008 23:19:06 GMT
Author: ebourg
Date: Sun Feb 17 15:18:59 2008
New Revision: 628577

URL: http://svn.apache.org/viewvc?rev=628577&view=rev
Log:
CONFIGURATION-300: Fixed the creation of a file based configuration if the filename contains
a '#'

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractFileConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractFileConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractFileConfiguration.java?rev=628577&r1=628576&r2=628577&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractFileConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractFileConfiguration.java
Sun Feb 17 15:18:59 2008
@@ -239,7 +239,7 @@
     {
         try
         {
-            load(file.toURL());
+            load(file.toURI().toURL());
         }
         catch (ConfigurationException e)
         {

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java?rev=628577&r1=628576&r2=628577&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
Sun Feb 17 15:18:59 2008
@@ -291,7 +291,7 @@
         File f = new File(file);
         if (f.isAbsolute()) // already absolute?
         {
-            return f.toURL();
+            return f.toURI().toURL();
         }
 
         try
@@ -308,7 +308,7 @@
         }
         catch (MalformedURLException uex)
         {
-            return constructFile(basePath, file).toURL();
+            return constructFile(basePath, file).toURI().toURL();
         }
     }
 
@@ -449,7 +449,7 @@
             {
                 try
                 {
-                    url = file.toURL();
+                    url = file.toURI().toURL();
                     log.fine("Loading configuration from the absolute path " + name);
                 }
                 catch (MalformedURLException e)
@@ -467,7 +467,7 @@
                 File file = constructFile(base, name);
                 if (file != null && file.exists())
                 {
-                    url = file.toURL();
+                    url = file.toURI().toURL();
                 }
 
                 if (url != null)
@@ -489,7 +489,7 @@
                 File file = constructFile(System.getProperty("user.home"), name);
                 if (file != null && file.exists())
                 {
-                    url = file.toURL();
+                    url = file.toURI().toURL();
                 }
 
                 if (url != null)

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java?rev=628577&r1=628576&r2=628577&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
Sun Feb 17 15:18:59 2008
@@ -34,12 +34,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.commons.configuration2.BaseConfiguration;
-import org.apache.commons.configuration2.Configuration;
-import org.apache.commons.configuration2.ConfigurationException;
-import org.apache.commons.configuration2.ConfigurationFactory;
-import org.apache.commons.configuration2.PropertiesConfiguration;
-import org.apache.commons.configuration2.PropertiesConfigurationLayout;
 import org.apache.commons.configuration2.reloading.FileChangedReloadingStrategy;
 
 import junit.framework.TestCase;
@@ -743,6 +737,20 @@
             assertTrue("Wrong root cause: " + cex,
                     cex.getCause() instanceof IOException);
         }
+    }
+
+    /**
+     * Test the creation of a file containing a '#' in its name.
+     */
+    public void testFileWithSharpSymbol() throws Exception
+    {
+        File file = new File("target/sharp#1.properties");
+        file.createNewFile();
+
+        PropertiesConfiguration conf = new PropertiesConfiguration(file);
+        conf.save();
+
+        assertTrue("Missing file " + file, file.exists());
     }
 
     /**



Mime
View raw message