mirror of https://github.com/apache/maven.git
[MNG-3372] Adding an integration test to make sure plugin-version resolution works correctly for maven prerequisites, and that plugins without matching mojo-descriptors for the specified goal throw exceptions.
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@616450 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d114a265bc
commit
d6cdc2505e
|
@ -184,6 +184,7 @@ public class IntegrationTestSuite
|
|||
// 2.0.7 only (TODO: detect what version is used before running them)
|
||||
suite.addTestSuite( MavenIT0115CustomArtifactHandlerAndCustomLifecycleTest.class );
|
||||
suite.addTestSuite( MavenIT0119PluginPrefixOrder.class );
|
||||
suite.addTestSuite( MavenITmng3372DirectInvocationOfPlugins.class );
|
||||
// suite.addTestSuite( MavenIT0120EjbClientDependency.class ); -- not passing for 2.0.7 either, looks to be 2.1+ ?
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package org.apache.maven.integrationtests;
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* This is a sample integration test. The IT tests typically
|
||||
* operate by having a sample project in the
|
||||
* /src/test/resources folder along with a junit test like
|
||||
* this one. The junit test uses the verifier (which uses
|
||||
* the invoker) to invoke a new instance of Maven on the
|
||||
* project in the resources folder. It then checks the
|
||||
* results. This is a non-trivial example that shows two
|
||||
* phases. See more information inline in the code.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
*
|
||||
*/
|
||||
public class MavenITmng3372DirectInvocationOfPlugins
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
public void testDirectMojoInvocationWithPrefix()
|
||||
throws Exception
|
||||
{
|
||||
// The testdir is computed from the location of this
|
||||
// file.
|
||||
File testBaseDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3372-directInvocationOfPlugins/direct-using-prefix" );
|
||||
File plugin = new File( testBaseDir, "plugin" );
|
||||
File project = new File( testBaseDir, "project" );
|
||||
File settingsFile = new File( testBaseDir, "settings.xml" );
|
||||
|
||||
Verifier verifier = new Verifier( plugin.getAbsolutePath() );
|
||||
|
||||
verifier.deleteArtifact( "org.apache.maven.its.mng3372", "mng3372-maven-plugin", "1", "jar" );
|
||||
|
||||
verifier.executeGoals( Arrays.asList( new String[]{ "clean", "install" } ) );
|
||||
|
||||
verifier = new Verifier( project.getAbsolutePath() );
|
||||
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "-s" );
|
||||
cliOptions.add( settingsFile.getAbsolutePath() );
|
||||
|
||||
verifier.setCliOptions( cliOptions );
|
||||
verifier.executeGoal( "mng3372:test" );
|
||||
|
||||
verifier.verifyErrorFreeLog();
|
||||
|
||||
verifier.resetStreams();
|
||||
}
|
||||
|
||||
public void testDependencyTreeInvocation()
|
||||
throws Exception
|
||||
{
|
||||
// The testdir is computed from the location of this
|
||||
// file.
|
||||
File testBaseDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3372-directInvocationOfPlugins/dependency-tree" );
|
||||
File settingsFile = new File( testBaseDir, "settings.xml" );
|
||||
|
||||
Verifier verifier = new Verifier( testBaseDir.getAbsolutePath() );
|
||||
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "-s" );
|
||||
cliOptions.add( settingsFile.getAbsolutePath() );
|
||||
cliOptions.add( "-U" );
|
||||
|
||||
verifier.setCliOptions( cliOptions );
|
||||
verifier.executeGoal( "dependency:tree" );
|
||||
|
||||
verifier.verifyErrorFreeLog();
|
||||
|
||||
verifier.resetStreams();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
<settings>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>asf-snapshots</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>asf-snapshots</id>
|
||||
<url>http://people.apache.org/repo/m2-snapshot-repository/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>asf-snapshots</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
|
@ -0,0 +1,16 @@
|
|||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.its.mng3372</groupId>
|
||||
<artifactId>mng3372-maven-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<version>1</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,68 @@
|
|||
package org.plugin;
|
||||
|
||||
import org.apache.maven.plugin.Mojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @goal test
|
||||
*/
|
||||
public class TestMojo
|
||||
implements Mojo
|
||||
{
|
||||
|
||||
private Log log;
|
||||
|
||||
/**
|
||||
* @parameter default-value="${project.build.directory}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
private File buildDir;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
File outFile = new File( buildDir, "out.txt" );
|
||||
FileWriter writer = null;
|
||||
try
|
||||
{
|
||||
outFile.getParentFile().mkdirs();
|
||||
|
||||
writer = new FileWriter( outFile );
|
||||
writer.write( "Test" );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Failed to write: " + outFile.getAbsolutePath(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( writer != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Log getLog()
|
||||
{
|
||||
return log;
|
||||
}
|
||||
|
||||
public void setLog( Log log )
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.its.mng3372</groupId>
|
||||
<artifactId>project</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>project</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package org.test;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.test;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<settings>
|
||||
<pluginGroups>
|
||||
<pluginGroup>org.apache.maven.its.mng3372</pluginGroup>
|
||||
</pluginGroups>
|
||||
</settings>
|
Loading…
Reference in New Issue