You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sn...@apache.org on 2007/08/12 12:26:18 UTC

svn commit: r565036 [2/2] - in /maven/plugins/trunk/maven-war-plugin: ./ src/main/java/org/apache/maven/plugin/war/ src/main/java/org/apache/maven/plugin/war/overlay/ src/main/java/org/apache/maven/plugin/war/packaging/ src/main/java/org/apache/maven/p...

Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java?view=diff&rev=565036&r1=565035&r2=565036
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java Sun Aug 12 03:26:14 2007
@@ -21,7 +21,9 @@
 
 import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.plugin.testing.stubs.ArtifactStub;
+import org.apache.maven.plugin.war.stub.AarArtifactStub;
 import org.apache.maven.plugin.war.stub.EJBArtifactStub;
+import org.apache.maven.plugin.war.stub.EJBArtifactStubWithClassifier;
 import org.apache.maven.plugin.war.stub.EJBClientArtifactStub;
 import org.apache.maven.plugin.war.stub.IncludeExcludeWarArtifactStub;
 import org.apache.maven.plugin.war.stub.JarArtifactStub;
@@ -29,10 +31,8 @@
 import org.apache.maven.plugin.war.stub.MavenProjectBasicStub;
 import org.apache.maven.plugin.war.stub.PARArtifactStub;
 import org.apache.maven.plugin.war.stub.ResourceStub;
-import org.apache.maven.plugin.war.stub.SimpleWarArtifactStub;
 import org.apache.maven.plugin.war.stub.TLDArtifactStub;
-import org.apache.maven.plugin.war.stub.EJBArtifactStubWithClassifier;
-import org.apache.maven.plugin.war.stub.AarArtifactStub;
+import org.apache.maven.plugin.war.stub.WarArtifactStub;
 import org.codehaus.plexus.util.FileUtils;
 
 import java.io.BufferedReader;
@@ -44,26 +44,17 @@
 import java.util.Locale;
 
 public class WarExplodedMojoTest
