You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jt...@apache.org on 2006/04/26 17:10:46 UTC

svn commit: r397215 - in /maven/plugins/trunk/maven-resources-plugin: ./ src/main/java/org/apache/maven/plugin/resources/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/maven/ src/test/java/org/apache/mav...

Author: jtolentino
Date: Wed Apr 26 08:10:43 2006
New Revision: 397215

URL: http://svn.apache.org/viewcvs?rev=397215&view=rev
Log:
PR: MRESOURCES-16
Submitted by: Pete Marvin King

Unit tests patch for maven-resources-plugin using the plugin testing harness.

Added:
    maven/plugins/trunk/maven-resources-plugin/src/test/
    maven/plugins/trunk/maven-resources-plugin/src/test/java/
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/AbstractPropertyUtilsTest.java
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/AdvancePropertyUtilsTest.java
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/BasicPropertyUtilsTest.java
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ReflectionPropertiesTest.java
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/TestResourcesTest.java
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBasicStub.java
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectResourcesStub.java
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/advance.properties
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/advance_validation.properties
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/basic.properties
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/basic_validation.properties
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/plugin-config.xml
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/validation.properties
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/validation_escapebackslashinpath.properties
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config-absolute-path.xml
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config-relative-path.xml
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config.xml
    maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/validation.properties
Modified:
    maven/plugins/trunk/maven-resources-plugin/pom.xml
    maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java

Modified: maven/plugins/trunk/maven-resources-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/pom.xml?rev=397215&r1=397214&r2=397215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-resources-plugin/pom.xml Wed Apr 26 08:10:43 2006
@@ -30,5 +30,11 @@
       <artifactId>maven-model</artifactId>
       <version>2.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-testing-harness</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

Modified: maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java?rev=397215&r1=397214&r2=397215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java (original)
+++ maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java Wed Apr 26 08:10:43 2006
@@ -193,8 +193,10 @@
     private void initializeFiltering()
         throws MojoExecutionException
     {
+        filterProperties = new Properties();
+        
         // System properties
-        filterProperties = new Properties( System.getProperties() );
+        filterProperties.putAll( System.getProperties() );
         
         // Project properties
         filterProperties.putAll( project.getProperties() );

Added: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/AbstractPropertyUtilsTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/AbstractPropertyUtilsTest.java?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/AbstractPropertyUtilsTest.java (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/AbstractPropertyUtilsTest.java Wed Apr 26 08:10:43 2006
@@ -0,0 +1,103 @@
+package org.apache.maven.plugin.resources;
+
+/*
+ * Copyright 2001-2006 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.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+
+/**
+ * Base class for propertyutils test case
+ */
+
+public abstract class AbstractPropertyUtilsTest
+    extends AbstractMojoTestCase
+{
+    protected File propertyFile;
+
+    protected File validationFile;
+
+    protected Properties validationProp;
+
+    protected abstract File getPropertyFile();
+
+    protected abstract File getValidationFile();
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        // load data
+        propertyFile = getPropertyFile();
+        assertNotNull( propertyFile );
+
+        validationFile = getValidationFile();
+        assertNotNull( validationFile );
+
+        loadValidationProperties( validationFile );
+    }
+
+    protected void tearDown()
+    {
+
+    }
+
+    protected boolean validateProperties( Properties prop )
+    {
+        boolean bRetVal = false;
+
+        Enumeration propKeys = prop.keys();
+        String key;
+
+        while ( propKeys.hasMoreElements() )
+        {
+            key = (String) propKeys.nextElement();
+            bRetVal = prop.getProperty( key ).equals( validationProp.getProperty( key ) );
+            if ( !bRetVal )
+            {
+                break;
+            }
+        }
+
+        return bRetVal;
+    }
+
+    /**
+     * load the property file for cross checking the
+     * values in the processed property file
+     *
+     * @param validationPropFile
+     */
+    private void loadValidationProperties( File validationPropFile )
+    {
+        validationProp = new Properties();
+
+        try
+        {
+            validationProp.load( new FileInputStream( validationPropFile ) );
+        }
+        catch ( IOException ex )
+        {
+            // TODO: do error handling
+        }
+    }
+}

Added: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/AdvancePropertyUtilsTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/AdvancePropertyUtilsTest.java?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/AdvancePropertyUtilsTest.java (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/AdvancePropertyUtilsTest.java Wed Apr 26 08:10:43 2006
@@ -0,0 +1,116 @@
+package org.apache.maven.plugin.resources;
+
+/*
+ * Copyright 2001-2006 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.
+ */
+
+import java.io.File;
+import java.util.Properties;
+
+public class AdvancePropertyUtilsTest
+    extends AbstractPropertyUtilsTest
+{
+    final static protected String propFileName = "/target/test-classes/unit/propertiesutils-test/advance.properties";
+
+    final static protected String validationFileName =
+        "/target/test-classes/unit/propertiesutils-test/advance_validation.properties";
+
+    protected File getPropertyFile()
+    {
+
+        File propFile = new File( getBasedir(), propFileName );
+
+        if ( !propFile.exists() )
+        {
+            propFile = null;
+        }
+
+        return propFile;
+    }
+
+    protected File getValidationFile()
+    {
+
+        File validationFile = new File( getBasedir(), validationFileName );
+
+        if ( !validationFile.exists() )
+        {
+            validationFile = null;
+        }
+
+        return validationFile;
+    }
+
+    /**
+     * load property test case can be adjusted by modifying the advance.properties and
+     * advance_validation.properties
+     *
+     * @throws Exception
+     */
+    public void testAdvanceLoadProperty_FF()
+        throws Exception
+    {
+        Properties prop;
+        boolean throwsException = false;
+
+        try
+        {
+            prop = PropertyUtils.loadPropertyFile( propertyFile, false, false );
+        }
+        catch ( Exception ex )
+        {
+            prop = null;
+            throwsException = true;
+        }
+
+        assertFalse( throwsException );
+        assertNotNull( prop );
+        assertTrue( validateProperties( prop ) );
+
+    }
+
+    /**
+     * load property test case can be adjusted by modifying the advance.properties and
+     * advance_validation properties
+     *
+     * @throws Exception
+     */
+    public void testAdvanceLoadProperty_TF()
+        throws Exception
+    {
+        Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, false );
+
+        assertNotNull( prop );
+        assertTrue( validateProperties( prop ) );
+    }
+
+    /**
+     * load property test case can be adjusted by modifying the advance.properties and
+     * advance_validation properties
+     *
+     * @throws Exception
+     */
+    public void testAdvanceLoadProperty_TT()
+        throws Exception
+    {
+        Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, true );
+
+        // add system properties to our
+        // validation table
+        validationProp.putAll( System.getProperties() );
+        assertNotNull( prop );
+        assertTrue( validateProperties( prop ) );
+    }
+}

