You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ep...@apache.org on 2006/04/28 10:32:30 UTC
svn commit: r397801 - in /maven/plugins/trunk/maven-assembly-plugin/src/test:
java/org/apache/maven/plugin/assembly/
java/org/apache/maven/plugin/assembly/stubs/ plugin-configs/unpack/
Author: epunzalan
Date: Fri Apr 28 01:32:26 2006
New Revision: 397801
URL: http://svn.apache.org/viewcvs?rev=397801&view=rev
Log:
PR: MASSEMBLY-88
Finished test harness tests for unpack goal
Added:
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ArchiverManagerWithExceptionStub.java
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ReactorMavenProjectStub.java
- copied, changed from r397782, maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ReactorMavenProject.java
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/unpack/archiver-manager-exception-plugin-config.xml
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/unpack/with-reactor-projects-plugin-config.xml
Removed:
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ReactorMavenProject.java
Modified:
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/UnpackMojoTest.java
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/UnArchiverStub.java
Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/UnpackMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/UnpackMojoTest.java?rev=397801&r1=397800&r2=397801&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/UnpackMojoTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/UnpackMojoTest.java Fri Apr 28 01:32:26 2006
@@ -18,9 +18,13 @@
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.artifact.Artifact;
import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
import java.io.File;
+import java.util.List;
+import java.util.Iterator;
/**
* @author Edwin Punzalan
@@ -31,8 +35,45 @@
public void testMinConfiguration()
throws Exception
{
- String pluginXml = "min-plugin-config.xml";
+ executeMojo( "min-plugin-config.xml" );
+ }
+ public void testMinConfigurationWithReactorProjects()
+ throws Exception
+ {
+ executeMojo( "with-reactor-projects-plugin-config.xml" );
+ }
+
+ public void testArchiverManagerException()
+ throws Exception
+ {
+ try
+ {
+ String pluginXml = "archiver-manager-exception-plugin-config.xml";
+
+ UnpackMojo mojo = (UnpackMojo) lookupMojo( "unpack", PlexusTestCase.getBasedir() +
+ "/src/test/plugin-configs/unpack/" + pluginXml );
+
+ mojo.execute();
+
+ MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
+ String filename = project.getArtifact().getFile().getName();
+ String dir = filename.substring( 0, filename.lastIndexOf( '.' ) );
+ File workDir = (File) getVariableValueFromObject( mojo, "workDirectory" );
+ File unpackDir = new File( workDir, dir );
+ File unpacked = new File( unpackDir, filename + ".extracted" );
+
+ assertFalse( "Test extracted project artifact", unpacked.exists() );
+ }
+ catch ( NoSuchArchiverException e )
+ {
+ fail( "Expected exception in ArchiverManager should not fail the build" );
+ }
+ }
+
+ public void executeMojo( String pluginXml )
+ throws Exception
+ {
UnpackMojo mojo = (UnpackMojo) lookupMojo( "unpack", PlexusTestCase.getBasedir() +
"/src/test/plugin-configs/unpack/" + pluginXml );
@@ -46,5 +87,30 @@
File unpacked = new File( unpackDir, filename + ".extracted" );
assertTrue( "Test extracted project artifact", unpacked.exists() );
+
+ List reactorProjectList = (List) getVariableValueFromObject( mojo, "reactorProjects" );
+ for ( Iterator reactorProjects = reactorProjectList.iterator(); reactorProjects.hasNext(); )
+ {
+ MavenProject reactorProject = (MavenProject) reactorProjects.next();
+
+ filename = reactorProject.getArtifact().getFile().getName();
+ dir = filename.substring( 0, filename.lastIndexOf( '.' ) );
+ unpackDir = new File( workDir, dir );
+ unpacked = new File( unpackDir, filename + ".extracted" );
+
+ assertTrue( "Test reactor project was extracted", unpacked.exists() );
+
+ for ( Iterator artifacts = reactorProject.getArtifacts().iterator(); artifacts.hasNext(); )
+ {
+ Artifact artifact = (Artifact) artifacts.next();
+
+ filename = artifact.getFile().getName();
+ dir = filename.substring( 0, filename.lastIndexOf( '.' ) );
+ unpackDir = new File( workDir, dir );
+ unpacked = new File( unpackDir, filename + ".extracted" );
+
+ assertTrue( "Test reactor project artifact was extracted", unpacked.exists() );
+ }
+ }
}
}
Added: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ArchiverManagerWithExceptionStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ArchiverManagerWithExceptionStub.java?rev=397801&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ArchiverManagerWithExceptionStub.java (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ArchiverManagerWithExceptionStub.java Fri Apr 28 01:32:26 2006
@@ -0,0 +1,40 @@
+package org.apache.maven.plugin.assembly.stubs;
+
+import org.codehaus.plexus.archiver.Archiver;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class ArchiverManagerWithExceptionStub
+ extends ArchiverManagerStub
+{
+ public UnArchiver getUnArchiver( String string )
+ throws NoSuchArchiverException
+ {
+ throw new NoSuchArchiverException( "Expected exception" );
+ }
+
+ public Archiver getArchiver( String string )
+ throws NoSuchArchiverException
+ {
+ throw new NoSuchArchiverException( "Expected exception" );
+ }
+}
Copied: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ReactorMavenProjectStub.java (from r397782, maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ReactorMavenProject.java)
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ReactorMavenProjectStub.java?p2=maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ReactorMavenProjectStub.java&p1=maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ReactorMavenProject.java&r1=397782&r2=397801&rev=397801&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ReactorMavenProject.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/ReactorMavenProjectStub.java Fri Apr 28 01:32:26 2006
@@ -17,12 +17,38 @@
*/
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.artifact.Artifact;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.Collections;
/**
* @author Edwin Punzalan
*/
-public class ReactorMavenProject
+public class ReactorMavenProjectStub
extends MavenProjectStub
{
-
+ public static List reactorProjects = new ArrayList();
+
+ public Set getArtifacts()
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ public ReactorMavenProjectStub()
+ {
+ super();
+
+ reactorProjects.add( this );
+
+ setGroupId( "assembly" );
+ setArtifactId( "reactor-project-" + reactorProjects.size() );
+ setVersion( "1.0" );
+ setPackaging( "jar" );
+
+ setArtifact( new ArtifactStub( getGroupId(), getArtifactId(),
+ getVersion(), getPackaging(), Artifact.SCOPE_COMPILE ) );
+ }
}
Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/UnArchiverStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/UnArchiverStub.java?rev=397801&r1=397800&r2=397801&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/UnArchiverStub.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/stubs/UnArchiverStub.java Fri Apr 28 01:32:26 2006
@@ -35,7 +35,10 @@
{
File extractedFile = new File( destDir, sourceFile.getName() + ".extracted" );
- extractedFile.createNewFile();
+ if ( !extractedFile.exists() )
+ {
+ extractedFile.createNewFile();
+ }
}
public File getDestDirectory()
Added: maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/unpack/archiver-manager-exception-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/unpack/archiver-manager-exception-plugin-config.xml?rev=397801&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/unpack/archiver-manager-exception-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/unpack/archiver-manager-exception-plugin-config.xml Fri Apr 28 01:32:26 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>
+ <outputDirectory>${basedir}/target/test-harness/unpack/archiver-manager-exception/target</outputDirectory>
+ <finalName>unpack-min</finalName>
+ <projectModulesOnly>false</projectModulesOnly>
+ <workDirectory>${basedir}/target/test-harness/unpack/archiver-manager-exception/work</workDirectory>
+ <archiverManager implementation="org.apache.maven.plugin.assembly.stubs.ArchiverManagerWithExceptionStub" />
+ <localRepository>${localRepository}</localRepository>
+ <reactorProjects></reactorProjects>
+ <classifier></classifier>
+ <project implementation="org.apache.maven.plugin.assembly.stubs.AssemblyMavenProjectStub" />
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/unpack/with-reactor-projects-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/unpack/with-reactor-projects-plugin-config.xml?rev=397801&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/unpack/with-reactor-projects-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/unpack/with-reactor-projects-plugin-config.xml Fri Apr 28 01:32:26 2006
@@ -0,0 +1,38 @@
+<!--
+ ~ 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>
+ <outputDirectory>${basedir}/target/test-harness/unpack/with-reactor-projects/target</outputDirectory>
+ <finalName>unpack-min</finalName>
+ <projectModulesOnly>false</projectModulesOnly>
+ <workDirectory>${basedir}/target/test-harness/unpack/with-reactor-projects/work</workDirectory>
+ <archiverManager implementation="org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub" />
+ <localRepository>${localRepository}</localRepository>
+ <reactorProjects>
+ <reactorProject implementation="org.apache.maven.plugin.assembly.stubs.ReactorMavenProjectStub" />
+ <reactorProject implementation="org.apache.maven.plugin.assembly.stubs.ReactorMavenProjectStub" />
+ </reactorProjects>
+ <classifier></classifier>
+ <project implementation="org.apache.maven.plugin.assembly.stubs.AssemblyMavenProjectStub" />
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>