-    extends AbstractWarMojoTest
+    extends AbstractWarExplodedMojoTest
 {
-    protected static final String pomFilePath =
-        getBasedir() + "/target/test-classes/unit/warexplodedmojo/plugin-config.xml";
-
-    private WarExplodedMojo mojo;
 
-    protected File getTestDirectory()
-        throws Exception
+    protected File getPomFile()
     {
-        return new File( getBasedir(), "target/test-classes/unit/warexplodedmojo/test-dir" );
+        return new File( getBasedir(), "/target/test-classes/unit/warexplodedmojo/plugin-config.xml" );
     }
 
-    public void setUp()
-        throws Exception
+    protected File getTestDirectory()
     {
-        super.setUp();
-
-        mojo = (WarExplodedMojo) lookupMojo( "exploded", pomFilePath );
-        assertNotNull( mojo );
+        return new File( getBasedir(), "target/test-classes/unit/warexplodedmojo/test-dir" );
     }
 
     /**
@@ -84,8 +75,8 @@
 
         createFile( sampleResource );
 
-        assertTrue("sampeResource not found",sampleResource.exists());
-      
+        assertTrue( "sampeResource not found", sampleResource.exists() );
+
         // configure mojo
         resources[0].setDirectory( webAppResource.getAbsolutePath() );
         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
@@ -104,7 +95,7 @@
         assertTrue( "resources doesn't exist: " + expectedWebResourceFile, expectedWebResourceFile.exists() );
         assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() );
         assertTrue( "META-INF not found", expectedMETAINFDir.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
@@ -131,7 +122,7 @@
 
         // configure mojo
         resources[0].setDirectory( webAppResource.getAbsolutePath() );
-        resources[0].setTargetPath("targetPath");
+        resources[0].setTargetPath( "targetPath" );
         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
         setVariableValueToObject( mojo, "webResources", resources );
         mojo.execute();
@@ -148,13 +139,13 @@
         assertTrue( "resources doesn't exist: " + expectedWebResourceFile, expectedWebResourceFile.exists() );
         assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() );
         assertTrue( "META-INF not found", expectedMETAINFDir.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
-        expectedWebResourceFile.delete();        
-    }    
-    
+        expectedWebResourceFile.delete();
+    }
+
     /**
      * @throws Exception
      */
@@ -185,10 +176,10 @@
         assertTrue( "WEB XML not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists() );
         assertTrue( "META-INF not found", expectedMETAINFDir.exists() );
         assertEquals( "WEB XML not correct", mojo.getWebXml().toString(), FileUtils.fileRead( expectedWEBXMLFile ) );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
-        expectedWebSource2File.delete();      
+        expectedWebSource2File.delete();
         expectedWEBXMLFile.delete();
         expectedMETAINFDir.delete();
     }
@@ -223,12 +214,12 @@
         assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() );
         assertTrue( "Container Config XML not found:" + expectedContainerConfigXMLFile.toString(),
                     expectedContainerConfigXMLFile.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
-        expectedWebSource2File.delete();    
-        expectedContainerConfigXMLFile.delete();        
-        expectedWEBINFDir.delete();        
+        expectedWebSource2File.delete();
+        expectedContainerConfigXMLFile.delete();
+        expectedWEBINFDir.delete();
     }
 
     /**
@@ -239,29 +230,28 @@
     {
         // setup test data
         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
-        SimpleWarArtifactStub simpleWarArtifact = new SimpleWarArtifactStub( getBasedir() );
+        WarArtifactStub warArtifact = new WarArtifactStub( getBasedir() );
 
         String testId = "ExplodedWar_WithSimpleExternalWARFile";
         File webAppDirectory = new File( getTestDirectory(), testId );
         File webAppSource = createWebAppSource( testId );
         File classesDir = createClassesDir( testId, true );
         File workDirectory = new File( getTestDirectory(), "/war/work-" + testId );
-        File simpleWarFile = simpleWarArtifact.getFile();
+        File simpleWarFile = warArtifact.getFile();
 
         assertTrue( "simple war not found: " + simpleWarFile.toString(), simpleWarFile.exists() );
 
         createDir( workDirectory );
 
         // configure mojo
-        project.addArtifact( simpleWarArtifact );
+        project.addArtifact( warArtifact );
         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
         setVariableValueToObject( mojo, "workDirectory", workDirectory );
         mojo.execute();
 
-        // validate operation
+        // validate operation - META-INF is automatically excluded so remove the file from the list
         File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
         File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
-        File expectedManifestFile = new File( webAppDirectory, "META-INF/MANIFEST.MF" );
         File expectedWEBXMLFile = new File( webAppDirectory, "WEB-INF/web.xml" );
         File expectedWARFile = new File( webAppDirectory, "/org/sample/company/test.jsp" );
 
@@ -269,13 +259,11 @@
         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
         // check simple.war in the unit test dir under resources to verify the list of files
         assertTrue( "web xml not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists() );
-        assertTrue( "manifest file not found: " + expectedManifestFile.toString(), expectedManifestFile.exists() );
         assertTrue( "war file not found: " + expectedWARFile.toString(), expectedWARFile.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
-        expectedManifestFile.delete();
         expectedWEBXMLFile.delete();
         expectedWARFile.delete();
     }
@@ -288,11 +276,11 @@
     {
         // setup test data
         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
-        SimpleWarArtifactStub simpleWarArtifact = new SimpleWarArtifactStub( getBasedir() );
+        WarArtifactStub warArtifact = new WarArtifactStub( getBasedir() );
 
         String testId = "testExplodedWarMergeWarLocalFileOverride";
         File webAppDirectory = new File( getTestDirectory(), testId );
-        File webAppSource = new File( getTestDirectory(), "/" + testId + "-test-data/source" );
+        File webAppSource = getWebAppSource( testId );
         File simpleJSP = new File( webAppSource, "org/sample/company/test.jsp" );
         createFile( simpleJSP );
 
@@ -302,7 +290,7 @@
         File classesDir = createClassesDir( testId, true );
 
         // configure mojo
-        project.addArtifact( simpleWarArtifact );
+        project.addArtifact( warArtifact );
         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
         setVariableValueToObject( mojo, "workDirectory", workDirectory );
         mojo.execute();
@@ -318,71 +306,73 @@
         simpleJSP.setLastModified( time );
         expectedFile.setLastModified( time );
 
-        project.addArtifact( simpleWarArtifact );
+        project.addArtifact( warArtifact );
         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
         setVariableValueToObject( mojo, "workDirectory", workDirectory );
         mojo.execute();
 
         assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
         assertEquals( "file incorrect", simpleJSP.toString(), FileUtils.fileRead( expectedFile ) );
-        
-        // house keeping
-        expectedFile.delete();
-    }
 
-    /**
-     * Merge a dependent WAR that gets updated since the last run.
-     */
-    public void testExplodedWarMergeWarUpdated()
-        throws Exception
-    {
-        // setup test data
-        MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
-        SimpleWarArtifactStub simpleWarArtifact = new SimpleWarArtifactStub( getBasedir() );
-
-        String testId = "testExplodedWarMergeWarUpdated";
-        File webAppDirectory = new File( getTestDirectory(), testId );
-        FileUtils.deleteDirectory( webAppDirectory );
-
-        File webAppSource = new File( getTestDirectory(), "/" + testId + "-test-data/source" );
-
-        File workDirectory = new File( getTestDirectory(), "/war/work-" + testId );
-        createDir( workDirectory );
-
-        File classesDir = createClassesDir( testId, true );
-
-        // configure mojo
-        project.addArtifact( simpleWarArtifact );
-        this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
-        setVariableValueToObject( mojo, "workDirectory", workDirectory );
-        mojo.execute();
-
-        // validate operation
-        File expectedFile = new File( webAppDirectory, "/org/sample/company/test.jsp" );
-
-        assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
-        assertEquals( "file incorrect", "", FileUtils.fileRead( expectedFile ) );
-
-        // update file, so the local one is older
-        simpleWarArtifact.setFile( new File( simpleWarArtifact.getFile().getParentFile(), "simple-updated.war" ) );
-
-        mojo.execute();
-
-        assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
-        assertEquals( "file incorrect", "updated\n", FileUtils.fileRead( expectedFile ) );
-
-        // update file, so the local one is newer
-        simpleWarArtifact.setFile( new File( simpleWarArtifact.getFile().getParentFile(), "simple.war" ) );
-
-        mojo.execute();
-
-        assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
-        assertEquals( "file incorrect", "updated\n", FileUtils.fileRead( expectedFile ) );
-        
         // house keeping
         expectedFile.delete();
     }
 
