Author: aramirez
Date: Wed Apr  5 19:17:32 2006
New Revision: 391877

URL: http://svn.apache.org/viewcvs?rev=391877&view=rev
Log:
PR:MINSTALL-16

added test cases for install-file mojo

Added:
    
maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java
    
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/
    
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/plugin-config.xml
    
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/target/
    
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/target/maven-install-test-1.0-SNAPSHOT.jar
   (with props)
    
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/
    
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/plugin-config.xml
    
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/target/
    
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/target/maven-install-test-1.0-SNAPSHOT.jar
   (with props)

Added: 
maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java?rev=391877&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java
 (added)
+++ 
maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java
 Wed Apr  5 19:17:32 2006
@@ -0,0 +1,117 @@
+package org.apache.maven.plugin.install;
+
+import java.io.File;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+
+/*
+ * 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 aramirez
+ */
+
+public class InstallFileMojoTest
+    extends AbstractMojoTestCase
+{
+    private String groupId;
+    
+    private String artifactId;
+    
+    private String version;
+    
+    private String packaging;
+    
+    private File file;
+    
+    private final String LOCAL_REPO = "target/local-repo/";
+    
+    public void testInstallFileTestEnvironment()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), 
+                                 
"target/test-classes/unit/install-file-basic-test/plugin-config.xml" );
+        
+        InstallFileMojo mojo = ( InstallFileMojo ) lookupMojo( "install-file", 
testPom );
+        
+        assertNotNull( mojo );
+    }   
+    
+    public void testBasicInstallFile()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), 
+                                 
"target/test-classes/unit/install-file-basic-test/plugin-config.xml" );
+        
+        InstallFileMojo mojo = ( InstallFileMojo ) lookupMojo( "install-file", 
testPom );
+        
+        assertNotNull( mojo );
+        
+        assignValuesForParameter( mojo );
+        
+        mojo.execute();
+        
+        File installedArtifact = new File( LOCAL_REPO + 
+                                           groupId + "/" + artifactId + "/" +
+                                           version + "/" + artifactId + "-" +
+                                           version + "." + packaging );
+     
+        assertTrue( installedArtifact.exists() );
+    }
+    
+    public void testInstallFileWithGeneratePom()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), 
+                                 
"target/test-classes/unit/install-file-test-generatePom/plugin-config.xml" );
+        
+        InstallFileMojo mojo = ( InstallFileMojo ) lookupMojo( "install-file", 
testPom );
+        
+        assertNotNull( mojo );
+        
+        assignValuesForParameter( mojo );
+        
+        mojo.execute();
+        
+        File installedArtifact = new File( LOCAL_REPO + 
+                                           groupId + "/" + artifactId + "/" +
+                                           version + "/" + artifactId + "-" +
+                                           version + "." + packaging );
+     
+        assertTrue( ( ( Boolean ) getVariableValueFromObject( mojo, 
"generatePom" ) ).booleanValue() );
+        
+        assertTrue( installedArtifact.exists() );
+    }
+    
+    private void assignValuesForParameter( Object obj )
+        throws Exception
+    {
+        this.groupId = dotToSlashReplacer( ( String ) 
getVariableValueFromObject( obj, "groupId" ) );
+        
+        this.artifactId = ( String ) getVariableValueFromObject( obj, 
"artifactId" );
+        
+        this.version = ( String ) getVariableValueFromObject( obj, "version" );
+        
+        this.packaging  = ( String ) getVariableValueFromObject( obj, 
"packaging" );
+        
+        this.file = ( File ) getVariableValueFromObject( obj, "file" );
+    }
+    
+    private String dotToSlashReplacer( String parameter )
+    {
+        return parameter.replace( '.', '/' );
+    }    
+}

Added: 
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/plugin-config.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/plugin-config.xml?rev=391877&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/plugin-config.xml
 (added)
+++ 
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/plugin-config.xml
 Wed Apr  5 19:17:32 2006
@@ -0,0 +1,17 @@
+<project>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-install-plugin</artifactId>
+               <configuration>
+                 <groupId>org.apache.maven.test</groupId>
+                 <artifactId>maven-install-file-test</artifactId>
+                 <version>1.0-SNAPSHOT</version>
+                 <packaging>jar</packaging>
+                 
<file>${basedir}/src/test/resources/unit/install-file-basic-test/target/maven-install-test-1.0-SNAPSHOT.jar</file>
+                 <localRepository>${localRepository}</localRepository>
+               </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: 
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/target/maven-install-test-1.0-SNAPSHOT.jar
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/target/maven-install-test-1.0-SNAPSHOT.jar?rev=391877&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-basic-test/target/maven-install-test-1.0-SNAPSHOT.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/plugin-config.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/plugin-config.xml?rev=391877&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/plugin-config.xml
 (added)
+++ 
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/plugin-config.xml
 Wed Apr  5 19:17:32 2006
@@ -0,0 +1,18 @@
+<project>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-install-plugin</artifactId>
+               <configuration>
+                 <groupId>org.apache.maven.test</groupId>
+                 <artifactId>maven-install-file-test</artifactId>
+                 <version>1.0-SNAPSHOT</version>
+                 <packaging>jar</packaging>
+                 
<file>${basedir}/src/test/resources/unit/install-file-basic-test/target/maven-install-test-1.0-SNAPSHOT.jar</file>
+                 <generatePom>true</generatePom>
+                 <localRepository>${localRepository}</localRepository>
+               </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: 
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/target/maven-install-test-1.0-SNAPSHOT.jar
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/target/maven-install-test-1.0-SNAPSHOT.jar?rev=391877&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/install-file-test-generatePom/target/maven-install-test-1.0-SNAPSHOT.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


Reply via email to