Added: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/BasicPropertyUtilsTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/BasicPropertyUtilsTest.java?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/BasicPropertyUtilsTest.java (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/BasicPropertyUtilsTest.java Wed Apr 26 08:10:43 2006
@@ -0,0 +1,138 @@
+package org.apache.maven.plugin.resources;
+
+/*
+ * Copyright 2001-2006 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.
+ */
+
+import java.io.File;
+import java.util.Properties;
+
+public class BasicPropertyUtilsTest
+    extends AbstractPropertyUtilsTest
+{
+    final static protected String validationFileName =
+        "/target/test-classes/unit/propertiesutils-test/basic_validation.properties";
+
+    final static protected String propFileName = "/target/test-classes/unit/propertiesutils-test/basic.properties";
+
+    protected File getPropertyFile()
+    {
+        File propFile = new File( getBasedir(), propFileName );
+
+        if ( !propFile.exists() )
+        {
+            propFile = null;
+        }
+
+        return propFile;
+    }
+
+    protected File getValidationFile()
+    {
+        File validationFile = new File( getBasedir(), validationFileName );
+
+        if ( !validationFile.exists() )
+        {
+            validationFile = null;
+        }
+
+        return validationFile;
+    }
+
+    /**
+     * load property test case can be adjusted by modifying the basic.properties and
+     * basic_validation properties
+     *
+     * @throws Exception
+     */
+    public void testBasicLoadProperty_FF()
+        throws Exception
+    {
+        Properties prop = PropertyUtils.loadPropertyFile( propertyFile, false, false );
+
+        assertNotNull( prop );
+        assertTrue( validateProperties( prop ) );
+    }
+
+    /**
+     * load property test case can be adjusted by modifying the basic.properties and
+     * basic_validation properties
+     *
+     * @throws Exception
+     */
+    public void testBasicLoadProperty_TF()
+        throws Exception
+    {
+        Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, false );
+
+        assertNotNull( prop );
+        assertTrue( validateProperties( prop ) );
+    }
+
+    /**
+     * load property test case can be adjusted by modifying the basic.properties and
+     * basic_validation properties
+     *
+     * @throws Exception
+     */
+    public void testBasicLoadProperty_TT()
+        throws Exception
+    {
+        Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, true );
+
+        validationProp.putAll( System.getProperties() );
+        assertNotNull( prop );
+        assertTrue( validateProperties( prop ) );
+    }
+
+    /**
+     * load property test case can be adjusted by modifying the basic.properties and
+     * basic_validation properties
+     *
+     * @throws Exception
+     */
+    public void testNonExistentProperty()
+        throws Exception
+    {
+        Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, true );
+
+        validationProp.putAll( System.getProperties() );
+        assertNotNull( prop );
+        assertNull( prop.getProperty( "does_not_exist" ) );
+    }
+
+    /**
+     * load property test case can be adjusted by modifying the basic.properties and
+     * basic_validation properties
+     *
+     * @throws Exception
+     */
+    public void testException()
+        throws Exception
+    {
+        boolean failed = false;
+
+        try
+        {
+            Properties prop = PropertyUtils.loadPropertyFile( new File( "NON_EXISTENT_FILE" ), true, true );
+        }
+        catch ( Exception ex )
+        {
+            failed = true;
+        }
+
+        assertTrue( failed );
+    }
+}