+//    The last modified thingy behavior is not applicable anymore. This is the only test that
+//    has been removed.
+//    /**
+//     * Merge a dependent WAR that gets updated since the last run.
+//     */
+//    public void testExplodedWarMergeWarUpdated()
+//        throws Exception
+//    {
+//        // setup test data
+//        MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
+//        WarArtifactStub warArtifact = new WarArtifactStub( getBasedir() );
+//
+//        String testId = "testExplodedWarMergeWarUpdated";
+//        File webAppDirectory = new File( getTestDirectory(), testId );
+//        FileUtils.deleteDirectory( webAppDirectory );
+//
+//        File webAppSource = getWebAppSource( testId );
+//
+//        File workDirectory = new File( getTestDirectory(), "/war/work-" + testId );
+//        createDir( workDirectory );
+//
+//        File classesDir = createClassesDir( testId, true );
+//
+//        // configure mojo
+//        project.addArtifact( warArtifact );
+//        this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
+//        setVariableValueToObject( mojo, "workDirectory", workDirectory );
+//        mojo.execute();
+//
+//        // validate operation
+//        File expectedFile = new File( webAppDirectory, "/org/sample/company/test.jsp" );
+//
+//        assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
+//        assertEquals( "file incorrect", "", FileUtils.fileRead( expectedFile ) );
+//
+//        // update file, so the local one is older
+//        warArtifact.setFile( new File( warArtifact.getFile().getParentFile(), "simple-updated.war" ) );
+//
+//        mojo.execute();
+//
+//        assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
+//        assertEquals( "file incorrect", "updated\n", FileUtils.fileRead( expectedFile ) );
+//
+//        // update file, so the local one is newer
+//        warArtifact.setFile( new File( warArtifact.getFile().getParentFile(), "simple.war" ) );
+//
+//        mojo.execute();
+//
+//        assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
+//        assertEquals( "file incorrect", "updated\n", FileUtils.fileRead( expectedFile ) );
+//
+//        // house keeping
+//        expectedFile.delete();
+//    }
+
     /**
      * @throws Exception
      */
