Author: niclas Date: Sat Jun 12 04:05:17 2004 New Revision: 21132 Modified: avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/DefaultResolver.java avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/PluginProperties.java avalon/trunk/tools/magic/engine/src/test/java/org/apache/avalon/magic/PluginContextTestCase.java avalon/trunk/tools/magic/prepare/src/dist/magic.bsh Log: Fixed bug, to not to try to copy if the source doesn't exist. Silently ignore this fact.
Modified: avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/DefaultResolver.java ============================================================================== --- avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/DefaultResolver.java (original) +++ avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/DefaultResolver.java Sat Jun 12 04:05:17 2004 @@ -33,6 +33,9 @@ public String resolve( PluginProperties props, String value ) { + if( value == null ) + return null; + // optimization for common case. int pos1 = value.indexOf( "${" ); if( pos1 < 0 ) Modified: avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/PluginProperties.java ============================================================================== --- avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/PluginProperties.java (original) +++ avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/PluginProperties.java Sat Jun 12 04:05:17 2004 @@ -54,7 +54,10 @@ public String getProperty( String name ) { - String value = m_Properties.getProperty( name ).trim(); + String value = m_Properties.getProperty( name ); + if( value == null ) + return null; + value = value.trim(); if( value.indexOf( "${" ) >= 0 ) throw new IllegalArgumentException( "The value of '" + name + "' contains a variable, and not supported to resolve with this method:" + value ); return value; @@ -72,7 +75,10 @@ public String resolve( String data, PropertyResolver resolver ) { - return resolver.resolve( this, data ).trim(); + String value = resolver.resolve( this, data ); + if( value != null ) + value = value.trim(); + return value; } public void setProperty( String name, String value ) Modified: avalon/trunk/tools/magic/engine/src/test/java/org/apache/avalon/magic/PluginContextTestCase.java ============================================================================== --- avalon/trunk/tools/magic/engine/src/test/java/org/apache/avalon/magic/PluginContextTestCase.java (original) +++ avalon/trunk/tools/magic/engine/src/test/java/org/apache/avalon/magic/PluginContextTestCase.java Sat Jun 12 04:05:17 2004 @@ -100,11 +100,17 @@ assertEquals( "Plugin ClassName failed.", "TestCasePlugin", m_Context.getPluginClassname()); } + public void testGetNullProperty() + { + String p1 = null; + String value = m_Context.resolve( p1 ); + assertNull( "Null lookup failed.", value ); + } + public void testGetProperty1() { String p1 = "niclas${abc.def}hedhman"; String value = m_Context.resolve( p1 ); - System.out.println( "1:" + value ); assertEquals( "Unresolvable failed.", p1, value ); } @@ -112,7 +118,6 @@ { String p1 = "niclas ${a.property } hedhman"; String value = m_Context.resolve( p1 ); - System.out.println( "2:" + value ); assertEquals( "Single Level resolution failed.", "niclas has the surname of hedhman", value ); } @@ -120,7 +125,6 @@ { String p1 = "${a2.this}"; String value = m_Context.resolve( p1 ); - System.out.println( "3:" + value ); assertEquals( "Property resolution failed.", "this is", value ); } @@ -128,7 +132,6 @@ { String p1 = "Hey, ${a2.${a1}} ${a2.${a4}} ${a3}"; String value = m_Context.resolve( p1 ); - System.out.println( "4:" + value ); assertEquals( "Nested resolution failed.", "Hey, this is this is not this is funky", value ); } @@ -136,7 +139,6 @@ { String p1 = "${${${${${${b1}}}}}}"; String value = m_Context.resolve( p1 ); - System.out.println( "5:" + value ); assertEquals( "Nested resolution failed.", "YEAH!!!!", value ); } Modified: avalon/trunk/tools/magic/prepare/src/dist/magic.bsh ============================================================================== --- avalon/trunk/tools/magic/prepare/src/dist/magic.bsh (original) +++ avalon/trunk/tools/magic/prepare/src/dist/magic.bsh Sat Jun 12 04:05:17 2004 @@ -86,6 +86,9 @@ public void copy( File fromDir, File toDir, String includes, String excludes, boolean filtering ) { + if( ! fromDir.exists() ) + return; + FileSet from = new FileSet(); from.setDir( fromDir ); from.setIncludes( includes ); @@ -110,6 +113,8 @@ public void copyFile( File fromFile, File toFile ) { + if( ! fromFile.exists() ) + return; Copy copy = (Copy) m_Project.createTask( "copy" ); copy.setTofile( toFile ); copy.setFile( fromFile ); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]