You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2008/09/09 00:37:17 UTC
svn commit: r693305 - in
/maven/core-integration-testing/trunk/core-integration-tests/src/test:
java/org/apache/maven/integrationtests/
resources/mng-3746-pomPropertyOverride/maven-mng3746-plugin/src/main/java/jar/
Author: jdcasey
Date: Mon Sep 8 15:37:16 2008
New Revision: 693305
URL: http://svn.apache.org/viewvc?rev=693305&view=rev
Log:
[MNG-3746] Add a test ensuring that cli-specified properties override those in the POM...the other test in this IT already verifies that POM properties override default sysprops (not from the cli) whenever there is an overlap.
Modified:
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3746POMPropertyOverrideTest.java
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3746-pomPropertyOverride/maven-mng3746-plugin/src/main/java/jar/MyMojo.java
Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3746POMPropertyOverrideTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3746POMPropertyOverrideTest.java?rev=693305&r1=693304&r2=693305&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3746POMPropertyOverrideTest.java (original)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3746POMPropertyOverrideTest.java Mon Sep 8 15:37:16 2008
@@ -20,6 +20,8 @@
package org.apache.maven.integrationtests;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.it.Verifier;
@@ -27,12 +29,10 @@
/**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3746">MNG-3746</a>.
- *
- * @todo Fill in a better description of what this test verifies!
*
+ * @todo Fill in a better description of what this test verifies!
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @author jdcasey
- *
*/
public class MavenITmng3746POMPropertyOverrideTest
extends AbstractMavenIntegrationTestCase
@@ -43,7 +43,7 @@
super( "(2.0.8,)" ); // only test in 2.0.9+
}
- public void testitMNG3746 ()
+ public void testitMNG3746_UsingDefaultSystemProperty()
throws Exception
{
// The testdir is computed from the location of this
@@ -58,10 +58,40 @@
verifier.executeGoal( "install" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
-
+
verifier = new Verifier( projectDir.getAbsolutePath() );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}
+
+ public void testitMNG3746_UsingCLIProperty()
+ throws Exception
+ {
+ // The testdir is computed from the location of this
+ // file.
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3746-pomPropertyOverride" );
+ File pluginDir = new File( testDir, "maven-mng3746-plugin" );
+ File projectDir = new File( testDir, "project" );
+
+ Verifier verifier;
+
+ verifier = new Verifier( pluginDir.getAbsolutePath() );
+ verifier.executeGoal( "install" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+
+ verifier = new Verifier( projectDir.getAbsolutePath() );
+
+ List cliOptions = new ArrayList();
+ cliOptions.add( "-Dtest.verification=cli" );
+ cliOptions.add( "-Dtest.usingCliValue=true" );
+ cliOptions.add( "-Djava.version=cli" );
+
+ verifier.setCliOptions( cliOptions );
+
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+ }
}
Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3746-pomPropertyOverride/maven-mng3746-plugin/src/main/java/jar/MyMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3746-pomPropertyOverride/maven-mng3746-plugin/src/main/java/jar/MyMojo.java?rev=693305&r1=693304&r2=693305&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3746-pomPropertyOverride/maven-mng3746-plugin/src/main/java/jar/MyMojo.java (original)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3746-pomPropertyOverride/maven-mng3746-plugin/src/main/java/jar/MyMojo.java Mon Sep 8 15:37:16 2008
@@ -34,11 +34,21 @@
private String check;
/**
+ * @parameter expression="${test.verification}"
+ */
+ private String verification;
+
+ /**
+ * @parameter expression="${test.usingCliValue}" default-value="false"
+ */
+ private boolean usingCliValue;
+
+ /**
* @parameter default-value="${project.properties}"
* @readonly
*/
private Properties properties;
-
+
public void execute()
throws MojoExecutionException
{
@@ -47,15 +57,23 @@
boolean fail = false;
- if ( check.equals( sysProp ) )
+ if ( !usingCliValue )
{
- getLog().error( "Check value is the same as the system property; interpolation failed! (value: " + check + ")" );
- fail = true;
+ if ( check.equals( sysProp ) )
+ {
+ getLog().error( "Check value is the same as the system property; interpolation failed! (value: " + check + ")" );
+ fail = true;
+ }
+
+ if ( !check.equals( pomProp ) )
+ {
+ getLog().error( "Check value is NOT the same as the POM property; interpolation failed! (value: " + check + ")" );
+ fail = true;
+ }
}
-
- if ( !check.equals( pomProp ) )
+ else if ( !check.equals( verification ) )
{
- getLog().error( "Check value is NOT the same as the POM property; interpolation failed! (value: " + check + ")" );
+ getLog().error( "Check value is NOT the same as the verification value; interpolation failed! (value: " + check + "; verification value: " + verification + ")" );
fail = true;
}