@@ -415,7 +405,7 @@
         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
         assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
@@ -451,7 +441,7 @@
         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
         assertTrue( "jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
@@ -489,9 +479,9 @@
         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
         assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
-        
+
         // house keeping
-        expectedWebSourceFile.delete();        
+        expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
         expectedEJBArtifact.delete();
     }
@@ -527,9 +517,9 @@
         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
         assertTrue( "tld artifact not found: " + expectedTLDArtifact.toString(), expectedTLDArtifact.exists() );
-        
+
         // house keeping
-        expectedWebSourceFile.delete();        
+        expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
         expectedTLDArtifact.delete();
     }
@@ -565,7 +555,7 @@
         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
         assertTrue( "par artifact not found: " + expectedPARArtifact.toString(), expectedPARArtifact.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
@@ -648,7 +638,7 @@
         assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
         assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(),
                     expectedEJBDupArtifact.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
@@ -735,7 +725,7 @@
         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
         assertTrue( "classes not found: " + expectedClass.toString(), expectedClass.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
@@ -825,7 +815,7 @@
 
         assertEquals( "error in filtering using System properties", "system_property=new-system-property-value",
                       reader.readLine() );
-        
+
         // update property, and generate again
         File filterFile = new File( getTestDirectory(), testId + "-test-data/filters/filter.properties" );
         createFile( filterFile );
@@ -853,14 +843,13 @@
         assertEquals( "error in filtering using System properties", "system_property=new-system-property-value",
                       reader.readLine() );
 
-        
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
         expectedResourceFile.delete();
         expectedResourceWDirFile.delete();
     }
-    
+
     public void testExplodedWar_WithSourceIncludeExclude()
         throws Exception
     {
@@ -887,7 +876,7 @@
         assertFalse( "source files found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
         assertTrue( "WEB XML not found: " + expectedWEBXMLDir.toString(), expectedWEBXMLDir.exists() );
         assertTrue( "META-INF not found", expectedMETAINFDir.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
@@ -930,18 +919,18 @@
 
         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
-        // check include-exclude.war in the unit test dir under resources to verify the list of files  
+        // check include-exclude.war in the unit test dir under resources to verify the list of files
         assertTrue( "web xml not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists() );
         assertFalse( "manifest file found: " + expectedManifestFile.toString(), expectedManifestFile.exists() );
         assertTrue( "war file not found: " + expectedIncludedWARFile.toString(), expectedIncludedWARFile.exists() );
         assertFalse( "war file not found: " + expectedExcludedWarfile.toString(), expectedExcludedWarfile.exists() );
-        
+
         // house keeping
         expectedWebSourceFile.delete();
         expectedWebSource2File.delete();
         expectedManifestFile.delete();
         expectedWEBXMLFile.delete();
-        expectedIncludedWARFile.delete();        
+        expectedIncludedWARFile.delete();
         expectedExcludedWarfile.delete();
     }
 
@@ -979,17 +968,18 @@
         assertFalse( "source files not updated with new copy: " + expectedWebSourceFile.toString(),
                      "error".equals( FileUtils.fileRead( expectedWebSourceFile ) ) );
 
-// TODO: uncomment when lastModified problem is resolved
-//        FileWriter writer = new FileWriter(expectedWebSourceFile);
-//
-//        // 2nd phase destination is newer than source
-//        // destination should not be replaced with an blank source
-//        writer.write("newdata");
-//        mojo.execute();
-//        reader = new FileReader(expectedWebSourceFile);
-//        reader.read(data);
-//        assertTrue("source file updated with old copy: " +expectedWebSourceFile.toString(),String.valueOf(data).equals("newdata") );    }
-        
+        // TODO: uncomment when lastModified problem is resolved
+        // FileWriter writer = new FileWriter(expectedWebSourceFile);
+        //
+        // // 2nd phase destination is newer than source
+        // // destination should not be replaced with an blank source
+        // writer.write("newdata");
+        // mojo.execute();
+        // reader = new FileReader(expectedWebSourceFile);
+        // reader.read(data);
+        // assertTrue("source file updated with old copy: "
+        // +expectedWebSourceFile.toString(),String.valueOf(data).equals("newdata") ); }
+
         // house keeping
         expectedWEBINFDir.delete();
         expectedMETAINFDir.delete();
@@ -1014,7 +1004,7 @@
 
         // configure mojo
         project.addArtifact( jarArtifact );
-        mojo.setOutputFileNameMapping( "${artifactId}.${extension}");
+        mojo.setOutputFileNameMapping( "${artifactId}.${extension}" );
         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
         mojo.execute();
 
@@ -1035,51 +1025,56 @@
     }
 
     /**
-        * @throws Exception
-        */
-       public void testExplodedWarWithOutputFileNameMappingAndDuplicateDependencies()
-           throws Exception
-       {
-           // setup test data
-           String testId = "ExplodedWarWithFileNameMappingAndDuplicateDependencies";
-           MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
-           File webAppDirectory = new File( getTestDirectory(), testId );
-           File webAppSource = createWebAppSource( testId );
-           File classesDir = createClassesDir( testId, true );
-           EJBArtifactStub ejbArtifact = new EJBArtifactStub( getBasedir() );
-           EJBArtifactStub ejbArtifactDup = new EJBArtifactStub( getBasedir() );
-           File ejbFile = ejbArtifact.getFile();
-
-           // ejbArtifact has a hard coded file, only one assert is needed
-           assertTrue( "ejb not found: " + ejbFile.getAbsolutePath(), ejbFile.exists() );
-
-           // configure mojo
-           ejbArtifact.setGroupId( "org.sample.ejb" );
-           ejbArtifactDup.setGroupId( "org.dup.ejb" );
-           project.addArtifact( ejbArtifact );
-           project.addArtifact( ejbArtifactDup );
-           mojo.setOutputFileNameMapping( "${artifactId}.${extension}");
-           this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
-           mojo.execute();
-
-           // validate operation
-           File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
-           File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
-           // final name form is <artifactId>-<version>.<type>
-           File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/org.sample.ejb-ejbartifact.jar" );
-           File expectedEJBDupArtifact = new File( webAppDirectory, "WEB-INF/lib/org.dup.ejb-ejbartifact.jar" );
-
-           assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
-           assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
-           assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
-           assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(),
-                       expectedEJBDupArtifact.exists() );
-
-           // house keeping
-           expectedWebSourceFile.delete();
-           expectedWebSource2File.delete();
-           expectedEJBArtifact.delete();
-           expectedEJBDupArtifact.delete();
-       }
+     * @throws Exception
+     */
+    public void testExplodedWarWithOutputFileNameMappingAndDuplicateDependencies()
+        throws Exception
+    {
+        // setup test data
+        String testId = "ExplodedWarWithFileNameMappingAndDuplicateDependencies";
+        MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
+        File webAppDirectory = new File( getTestDirectory(), testId );
+        File webAppSource = createWebAppSource( testId );
+        File classesDir = createClassesDir( testId, true );
+        EJBArtifactStub ejbArtifact = new EJBArtifactStub( getBasedir() );
+        EJBArtifactStub ejbArtifactDup = new EJBArtifactStub( getBasedir() );
+        File ejbFile = ejbArtifact.getFile();
+
+        // ejbArtifact has a hard coded file, only one assert is needed
+        assertTrue( "ejb not found: " + ejbFile.getAbsolutePath(), ejbFile.exists() );
+
+        // configure mojo
+        ejbArtifact.setGroupId( "org.sample.ejb" );
+        ejbArtifactDup.setGroupId( "org.dup.ejb" );
+        project.addArtifact( ejbArtifact );
+        project.addArtifact( ejbArtifactDup );
+        mojo.setOutputFileNameMapping( "${artifactId}.${extension}" );
+        this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
+        mojo.execute();
+
+        // validate operation
+        File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
+        File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
+        // final name form is <artifactId>-<version>.<type>
+        File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/org.sample.ejb-ejbartifact.jar" );
+        File expectedEJBDupArtifact = new File( webAppDirectory, "WEB-INF/lib/org.dup.ejb-ejbartifact.jar" );
+
+        assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
+        assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
+        assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
+        assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(),
+                    expectedEJBDupArtifact.exists() );
+
+        // house keeping
+        expectedWebSourceFile.delete();
+        expectedWebSource2File.delete();
+        expectedEJBArtifact.delete();
+        expectedEJBDupArtifact.delete();
+    }
+
+    /* --------------------- 2.1 Overlay tests ----------------------------------- */
+
+    /*---------------------------*/
+
 
 }

Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarMojoTest.java?view=diff&rev=565036&r1=565035&r2=565036
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarMojoTest.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarMojoTest.java Sun Aug 12 03:26:14 2007
@@ -21,7 +21,7 @@
 
 import org.apache.maven.plugin.war.stub.MavenProject4CopyConstructor;
 import org.apache.maven.plugin.war.stub.ProjectHelperStub;
