o helper has been separated and now used in the IT archteype

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@551806 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2007-06-29 06:01:25 +00:00
parent 59ebc673c0
commit aae6dbf4a3
6 changed files with 13 additions and 192 deletions

View File

@ -34,6 +34,11 @@
<artifactId>maven-verifier</artifactId> <artifactId>maven-verifier</artifactId>
<version>1.1-SNAPSHOT</version> <version>1.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>maven-integration-test-helper</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -1,109 +0,0 @@
package org.apache.maven.integrationtests;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.it.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import junit.framework.TestCase;
/**
* @author Jason van Zyl
* @author Kenney Westerhof
*/
public abstract class AbstractMavenIntegrationTestCase
extends TestCase
{
/**
* Save System.out for progress reports etc.
*/
private static PrintStream out = System.out;
private boolean skip;
private DefaultArtifactVersion version;
private VersionRange versionRange;
protected AbstractMavenIntegrationTestCase()
{
}
protected AbstractMavenIntegrationTestCase( String versionRangeStr )
throws InvalidVersionSpecificationException
{
this.versionRange = VersionRange.createFromVersionSpec( versionRangeStr );
String v = System.getProperty( "maven.version" );
if ( v != null )
{
this.version = new DefaultArtifactVersion( v );
if ( !versionRange.containsVersion( this.version ) )
{
skip = true;
}
}
else
{
out.print( "WARNING: " + getITName() + ": version range '" + versionRange
+ "' supplied but no maven version - not skipping test." );
}
}
protected void runTest()
throws Throwable
{
out.print( getITName() + "(" + getName() + ").." );
if ( skip )
{
out.println( " Skipping (version " + version + " not in range " + versionRange + ")" );
return;
}
if ( "true".equals( System.getProperty( "useEmptyLocalRepository", "false" ) ) )
{
setupLocalRepo();
}
try
{
super.runTest();
out.println( " Ok" );
}
catch ( Throwable t )
{
out.println( " Failure" );
throw t;
}
}
private String getITName()
{
String simpleName = getClass().getName();
int idx = simpleName.lastIndexOf( '.' );
simpleName = idx >= 0 ? simpleName.substring( idx + 1 ) : simpleName;
simpleName = simpleName.startsWith( "MavenIT" ) ? simpleName.substring( "MavenIT".length() ) : simpleName;
simpleName = simpleName.endsWith( "Test" ) ? simpleName.substring( 0, simpleName.length() - 4 ) : simpleName;
return simpleName;
}
protected File setupLocalRepo()
throws IOException
{
String tempDirPath = System.getProperty( "maven.test.tmpdir", System.getProperty( "java.io.tmpdir" ) );
File localRepo = new File( tempDirPath, "local-repository/" + getITName() );
if ( localRepo.isDirectory() )
{
FileUtils.deleteDirectory( localRepo );
}
System.setProperty( "maven.repo.local", localRepo.getAbsolutePath() );
return localRepo;
}
}

View File

@ -10,6 +10,11 @@
<artifactId>maven-verifier</artifactId> <artifactId>maven-verifier</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>maven-integration-test-helper</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -1,67 +0,0 @@
package org.apache.maven.integrationtests;
import org.apache.maven.it.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import junit.framework.TestCase;
/**
* @author Jason van Zyl
* @author Kenney Westerhof
*/
public abstract class AbstractMavenIntegrationTestCase
extends TestCase
{
protected void runTest()
throws Throwable
{
if ( "true".equals( System.getProperty( "useEmptyLocalRepository", "false" ) ) )
{
setupLocalRepo();
}
// save System.out since running the test will replace it
PrintStream out = System.out;
out.print( getITName() + "(" + getName() + ").." );
try
{
super.runTest();
out.println( " Ok" );
}
catch ( Throwable t )
{
out.println( " Failure" );
throw t;
}
}
private String getITName()
{
String simpleName = getClass().getName();
int idx = simpleName.lastIndexOf( '.' );
simpleName = idx >= 0 ? simpleName.substring( idx + 1 ) : simpleName;
simpleName = simpleName.startsWith( "MavenIT" ) ? simpleName.substring( "MavenIT".length() ) : simpleName;
simpleName = simpleName.endsWith( "Test" ) ? simpleName.substring( 0, simpleName.length() - 4 ) : simpleName;
return simpleName;
}
protected File setupLocalRepo()
throws IOException
{
String tempDirPath = System.getProperty( "maven.test.tmpdir", System.getProperty( "java.io.tmpdir" ) );
File localRepo = new File( tempDirPath, "local-repository/" + getITName() );
if ( localRepo.isDirectory() )
{
FileUtils.deleteDirectory( localRepo );
}
System.setProperty( "maven.repo.local", localRepo.getAbsolutePath() );
return localRepo;
}
}

View File

@ -1,15 +0,0 @@
package org.apache.maven.integrationtests;
import junit.framework.Test;
import junit.framework.TestSuite;
public class IntegrationTestSuite
extends AbstractMavenIntegrationTestCase
{
public static Test suite()
{
TestSuite suite = new TestSuite();
suite.addTestSuite( MavenIT0111PluginsThatRequireAResourceFromAnExtensionTest.class );
return suite;
}
}

View File

@ -47,7 +47,9 @@
</issueManagement> </issueManagement>
<modules> <modules>
<module>core-integration-testing-plugins</module> <module>core-integration-testing-plugins</module>
<module>core-integration-testing-support</module> <module>core-integration-testing-support</module>
<module>maven-integration-test-helper</module>
<module>maven-integration-test</module>
</modules> </modules>
<distributionManagement> <distributionManagement>
<repository> <repository>