You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ke...@apache.org on 2007/01/19 16:12:02 UTC
svn commit: r497840 -
/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/AbstractMavenIntegrationTestCase.java
Author: kenney
Date: Fri Jan 19 07:12:01 2007
New Revision: 497840
URL: http://svn.apache.org/viewvc?view=rev&rev=497840
Log:
add possibility of using a new empty local repo for each IT
Modified:
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/AbstractMavenIntegrationTestCase.java
Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/AbstractMavenIntegrationTestCase.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/AbstractMavenIntegrationTestCase.java?view=diff&rev=497840&r1=497839&r2=497840
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/AbstractMavenIntegrationTestCase.java (original)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/AbstractMavenIntegrationTestCase.java Fri Jan 19 07:12:01 2007
@@ -1,5 +1,9 @@
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;
@@ -14,15 +18,15 @@
protected void runTest()
throws Throwable
{
- 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;
+ if ( "true".equals( System.getProperty( "useEmptyLocalRepository", "false" ) ) )
+ {
+ setupLocalRepo();
+ }
+ // save System.out since running the test will replace it
PrintStream out = System.out;
- out.print( simpleName + ".." );
+ out.print( getITName() + "(" + getName() + ").." );
try
{
@@ -34,5 +38,30 @@
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;
}
}