Remove unused classes. They are implemented in surefire.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162565 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2004-02-11 22:25:15 +00:00
parent bb6dd6ae52
commit 68eea5fd4d
2 changed files with 0 additions and 194 deletions

View File

@ -1,57 +0,0 @@
import java.net.URLClassLoader;
import java.net.URL;
/**
*
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*
* @version $Id$
*/
public class IsolatedClassLoader
extends URLClassLoader
{
private ClassLoader parent = ClassLoader.getSystemClassLoader();
public IsolatedClassLoader()
{
super( new URL[0], null );
}
public void addURL( URL url )
{
super.addURL( url );
}
public synchronized Class loadClass( String className )
throws ClassNotFoundException
{
Class c = findLoadedClass( className );
ClassNotFoundException ex = null;
if ( c == null )
{
try
{
c = findClass( className );
}
catch ( ClassNotFoundException e )
{
ex = e;
if ( parent != null )
{
c = parent.loadClass( className );
}
}
}
if ( c == null )
{
throw ex;
}
return c;
}
}

View File

@ -1,137 +0,0 @@
import org.apache.maven.test.TestRunner;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.StringUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
public class TestRunnerBooter
{
public static void main(String[] args) throws Exception
{
TestRunnerBooter booter = new TestRunnerBooter();
booter.execute(args);
}
public void execute(String[] args) throws Exception
{
File basedir = new File(args[0]);
System.setProperty( "basedir", basedir.getPath() );
String mavenRepoLocal = args[1];
IsolatedClassLoader classLoader = new IsolatedClassLoader();
Thread.currentThread().setContextClassLoader( classLoader );
classLoader.addURL( new File ( mavenRepoLocal, "junit/jars/junit-3.8.1.jar" ).toURL() );
classLoader.addURL( new File ( mavenRepoLocal, "maven/jars/surefire-runner-1.0.jar" ).toURL() );
classLoader.addURL( new File( basedir, "target/classes/" ).toURL() );
classLoader.addURL( new File( basedir, "target/test-classes/" ).toURL() );
File dependenciesFile = new File(args[2]);
List dependencies = new ArrayList();
BufferedReader buf = new BufferedReader(new FileReader(dependenciesFile));
String line;
while ((line = buf.readLine()) != null)
{
dependencies.add(line);
}
buf.close();
processDependencies( dependencies, classLoader );
File includesFile = new File(args[3]);
List includes = new ArrayList();
buf = new BufferedReader(new FileReader(includesFile));
line = buf.readLine();
String includesStr = line.substring(line.indexOf("@")+1);
StringTokenizer st = new StringTokenizer( includesStr, "," );
while ( st.hasMoreTokens() )
{
includes.add( st.nextToken().trim() );
}
buf.close();
File excludesFile = new File(args[4]);
List excludes = new ArrayList();
buf = new BufferedReader(new FileReader(excludesFile));
line = buf.readLine();
String excludesStr = line.substring(line.indexOf("@")+1);
st = new StringTokenizer( excludesStr, "," );
while ( st.hasMoreTokens() )
{
excludes.add( st.nextToken().trim() );
}
buf.close();
String[] tests = collectTests( basedir,
includes,
excludes );
Class testRunnerClass = classLoader.loadClass( "org.apache.maven.test.TestRunner" );
Object testRunner = testRunnerClass.newInstance();
Method m = testRunnerClass.getMethod( "runTestClasses", new Class[] {
ClassLoader.class,
String[].class
} );
m.invoke( testRunner, new Object[]{
classLoader,
tests
} );
}
private void processDependencies(List dependencies, IsolatedClassLoader classLoader)
throws Exception
{
for (Iterator i=dependencies.iterator(); i.hasNext(); )
{
String dep = (String)i.next();
classLoader.addURL( new File( dep ).toURL() );
}
}
public String[] collectTests( File basedir, List includes, List excludes )
throws Exception
{
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( new File( basedir, "target/test-classes" ) );
String[] incs = new String[includes.size()];
for ( int i = 0; i < incs.length; i++ )
{
incs[i] = StringUtils.replace( (String) includes.get( i ), "java", "class" );
}
scanner.setIncludes( incs );
String[] excls = new String[excludes.size() + 1];
for ( int i = 0; i < excls.length - 1; i++ )
{
excls[i] = StringUtils.replace( (String) excludes.get( i ), "java", "class" );
}
// Exclude inner classes
excls[excludes.size()] = "**/*$*";
scanner.setExcludes( excls );
scanner.scan();
return scanner.getIncludedFiles();
}
}