PR: MASSEMBLY-88

added test for directory mojo

git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-assembly-plugin@399660 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/test/java/org/apache/maven/plugin/assembly/DirectoryMojoTest.java b/src/test/java/org/apache/maven/plugin/assembly/DirectoryMojoTest.java
new file mode 100644
index 0000000..42adce7
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugin/assembly/DirectoryMojoTest.java
@@ -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() ) );
+    }
+}
diff --git a/src/test/plugin-configs/directory/dependency-set-plugin-config.xml b/src/test/plugin-configs/directory/dependency-set-plugin-config.xml
new file mode 100644
index 0000000..a2d5c62
--- /dev/null
+++ b/src/test/plugin-configs/directory/dependency-set-plugin-config.xml
@@ -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
diff --git a/src/test/plugin-configs/directory/min-plugin-config.xml b/src/test/plugin-configs/directory/min-plugin-config.xml
new file mode 100644
index 0000000..8858d60
--- /dev/null
+++ b/src/test/plugin-configs/directory/min-plugin-config.xml
@@ -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