Added: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ReflectionPropertiesTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ReflectionPropertiesTest.java?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ReflectionPropertiesTest.java (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ReflectionPropertiesTest.java Wed Apr 26 08:10:43 2006
@@ -0,0 +1,77 @@
+package org.apache.maven.plugin.resources;
+
+/*
+ * Copyright 2001-2006 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.
+ */
+
+import org.apache.maven.plugin.resources.stub.MavenProjectBasicStub;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+
+public class ReflectionPropertiesTest
+    extends AbstractMojoTestCase
+{
+    // data
+    final static protected String pomFilePath = "/target/test-classes/unit/reflectionproperties-test/plugin-config.xml";
+
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+
+    }
+
+    public void testGet_escapeBackslashCharacterInPath()
+        throws Exception
+    {
+        // setup data
+        MavenProjectBasicStub project = new MavenProjectBasicStub( "escapeBackSlashCharacterInPath" );
+
+        // set dummy value
+        project.setDescription( "c:\\\\org\\apache\\test" );
+
+        ReflectionProperties reflectProp = new ReflectionProperties( project, true );
+
+        // project property to be verified
+        String reflectPropValue = (String) reflectProp.get( "description" );
+
+        // expected value is c\:\\\\org\\apache\\test 
+        assertTrue( reflectPropValue.equals( "c\\:\\\\\\\\org\\\\apache\\\\test" ) );
+    }
+
+    public void testGet_dontEscapeBackslashCharacterInPath()
+        throws Exception
+    {
+        // setup data
+        MavenProjectBasicStub project = new MavenProjectBasicStub( "dontEscapeBackSlashCharacterInPath" );
+
+        // set dummy value
+        project.setDescription( "c:\\\\org\\apache\\test" );
+
+        // project property to be verified
+        ReflectionProperties reflectProp = new ReflectionProperties( project, false );
+
+        // project property to be verified
+        String reflectPropValue = (String) reflectProp.get( "description" );
+
+        // expected value is c:\\org\apache\test 
+        assertTrue( reflectPropValue.equals( "c:\\\\org\\apache\\test" ) );
+    }
+}

