jmathlib.tools.junit.runner
Class TestCaseClassLoader

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

public class TestCaseClassLoader
extends java.lang.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.


Field Summary
private  java.lang.String[] defaultExclusions
          default excluded paths
(package private) static java.lang.String EXCLUDED_FILE
          name of excluded properties file
private  java.util.Vector fExcluded
          excluded paths
private  java.util.Vector fPathItems
          scanned class path
 
Constructor Summary
TestCaseClassLoader()
          Constructs a TestCaseLoader.
TestCaseClassLoader(java.lang.String classPath)
          Constructs a TestCaseLoader.
 
Method Summary
private  byte[] getClassData(java.io.File f)
           
 java.net.URL getResource(java.lang.String name)
           
 java.io.InputStream getResourceAsStream(java.lang.String name)
           
 boolean isExcluded(java.lang.String name)
           
(package private)  boolean isJar(java.lang.String pathEntry)
           
 java.lang.Class loadClass(java.lang.String name, boolean resolve)
           
private  byte[] loadFileData(java.lang.String path, java.lang.String fileName)
           
private  byte[] loadJarData(java.lang.String path, java.lang.String fileName)
           
private  byte[] lookupClassData(java.lang.String className)
           
private  void readExcludedPackages()
           
private  void scanPath(java.lang.String classPath)
           
 
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

fPathItems

private java.util.Vector fPathItems
scanned class path


defaultExclusions

private java.lang.String[] defaultExclusions
default excluded paths


EXCLUDED_FILE

static final java.lang.String EXCLUDED_FILE
name of excluded properties file

See Also:
Constant Field Values

fExcluded

private java.util.Vector fExcluded
excluded paths

Constructor Detail

TestCaseClassLoader

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


TestCaseClassLoader

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

Method Detail

scanPath

private void scanPath(java.lang.String classPath)

getResource

public java.net.URL getResource(java.lang.String name)
Overrides:
getResource in class java.lang.ClassLoader

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Overrides:
getResourceAsStream in class java.lang.ClassLoader

isExcluded

public boolean isExcluded(java.lang.String name)

loadClass

public java.lang.Class loadClass(java.lang.String name,
                                 boolean resolve)
                          throws java.lang.ClassNotFoundException
Overrides:
loadClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException

lookupClassData

private byte[] lookupClassData(java.lang.String className)
                        throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

isJar

boolean isJar(java.lang.String pathEntry)

loadFileData

private byte[] loadFileData(java.lang.String path,
                            java.lang.String fileName)

getClassData

private byte[] getClassData(java.io.File f)

loadJarData

private byte[] loadJarData(java.lang.String path,
                           java.lang.String fileName)

readExcludedPackages

private void readExcludedPackages()

FOOTER

BOTTOM