Author: aramirez
Date: Thu May  4 04:05:42 2006
New Revision: 399660

URL: http://svn.apache.org/viewcvs?rev=399660&view=rev
Log:
PR: MASSEMBLY-88

added test for directory mojo

Added:
    
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/DirectoryMojoTest.java
    maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/
    
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/dependency-set-plugin-config.xml
    
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/min-plugin-config.xml

Added: 
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=399660&view=auto
==============================================================================
--- 
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/DirectoryMojoTest.java
 Thu May  4 04:05:42 2006
@@ -0,0 +1,96 @@
+package org.apache.maven.plugin.assembly;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.artifact.Artifact;
+
+import java.io.File;
+import java.util.Map;
+import java.util.Set;
+import java.util.Iterator;
+
+/**
+ * @author Allan Q. Ramirez
+ */
+public class DirectoryMojoTest
+    extends AbstractMojoTestCase
+{
+    public void testEnvironment()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(),
+                                 
"src/test/plugin-configs/directory/min-plugin-config.xml" );
+
+        DirectoryMojo mojo = ( DirectoryMojo ) lookupMojo( "directory", 
testPom );
+
+        assertNotNull( mojo );
+    }
+
+    public void testAssemblyDirectory()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(),
+                                 
"src/test/plugin-configs/directory/min-plugin-config.xml" );
+
+        DirectoryMojo mojo = ( DirectoryMojo ) lookupMojo( "directory", 
testPom );
+
+        assertNotNull( mojo );
+
+        mojo.execute();
+
+        Map filesArchived = ArchiverManagerStub.archiverStub.getFiles();
+
+        Set files = filesArchived.keySet();
+
+        assertEquals( 1, files.size() );
+    }
+
+
+    public void testAssemblyDirectoryWithDependencySet()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(),
+                                 
"src/test/plugin-configs/directory/dependency-set-plugin-config.xml" );
+
+        DirectoryMojo mojo = ( DirectoryMojo ) lookupMojo( "directory", 
testPom );
+
+        assertNotNull( mojo );
+
+        MavenProject project = ( MavenProject ) getVariableValueFromObject( 
mojo, "executedProject" );
+
+        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/directory/dependency-set-plugin-config.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/dependency-set-plugin-config.xml?rev=399660&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/dependency-set-plugin-config.xml
 (added)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/dependency-set-plugin-config.xml
 Thu May  4 04:05:42 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.AssemblyMavenProjectStub"
 />

+                 <executedProject 
implementation="org.apache.maven.plugin.assembly.stubs.MavenProjectWithArtifactsStub"
 />

+          
<outputDirectory>${basedir}/target/test-harness/directory/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

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/min-plugin-config.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/min-plugin-config.xml?rev=399660&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/min-plugin-config.xml
 (added)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/test/plugin-configs/directory/min-plugin-config.xml
 Thu May  4 04:05:42 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/simple.xml</descriptor>

+                 <basedir>${basedir}</basedir>

+          <project 
implementation="org.apache.maven.plugin.assembly.stubs.AssemblyMavenProjectStub"
 />

+                 <executedProject 
implementation="org.apache.maven.plugin.assembly.stubs.AssemblyMavenProjectStub"
 />

+          
<outputDirectory>${basedir}/target/test-harness/directory/min/target</outputDirectory>

+          <finalName>directory-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


Reply via email to