Added: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java Wed Apr 26 08:10:43 2006
@@ -0,0 +1,450 @@
+package org.apache.maven.plugin.resources;
+
+/*
+ * Copyright 2001-2006 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.
+ */
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.maven.plugin.resources.stub.MavenProjectResourcesStub;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+public class ResourcesMojoTest
+    extends AbstractMojoTestCase
+{
+    protected final static String defaultPomFilePath = "/target/test-classes/unit/resources-test/plugin-config.xml";
+
+    /**
+     * test mojo lookup, test harness should be working fine
+     *
+     * @throws Exception
+     */
+    public void testHarnessEnvironment()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+
+        assertNotNull( mojo );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testResourceDirectoryStructure()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "resourceDirectoryStructure" );
+        List resources = project.getBuild().getResources();
+
+        assertNotNull( mojo );
+
+        project.addFile( "file4.txt" );
+        project.addFile( "package/file3.nottest" );
+        project.addFile( "notpackage/file1.include" );
+        project.addFile( "package/test/file1.txt" );
+        project.addFile( "notpackage/test/file2.txt" );
+        project.setupBuildEnvironment();
+
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getOutputDirectory() );
+        setVariableValueToObject( mojo, "filters", new LinkedList() );
+        mojo.execute();
+
+        String resorucesDir = project.getOutputDirectory();
+
+        assertTrue( FileUtils.fileExists( resorucesDir + "/file4.txt" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/package/file3.nottest" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/notpackage/file1.include" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/package/test" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/notpackage/test" ) );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testResourceDirectoryStructure_RelativePath()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "resourceDirectoryStructure_RelativePath" );
+        List resources = project.getBuild().getResources();
+
+        assertNotNull( mojo );
+
+        project.setOutputDirectory( "../relative_dir" );
+        project.addFile( "file4.txt" );
+        project.addFile( "package/file3.nottest" );
+        project.addFile( "notpackage/file1.include" );
+        project.addFile( "package/test/file1.txt" );
+        project.addFile( "notpackage/test/file2.txt" );
+        project.setupBuildEnvironment();
+
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getOutputDirectory() );
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "filters", new LinkedList() );
+        mojo.execute();
+
+        String resorucesDir = project.getOutputDirectory();
+
+        assertTrue( FileUtils.fileExists( resorucesDir + "/file4.txt" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/package/file3.nottest" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/notpackage/file1.include" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/package/test" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/notpackage/test" ) );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testResourceEncoding()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "encoding" );
+        List resources = project.getBuild().getResources();
+
+        assertNotNull( mojo );
+
+        project.addFile( "file4.txt" );
+        project.setResourceFiltering( 0, true );
+        project.setupBuildEnvironment();
+
+        setVariableValueToObject( mojo, "encoding", "UTF-8" );
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getOutputDirectory() );
+        setVariableValueToObject( mojo, "filters", new LinkedList() );
+        mojo.execute();
+
+        String resorucesDir = project.getOutputDirectory();
+
+        assertTrue( FileUtils.fileExists( resorucesDir + "/file4.txt" ) );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testResourceInclude()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "resourceInclude" );
+        List resources = project.getBuild().getResources();
+
+        assertNotNull( mojo );
+
+        project.addFile( "file1.include" );
+        project.addFile( "file2.exclude" );
+        project.addFile( "file3.nottest" );
+        project.addFile( "file4.txt" );
+        project.addFile( "package/file1.include" );
+        project.addFile( "package/file2.exclude" );
+        project.addFile( "package/file3.nottest" );
+        project.addFile( "package/file4.txt" );
+        project.addFile( "notpackage/file1.include" );
+        project.addFile( "notpackage/file2.exclude" );
+        project.addFile( "notpackage/file3.nottest" );
+        project.addFile( "notpackage/file4.txt" );
+        project.addFile( "package/test/file1.txt" );
+        project.addFile( "package/nottest/file2.txt" );
+        project.addFile( "notpackage/test/file1.txt" );
+        project.addFile( "notpackage/nottest/file.txt" );
+        project.setupBuildEnvironment();
+
+        project.addInclude( "*.include" );
+        project.addInclude( "**/test" );
+        project.addInclude( "**/test/file*" );
+        project.addInclude( "**/package/*.include" );
+
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getOutputDirectory() );
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "filters", new LinkedList() );
+        mojo.execute();
+
+        String resorucesDir = project.getOutputDirectory();
+
+        assertTrue( FileUtils.fileExists( resorucesDir + "/package/test" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/file1.include" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/package/file1.include" ) );
+        assertFalse( FileUtils.fileExists( resorucesDir + "/notpackage/file1.include" ) );
+        assertFalse( FileUtils.fileExists( resorucesDir + "/notpackage/nottest/file.txt" ) );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testResourceExclude()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "resourceExclude" );
+        List resources = project.getBuild().getResources();
+        ;
+
+        assertNotNull( mojo );
+
+        project.addFile( "file1.include" );
+        project.addFile( "file2.exclude" );
+        project.addFile( "file3.nottest" );
+        project.addFile( "file4.txt" );
+        project.addFile( "package/file1.include" );
+        project.addFile( "package/file2.exclude" );
+        project.addFile( "package/file3.nottest" );
+        project.addFile( "package/file4.txt" );
+        project.addFile( "notpackage/file1.include" );
+        project.addFile( "notpackage/file2.exclude" );
+        project.addFile( "notpackage/file3.nottest" );
+        project.addFile( "notpackage/file4.txt" );
+        project.addFile( "package/test/file1.txt" );
+        project.addFile( "package/nottest/file2.txt" );
+        project.addFile( "notpackage/test/file1.txt" );
+        project.addFile( "notpackage/nottest/file.txt" );
+        project.setupBuildEnvironment();
+
+        project.addExclude( "**/*.exclude" );
+        project.addExclude( "**/nottest*" );
+        project.addExclude( "**/notest" );
+        project.addExclude( "**/notpackage*" );
+        project.addExclude( "**/notpackage*/**" );
+
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getOutputDirectory() );
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "filters", new LinkedList() );
+        mojo.execute();
+
+        String resorucesDir = project.getOutputDirectory();
+
+        assertTrue( FileUtils.fileExists( resorucesDir + "/package/test" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/file1.include" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/package/file1.include" ) );
+        assertFalse( FileUtils.fileExists( resorucesDir + "/notpackage/file1.include" ) );
+        assertFalse( FileUtils.fileExists( resorucesDir + "/notpackage/nottest/file.txt" ) );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testResourceTargetPath()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "resourceTargetPath" );
+        List resources = project.getBuild().getResources();
+
+        assertNotNull( mojo );
+
+        project.setTargetPath( "org/apache/maven/plugin/test" );
+
+        project.addFile( "file4.txt" );
+        project.addFile( "package/file3.nottest" );
+        project.addFile( "notpackage/file1.include" );
+        project.addFile( "package/test/file1.txt" );
+        project.addFile( "notpackage/test/file2.txt" );
+        project.setupBuildEnvironment();
+
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getOutputDirectory() );
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "filters", new LinkedList() );
+        mojo.execute();
+
+        String resourcesDir = project.getOutputDirectory();
+
+        assertTrue( FileUtils.fileExists( resourcesDir + "/org/apache/maven/plugin/test/file4.txt" ) );
+        assertTrue( FileUtils.fileExists( resourcesDir + "/org/apache/maven/plugin/test/package/file3.nottest" ) );
+        assertTrue( FileUtils.fileExists( resourcesDir + "/org/apache/maven/plugin/test/notpackage/file1.include" ) );
+        assertTrue( FileUtils.fileExists( resourcesDir + "/org/apache/maven/plugin/test/package/test" ) );
+        assertTrue( FileUtils.fileExists( resourcesDir + "/org/apache/maven/plugin/test/notpackage/test" ) );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testResourceSystemProperties_Filtering()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "resourceSystemProperties_Filtering" );
+        List resources = project.getBuild().getResources();
+
+        assertNotNull( mojo );
+
+        project.addFile( "file4.txt", "current working directory = ${user.dir}" );
+        project.setResourceFiltering( 0, true );
+        project.setupBuildEnvironment();
+
+        //setVariableValueToObject(mojo,"encoding","UTF-8");
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getOutputDirectory() );
+        setVariableValueToObject( mojo, "filters", new LinkedList() );
+        mojo.execute();
+
+        String resourcesDir = project.getOutputDirectory();
+        String checkString = "current working directory = " + (String) System.getProperty( "user.dir" );
+
+        assertTrue( FileUtils.fileExists( resourcesDir + "/file4.txt" ) );
+        assertTrue( fileContains( resourcesDir + "/file4.txt", checkString ) );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testResourceProjectProperties_Filtering()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "resourceProjectProperties_Filtering" );
+        List resources = project.getBuild().getResources();
+
+        assertNotNull( mojo );
+
+        project.addFile( "file4.txt", "current working directory = ${user.dir}" );
+        project.setResourceFiltering( 0, true );
+        project.addProperty( "user.dir", "FPJ kami!!!" );
+        project.setupBuildEnvironment();
+
+        //setVariableValueToObject(mojo,"encoding","UTF-8");
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getOutputDirectory() );
+        setVariableValueToObject( mojo, "filters", new LinkedList() );
+        mojo.execute();
+
+        String resourcesDir = project.getOutputDirectory();
+        String checkString = "current working directory = FPJ kami!!!";
+
+        assertTrue( FileUtils.fileExists( resourcesDir + "/file4.txt" ) );
+        assertTrue( fileContains( resourcesDir + "/file4.txt", checkString ) );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testProjectProperty_Filtering_PropertyDestination()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+        MavenProjectResourcesStub project =
+            new MavenProjectResourcesStub( "resourcePojectProperty_Filtering_PropertyDestination" );
+        List resources = project.getBuild().getResources();
+
+        assertNotNull( mojo );
+
+        project.addFile( "file4.properties", "current working directory=${description}" );
+        project.setResourceFiltering( 0, true );
+        project.setupBuildEnvironment();
+
+        // setup dummy property
+        project.setDescription( "c:\\\\org\\apache\\test" );
+
+        //setVariableValueToObject(mojo,"encoding","UTF-8");
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getOutputDirectory() );
+        setVariableValueToObject( mojo, "filters", new LinkedList() );
+        mojo.execute();
+
+        String resourcesDir = project.getOutputDirectory();
+        String checkString = "current working directory=c\\:\\\\\\\\org\\\\apache\\\\test";
+
+        assertTrue( FileUtils.fileExists( resourcesDir + "/file4.properties" ) );
+        assertTrue( fileContains( resourcesDir + "/file4.properties", checkString ) );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testPropertyFiles_Filtering()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "resourcePropertyFiles_Filtering" );
+        List resources = project.getBuild().getResources();
+        LinkedList filterList = new LinkedList();
+
+        assertNotNull( mojo );
+
+        project.addFile( "file4.properties", "current working directory=${dir}" );
+        project.addFile( "filter.properties", "dir:testdir" );
+        project.setResourceFiltering( 0, true );
+        project.setupBuildEnvironment();
+        filterList.add( project.getResourcesDirectory() + "filter.properties" );
+
+        //setVariableValueToObject(mojo,"encoding","UTF-8");
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getOutputDirectory() );
+        setVariableValueToObject( mojo, "filters", filterList );
+        mojo.execute();
+
+        String resourcesDir = project.getOutputDirectory();
+        String checkString = "current working directory=testdir";
+
+        assertTrue( FileUtils.fileExists( resourcesDir + "/file4.properties" ) );
+        assertTrue( fileContains( resourcesDir + "/file4.properties", checkString ) );
+    }
+
+    // reads the first line of the file and compares it
+    // with data. returns true if equal
+    private boolean fileContains( String fileName, String data )
+    {
+        boolean bRetVal = false;
+
+        try
+        {
+            File file = new File( fileName );
+            FileReader reader = new FileReader( file );
+            char[] readChar = new char[100];
+            String readString;
+            int readSize;
+
+            readSize = reader.read( readChar );
+            readString = new String( readChar, 0, readSize );
+
+            if ( data.equals( readString ) )
+            {
+                bRetVal = true;
+            }
+        }
+        catch ( IOException io )
+        {
+            // TODO: handle exception
+        }
+
+        return bRetVal;
+    }
+}