-import org.apache.maven.plugin.war.stub.SimpleWarArtifact4CCStub;
+import org.apache.maven.plugin.war.stub.WarArtifact4CCStub;
 import org.codehaus.plexus.util.IOUtil;
 
 import java.io.File;
@@ -70,7 +70,7 @@
         MavenProject4CopyConstructor project = new MavenProject4CopyConstructor();
         String outputDir = getTestDirectory().getAbsolutePath() + "/" + testId + "-output";
         File webAppDirectory = new File( getTestDirectory(), testId );
-        SimpleWarArtifact4CCStub warArtifact = new SimpleWarArtifact4CCStub( getBasedir() );
+        WarArtifact4CCStub warArtifact = new WarArtifact4CCStub( getBasedir() );
         String warName = "simple";
         File webAppSource = createWebAppSource( testId );
         File classesDir = createClassesDir( testId, true );
@@ -120,7 +120,7 @@
         MavenProject4CopyConstructor project = new MavenProject4CopyConstructor();
         String outputDir = getTestDirectory().getAbsolutePath() + "/" + testId + "-output";
         File webAppDirectory = new File( getTestDirectory(), testId );
-        SimpleWarArtifact4CCStub warArtifact = new SimpleWarArtifact4CCStub( getBasedir() );
+        WarArtifact4CCStub warArtifact = new WarArtifact4CCStub( getBasedir() );
         ProjectHelperStub projectHelper = new ProjectHelperStub();
         String warName = "simple";
         File webAppSource = createWebAppSource( testId );
