com.mockrunner.gen.jar.TestConfigurationClassLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
Mockrunner is a lightweight framework for unit testing applications
in the J2EE environment. It supports servlets, filters, tag classes
and Struts actions. It includes a JDBC a JMS and a JCA test
framework and can be used to test EJB based applications.
The newest version!
package com.mockrunner.gen.jar;
import java.net.URL;
import java.net.URLClassLoader;
/*
* Used by Mockrunner test suite to run the tests against different jars
*/
public class TestConfigurationClassLoader extends URLClassLoader
{
public TestConfigurationClassLoader(URL[] urls, ClassLoader parent)
{
super(urls, parent);
}
protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException
{
Class clazz = findLoadedClass(name);
if(null != clazz) return clazz;
try
{
clazz = findClass(name);
}
catch(ClassNotFoundException exc)
{
/*
* Dirty hack to get around CGLib 2.0.2 (and up) issues.
* CGLib tries to load some internal enhanced classes
* with the classloader before recreating them. The system
* classloader returns the enhanced version of the previous
* run which causes a ClassCastException. The ClassNotFoundException
* forces CGLib to recreate this classes.
* This is not necessary for CGGLIB 2.0 and previous.
*/
if(name.indexOf("ByCGLIB$") != -1)
{
throw exc;
}
clazz = getParent().loadClass(name);
}
if(resolve)
{
resolveClass(clazz);
}
return clazz;
}
}