Added: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/TestResourcesTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/TestResourcesTest.java?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/TestResourcesTest.java (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/TestResourcesTest.java Wed Apr 26 08:10:43 2006
@@ -0,0 +1,91 @@
+package org.apache.maven.plugin.resources;
+
+/*
+ * Copyright 2001-2006 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.
+ */
+
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.maven.plugin.resources.stub.MavenProjectResourcesStub;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+public class TestResourcesTest
+    extends AbstractMojoTestCase
+{
+    protected final static String defaultPomFilePath = "/target/test-classes/unit/resources-test/plugin-config.xml";
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+    }
+
+    protected void tearDown()
+    {
+
+    }
+
+    /**
+     * test mojo lookup, test harness should be working fine
+     *
+     * @throws Exception
+     */
+    public void testHarnessEnvironment()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "testResources", testPom );
+
+        assertNotNull( mojo );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testTestResourceDirectoryCreation()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        TestResourcesMojo mojo = (TestResourcesMojo) lookupMojo( "testResources", testPom );
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "testResourceDirectoryStructure" );
+        List resources = project.getBuild().getResources();
+
+        assertNotNull( mojo );
+
+        project.addFile( "file4.txt" );
+        project.addFile( "package/file3.nottest" );
+        project.addFile( "notpackage/file1.include" );
+        project.addFile( "package/test/file1.txt" );
+        project.addFile( "notpackage/test/file2.txt" );
+        project.setupBuildEnvironment();
+
+        setVariableValueToObject( mojo, "project", project );
+        setVariableValueToObject( mojo, "resources", resources );
+        setVariableValueToObject( mojo, "outputDirectory", project.getBuild().getTestOutputDirectory() );
+        setVariableValueToObject( mojo, "filters", new LinkedList() );
+        mojo.execute();
+
+        String resorucesDir = project.getTestOutputDirectory();
+
+        assertTrue( FileUtils.fileExists( resorucesDir + "/file4.txt" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/package/file3.nottest" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/notpackage/file1.include" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/package/test" ) );
+        assertTrue( FileUtils.fileExists( resorucesDir + "/notpackage/test" ) );
+    }
+}