@@ -172,7 +172,7 @@
         MavenProject4CopyConstructor project = new MavenProject4CopyConstructor();
         String outputDir = getTestDirectory().getAbsolutePath() + "/" + testId + "-output";
         File webAppDirectory = new File( getTestDirectory(), testId );
-        SimpleWarArtifact4CCStub warArtifact = new SimpleWarArtifact4CCStub( getBasedir() );
+        WarArtifact4CCStub warArtifact = new WarArtifact4CCStub( getBasedir() );
         ProjectHelperStub projectHelper = new ProjectHelperStub();
         String warName = "simple";
         File webAppSource = createWebAppSource( testId );
@@ -229,7 +229,7 @@
         MavenProject4CopyConstructor project = new MavenProject4CopyConstructor();
         String outputDir = getTestDirectory().getAbsolutePath() + "/" + testId + "-output";
         File webAppDirectory = new File( getTestDirectory(), testId );
-        SimpleWarArtifact4CCStub warArtifact = new SimpleWarArtifact4CCStub( getBasedir() );
+        WarArtifact4CCStub warArtifact = new WarArtifact4CCStub( getBasedir() );
         ProjectHelperStub projectHelper = new ProjectHelperStub();
         String warName = "simple";
         File webAppSource = createWebAppSource( testId );

Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AbstractArtifactStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AbstractArtifactStub.java?view=diff&rev=565036&r1=565035&r2=565036
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AbstractArtifactStub.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AbstractArtifactStub.java Sun Aug 12 03:26:14 2007
@@ -53,4 +53,104 @@
     {
         return new DefaultArtifactHandler( getType() );
     }
