Author: brianf Date: Mon Jul 23 19:20:12 2007 New Revision: 558915 URL: http://svn.apache.org/viewvc?view=rev&rev=558915 Log: changes to sample to make it generic and self documenting
Added: maven/core-integration-testing/trunk/maven-integration-test/src/test/java/org/apache/maven/integrationtests/MavenITmngXXXXDescriptionOfProblemTest.java - copied, changed from r557106, maven/core-integration-testing/trunk/maven-integration-test/src/test/java/org/apache/maven/integrationtests/MavenIT0111PluginsThatRequireAResourceFromAnExtensionTest.java maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/ - copied from r557106, maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/it0111-pluginThatRequiresResourceFromAnExtension/ maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/readme.txt Removed: maven/core-integration-testing/trunk/maven-integration-test/src/test/java/org/apache/maven/integrationtests/MavenIT0111PluginsThatRequireAResourceFromAnExtensionTest.java maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/it0111-pluginThatRequiresResourceFromAnExtension/ Modified: maven/core-integration-testing/trunk/maven-integration-test/ (props changed) maven/core-integration-testing/trunk/maven-integration-test/pom.xml maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/ (props changed) maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/pom.xml maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-test/pom.xml maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/pom.xml Propchange: maven/core-integration-testing/trunk/maven-integration-test/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Jul 23 19:20:12 2007 @@ -0,0 +1 @@ +target Modified: maven/core-integration-testing/trunk/maven-integration-test/pom.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/maven-integration-test/pom.xml?view=diff&rev=558915&r1=558914&r2=558915 ============================================================================== --- maven/core-integration-testing/trunk/maven-integration-test/pom.xml (original) +++ maven/core-integration-testing/trunk/maven-integration-test/pom.xml Mon Jul 23 19:20:12 2007 @@ -11,10 +11,10 @@ <version>1.0</version> </dependency> <dependency> - <groupId>org.apache.maven.its</groupId> - <artifactId>maven-integration-test-helper</artifactId> - <version>1.0-SNAPSHOT</version> - </dependency> + <groupId>org.apache.maven.its</groupId> + <artifactId>maven-integration-test-helper</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> @@ -22,4 +22,17 @@ <scope>test</scope> </dependency> </dependencies> + <!-- TODO: remove when snapshots are released --> + <repositories> + <repository> + <id>apache.snapshots</id> + <url>http://people.apache.org/repo/m2-snapshot-repository</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> </project> Copied: maven/core-integration-testing/trunk/maven-integration-test/src/test/java/org/apache/maven/integrationtests/MavenITmngXXXXDescriptionOfProblemTest.java (from r557106, maven/core-integration-testing/trunk/maven-integration-test/src/test/java/org/apache/maven/integrationtests/MavenIT0111PluginsThatRequireAResourceFromAnExtensionTest.java) URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/maven-integration-test/src/test/java/org/apache/maven/integrationtests/MavenITmngXXXXDescriptionOfProblemTest.java?view=diff&rev=558915&p1=maven/core-integration-testing/trunk/maven-integration-test/src/test/java/org/apache/maven/integrationtests/MavenIT0111PluginsThatRequireAResourceFromAnExtensionTest.java&r1=557106&p2=maven/core-integration-testing/trunk/maven-integration-test/src/test/java/org/apache/maven/integrationtests/MavenITmngXXXXDescriptionOfProblemTest.java&r2=558915 ============================================================================== --- maven/core-integration-testing/trunk/maven-integration-test/src/test/java/org/apache/maven/integrationtests/MavenIT0111PluginsThatRequireAResourceFromAnExtensionTest.java (original) +++ maven/core-integration-testing/trunk/maven-integration-test/src/test/java/org/apache/maven/integrationtests/MavenITmngXXXXDescriptionOfProblemTest.java Mon Jul 23 19:20:12 2007 @@ -7,39 +7,107 @@ import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; -//!! public class ${className} -public class MavenIT0111PluginsThatRequireAResourceFromAnExtensionTest +/** + * 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:[EMAIL PROTECTED]">Brian Fox</a> + * + */ +public class MavenITmngXXXXDescriptionOfProblemTest extends AbstractMavenIntegrationTestCase { - public void testit0111() + public void testitMNGxxxx () throws Exception { - File testDir = - ResourceExtractor.simpleExtractResources( getClass(), "/it0111-pluginThatRequiresResourceFromAnExtension" ); + // TODO: RENAME THIS TEST TO SUIT YOUR SCENARIO. + // Usign the Jira issue id this reproduces is a good + // start, along with a description: + // ie MNG-13x-HoustonWeHaveAProblemTest (must end in test) + + // The testdir is computed from the location of this + // file. + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-xxxx-descriptionOfProblem" ); Verifier verifier; - // Install the parent POM + /* + * We must first make sure that any artifact created + * by this test has been removed from the local + * repository. Failing to do this could cause + * unstable test results. Fortunately, the verifier + * makes it easy to do this. + */ verifier = new Verifier( testDir.getAbsolutePath() ); - verifier.deleteArtifact( "org.apache.maven.its.it0111", "parent", "1.0", "pom" ); - verifier.deleteArtifact( "org.apache.maven.its.it0111", "checkstyle-test", "1.0", "jar" ); - verifier.deleteArtifact( "org.apache.maven.its.it0111", "checkstyle-assembly", "1.0", "jar" ); + verifier.deleteArtifact( "org.apache.maven.its.itsample", "parent", "1.0", "pom" ); + verifier.deleteArtifact( "org.apache.maven.its.itsample", "checkstyle-test", "1.0", "jar" ); + verifier.deleteArtifact( "org.apache.maven.its.itsample", "checkstyle-assembly", "1.0", "jar" ); + + /* + * The Command Line Options (CLI) are passed to the + * verifier as a list. This is handy for things like + * redefining the local repository if needed. In + * this case, we use the -N flag so that Maven won't + * recurse. We are only installing the parent pom to + * the local repo here. + */ List cliOptions = new ArrayList(); cliOptions.add( "-N" ); 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(); + + /* + * Reset the streams before executing the verifier + * again. + */ verifier.resetStreams(); - // Install the extension with the resources required for the test + /* + * This particular test requires an extension + * containing resources to be installed that is then + * used by the actual IT test. Here we invoker Maven + * again to install it. Again, this is just + * preparation for the test. + */ verifier = new Verifier( new File( testDir.getAbsolutePath(), "checkstyle-assembly" ).getAbsolutePath() ); verifier.executeGoal( "install" ); verifier.verifyErrorFreeLog(); verifier.resetStreams(); - // Run the whole test + /* + * Now we are running the actual test. This + * particular test will attempt to load the + * resources from the extension jar previously + * installed. If Maven doesn't pass this to the + * classpath correctly, the build will fail. This + * particular test will fail in Maven <2.0.6. + */ verifier = new Verifier( new File( testDir.getAbsolutePath(), "checkstyle-test" ).getAbsolutePath() ); verifier.executeGoal( "install" ); verifier.verifyErrorFreeLog(); verifier.resetStreams(); + + /* + * The verifier also supports beanshell scripts for + * verification of more complex scenarios. There are + * plenty of examples in the core-it tests here: + * http://svn.apache.org/repos/asf/maven/core-integration-testing/trunk + */ } } Propchange: maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Jul 23 19:20:12 2007 @@ -0,0 +1 @@ +target Modified: maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/pom.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/pom.xml?view=diff&rev=558915&r1=557106&r2=558915 ============================================================================== --- maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/pom.xml (original) +++ maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-assembly/pom.xml Mon Jul 23 19:20:12 2007 @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.apache.maven.its.it0111</groupId> + <groupId>org.apache.maven.its.itsample</groupId> <artifactId>parent</artifactId> <version>1</version> </parent> Modified: maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-test/pom.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-test/pom.xml?view=diff&rev=558915&r1=557106&r2=558915 ============================================================================== --- maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-test/pom.xml (original) +++ maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/checkstyle-test/pom.xml Mon Jul 23 19:20:12 2007 @@ -1,7 +1,7 @@ <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> <parent> - <groupId>org.apache.maven.its.it0111</groupId> + <groupId>org.apache.maven.its.itsample</groupId> <artifactId>parent</artifactId> <version>1</version> </parent> @@ -9,15 +9,20 @@ <name>Checkstyle Test</name> <build> + <!--This extension is installed by the IT prior to invoking this build. See ../checkstyle-assembly--> <extensions> <extension> - <groupId>org.apache.maven.its.it0111</groupId> + <groupId>org.apache.maven.its.itsample</groupId> <artifactId>checkstyle-assembly</artifactId> <version>1.0</version> </extension> </extensions> - + <!-- Typically the tests will not rely on actual plugins and should be self-contained, in this case the problem was most + often experienced with Checkstyle so it makes it a valid test. Notice however that it is pinned to a known released version + so the test won't randomly fail in the future if the plugin behavior changes. + + If the extension listed above isn't correctly installed on the plugin classpath, this invocation will fail to find the custom rule --> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -40,7 +45,6 @@ </execution> </executions> </plugin> - </plugins> </build> </project> Modified: maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/pom.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/pom.xml?view=diff&rev=558915&r1=557106&r2=558915 ============================================================================== --- maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/pom.xml (original) +++ maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/pom.xml Mon Jul 23 19:20:12 2007 @@ -1,6 +1,6 @@ <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.it0111</groupId> + <groupId>org.apache.maven.its.itsample</groupId> <artifactId>parent</artifactId> <packaging>pom</packaging> <version>1</version> Added: maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/readme.txt URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/readme.txt?view=auto&rev=558915 ============================================================================== --- maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/readme.txt (added) +++ maven/core-integration-testing/trunk/maven-integration-test/src/test/resources/mng-xxxx-descriptionOfProblem/readme.txt Mon Jul 23 19:20:12 2007 @@ -0,0 +1,3 @@ +This is a sample IT based on a real one. This test first installs a jar containing some checkstyle rules. The second invocation uses that jar as an extension +so that checkstyle finds the resources. If Maven behaves properly, the build succeeds, if not, the build fails. This is the simplest way to structure an IT when +possible as it's cut and dry and is very easy to check with the verifier. \ No newline at end of file