Added: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBasicStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBasicStub.java?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBasicStub.java (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBasicStub.java Wed Apr 26 08:10:43 2006
@@ -0,0 +1,108 @@
+package org.apache.maven.plugin.resources.stub;
+
+/*
+ * Copyright 2001-2006 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.
+ */
+
+import java.io.File;
+import java.util.Properties;
+
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+public class MavenProjectBasicStub
+    extends MavenProjectStub
+{
+    protected String identifier;
+
+    protected String testRootDir;
+
+    protected Properties properties;
+
+    protected String description;
+
+    public MavenProjectBasicStub( String id )
+        throws Exception
+    {
+        properties = new Properties();
+        identifier = id;
+        testRootDir = PlexusTestCase.getBasedir() + "/target/test-classes/unit/test-dir/" + identifier;
+
+        if ( !FileUtils.fileExists( testRootDir ) )
+        {
+            FileUtils.mkdir( testRootDir );
+        }
+    }
+
+    public String getName()
+    {
+        return "Test Project " + identifier;
+    }
+
+    public void setDescription( String desc )
+    {
+        description = desc;
+    }
+
+    public String getDescription()
+    {
+        if ( description == null )
+        {
+            return "this is a test project";
+        }
+        else
+        {
+            return description;
+        }
+    }
+
+    public File getBasedir()
+    {
+        // create an isolated environment
+        // see setupTestEnvironment for details
+        return new File( testRootDir );
+    }
+
+    public String getGroupId()
+    {
+        return "org.apache.maven.plugin.test";
+    }
+
+    public String getArtifactId()
+    {
+        return "maven-resource-plugin-test#" + identifier;
+    }
+
+    public String getPackaging()
+    {
+        return "org.apache.maven.plugin.test";
+    }
+
+    public String getVersion()
+    {
+        return identifier;
+    }
+
+    public void addProperty( String key, String value )
+    {
+        properties.put( key, value );
+    }
+
+    public Properties getProperties()
+    {
+        return properties;
+    }
+}

Added: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java Wed Apr 26 08:10:43 2006
@@ -0,0 +1,287 @@
+package org.apache.maven.plugin.resources.stub;
+
+/*
+ * Copyright 2001-2006 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.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.apache.maven.model.Build;
+import org.codehaus.plexus.util.FileUtils;
+
+public class MavenProjectBuildStub
+    extends MavenProjectBasicStub
+{
+    protected Build build;
+
+    protected String srcDirectory;
+
+    protected String targetDirectory;
+
+    protected String buildDirectory;
+
+    protected String outputDirectory;
+
+    protected String testOutputDirectory;
+
+    protected String resourcesDirectory;
+
+    protected String testResourcesDirectory;
+
+    protected String targetResourceDirectory;
+
+    protected String targetTestResourcesDirectory;
+
+    protected ArrayList fileList;
+
+    protected ArrayList directoryList;
+
+    protected HashMap dataMap;
+
+    public MavenProjectBuildStub( String key )
+        throws Exception
+    {
+        super( key );
+
+        build = new Build();
+        fileList = new ArrayList();
+        directoryList = new ArrayList();
+        dataMap = new HashMap();
+        setupBuild();
+    }
+
+    public void addDirectory( String name )
+    {
+        if ( isValidPath( name ) )
+        {
+            directoryList.add( name );
+        }
+    }
+
+    public void setOutputDirectory( String dir )
+    {
+        outputDirectory = buildDirectory + "/" + dir;
+        build.setOutputDirectory( outputDirectory );
+    }
+
+    public void addFile( String name )
+    {
+        if ( isValidPath( name ) )
+        {
+            fileList.add( name );
+        }
+    }
+
+    public void addFile( String name, String data )
+    {
+        File fileName = new File( name );
+
+        addFile( name );
+        dataMap.put( fileName.getName(), data );
+    }
+
+    public String getOutputDirectory()
+    {
+        return outputDirectory;
+    }
+
+    public String getTestOutputDirectory()
+    {
+        return testOutputDirectory;
+    }
+
+    public String getResourcesDirectory()
+    {
+        return resourcesDirectory;
+    }
+
+    public String getTestResourcesDirectory()
+    {
+        return testResourcesDirectory;
+    }
+
+    public Build getBuild()
+    {
+        return build;
+    }
+
+    /**
+     * returns true if the path is relative
+     * and false if absolute
+     * also returns false if it is relative to
+     * the parent
+     *
+     * @param path
+     * @return
+     */
+    private boolean isValidPath( String path )
+    {
+        boolean bRetVal = true;
+
+        if ( path.startsWith( "c:" ) || path.startsWith( ".." ) || path.startsWith( "/" ) || path.startsWith( "\\" ) )
+        {
+            bRetVal = false;
+        }
+
+        return bRetVal;
+    }
+
+    private void setupBuild()
+    {
+        // check getBasedir method for the exact path
+        // we need to recreate the dir structure in 
+        // an isolated environment
+        srcDirectory = testRootDir + "/src";
+        buildDirectory = testRootDir + "/target";
+        outputDirectory = buildDirectory + "/classes";
+        testOutputDirectory = buildDirectory + "/test-classes";
+        resourcesDirectory = srcDirectory + "/main/resources/";
+        testResourcesDirectory = srcDirectory + "/test/resources/";
+
+        build.setDirectory( buildDirectory );
+        build.setOutputDirectory( outputDirectory );
+        build.setTestOutputDirectory( testOutputDirectory );
+    }
+
+    public void setupBuildEnvironment()
+        throws Exception
+    {
+        // populate dummy resources and dummy test resources
+
+        // setup src dir
+        if ( !FileUtils.fileExists( resourcesDirectory ) )
+        {
+            FileUtils.mkdir( resourcesDirectory );
+        }
+
+        if ( !FileUtils.fileExists( testResourcesDirectory ) )
+        {
+            FileUtils.mkdir( testResourcesDirectory );
+        }
+
+        createDirectories( resourcesDirectory, testResourcesDirectory );
+        createFiles( resourcesDirectory, testResourcesDirectory );
+
+        // setup target dir        
+        if ( !FileUtils.fileExists( outputDirectory ) )
+        {
+            FileUtils.mkdir( outputDirectory );
+        }
+
+        if ( !FileUtils.fileExists( testOutputDirectory ) )
+        {
+            FileUtils.mkdir( testOutputDirectory );
+        }
+    }
+
+    private void createDirectories( String parent, String testparent )
+    {
+        File currentDirectory;
+
+        for ( int nIndex = 0; nIndex < directoryList.size(); nIndex++ )
+        {
+            currentDirectory = new File( parent, "/" + (String) directoryList.get( nIndex ) );
+
+            if ( !currentDirectory.exists() )
+            {
+                currentDirectory.mkdirs();
+            }
+
+            // duplicate dir structure in test resources
+            currentDirectory = new File( testparent, "/" + (String) directoryList.get( nIndex ) );
+
+            if ( !currentDirectory.exists() )
+            {
+                currentDirectory.mkdirs();
+            }
+        }
+    }
+
+    private void createFiles( String parent, String testparent )
+    {
+        File currentFile;
+
+        for ( int nIndex = 0; nIndex < fileList.size(); nIndex++ )
+        {
+            currentFile = new File( parent, (String) fileList.get( nIndex ) );
+
+            // create the necessary parent directories
+            // before we create the files
+            if ( !currentFile.getParentFile().exists() )
+            {
+                currentFile.getParentFile().mkdirs();
+            }
+
+            if ( !currentFile.exists() )
+            {
+                try
+                {
+                    currentFile.createNewFile();
+                    populateFile( currentFile );
+                }
+                catch ( IOException io )
+                {
+                    //TODO: handle exception
+                }
+            }
+
+            // duplicate file in test resources
+            currentFile = new File( testparent, (String) fileList.get( nIndex ) );
+
+            if ( !currentFile.getParentFile().exists() )
+            {
+                currentFile.getParentFile().mkdirs();
+            }
+
+            if ( !currentFile.exists() )
+            {
+                try
+                {
+                    currentFile.createNewFile();
+                    populateFile( currentFile );
+                }
+                catch ( IOException io )
+                {
+                    //TODO: handle exception
+                }
+            }
+        }
+    }
+
+    private void populateFile( File file )
+    {
+        FileOutputStream outputStream;
+        String data = (String) dataMap.get( file.getName() );
+
+        if ( ( data != null ) && file.exists() )
+        {
+            try
+            {
+                outputStream = new FileOutputStream( file );
+                outputStream.write( data.getBytes() );
+                outputStream.flush();
+                outputStream.close();
+            }
+            catch ( IOException ex )
+            {
+                // TODO: handle exception here
+            }
+        }
+    }
+}