+
+    /*
+     * TODO: Coppied from org/apache/maven/artifact/DefaultArtifact.java; Consider merging...
+     */
+    public int compareTo( Object o )
+    {
+        Artifact a = (Artifact) o;
+
+        /* -- We need to support groupId=null (it is missing in DefaultArtifact.java) */
+        int result;
+        if ( a.getGroupId() != null )
+        {
+            result = getGroupId().compareTo( a.getGroupId() );
+        }
+        else
+        {
+            result = ( getGroupId() == null ? 0 : -1 );
+        }
+        /* -- */
+
+        if ( result == 0 )
+        {
+            result = getArtifactId().compareTo( a.getArtifactId() );
+            if ( result == 0 )
+            {
+                result = getType().compareTo( a.getType() );
+                if ( result == 0 )
+                {
+                    if ( getClassifier() == null )
+                    {
+                        if ( a.getClassifier() != null )
+                        {
+                            result = 1;
+                        }
+                    }
+                    else
+                    {
+                        if ( a.getClassifier() != null )
+                        {
+                            result = getClassifier().compareTo( a.getClassifier() );
+                        }
+                        else
+                        {
+                            result = -1;
+                        }
+                    }
+                    if ( result == 0 )
+                    {
+                        // We don't consider the version range in the comparison, just the resolved version
+                        result = getVersion().compareTo( a.getVersion() );
+                    }
+                }
+            }
+        }
+        return result;
+    }
+
+    /*
+     * TODO: Coppied from org/apache/maven/artifact/DefaultArtifact.java; Consider merging...
+     */
+    public boolean equals( Object o )
+    {
+        if ( o == this )
+        {
+            return true;
+        }
+
+        if ( !( o instanceof Artifact ) )
+        {
+            return false;
+        }
+
+        Artifact a = (Artifact) o;
+
+        /* -- We need to support groupId=null (it is missing in DefaultArtifact.java) */
+        if ( a.getGroupId() == null ? ( getGroupId() != null ) : a.getGroupId().equals( getGroupId() ) )
+        {
+            return false;
+        }
+        else if ( !a.getArtifactId().equals( getArtifactId() ) )
+        {
+            return false;
+        }
+        else if ( !a.getVersion().equals( getVersion() ) )
+        {
+            return false;
+        }
+        else if ( !a.getType().equals( getType() ) )
+        {
+            return false;
+        }
+        else if ( a.getClassifier() == null ? getClassifier() != null : !a.getClassifier().equals( getClassifier() ) )
+        {
+            return false;
+        }
+
+        // We don't consider the version range in the comparison, just the resolved version
+
+        return true;
+    }
 }

Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/IncludeExcludeWarArtifactStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/IncludeExcludeWarArtifactStub.java?view=diff&rev=565036&r1=565035&r2=565036
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/IncludeExcludeWarArtifactStub.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/IncludeExcludeWarArtifactStub.java Sun Aug 12 03:26:14 2007
@@ -22,11 +22,12 @@
 import java.io.File;
 
 public class IncludeExcludeWarArtifactStub
