Author: stephenc
Date: Mon Jun 13 15:18:52 2011
New Revision: 1135138

URL: http://svn.apache.org/viewvc?rev=1135138&view=rev
Log:
add a trivial impl of property utils as I cannot find a good source for this 
class... consider donating to commons-io

Modified:
    
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
    
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PropertyUtilsTest.java

Modified: 
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/PropertyUtils.java?rev=1135138&r1=1135137&r2=1135138&view=diff
==============================================================================
--- 
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
 (original)
+++ 
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-commons-bridge/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
 Mon Jun 13 15:18:52 2011
@@ -19,6 +19,12 @@ package org.codehaus.plexus.util;
  * under the License.
  */
 
+import org.apache.commons.io.IOUtils;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
 public class PropertyUtils
 {
 
@@ -29,17 +35,58 @@ public class PropertyUtils
 
     public static java.util.Properties loadProperties( java.net.URL url )
     {
-        throw new UnsupportedOperationException( "Not implemented yet" );
+        try
+        {
+            return loadProperties( url.openStream() );
+        }
+        catch ( Exception e )
+        {
+            // ignore
+        }
+        return null;
     }
 
     public static java.util.Properties loadProperties( java.io.File file )
     {
-        throw new UnsupportedOperationException( "Not implemented yet" );
+        try
+        {
+            return loadProperties( new FileInputStream( file ) );
+        }
+        catch ( Exception e )
+        {
+            // ignore
+        }
+        return null;
     }
 
     public static java.util.Properties loadProperties( java.io.InputStream is )
     {
-        throw new UnsupportedOperationException( "Not implemented yet" );
+        try
+        {
+            // to make this the same behaviour as the others we should really 
return null on any error
+            Properties result = new Properties();
+            if ( is != null )
+            {
+                try
+                {
+                    result.load( is );
+                }
+                catch ( IOException e )
+                {
+                    // ignore
+                }
+            }
+            return result;
+        }
+        catch ( Exception e )
+        {
+            // ignore
+        }
+        finally
+        {
+            IOUtils.closeQuietly( is );
+        }
+        return null;
     }
 
 }
\ No newline at end of file

Modified: 
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PropertyUtilsTest.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PropertyUtilsTest.java?rev=1135138&r1=1135137&r2=1135138&view=diff
==============================================================================
--- 
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PropertyUtilsTest.java
 (original)
+++ 
maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PropertyUtilsTest.java
 Mon Jun 13 15:18:52 2011
@@ -20,6 +20,7 @@ package org.codehaus.plexus.util;
  */
 
 import org.apache.maven.tck.FixPlexusBugs;
+import org.apache.maven.tck.ReproducesPlexusBug;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.MethodRule;
@@ -79,6 +80,7 @@ public class PropertyUtilsTest
     }
 
     @Test
+    @ReproducesPlexusBug( "Should return null on error like url and file do" )
     public void loadNullInputStream()
         throws Exception
     {


Reply via email to