You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ma...@apache.org on 2007/10/13 17:53:30 UTC

svn commit: r584417 - /maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java

Author: mauro
Date: Sat Oct 13 08:53:29 2007
New Revision: 584417

URL: http://svn.apache.org/viewvc?rev=584417&view=rev
Log:
MRESOURCES-47:  added test left out in patch application.

Modified:
    maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java

Modified: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java?rev=584417&r1=584416&r2=584417&view=diff
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java (original)
+++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java Sat Oct 13 08:53:29 2007
@@ -416,6 +416,43 @@
     }
 
     /**
+     * Validates that a Filter token containing a project property will be
+     * resolved before the Filter is applied to the resources.
+     * 
+     * @throws Exception
+     */
+    public void testPropertyFiles_Filtering_TokensInFilters() 
+        throws Exception
+    {
+        final File testPom = new File(getBasedir(), defaultPomFilePath);
+        final ResourcesMojo mojo = (ResourcesMojo) lookupMojo("resources", testPom);
+        final MavenProjectResourcesStub project = new MavenProjectResourcesStub(
+                "resourcePropertyFiles_Filtering_TokensInFilters");
+        final List resources = project.getBuild().getResources();
+        final LinkedList filterList = new LinkedList();
+
+        assertNotNull(mojo);
+
+        project.addFile("file4.properties", "current working directory=${filter.token}");
+        project.addFile("filter.properties", "filter.token=${pom-property}");
+        project.setResourceFiltering(0, true);
+        project.addProperty("pom-property", "foobar");
+        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();
+        final String resourcesDir = project.getOutputDirectory();
+        final String checkString = "current working directory=foobar";
+
+        assertContent(resourcesDir + "/file4.properties", checkString);
+    }    
+    
+    /**
      * Ensures the file exists and its first line equals the given data.
      */
     private void assertContent( String fileName, String data )