-    extends SimpleWarArtifactStub
+    extends WarArtifactStub
 {
     public IncludeExcludeWarArtifactStub( String id )
     {
         super( id );
+        setGroupId( "wartests" );
     }
 
     public String getArtifactId()

Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectArtifactsStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectArtifactsStub.java?view=diff&rev=565036&r1=565035&r2=565036
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectArtifactsStub.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectArtifactsStub.java Sun Aug 12 03:26:14 2007
@@ -22,19 +22,19 @@
 import org.apache.maven.plugin.testing.stubs.ArtifactStub;
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.TreeSet;
 
 public class MavenProjectArtifactsStub
     extends MavenProjectBasicStub
 {
-    HashSet artifacts;
+    TreeSet artifacts;
 
     public MavenProjectArtifactsStub()
         throws Exception
     {
-        artifacts = new HashSet();
+        artifacts = new TreeSet();
     }
 
     public void addArtifact( ArtifactStub stub )

Copied: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifact4CCStub.java (from r565032, maven/plugins/branches/MWAR-97-2/src/test/java/org/apache/maven/plugin/war/stub/WarArtifact4CCStub.java)
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifact4CCStub.java?view=diff&rev=565036&p1=maven/plugins/branches/MWAR-97-2/src/test/java/org/apache/maven/plugin/war/stub/WarArtifact4CCStub.java&r1=565032&p2=maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifact4CCStub.java&r2=565036
==============================================================================
--- maven/plugins/branches/MWAR-97-2/src/test/java/org/apache/maven/plugin/war/stub/WarArtifact4CCStub.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifact4CCStub.java Sun Aug 12 03:26:14 2007
@@ -24,10 +24,8 @@
 import org.apache.maven.artifact.versioning.VersionRange;
 
 /**
- * 
- *  stub for copy constructor
- *  to preven the copy constructor frow blowing up
- *
+ * stub for copy constructor
+ * to preven the copy constructor frow blowing up
  */
 public class WarArtifact4CCStub
     extends WarArtifactStub

Propchange: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifact4CCStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifact4CCStub.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifactStub.java (from r565032, maven/plugins/branches/MWAR-97-2/src/test/java/org/apache/maven/plugin/war/stub/WarArtifactStub.java)
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifactStub.java?view=diff&rev=565036&p1=maven/plugins/branches/MWAR-97-2/src/test/java/org/apache/maven/plugin/war/stub/WarArtifactStub.java&r1=565032&p2=maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifactStub.java&r2=565036
==============================================================================
    (empty)

Propchange: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifactStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/WarArtifactStub.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/util/PathSetTest.java (from r565032, maven/plugins/branches/MWAR-97-2/src/test/java/org/apache/maven/plugin/war/util/PathSetTest.java)
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/util/PathSetTest.java?view=diff&rev=565036&p1=maven/plugins/branches/MWAR-97-2/src/test/java/org/apache/maven/plugin/war/util/PathSetTest.java&r1=565032&p2=maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/util/PathSetTest.java&r2=565036
==============================================================================
--- maven/plugins/branches/MWAR-97-2/src/test/java/org/apache/maven/plugin/war/util/PathSetTest.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/util/PathSetTest.java Sun Aug 12 03:26:14 2007
@@ -272,7 +272,7 @@
         assertTrue( ps.contains( "123\\f1" ) );
         assertTrue( ps.contains( "123\\f2" ) );
         assertTrue( ps.contains( "\\123/d1\\d2/f1" ) );
-        assertTrue( ps.contains("123\\d1/d2\\f2"));
-		assertFalse(ps.contains("123\\f3"));
-	}
+        assertTrue( ps.contains( "123\\d1/d2\\f2" ) );
+        assertFalse( ps.contains( "123\\f3" ) );
+    }
 }

Copied: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/util/PropertyUtilsTest.java (from r565032, maven/plugins/branches/MWAR-97-2/src/test/java/org/apache/maven/plugin/war/util/PropertyUtilsTest.java)
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/util/PropertyUtilsTest.java?view=diff&rev=565036&p1=maven/plugins/branches/MWAR-97-2/src/test/java/org/apache/maven/plugin/war/util/PropertyUtilsTest.java&r1=565032&p2=maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/util/PropertyUtilsTest.java&r2=565036
==============================================================================
    (empty)

Propchange: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/util/PropertyUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/util/PropertyUtilsTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"