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/10/28 11:02:40 UTC
svn commit: r589316 - in /maven/plugins/trunk/maven-war-plugin/src:
it/scoped-dependency-same-artifact/ it/scoped-dependency-same-artifact/src/
it/scoped-dependency-same-artifact/src/main/
it/scoped-dependency-same-artifact/src/main/webapp/ it/scoped-d...
Author: snicoll
Date: Sun Oct 28 03:02:34 2007
New Revision: 589316
URL: http://svn.apache.org/viewvc?rev=589316&view=rev
Log:
MWAR-101: Added an IT that validates that dependencies with the same artifactId and different classifiers are handled correctly.
Added:
maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/ (with props)
maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/goals.txt
maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/pom.xml
maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/
maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/
maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/
maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/WEB-INF/
maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/WEB-INF/web.xml
maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/index.jsp
maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/verify.bsh
Modified:
maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarMojoTest.java
maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarOverlaysTest.java
maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarZipTest.java
Propchange: maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Oct 28 03:02:34 2007
@@ -0,0 +1,2 @@
+target
+build.log
Added: maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/goals.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/goals.txt?rev=589316&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/goals.txt (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/goals.txt Sun Oct 28 03:02:34 2007
@@ -0,0 +1 @@
+clean package
\ No newline at end of file
Added: maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/pom.xml?rev=589316&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/pom.xml (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/pom.xml Sun Oct 28 03:02:34 2007
@@ -0,0 +1,52 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>scope-depdency-same-artifact</artifactId>
+ <packaging>war</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>Maven Simple War Project Test</name>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.4.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <classifier>sources</classifier>
+ <version>1.4.7</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/WEB-INF/web.xml?rev=589316&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/WEB-INF/web.xml (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/WEB-INF/web.xml Sun Oct 28 03:02:34 2007
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <display-name>Maven Simple War Project Test</display-name>
+
+</web-app>
+
Added: maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/index.jsp?rev=589316&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/index.jsp (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/src/main/webapp/index.jsp Sun Oct 28 03:02:34 2007
@@ -0,0 +1,20 @@
+<%--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ --%>
+
+<% response.sendRedirect( request.getContextPath() + "/groupSummary.action" ); %>
Added: maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/verify.bsh?rev=589316&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/verify.bsh (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/scoped-dependency-same-artifact/verify.bsh Sun Oct 28 03:02:34 2007
@@ -0,0 +1,88 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.*;
+
+boolean result = true;
+
+try
+{
+ File target = new File( basedir, "target" );
+ if ( !target.exists() || !target.isDirectory() )
+ {
+ System.err.println( "target file is missing or a directory." );
+ return false;
+ }
+
+ File webappDirectory = new File( target, "scope-depdency-same-artifact-1.0-SNAPSHOT" );
+ if ( !webappDirectory.exists() || !webappDirectory.isDirectory() )
+ {
+ System.err.println( "webappDirectory is missing or not a directory." );
+ return false;
+ }
+
+ File webInfFile = new File( webappDirectory, "WEB-INF/web.xml" );
+ if ( !webInfFile.exists() || webInfFile.isDirectory() )
+ {
+ System.err.println( "webInfFile is missing or a directory." );
+ return false;
+ }
+
+ File indexJsp = new File( webappDirectory, "index.jsp" );
+ if ( !indexJsp.exists() || indexJsp.isDirectory() )
+ {
+ System.err.println( "indexJsp is missing or a directory." );
+ return false;
+ }
+
+ File warFile = new File (target, "scope-depdency-same-artifact-1.0-SNAPSHOT.war" );
+ if ( !warFile.exists() || warFile.isDirectory() )
+ {
+ System.err.println( "warFile is missing or a directory." );
+ return false;
+ }
+
+ File libDir = new File ( webappDirectory, "WEB-INF/lib" );
+ if ( !libDir.exists() || !libDir.isDirectory() )
+ {
+ System.err.println( "WEB-INF/lib is missing or not a directory." );
+ return false;
+ }
+
+ File plexusUtilsDependency = new File ( libDir, "plexus-utils-1.4.7.jar" );
+ if ( !plexusUtilsDependency.exists() || plexusUtilsDependency.isDirectory() )
+ {
+ System.err.println( "plexus-utils-1.4.7.jar is missing or a directory." );
+ return false;
+ }
+ File plexusUtilsSourceDependency = new File ( libDir, "plexus-utils-1.4.7-sources.jar" );
+ if ( !plexusUtilsSourceDependency.exists() || plexusUtilsSourceDependency.isDirectory() )
+ {
+ System.err.println( "plexus-utils-1.4.7-sources.jar is missing or a directory." );
+ return false;
+ }
+}
+catch( IOException e )
+{
+ e.printStackTrace();
+ result = false;
+}
+
+return result;
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?rev=589316&r1=589315&r2=589316&view=diff
==============================================================================
--- 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 Oct 28 03:02:34 2007
@@ -25,9 +25,9 @@
import org.codehaus.plexus.util.IOUtil;
import java.io.File;
+import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.jar.JarEntry;
@@ -86,31 +86,10 @@
//validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- Map jarContent = new HashMap();
-
- assertTrue( "war file not created: " + expectedJarFile.toString(), expectedJarFile.exists() );
-
- JarFile jarFile = new JarFile( expectedJarFile );
- JarEntry entry;
- Enumeration enumeration = jarFile.entries();
-
- while ( enumeration.hasMoreElements() )
- {
- entry = (JarEntry) enumeration.nextElement();
- jarContent.put( entry.getName(), entry );
- }
-
- assertTrue( "manifest file not found", jarContent.containsKey( "META-INF/MANIFEST.MF" ) );
- assertTrue( "web xml not found", jarContent.containsKey( "WEB-INF/web.xml" ) );
- assertEquals( "web xml file incorrect", mojo.getWebXml().toString(),
- IOUtil.toString( jarFile.getInputStream( (ZipEntry) jarContent.get( "WEB-INF/web.xml" ) ) ) );
- assertTrue( "web source not found: pansit.jsp", jarContent.containsKey( "pansit.jsp" ) );
- assertTrue( "web source not found: org/web/app/last-exile.jsp",
- jarContent.containsKey( "org/web/app/last-exile.jsp" ) );
- assertTrue( "pom file not found",
- jarContent.containsKey( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml" ) );
- assertTrue( "pom properties not found",
- jarContent.containsKey( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" ) );
+ assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
+ "org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"},
+ new String[]{null, mojo.getWebXml().toString(), null, null, null, null} );
}
public void testClassifier()
@@ -139,30 +118,10 @@
//validate jar file
File expectedJarFile = new File( outputDir, "simple-test-classifier.war" );
- HashSet jarContent = new HashSet();
-
- assertTrue( "war file not created: " + expectedJarFile.toString(), expectedJarFile.exists() );
- assertNotNull( "artifact not attached to project", projectHelper.getArtifactFile() );
-
- JarFile jarFile = new JarFile( expectedJarFile );
- JarEntry entry;
- Enumeration enumeration = jarFile.entries();
-
- while ( enumeration.hasMoreElements() )
- {
- entry = (JarEntry) enumeration.nextElement();
- jarContent.add( entry.getName() );
- }
-
- assertTrue( "manifest file not found", jarContent.contains( "META-INF/MANIFEST.MF" ) );
- assertTrue( "web xml not found", jarContent.contains( "WEB-INF/web.xml" ) );
- assertTrue( "web source not found: pansit.jsp", jarContent.contains( "pansit.jsp" ) );
- assertTrue( "web source not found: org/web/app/last-exile.jsp",
- jarContent.contains( "org/web/app/last-exile.jsp" ) );
- assertTrue( "pom file not found",
- jarContent.contains( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml" ) );
- assertTrue( "pom properties not found",
- jarContent.contains( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" ) );
+ assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
+ "org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"},
+ new String[]{null, mojo.getWebXml().toString(), null, null, null, null} );
}
public void testPrimaryArtifact()
@@ -191,31 +150,10 @@
//validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- HashSet jarContent = new HashSet();
-
- assertTrue( "war file not created: " + expectedJarFile.toString(), expectedJarFile.exists() );
- assertTrue( "war file was not set as primary artifact",
- project.getArtifact().getFile().getName().equals( "simple.war" ) );
-
- JarFile jarFile = new JarFile( expectedJarFile );
- JarEntry entry;
- Enumeration enumeration = jarFile.entries();
-
- while ( enumeration.hasMoreElements() )
- {
- entry = (JarEntry) enumeration.nextElement();
- jarContent.add( entry.getName() );
- }
-
- assertTrue( "manifest file not found", jarContent.contains( "META-INF/MANIFEST.MF" ) );
- assertTrue( "web xml not found", jarContent.contains( "WEB-INF/web.xml" ) );
- assertTrue( "web source not found: pansit.jsp", jarContent.contains( "pansit.jsp" ) );
- assertTrue( "web source not found: org/web/app/last-exile.jsp",
- jarContent.contains( "org/web/app/last-exile.jsp" ) );
- assertTrue( "pom file not found",
- jarContent.contains( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml" ) );
- assertTrue( "pom properties not found",
- jarContent.contains( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" ) );
+ assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
+ "org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"},
+ new String[]{null, mojo.getWebXml().toString(), null, null, null, null} );
}
public void testNotPrimaryArtifact()
@@ -248,30 +186,10 @@
//validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- HashSet jarContent = new HashSet();
-
- assertTrue( "war file not created: " + expectedJarFile.toString(), expectedJarFile.exists() );
- assertTrue( "war file was set", project.getArtifact().getFile().getName().equals( "error.war" ) );
-
- JarFile jarFile = new JarFile( expectedJarFile );
- JarEntry entry;
- Enumeration enumeration = jarFile.entries();
-
- while ( enumeration.hasMoreElements() )
- {
- entry = (JarEntry) enumeration.nextElement();
- jarContent.add( entry.getName() );
- }
-
- assertTrue( "manifest file not found", jarContent.contains( "META-INF/MANIFEST.MF" ) );
- assertTrue( "web xml not found", jarContent.contains( "WEB-INF/web.xml" ) );
- assertTrue( "web source not found: pansit.jsp", jarContent.contains( "pansit.jsp" ) );
- assertTrue( "web source not found: org/web/app/last-exile.jsp",
- jarContent.contains( "org/web/app/last-exile.jsp" ) );
- assertTrue( "pom file not found",
- jarContent.contains( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml" ) );
- assertTrue( "pom properties not found",
- jarContent.contains( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" ) );
+ assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
+ "org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"},
+ new String[]{null, mojo.getWebXml().toString(), null, null, null, null} );
}
public void testMetaInfContent()
@@ -301,32 +219,11 @@
//validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- Map jarContent = new HashMap();
-
- assertTrue( "war file not created: " + expectedJarFile.toString(), expectedJarFile.exists() );
-
- JarFile jarFile = new JarFile( expectedJarFile );
- JarEntry entry;
- Enumeration enumeration = jarFile.entries();
-
- while ( enumeration.hasMoreElements() )
- {
- entry = (JarEntry) enumeration.nextElement();
- jarContent.put( entry.getName(), entry );
- }
-
- assertTrue( "manifest file not found", jarContent.containsKey( "META-INF/MANIFEST.MF" ) );
- assertTrue( "custom manifest data file not found", jarContent.containsKey( "META-INF/config.xml" ) );
- assertTrue( "web xml not found", jarContent.containsKey( "WEB-INF/web.xml" ) );
- assertEquals( "web xml file incorrect", mojo.getWebXml().toString(),
- IOUtil.toString( jarFile.getInputStream( (ZipEntry) jarContent.get( "WEB-INF/web.xml" ) ) ) );
- assertTrue( "web source not found: pansit.jsp", jarContent.containsKey( "pansit.jsp" ) );
- assertTrue( "web source not found: org/web/app/last-exile.jsp",
- jarContent.containsKey( "org/web/app/last-exile.jsp" ) );
- assertTrue( "pom file not found",
- jarContent.containsKey( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml" ) );
- assertTrue( "pom properties not found",
- jarContent.containsKey( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" ) );
+ assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "META-INF/config.xml",
+ "WEB-INF/web.xml", "pansit.jsp", "org/web/app/last-exile.jsp",
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"}, new String[]{null, null,
+ mojo.getWebXml().toString(), null, null, null, null} );
}
public void testMetaInfContentWithContainerConfig()
@@ -357,32 +254,42 @@
//validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- Map jarContent = new HashMap();
+ assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "META-INF/config.xml",
+ "WEB-INF/web.xml", "pansit.jsp", "org/web/app/last-exile.jsp",
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"}, new String[]{null, null,
+ mojo.getWebXml().toString(), null, null, null, null} );
+ }
+
+ protected void assertJarContent( final File expectedJarFile, final String[] files, final String[] filesContent )
+ throws IOException
+ {
+ // Sanity check
+ assertEquals( "Could not test, files and filesContent lenght does not match", files.length,
+ filesContent.length );
assertTrue( "war file not created: " + expectedJarFile.toString(), expectedJarFile.exists() );
+ final Map jarContent = new HashMap();
+ final JarFile jarFile = new JarFile( expectedJarFile );
- JarFile jarFile = new JarFile( expectedJarFile );
JarEntry entry;
Enumeration enumeration = jarFile.entries();
-
while ( enumeration.hasMoreElements() )
{
entry = (JarEntry) enumeration.nextElement();
jarContent.put( entry.getName(), entry );
}
- assertTrue( "manifest file not found", jarContent.containsKey( "META-INF/MANIFEST.MF" ) );
- assertTrue( "custom manifest data file not found", jarContent.containsKey( "META-INF/config.xml" ) );
- assertTrue( "web xml not found", jarContent.containsKey( "WEB-INF/web.xml" ) );
- assertEquals( "web xml file incorrect", mojo.getWebXml().toString(),
- IOUtil.toString( jarFile.getInputStream( (ZipEntry) jarContent.get( "WEB-INF/web.xml" ) ) ) );
- assertTrue( "web source not found: pansit.jsp", jarContent.containsKey( "pansit.jsp" ) );
- assertTrue( "web source not found: org/web/app/last-exile.jsp",
- jarContent.containsKey( "org/web/app/last-exile.jsp" ) );
- assertTrue( "pom file not found",
- jarContent.containsKey( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml" ) );
- assertTrue( "pom properties not found",
- jarContent.containsKey( "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" ) );
+ for ( int i = 0; i < files.length; i++ )
+ {
+ String file = files[i];
+ assertTrue( "File[" + file + "] not found in archive", jarContent.containsKey( file ) );
+ if ( filesContent[i] != null )
+ {
+ assertEquals( "Content of file[" + file + "] does not match", filesContent[i],
+ IOUtil.toString( jarFile.getInputStream( (ZipEntry) jarContent.get( file ) ) ) );
+ }
+ }
}
}
Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarOverlaysTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarOverlaysTest.java?rev=589316&r1=589315&r2=589316&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarOverlaysTest.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarOverlaysTest.java Sun Oct 28 03:02:34 2007
@@ -591,6 +591,7 @@
* Note that the <tt>filePath</tt> is relative to both the webapp
* directory and the overlayed directory, defined by the <tt>overlayId</tt>.
*
+ * @param testId te id of the test
* @param webAppDirectory the webapp directory
* @param filePath the relative path
* @throws IOException if an error occured while reading the files
Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarZipTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarZipTest.java?rev=589316&r1=589315&r2=589316&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarZipTest.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarZipTest.java Sun Oct 28 03:02:34 2007
@@ -19,9 +19,6 @@
* under the License.
*/
-import java.io.File;
-import java.util.LinkedList;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.plugin.war.overlay.DefaultOverlay;
@@ -30,10 +27,13 @@
import org.apache.maven.plugin.war.stub.ZipArtifactStub;
import org.codehaus.plexus.util.FileUtils;
+import java.io.File;
+import java.util.LinkedList;
+
/**
* @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 7 Oct 07
* @version $Id$
+ * @since 7 Oct 07
*/
public class WarZipTest
extends AbstractWarMojoTest
@@ -42,8 +42,7 @@
private static File pomFile = new File( getBasedir(), "src/test/resources/unit/warziptest/war-with-zip.xml" );
-
-
+
protected File getTestDirectory()
{
return new File( getBasedir(), "target/test-classes/unit/warziptest" );
@@ -61,18 +60,17 @@
{
ArtifactHandler artifactHandler = (ArtifactHandler) lookup( ArtifactHandler.ROLE, "jar" );
File zipFile = new File( getTestDirectory(), "foobar.zip" );
- Artifact artifact = new ZipArtifactStub( "src/test/resources/unit/warziptest", artifactHandler, zipFile );
- return artifact;
+ return new ZipArtifactStub( "src/test/resources/unit/warziptest", artifactHandler, zipFile );
}
-
+
private File configureMojo( String testId )
throws Exception
{
MavenZipProject project = new MavenZipProject();
String outputDir = getTestDirectory().getAbsolutePath() + File.separatorChar + testId + "-output";
// clean up
- File outputDirFile = new File(outputDir);
- if (outputDirFile.exists())
+ File outputDirFile = new File( outputDir );
+ if ( outputDirFile.exists() )
{
FileUtils.deleteDirectory( outputDirFile );
}
@@ -81,16 +79,14 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, true );
- File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
+ File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
project.setArtifact( warArtifact );
-
+
this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "outputDirectory", outputDir );
setVariableValueToObject( mojo, "warName", warName );
setVariableValueToObject( mojo, "workDirectory", new File( getTestDirectory(), "work" ) );
mojo.setWebXml( new File( xmlSource, "web.xml" ) );
-
-
project.getArtifacts().add( buildZipArtifact() );
@@ -101,11 +97,11 @@
throws Exception
{
File webAppDirectory = configureMojo( "one-zip" );
-
+
Overlay overlay = new DefaultOverlay( buildZipArtifact() );
//overlay.setSkip( false );
overlay.setType( "zip" );
- mojo.addOverlay( overlay );
+ mojo.addOverlay( overlay );
mojo.execute();
File foo = new File( webAppDirectory, "foo.txt" );
@@ -125,13 +121,13 @@
throws Exception
{
File webAppDirectory = configureMojo( "one-zip-overlay-targetPath" );
-
+
Overlay overlay = new DefaultOverlay( buildZipArtifact() );
overlay.setSkip( false );
overlay.setType( "zip" );
overlay.setTargetPath( "overridePath" );
mojo.addOverlay( overlay );
-
+
mojo.execute();
File foo = new File( webAppDirectory.getPath() + File.separatorChar + "overridePath", "foo.txt" );
@@ -145,8 +141,8 @@
File bar = new File( barDirectory, "bar.txt" );
assertTrue( "bar/bar.txt not exists", bar.exists() );
assertTrue( "bar/bar.txt not a file", bar.isFile() );
- }
-
+ }
+
public void testOneZipDefaultSkip()
throws Exception
{
@@ -169,9 +165,9 @@
mojo.execute();
assertZipContentNotHere( webAppDirectory );
- }
-
- protected void assertZipContentNotHere(File webAppDirectory)
+ }
+
+ protected void assertZipContentNotHere( File webAppDirectory )
{
File foo = new File( webAppDirectory.getPath() + File.separatorChar + "overridePath", "foo.txt" );
assertFalse( "foo.txt exists", foo.exists() );