You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ar...@apache.org on 2006/05/05 12:18:14 UTC
svn commit: r400037 - in /maven/plugins/trunk/maven-assembly-plugin/src/test:
java/org/apache/maven/plugin/assembly/ plugin-configs/directory-inline/
plugin-configs/directory/
Author: aramirez
Date: Fri May 5 03:18:12 2006
New Revision: 400037
URL: http://svn.apache.org/viewcvs?rev=400037&view=rev
Log:
PR: MASSEMBLY-88
added test for both directory-inline and directory mojo
Added:
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryInlineMojoTest.java
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/min-plugin-config.xml
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/appendAssemblyId-false-plugin-config.xml
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/min-plugin-config-with-exceptions.xml
Modified:
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryMojoTest.java
Added: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryInlineMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryInlineMojoTest.java?rev=400037&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryInlineMojoTest.java (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryInlineMojoTest.java Fri May 5 03:18:12 2006
@@ -0,0 +1,50 @@
+package org.apache.maven.plugin.assembly;
+
+import org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.util.Map;
+import java.util.Set;
+import java.util.Iterator;
+
+/*
+ * 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.
+ */
+
+public class DirectoryInlineMojoTest
+extends AbstractMojoTestCase
+{
+ public void testAssemblyDirectory()
+ throws Exception
+ {
+ File testPom = new File( getBasedir(),
+ "src/test/plugin-configs/directory-inline/min-plugin-config.xml" );
+
+ DirectoryInlineMojo mojo = ( DirectoryInlineMojo ) lookupMojo( "directory-inline", testPom );
+
+ assertNotNull( mojo );
+
+ mojo.execute();
+
+ Map filesArchived = ArchiverManagerStub.archiverStub.getFiles();
+
+ Set files = filesArchived.keySet();
+
+ assertEquals( 1, files.size() );
+ }
+}
Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryMojoTest.java?rev=400037&r1=400036&r2=400037&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryMojoTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryMojoTest.java Fri May 5 03:18:12 2006
@@ -1,7 +1,7 @@
package org.apache.maven.plugin.assembly;
/*
- * Copyright 2001-2006 The Apache Software Foundation.
+ * Copyright 2001-2005 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.
@@ -62,6 +62,46 @@
assertEquals( 1, files.size() );
}
+ public void testAssemblyDirectoryWithAppendAssemblyIdAsFalse()
+ throws Exception
+ {
+ File testPom = new File( getBasedir(),
+ "src/test/plugin-configs/directory/appendAssemblyId-false-plugin-config.xml" );
+
+ DirectoryMojo mojo = ( DirectoryMojo ) lookupMojo( "directory", testPom );
+
+ assertNotNull( mojo );
+
+ String classifier = ( String ) getVariableValueFromObject( mojo, "classifier" );
+
+ String finalName = ( String ) getVariableValueFromObject( mojo, "finalName" );
+
+ File outputDir = ( File ) getVariableValueFromObject( mojo, "outputDirectory" );
+
+ MavenProject project = ( MavenProject ) getVariableValueFromObject( mojo, "executedProject" );
+
+ Set artifacts = project.getArtifacts();
+
+ mojo.execute();
+
+ File dir = new File( outputDir, finalName + "-" + classifier );
+
+ assertTrue( dir.exists() );
+
+ Map filesArchived = ArchiverManagerStub.archiverStub.getFiles();
+
+ Set files = filesArchived.keySet();
+
+ for( Iterator iter = artifacts.iterator(); iter.hasNext(); )
+ {
+ Artifact artifact = ( Artifact ) iter.next();
+
+ assertTrue( files.contains( artifact.getFile() ) );
+ assertTrue( artifact.getFile().getName().endsWith( ".jar" ) );
+ }
+
+ assertTrue( "Test project is in archive", files.contains( project.getArtifact().getFile() ) );
+ }
public void testAssemblyDirectoryWithDependencySet()
throws Exception
@@ -92,5 +132,27 @@
}
assertTrue( "Test project is in archive", files.contains( project.getArtifact().getFile() ) );
+ }
+
+ public void testAssemblyDirectoryToThrowNoSuchArchiverException()
+ throws Exception
+ {
+ File testPom = new File( getBasedir(),
+ "src/test/plugin-configs/directory/min-plugin-config-with-exceptions.xml" );
+
+ DirectoryMojo mojo = ( DirectoryMojo ) lookupMojo( "directory", testPom );
+
+ assertNotNull( mojo );
+
+ try
+ {
+ mojo.execute();
+
+ fail( "Failure Expected" );
+ }
+ catch( Exception e )
+ {
+ //expected
+ }
}
}
Added: maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/min-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/min-plugin-config.xml?rev=400037&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/min-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/min-plugin-config.xml Fri May 5 03:18:12 2006
@@ -0,0 +1,33 @@
+<!--
+ ~ 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.
+ -->
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptor>${basedir}/src/test/resources/assemblies/simple.xml</descriptor>
+ <basedir>${basedir}</basedir>
+ <project implementation="org.apache.maven.plugin.assembly.stubs.AssemblyMavenProjectStub" />
+ <outputDirectory>${basedir}/target/test-harness/directory-inline/min/target</outputDirectory>
+ <finalName>directory-inline-min</finalName>
+ <archiverManager implementation="org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub" />
+ <appendAssemblyId>true</appendAssemblyId>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/appendAssemblyId-false-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/appendAssemblyId-false-plugin-config.xml?rev=400037&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/appendAssemblyId-false-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/appendAssemblyId-false-plugin-config.xml Fri May 5 03:18:12 2006
@@ -0,0 +1,35 @@
+<!--
+ ~ 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.
+ -->
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptor>${basedir}/src/test/resources/assemblies/dependencySet-default.xml</descriptor>
+ <basedir>${basedir}</basedir>
+ <project implementation="org.apache.maven.plugin.assembly.stubs.AssemblyMavenProjectStub" />
+ <executedProject implementation="org.apache.maven.plugin.assembly.stubs.MavenProjectWithArtifactsStub" />
+ <outputDirectory>${basedir}/target/test-harness/directory/appendAssemblyId-false/target</outputDirectory>
+ <finalName>directory-appendAssemblyId-false</finalName>
+ <archiverManager implementation="org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub" />
+ <appendAssemblyId>false</appendAssemblyId>
+ <classifier>classifier</classifier>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/min-plugin-config-with-exceptions.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/min-plugin-config-with-exceptions.xml?rev=400037&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/min-plugin-config-with-exceptions.xml (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/min-plugin-config-with-exceptions.xml Fri May 5 03:18:12 2006
@@ -0,0 +1,33 @@
+<!--
+ ~ 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.
+ -->
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptor>${basedir}/src/test/resources/assemblies/simple.xml</descriptor>
+ <basedir>${basedir}</basedir>
+ <project implementation="org.apache.maven.plugin.assembly.stubs.AssemblyMavenProjectStub" />
+ <outputDirectory>${basedir}/target/test-harness/directory-inline/min/target</outputDirectory>
+ <finalName>directory-inline-min</finalName>
+ <archiverManager implementation="org.apache.maven.plugin.assembly.stubs.ArchiverManagerWithExceptionStub" />
+ <appendAssemblyId>true</appendAssemblyId>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file