o Decoupled IT from production plugins

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@784264 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-06-12 20:35:43 +00:00
parent 56f8e5c276
commit ed2a382640
5 changed files with 32 additions and 67 deletions

View File

@ -51,75 +51,31 @@ public class MavenITmng3394POMPluginVersionDominanceTest
//testShouldUsePluginVersionFromPluginMgmtForLifecycleMojoWhenNotInBuildPlugins //testShouldUsePluginVersionFromPluginMgmtForLifecycleMojoWhenNotInBuildPlugins
File testDir = ResourceExtractor.simpleExtractResources( getClass(), BASEDIR_PREFIX + "lifecycleMojoVersionInPluginMgmt" ); File testDir = ResourceExtractor.simpleExtractResources( getClass(), BASEDIR_PREFIX + "lifecycleMojoVersionInPluginMgmt" );
Verifier verifier; Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier = new Verifier( testDir.getAbsolutePath() ); verifier.deleteDirectory( "target" );
verifier.executeGoal( "process-resources" );
verifier.setCliOptions( Collections.singletonList( "-X" ) );
verifier.executeGoal( "install" );
/*
* This is the simplest way to check a build
* succeeded. It is also the simplest way to create
* an IT test: make the build pass when the test
* should pass, and make the build fail when the
* test should fail. There are other methods
* supported by the verifier. They can be seen here:
* http://maven.apache.org/shared/maven-verifier/apidocs/index.html
*/
verifier.verifyErrorFreeLog(); verifier.verifyErrorFreeLog();
List logFile = verifier.loadFile( new File( testDir, "log.txt" ), false );
boolean foundSiteBeta5 = false;
for ( Iterator it = logFile.iterator(); it.hasNext(); )
{
String line = (String) it.next();
if ( line.indexOf( "maven-site-plugin:2.0-beta-5" ) > -1 )
{
foundSiteBeta5 = true;
break;
}
}
/*
* Reset the streams before executing the verifier
* again.
*/
verifier.resetStreams(); verifier.resetStreams();
assertTrue( "No reference to maven-site-plugin, version 2.0-beta-5 found in build log.", foundSiteBeta5 ); verifier.assertFilePresent( "target/resources-resources.txt" );
} }
public void testitMNG3394b () public void testitMNG3394b()
throws Exception throws Exception
{ {
//testShouldPreferPluginVersionFromBuildPluginsOverThatInPluginMgmt //testShouldPreferPluginVersionFromBuildPluginsOverThatInPluginMgmt
File testDir = ResourceExtractor.simpleExtractResources( getClass(), BASEDIR_PREFIX + "preferBuildPluginOverPluginMgmt" ); File testDir = ResourceExtractor.simpleExtractResources( getClass(), BASEDIR_PREFIX + "preferBuildPluginOverPluginMgmt" );
Verifier verifier; Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false ); verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "clean" ); verifier.executeGoal( "clean" );
/*
* This is the simplest way to check a build
* succeeded. It is also the simplest way to create
* an IT test: make the build pass when the test
* should pass, and make the build fail when the
* test should fail. There are other methods
* supported by the verifier. They can be seen here:
* http://maven.apache.org/shared/maven-verifier/apidocs/index.html
*/
verifier.verifyErrorFreeLog(); verifier.verifyErrorFreeLog();
/*
* Reset the streams before executing the verifier
* again.
*/
verifier.resetStreams(); verifier.resetStreams();
verifier.assertFilePresent( "target/clean-clean.txt" );
} }
} }

View File

@ -1,18 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3394</groupId> <groupId>org.apache.maven.its.mng3394</groupId>
<artifactId>lifecycleMojoVersionInPluginMgmt</artifactId> <artifactId>lifecycleMojoVersionInPluginMgmt</artifactId>
<packaging>pom</packaging>
<version>1</version> <version>1</version>
<name>lifecycleMojoVersionInPluginMgmt</name> <packaging>jar</packaging>
<name>Maven Integration Test :: MNG-3394</name>
<description>
This test should verify that the Resources Plugin version used is 0.1-stub, not the latest one. It should
get this version from the POM's pluginManagement section, even though the plugin's mojo call is coming from
the default lifecycle bindings, and the plugin is not specified in the POM's build/plugins section.
</description>
<build> <build>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-site-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>2.0-beta-5</version> <version>0.1-stub-SNAPSHOT</version>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>

View File

@ -1,5 +0,0 @@
This test should verify that the site plugin version used is 2.0-beta-5, not the latest one (which is currently 2.0-beta-6). It should get this version from the POM's pluginManagement section, even though the site-plugin's mojo call is coming from the default lifecycle bindings, and the site plugin is not specified in the POM's build/plugins section.
To test, run `mvn -X install | tee build.log` or similar, to capture output to a separate file. Then, search the debug output for the string:
org.apache.maven.plugins:maven-site-plugin:2.0-beta-5

View File

@ -1,10 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3394</groupId> <groupId>org.apache.maven.its.mng3394</groupId>
<artifactId>preferBuildPluginOverPluginMgmt</artifactId> <artifactId>preferBuildPluginOverPluginMgmt</artifactId>
<packaging>jar</packaging>
<version>1</version> <version>1</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-3394</name>
<description>
Test that the plugin version given in project/build/plugins overrides that in project/build/pluginManagement/plugins.
If this is correct, the clean plugin should find a valid version, and execute. Otherwise, the version 'invalid' is
used by Maven, and the clean plugin with that version cannot be resolved...so the build fails. Use `mvn clean` to test.
</description>
<build> <build>
<pluginManagement> <pluginManagement>
@ -18,7 +26,7 @@
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-clean-plugin</artifactId> <artifactId>maven-clean-plugin</artifactId>
<version>2.1.1</version> <version>0.1-stub-SNAPSHOT</version>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -1 +0,0 @@
Test that the plugin version given in project/build/plugins overrides that in project/build/pluginManagement/plugins. If this is correct, the clean plugin should find a valid version, and execute. Otherwise, the version 'invalid' is used by Maven, and the clean plugin with that version cannot be resolved...so the build fails. Use `mvn clean` to test.