You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ar...@apache.org on 2006/02/03 10:07:23 UTC
svn commit: r374609 - in /maven/plugins/trunk/maven-deploy-plugin/src/test:
./ java/ java/org/ java/org/apache/ java/org/apache/maven/
java/org/apache/maven/plugin/ java/org/apache/maven/plugin/deploy/
Author: aramirez
Date: Fri Feb 3 01:07:09 2006
New Revision: 374609
URL: http://svn.apache.org/viewcvs?rev=374609&view=rev
Log:
-added test
Submitted by: Jerome Lacoste
Added:
maven/plugins/trunk/maven-deploy-plugin/src/test/
maven/plugins/trunk/maven-deploy-plugin/src/test/java/
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java
Added: maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java?rev=374609&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java Fri Feb 3 01:07:09 2006
@@ -0,0 +1,189 @@
+package org.apache.maven.plugin.deploy;
+
+/*
+ * 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 junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+
+/**
+ * @author <a href="jerome@coffeebreaks.org">Jerome Lacoste</a>
+ * @version $Id$
+ */
+public class DeployFileMojoTest
+ extends TestCase
+{
+ public static void main( String[] args )
+ {
+ junit.textui.TestRunner.run( suite() );
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite( DeployFileMojoTest.class );
+
+ return suite;
+ }
+
+ MockDeployFileMojo mojo;
+ Parent parent;
+
+ public void setUp()
+ {
+ Model pomModel = new Model();
+ pomModel.setPackaging( null );
+
+ parent = new Parent();
+ parent.setGroupId( "parentGroup" );
+ parent.setArtifactId( "parentArtifact" );
+ parent.setVersion( "parentVersion" );
+
+ mojo = new MockDeployFileMojo( pomModel );
+ }
+
+ public void tearDown()
+ {
+ mojo = null;
+ }
+
+ class MockDeployFileMojo extends DeployFileMojo {
+ private Model model;
+
+ public MockDeployFileMojo(Model model) {
+ this.model = model;
+ }
+
+ public void setModel(Model model) {
+ this.model = model;
+ }
+
+ protected Model readModel(File pomFile) throws MojoExecutionException {
+ return model;
+ }
+ }
+
+ public void testProcessPomFromPomFileWithParent1() throws MojoExecutionException
+ {
+ mojo.setPomFile( new File( "foo.bar" ) );
+
+ setMojoModel( mojo.model, null, null, null, null, parent );
+
+ try {
+ mojo.initProperties();
+ } catch (MojoExecutionException expected) {
+ assertTrue( true ); // missing artifact version and packaging
+ }
+
+ checkMojoProperties("parentGroup", null, null, null);
+ }
+
+ public void testProcessPomFromPomFileWithParent2() throws MojoExecutionException
+ {
+ mojo.setPomFile( new File( "foo.bar" ) );
+ setMojoModel( mojo.model, null, "artifact", null, null, parent );
+
+ try {
+ mojo.initProperties();
+ } catch (MojoExecutionException expected) {
+ assertTrue( true ); // missing version and packaging
+ }
+
+ checkMojoProperties("parentGroup", "artifact", null, null );
+
+ }
+
+ public void testProcessPomFromPomFileWithParent3() throws MojoExecutionException
+ {
+ mojo.setPomFile( new File( "foo.bar" ) );
+ setMojoModel( mojo.model, null, "artifact", "version", null, parent );
+
+ try {
+ mojo.initProperties();
+ } catch (MojoExecutionException expected) {
+ assertTrue( true ); // missing version and packaging
+ }
+
+ checkMojoProperties( "parentGroup", "artifact", "version", null );
+ }
+
+ public void testProcessPomFromPomFileWithParent4() throws MojoExecutionException
+ {
+ mojo.setPomFile( new File( "foo.bar" ) );
+ setMojoModel( mojo.model, null, "artifact", "version", "packaging", parent );
+
+ mojo.initProperties();
+
+ checkMojoProperties("parentGroup", "artifact", "version", "packaging");
+ }
+
+ public void testProcessPomFromPomFileWithParent5() throws MojoExecutionException
+ {
+ mojo.setPomFile( new File( "foo.bar" ) );
+ setMojoModel( mojo.model, "group", "artifact", "version", "packaging", parent );
+
+ mojo.initProperties();
+
+ checkMojoProperties("group", "artifact", "version", "packaging");
+ }
+
+ public void testProcessPomFromPomFileWithParent6() throws MojoExecutionException
+ {
+ mojo.setPomFile( new File( "foo.bar" ) );
+ setMojoModel( mojo.model, "group", "artifact", "version", "packaging", null );
+
+ mojo.initProperties();
+
+ checkMojoProperties("group", "artifact", "version", "packaging");
+
+ }
+
+ public void testProcessPomFromPomFileWithOverrides() throws MojoExecutionException
+ {
+ mojo.setPomFile( new File( "foo.bar" ) );
+ setMojoModel( mojo.model, "group", "artifact", "version", "packaging", null );
+
+ mojo.setGroupId( "groupO" );
+ mojo.setArtifactId( "artifactO" );
+ mojo.setVersion( "versionO" );
+ mojo.setPackaging( "packagingO" );
+
+ mojo.initProperties();
+
+ checkMojoProperties("groupO", "artifactO", "versionO", "packagingO");
+ }
+
+ private void checkMojoProperties(final String expectedGroup, final String expectedArtifact, final String expectedVersion, final String expectedPackaging) {
+ assertEquals( expectedGroup, mojo.getGroupId() );
+ assertEquals( expectedArtifact, mojo.getArtifactId() );
+ assertEquals( expectedVersion, mojo.getVersion() );
+ assertEquals( expectedPackaging, mojo.getPackaging() );
+ }
+
+ private void setMojoModel(Model model, String group, String artifact, String version, String packaging, Parent parent ) {
+ model.setGroupId( group );
+ model.setArtifactId( artifact );
+ model.setVersion( version );
+ model.setPackaging( packaging );
+ model.setParent( parent );
+ }
+
+}