Build 1.0_r1(from source)

junit.runner
Class TestCaseClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by junit.runner.TestCaseClassLoader

public class TestCaseClassLoader
extends ClassLoader

A custom class loader which enables the reloading of classes for each test run. The class loader can be configured with a list of package paths that should be excluded from loading. The loading of these packages is delegated to the system class loader. They will be shared across test runs.

The list of excluded package paths is specified in a properties file "excluded.properties" that is located in the same place as the TestCaseClassLoader class.

Known limitation: the TestCaseClassLoader cannot load classes from jar files. - Not needed for 1.0 SDK


Field Summary
(package private) static String EXCLUDED_FILE
          name of excluded properties file
 
Constructor Summary
TestCaseClassLoader()
          Constructs a TestCaseLoader.
TestCaseClassLoader(String classPath)
          Constructs a TestCaseLoader.
 
Method Summary
 URL getResource(String name)
          Returns an URL which can be used to access the resource described by resName, using the class loader's resource lookup algorithm.
 InputStream getResourceAsStream(String name)
          Returns a stream on a resource found by looking up resName using the class loader's resource lookup algorithm.
 boolean isExcluded(String name)
           
(package private)  boolean isJar(String pathEntry)
           
 Class loadClass(String name, boolean resolve)
          Loads the class with the specified name, optionally linking the class after load.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXCLUDED_FILE

static final String EXCLUDED_FILE
name of excluded properties file

See Also:
Constant Field Values
Constructor Detail

TestCaseClassLoader

public TestCaseClassLoader()
Constructs a TestCaseLoader. It scans the class path and the excluded package paths


TestCaseClassLoader

public TestCaseClassLoader(String classPath)
Constructs a TestCaseLoader. It scans the class path and the excluded package paths

Method Detail

getResource

public URL getResource(String name)
Description copied from class: ClassLoader
Returns an URL which can be used to access the resource described by resName, using the class loader's resource lookup algorithm. The default behavior is just to return null.

Overrides:
getResource in class ClassLoader
Parameters:
name - String the name of the resource to find.
Returns:
The location of the resource.
See Also:
Class.getResource(java.lang.String)

getResourceAsStream

public InputStream getResourceAsStream(String name)
Description copied from class: ClassLoader
Returns a stream on a resource found by looking up resName using the class loader's resource lookup algorithm. The default behavior is just to return null.

Overrides:
getResourceAsStream in class ClassLoader
Parameters:
name - String the name of the resource to find.
Returns:
A stream on the resource or null.
See Also:
Class.getResourceAsStream(java.lang.String)

isExcluded

public boolean isExcluded(String name)

loadClass

public Class loadClass(String name,
                       boolean resolve)
                throws ClassNotFoundException
Description copied from class: ClassLoader
Loads the class with the specified name, optionally linking the class after load. Steps are: 1) Call findLoadedClass(className) to determine if class is loaded 2) Call loadClass(className, resolveClass) on the parent loader. 3) Call findClass(className) to find the class

Overrides:
loadClass in class ClassLoader
Parameters:
name - The name of the class to search for.
resolve - Indicates if class should be resolved after loading. Note: On the android reference implementation this parameter does not have any effect.
Returns:
The Class object.
Throws:
ClassNotFoundException - if the class could not be found.

isJar

boolean isJar(String pathEntry)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature