Author: epunzalan Date: Thu May 18 20:02:38 2006 New Revision: 407693 URL: http://svn.apache.org/viewvc?rev=407693&view=rev Log: PR: MASSEMBLY-88
more test cases Added: maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/attached/depSet-plugin-config.xml (with props) maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/dependency-set-plugin-config.xml (with props) Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryInlineMojoTest.java Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java?rev=407693&r1=407692&r2=407693&view=diff ============================================================================== --- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java (original) +++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java Thu May 18 20:02:38 2006 @@ -1411,6 +1411,43 @@ assertTrue( "Test an archive was created", ArchiverManagerStub.archiverStub.getDestFile().exists() ); } + public void testAttachedMojoDependencySet() + throws Exception + { + Mojo mojo = lookupMojo( "attached", basedir + "/src/test/plugin-configs/attached/depSet-plugin-config.xml" ); + + mojo.execute(); + + MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); + Set artifactSet = project.getArtifacts(); + + Map archiveMap = ArchiverManagerStub.archiverStub.getFiles(); + Collection archivedFiles = archiveMap.keySet(); + + assertEquals( "Test number of files in archive", artifactSet.size() + 1, archivedFiles.size() ); + + for ( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); ) + { + Artifact expected = (Artifact) artifacts.next(); + + assertTrue( "Test expected dependency artifacts in archive", archivedFiles.contains( expected.getFile() ) ); + assertTrue( "Test expected dependency is not unpacked", expected.getFile().getName().endsWith( ".jar" ) ); + + JarArchiverStub.ArchiverFile archiveFile = + (JarArchiverStub.ArchiverFile) archiveMap.get( expected.getFile() ); + String archivePath = archiveFile.getOutputName(); + assertTrue( "Test includeBaseDirectory", archivePath.startsWith( "assembly/" ) ); + } + + assertTrue( "Test project is in archive", archivedFiles.contains( project.getArtifact().getFile() ) ); + assertTrue( "Test project is not unpacked", project.getArtifact().getFile().getName().endsWith( ".jar" ) ); + + JarArchiverStub.ArchiverFile archiveFile = + (JarArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() ); + String archivePath = archiveFile.getOutputName(); + assertTrue( "Test includeBaseDirectory", archivePath.startsWith( "assembly/" ) ); + } + private AssemblyMojo getMojo( String pluginXml ) throws Exception { Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryInlineMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryInlineMojoTest.java?rev=407693&r1=407692&r2=407693&view=diff ============================================================================== --- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryInlineMojoTest.java (original) +++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryInlineMojoTest.java Thu May 18 20:02:38 2006 @@ -2,8 +2,8 @@ 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 org.apache.maven.artifact.Artifact; import java.io.File; import java.util.Map; @@ -46,5 +46,36 @@ Set files = filesArchived.keySet(); assertEquals( 1, files.size() ); + } + + public void testDependencySet() + throws Exception + { + File testPom = new File( getBasedir(), + "src/test/plugin-configs/directory-inline/dependency-set-plugin-config.xml" ); + + DirectoryInlineMojo mojo = ( DirectoryInlineMojo ) lookupMojo( "directory-inline", testPom ); + + assertNotNull( mojo ); + + MavenProject project = ( MavenProject ) getVariableValueFromObject( mojo, "project" ); + + Set artifacts = project.getArtifacts(); + + mojo.execute(); + + 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() ) ); } } Added: maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/attached/depSet-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/attached/depSet-plugin-config.xml?rev=407693&view=auto ============================================================================== --- maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/attached/depSet-plugin-config.xml (added) +++ maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/attached/depSet-plugin-config.xml Thu May 18 20:02:38 2006 @@ -0,0 +1,44 @@ +<!-- + ~ 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/attached/depSet/target</outputDirectory> + <finalName>assembly</finalName> + <workDirectory>${basedir}/target/test-harness/attached/depSet/work</workDirectory> + <archiverManager implementation="org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub" /> + <localRepository>${localRepository}</localRepository> + <reactorProjects></reactorProjects> + <classifier></classifier> + <project implementation="org.apache.maven.plugin.assembly.stubs.MavenProjectWithArtifactsStub" /> + <descriptorRefs> + <descriptorRef>dependencySet-default</descriptorRef> + </descriptorRefs> + <tarLongFileMode>warn</tarLongFileMode> + <basedir>${basedir}</basedir> + <tempRoot>${basedir}/target/test-harness/attached/depSet/archive-tmp</tempRoot> + <siteDirectory>${basedir}/target/test-harness/attached/depSet/site</siteDirectory> + <includeSite>false</includeSite> + <appendAssemblyId>true</appendAssemblyId> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/attached/depSet-plugin-config.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/dependency-set-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/dependency-set-plugin-config.xml?rev=407693&view=auto ============================================================================== --- maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/dependency-set-plugin-config.xml (added) +++ maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/dependency-set-plugin-config.xml Thu May 18 20:02:38 2006 @@ -0,0 +1,34 @@ +<!-- + ~ 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.MavenProjectWithArtifactsStub" /> + <outputDirectory>${basedir}/target/test-harness/directory-inlince/dependency-set/target</outputDirectory> + <finalName>directory-dependency-set</finalName> + <archiverManager implementation="org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub" /> + <appendAssemblyId>true</appendAssemblyId> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Propchange: maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory-inline/dependency-set-plugin-config.xml ------------------------------------------------------------------------------ svn:eol-style = native