Added: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectResourcesStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectResourcesStub.java?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectResourcesStub.java (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectResourcesStub.java Wed Apr 26 08:10:43 2006
@@ -0,0 +1,108 @@
+package org.apache.maven.plugin.resources.stub;
+
+/*
+ * Copyright 2001-2006 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.
+ */
+
+import org.apache.maven.model.Resource;
+
+public class MavenProjectResourcesStub
+    extends MavenProjectBuildStub
+{
+
+    public MavenProjectResourcesStub( String id )
+        throws Exception
+    {
+        super( id );
+        setupResources();
+        setupTestResources();
+    }
+
+    public void addInclude( String pattern )
+    {
+        ( (Resource) build.getResources().get( 0 ) ).addInclude( pattern );
+    }
+
+    public void addExclude( String pattern )
+    {
+        ( (Resource) build.getResources().get( 0 ) ).addExclude( pattern );
+    }
+
+    public void addTestInclude( String pattern )
+    {
+        ( (Resource) build.getTestResources().get( 0 ) ).addInclude( pattern );
+    }
+
+    public void addTestExclude( String pattern )
+    {
+        ( (Resource) build.getTestResources().get( 0 ) ).addExclude( pattern );
+    }
+
+    public void setTargetPath( String path )
+    {
+        ( (Resource) build.getResources().get( 0 ) ).setTargetPath( path );
+    }
+
+    public void setTestTargetPath( String path )
+    {
+        ( (Resource) build.getTestResources().get( 0 ) ).setTargetPath( path );
+    }
+
+    public void setDirectory( String dir )
+    {
+        ( (Resource) build.getResources().get( 0 ) ).setDirectory( dir );
+    }
+
+    public void setTestDirectory( String dir )
+    {
+        ( (Resource) build.getTestResources().get( 0 ) ).setDirectory( dir );
+    }
+
+    public void setResourceFiltering( int nIndex, boolean filter )
+    {
+        if ( build.getResources().size() > nIndex )
+        {
+            ( (Resource) build.getResources().get( nIndex ) ).setFiltering( filter );
+        }
+    }
+
+    private void setupResources()
+    {
+        Resource resource = new Resource();
+
+        // see MavenProjectBasicStub for details 
+        // of getBasedir
+
+        // setup default resources
+        resource.setDirectory( getBasedir().getPath() + "/src/main/resources" );
+        resource.setFiltering( false );
+        resource.setTargetPath( null );
+        build.addResource( resource );
+    }
+
+    private void setupTestResources()
+    {
+        Resource resource = new Resource();
+
+        // see MavenProjectBasicStub for details 
+        // of getBasedir      
+
+        // setup default test resources         
+        resource.setDirectory( getBasedir().getPath() + "/src/test/resources" );
+        resource.setFiltering( false );
+        resource.setTargetPath( null );
+        build.addTestResource( resource );
+    }
+}

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/advance.properties
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/advance.properties?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/advance.properties (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/advance.properties Wed Apr 26 08:10:43 2006
@@ -0,0 +1,6 @@
+key1:value1
+key2:value 2
+key3:value 3
+key4:${key3}
+key5:${key1}.value4
+key6:${key1}_${key3}_value5

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/advance_validation.properties
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/advance_validation.properties?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/advance_validation.properties (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/advance_validation.properties Wed Apr 26 08:10:43 2006
@@ -0,0 +1,6 @@
+key1  : value1
+key2  : value 2
+key3 : value 3
+key4  : value 3
+key5  : value1.value4
+key6  : value1_value 3_value5

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/basic.properties
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/basic.properties?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/basic.properties (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/basic.properties Wed Apr 26 08:10:43 2006
@@ -0,0 +1,5 @@
+key1:value1
+key2:value2
+key3:value3
+key4:value4
+key5:${key4}

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/basic_validation.properties
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/basic_validation.properties?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/basic_validation.properties (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/propertiesutils-test/basic_validation.properties Wed Apr 26 08:10:43 2006
@@ -0,0 +1,5 @@
+key1:value1
+key2:value2
+key3:value3
+key4:value4
+key5:value4

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/plugin-config.xml?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/plugin-config.xml (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/plugin-config.xml Wed Apr 26 08:10:43 2006
@@ -0,0 +1,14 @@
+<project>
+  <description>c:\root\home\my_dir</description>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <configuration>
+            <encoding>UTF-8</encoding>
+            <outputDirectory>${basedir}\target\test-classes\unit\reflectionproperties-test</outputDirectory>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/validation.properties
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/validation.properties?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/validation.properties (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/validation.properties Wed Apr 26 08:10:43 2006
@@ -0,0 +1,4 @@
+project_property:description
+description:c\:\\root\\home\\my_dir
+outputDirectory:\\target\\test-classes\\unit\\reflectionproperties-test
+encoding:UTF-8

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/validation_escapebackslashinpath.properties
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/validation_escapebackslashinpath.properties?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/validation_escapebackslashinpath.properties (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/reflectionproperties-test/validation_escapebackslashinpath.properties Wed Apr 26 08:10:43 2006
@@ -0,0 +1,4 @@
+project_property:description
+description:c\\:\\\\root\\\\home\\\\my_dir
+outputDirectory:\\target\\test-classes\\unit\\reflectionproperties-test
+encoding:UTF-8

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config-absolute-path.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config-absolute-path.xml?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config-absolute-path.xml (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config-absolute-path.xml Wed Apr 26 08:10:43 2006
@@ -0,0 +1,27 @@
+<project>
+  <name>test2</name>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+       <configuration>
+          <outputDirectory>/test-classes/unit/result-dir</outputDirectory>
+        </configuration>        
+      </plugin>
+    </plugins>
+    <resources>
+      <resource>
+        <filtering>false</filtering>
+        <directory>/src/test/resources/unit/test-dir</directory>
+        <includes>
+          **/*.include 
+          **/*.test
+        </includes>
+        <excludes>
+          **/*.exclude 
+          **/*.nottest
+        </excludes>
+      </resource>      
+    </resources>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config-relative-path.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config-relative-path.xml?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config-relative-path.xml (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config-relative-path.xml Wed Apr 26 08:10:43 2006
@@ -0,0 +1,27 @@
+<project>
+  <name>test3</name>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+       <configuration>
+          <outputDirectory>/test-classes/unit/result-dir</outputDirectory>
+        </configuration>        
+      </plugin>
+    </plugins>
+    <resources>
+      <resource>
+        <filtering>false</filtering>
+        <directory>../src/test/resources/unit/test-dir</directory>
+        <includes>
+          **/*.include 
+          **/*.test
+        </includes>
+        <excludes>
+          **/*.exclude 
+          **/*.nottest
+        </excludes>
+      </resource>      
+    </resources>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config.xml?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config.xml (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/plugin-config.xml Wed Apr 26 08:10:43 2006
@@ -0,0 +1,27 @@
+<project>
+  <name>test1</name>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <configuration>
+          <outputDirectory>/test-classes/unit/resources-test</outputDirectory>
+        </configuration>
+      </plugin>
+    </plugins>
+    <resources>
+      <resource>
+        <filtering>false</filtering>
+        <directory>/test/resources/unit/test-dir</directory>
+        <includes>
+          **/*.include 
+          **/*.test
+        </includes>
+        <excludes>
+          **/**.exclude 
+          **/*.nottest
+        </excludes>
+      </resource>      
+    </resources>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/validation.properties
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/validation.properties?rev=397215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/validation.properties (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/resources/unit/resources-test/validation.properties Wed Apr 26 08:10:43 2006
@@ -0,0 +1,3 @@
+test1 : C\:\\Source\\maven_core\\plugins\\maven-resources-plugin\\target\\test-classes\\unit\\test-dir\\package\test   
+test2 :
+test3 :