Fix generics warnings in tests
Javadoc in test
This commit is contained in:
@@ -28,7 +28,7 @@ import junit.framework.TestCase;
|
|||||||
public class AltHashtableTestCase extends TestCase {
|
public class AltHashtableTestCase extends TestCase {
|
||||||
|
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = AltHashtableTestCase.class;
|
final Class<AltHashtableTestCase> thisClass = AltHashtableTestCase.class;
|
||||||
final ClassLoader thisClassLoader = thisClass.getClassLoader();
|
final ClassLoader thisClassLoader = thisClass.getClassLoader();
|
||||||
|
|
||||||
final PathableClassLoader loader = new PathableClassLoader(null);
|
final PathableClassLoader loader = new PathableClassLoader(null);
|
||||||
@@ -36,7 +36,7 @@ public class AltHashtableTestCase extends TestCase {
|
|||||||
loader.addLogicalLib("testclasses");
|
loader.addLogicalLib("testclasses");
|
||||||
loader.addLogicalLib("commons-logging");
|
loader.addLogicalLib("commons-logging");
|
||||||
|
|
||||||
final Class testClass = loader.loadClass(thisClass.getName());
|
final Class<?> testClass = loader.loadClass(thisClass.getName());
|
||||||
return new PathableTestSuite(testClass, loader);
|
return new PathableTestSuite(testClass, loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class LoadTestCase extends TestCase {
|
|||||||
// not very trivial to emulate we must implement "findClass",
|
// not very trivial to emulate we must implement "findClass",
|
||||||
// but it will delegate to JUnit class loader first
|
// but it will delegate to JUnit class loader first
|
||||||
@Override
|
@Override
|
||||||
public Class loadClass(final String name) throws ClassNotFoundException {
|
public Class<?> loadClass(final String name) throws ClassNotFoundException {
|
||||||
// isolates all logging classes, application in the same class loader too.
|
// isolates all logging classes, application in the same class loader too.
|
||||||
// filters exceptions to simplify handling in test
|
// filters exceptions to simplify handling in test
|
||||||
for (final String element : LOG_PCKG) {
|
for (final String element : LOG_PCKG) {
|
||||||
@@ -96,7 +96,7 @@ public class LoadTestCase extends TestCase {
|
|||||||
|
|
||||||
private ClassLoader origContextClassLoader;
|
private ClassLoader origContextClassLoader;
|
||||||
|
|
||||||
private void execute(final Class cls) throws Exception {
|
private void execute(final Class<?> cls) throws Exception {
|
||||||
cls.getConstructor().newInstance();
|
cls.getConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,8 +104,8 @@ public class LoadTestCase extends TestCase {
|
|||||||
* Load class UserClass via a temporary class loader which is a child of
|
* Load class UserClass via a temporary class loader which is a child of
|
||||||
* the class loader used to load this test class.
|
* the class loader used to load this test class.
|
||||||
*/
|
*/
|
||||||
private Class reload() throws Exception {
|
private Class<?> reload() throws Exception {
|
||||||
Class testObjCls = null;
|
Class<?> testObjCls = null;
|
||||||
final AppClassLoader appLoader = new AppClassLoader(this.getClass().getClassLoader());
|
final AppClassLoader appLoader = new AppClassLoader(this.getClass().getClassLoader());
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ public class PathableClassLoader extends URLClassLoader {
|
|||||||
* that entries' class loader.
|
* that entries' class loader.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Class loadClass(final String name, final boolean resolve)
|
protected Class<?> loadClass(final String name, final boolean resolve)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException {
|
||||||
// just for performance, check java and javax
|
// just for performance, check java and javax
|
||||||
if (name.startsWith("java.") || name.startsWith("javax.")) {
|
if (name.startsWith("java.") || name.startsWith("javax.")) {
|
||||||
@@ -326,7 +326,7 @@ public class PathableClassLoader extends URLClassLoader {
|
|||||||
return super.loadClass(name, resolve);
|
return super.loadClass(name, resolve);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Class clazz = findLoadedClass(name);
|
Class<?> clazz = findLoadedClass(name);
|
||||||
if (clazz == null) {
|
if (clazz == null) {
|
||||||
clazz = super.findClass(name);
|
clazz = super.findClass(name);
|
||||||
}
|
}
|
||||||
@@ -360,7 +360,6 @@ public class PathableClassLoader extends URLClassLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Clean implementation of list function of
|
* Clean implementation of list function of
|
||||||
* {@link java.util.Collection} added in JDK 1.4
|
* {@link java.util.Collection} added in JDK 1.4
|
||||||
* @param en {@code Enumeration}, possibly null
|
* @param en {@code Enumeration}, possibly null
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class PathableTestSuite extends TestSuite {
|
|||||||
* calls to Thread.currentThread.getContextClassLoader from test methods
|
* calls to Thread.currentThread.getContextClassLoader from test methods
|
||||||
* (or any method called by test methods).
|
* (or any method called by test methods).
|
||||||
*/
|
*/
|
||||||
public PathableTestSuite(final Class testClass, final ClassLoader contextClassLoader) {
|
public PathableTestSuite(final Class<?> testClass, final ClassLoader contextClassLoader) {
|
||||||
super(testClass);
|
super(testClass);
|
||||||
contextLoader = contextClassLoader;
|
contextLoader = contextClassLoader;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class FirstPriorityConfigTestCase extends TestCase {
|
|||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
*/
|
*/
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = FirstPriorityConfigTestCase.class;
|
final Class<FirstPriorityConfigTestCase> thisClass = FirstPriorityConfigTestCase.class;
|
||||||
|
|
||||||
// Determine the URL to this .class file, so that we can then
|
// Determine the URL to this .class file, so that we can then
|
||||||
// append the priority dirs to it. For tidiness, load this
|
// append the priority dirs to it. For tidiness, load this
|
||||||
@@ -75,7 +75,7 @@ public class FirstPriorityConfigTestCase extends TestCase {
|
|||||||
|
|
||||||
// load the test class via webapp loader, and use the webapp loader
|
// load the test class via webapp loader, and use the webapp loader
|
||||||
// as the tccl loader too.
|
// as the tccl loader too.
|
||||||
final Class testClass = webappLoader.loadClass(thisClass.getName());
|
final Class<?> testClass = webappLoader.loadClass(thisClass.getName());
|
||||||
return new PathableTestSuite(testClass, webappLoader);
|
return new PathableTestSuite(testClass, webappLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class PriorityConfigTestCase extends TestCase {
|
|||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
*/
|
*/
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = PriorityConfigTestCase.class;
|
final Class<PriorityConfigTestCase> thisClass = PriorityConfigTestCase.class;
|
||||||
|
|
||||||
// Determine the URL to this .class file, so that we can then
|
// Determine the URL to this .class file, so that we can then
|
||||||
// append the priority dirs to it. For tidiness, load this
|
// append the priority dirs to it. For tidiness, load this
|
||||||
@@ -93,7 +93,7 @@ public class PriorityConfigTestCase extends TestCase {
|
|||||||
|
|
||||||
// load the test class via webapp loader, and use the webapp loader
|
// load the test class via webapp loader, and use the webapp loader
|
||||||
// as the tccl loader too.
|
// as the tccl loader too.
|
||||||
final Class testClass = webappLoader.loadClass(thisClass.getName());
|
final Class<?> testClass = webappLoader.loadClass(thisClass.getName());
|
||||||
return new PathableTestSuite(testClass, webappLoader);
|
return new PathableTestSuite(testClass, webappLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class CustomConfigAPITestCase extends CustomConfigTestCase {
|
|||||||
child.addLogicalLib("testclasses");
|
child.addLogicalLib("testclasses");
|
||||||
child.addLogicalLib("commons-logging");
|
child.addLogicalLib("commons-logging");
|
||||||
|
|
||||||
final Class testClass = child.loadClass(CustomConfigAPITestCase.class.getName());
|
final Class<?> testClass = child.loadClass(CustomConfigAPITestCase.class.getName());
|
||||||
return new PathableTestSuite(testClass, child);
|
return new PathableTestSuite(testClass, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class CustomConfigFullTestCase extends CustomConfigTestCase {
|
|||||||
final PathableClassLoader child = new PathableClassLoader(parent);
|
final PathableClassLoader child = new PathableClassLoader(parent);
|
||||||
child.addLogicalLib("testclasses");
|
child.addLogicalLib("testclasses");
|
||||||
|
|
||||||
final Class testClass = child.loadClass(CustomConfigFullTestCase.class.getName());
|
final Class<?> testClass = child.loadClass(CustomConfigFullTestCase.class.getName());
|
||||||
return new PathableTestSuite(testClass, child);
|
return new PathableTestSuite(testClass, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
final ClassLoader srcCL = CustomConfigAPITestCase.class.getClassLoader();
|
final ClassLoader srcCL = CustomConfigAPITestCase.class.getClassLoader();
|
||||||
final byte[] classData = readClass(className, srcCL);
|
final byte[] classData = readClass(className, srcCL);
|
||||||
|
|
||||||
final Class[] params = { String.class, classData.getClass(), Integer.TYPE, Integer.TYPE };
|
final Class<?>[] params = { String.class, classData.getClass(), Integer.TYPE, Integer.TYPE };
|
||||||
final Method m = ClassLoader.class.getDeclaredMethod("defineClass", params);
|
final Method m = ClassLoader.class.getDeclaredMethod("defineClass", params);
|
||||||
|
|
||||||
final Object[] args = new Object[4];
|
final Object[] args = new Object[4];
|
||||||
@@ -118,7 +118,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
cl.addLogicalLib("commons-logging");
|
cl.addLogicalLib("commons-logging");
|
||||||
cl.addLogicalLib("testclasses");
|
cl.addLogicalLib("testclasses");
|
||||||
|
|
||||||
final Class testClass = cl.loadClass(CustomConfigTestCase.class.getName());
|
final Class<?> testClass = cl.loadClass(CustomConfigTestCase.class.getName());
|
||||||
return new PathableTestSuite(testClass, cl);
|
return new PathableTestSuite(testClass, cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class DefaultConfigTestCase extends TestCase {
|
|||||||
loader.addLogicalLib("testclasses");
|
loader.addLogicalLib("testclasses");
|
||||||
loader.addLogicalLib("commons-logging");
|
loader.addLogicalLib("commons-logging");
|
||||||
|
|
||||||
final Class testClass = loader.loadClass(DefaultConfigTestCase.class.getName());
|
final Class<?> testClass = loader.loadClass(DefaultConfigTestCase.class.getName());
|
||||||
return new PathableTestSuite(testClass, loader);
|
return new PathableTestSuite(testClass, loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class ApiClasspathStandardTestCase extends TestCase {
|
|||||||
child.addLogicalLib("commons-logging");
|
child.addLogicalLib("commons-logging");
|
||||||
child.addLogicalLib("testclasses");
|
child.addLogicalLib("testclasses");
|
||||||
|
|
||||||
final Class testClass = child.loadClass(
|
final Class<?> testClass = child.loadClass(
|
||||||
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
|
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
|
||||||
return new PathableTestSuite(testClass, child);
|
return new PathableTestSuite(testClass, child);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class AppClasspathStandardTestCase extends TestCase {
|
|||||||
loader.addLogicalLib("log4j2-core");
|
loader.addLogicalLib("log4j2-core");
|
||||||
loader.addLogicalLib("commons-logging");
|
loader.addLogicalLib("commons-logging");
|
||||||
|
|
||||||
final Class testClass = loader.loadClass(
|
final Class<?> testClass = loader.loadClass(
|
||||||
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
|
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
|
||||||
return new PathableTestSuite(testClass, loader);
|
return new PathableTestSuite(testClass, loader);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class ChildClasspathStandardTestCase extends TestCase {
|
|||||||
child.addLogicalLib("log4j2-core");
|
child.addLogicalLib("log4j2-core");
|
||||||
child.addLogicalLib("commons-logging");
|
child.addLogicalLib("commons-logging");
|
||||||
|
|
||||||
final Class testClass = child.loadClass(
|
final Class<?> testClass = child.loadClass(
|
||||||
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
|
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
|
||||||
return new PathableTestSuite(testClass, child);
|
return new PathableTestSuite(testClass, child);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class ParentClasspathStandardTestCase extends TestCase {
|
|||||||
final PathableClassLoader child = new PathableClassLoader(parent);
|
final PathableClassLoader child = new PathableClassLoader(parent);
|
||||||
child.addLogicalLib("testclasses");
|
child.addLogicalLib("testclasses");
|
||||||
|
|
||||||
final Class testClass = child.loadClass(
|
final Class<?> testClass = child.loadClass(
|
||||||
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
|
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
|
||||||
return new PathableTestSuite(testClass, child);
|
return new PathableTestSuite(testClass, child);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class StandardTestCase extends AbstractLogTest {
|
|||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
*/
|
*/
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = StandardTestCase.class;
|
final Class<StandardTestCase> thisClass = StandardTestCase.class;
|
||||||
|
|
||||||
final PathableClassLoader loader = new PathableClassLoader(null);
|
final PathableClassLoader loader = new PathableClassLoader(null);
|
||||||
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
|
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
|
||||||
@@ -49,7 +49,7 @@ public class StandardTestCase extends AbstractLogTest {
|
|||||||
loader.addLogicalLib("commons-logging");
|
loader.addLogicalLib("commons-logging");
|
||||||
loader.addLogicalLib("logkit");
|
loader.addLogicalLib("logkit");
|
||||||
|
|
||||||
final Class testClass = loader.loadClass(thisClass.getName());
|
final Class<?> testClass = loader.loadClass(thisClass.getName());
|
||||||
return new PathableTestSuite(testClass, loader);
|
return new PathableTestSuite(testClass, loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ChildFirstTestCase extends TestCase {
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = ChildFirstTestCase.class;
|
final Class<ChildFirstTestCase> thisClass = ChildFirstTestCase.class;
|
||||||
final ClassLoader thisClassLoader = thisClass.getClassLoader();
|
final ClassLoader thisClassLoader = thisClass.getClassLoader();
|
||||||
|
|
||||||
// Make the parent a direct child of the bootloader to hide all
|
// Make the parent a direct child of the bootloader to hide all
|
||||||
@@ -86,7 +86,7 @@ public class ChildFirstTestCase extends TestCase {
|
|||||||
context.setParentFirst(false);
|
context.setParentFirst(false);
|
||||||
|
|
||||||
// reload this class via the child class loader
|
// reload this class via the child class loader
|
||||||
final Class testClass = child.loadClass(thisClass.getName());
|
final Class<?> testClass = child.loadClass(thisClass.getName());
|
||||||
|
|
||||||
// and return our custom TestSuite class
|
// and return our custom TestSuite class
|
||||||
return new PathableTestSuite(testClass, context);
|
return new PathableTestSuite(testClass, context);
|
||||||
@@ -167,30 +167,30 @@ public class ChildFirstTestCase extends TestCase {
|
|||||||
// junit classes should be visible; their class loader is not
|
// junit classes should be visible; their class loader is not
|
||||||
// in the hierarchy of parent class loaders for this class,
|
// in the hierarchy of parent class loaders for this class,
|
||||||
// though it is accessible due to trickery in the PathableClassLoader.
|
// though it is accessible due to trickery in the PathableClassLoader.
|
||||||
final Class junitTest = contextLoader.loadClass("junit.framework.Test");
|
final Class<?> junitTest = contextLoader.loadClass("junit.framework.Test");
|
||||||
final Set<ClassLoader> ancestorCLs = getAncestorCLs();
|
final Set<ClassLoader> ancestorCLs = getAncestorCLs();
|
||||||
assertFalse("Junit not loaded by ancestor class loader",
|
assertFalse("Junit not loaded by ancestor class loader",
|
||||||
ancestorCLs.contains(junitTest.getClassLoader()));
|
ancestorCLs.contains(junitTest.getClassLoader()));
|
||||||
|
|
||||||
// jcl api classes should be visible only via the parent
|
// jcl api classes should be visible only via the parent
|
||||||
final Class logClass = contextLoader.loadClass("org.apache.commons.logging.Log");
|
final Class<?> logClass = contextLoader.loadClass("org.apache.commons.logging.Log");
|
||||||
assertSame("Log class not loaded via parent",
|
assertSame("Log class not loaded via parent",
|
||||||
logClass.getClassLoader(), parentLoader);
|
logClass.getClassLoader(), parentLoader);
|
||||||
|
|
||||||
// jcl adapter classes should be visible via both parent and child. However
|
// jcl adapter classes should be visible via both parent and child. However
|
||||||
// as the class loaders are child-first we should see the child one.
|
// as the class loaders are child-first we should see the child one.
|
||||||
final Class log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
|
final Class<?> log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
|
||||||
assertSame("Log4JLogger not loaded via child",
|
assertSame("Log4JLogger not loaded via child",
|
||||||
log4jClass.getClassLoader(), thisLoader);
|
log4jClass.getClassLoader(), thisLoader);
|
||||||
|
|
||||||
// test classes should be visible via the child only
|
// test classes should be visible via the child only
|
||||||
final Class testClass = contextLoader.loadClass("org.apache.commons.logging.PathableTestSuite");
|
final Class<?> testClass = contextLoader.loadClass("org.apache.commons.logging.PathableTestSuite");
|
||||||
assertSame("PathableTestSuite not loaded via child",
|
assertSame("PathableTestSuite not loaded via child",
|
||||||
testClass.getClassLoader(), thisLoader);
|
testClass.getClassLoader(), thisLoader);
|
||||||
|
|
||||||
// test loading of class that is not available
|
// test loading of class that is not available
|
||||||
try {
|
try {
|
||||||
final Class noSuchClass = contextLoader.loadClass("no.such.class");
|
final Class<?> noSuchClass = contextLoader.loadClass("no.such.class");
|
||||||
fail("Class no.such.class is unexpectedly available");
|
fail("Class no.such.class is unexpectedly available");
|
||||||
assertNotNull(noSuchClass); // silence warning about unused var
|
assertNotNull(noSuchClass); // silence warning about unused var
|
||||||
} catch (final ClassNotFoundException ex) {
|
} catch (final ClassNotFoundException ex) {
|
||||||
@@ -198,7 +198,7 @@ public class ChildFirstTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// String class class loader is null
|
// String class class loader is null
|
||||||
final Class stringClass = contextLoader.loadClass("java.lang.String");
|
final Class<?> stringClass = contextLoader.loadClass("java.lang.String");
|
||||||
assertNull("String class class loader is not null!",
|
assertNull("String class class loader is not null!",
|
||||||
stringClass.getClassLoader());
|
stringClass.getClassLoader());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class GeneralTestCase extends TestCase {
|
|||||||
* Sets up a custom class loader hierarchy for this test case.
|
* Sets up a custom class loader hierarchy for this test case.
|
||||||
*/
|
*/
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = GeneralTestCase.class;
|
final Class<GeneralTestCase> thisClass = GeneralTestCase.class;
|
||||||
final ClassLoader thisClassLoader = thisClass.getClassLoader();
|
final ClassLoader thisClassLoader = thisClass.getClassLoader();
|
||||||
|
|
||||||
final PathableClassLoader loader = new PathableClassLoader(null);
|
final PathableClassLoader loader = new PathableClassLoader(null);
|
||||||
@@ -68,7 +68,7 @@ public class GeneralTestCase extends TestCase {
|
|||||||
loader.addLogicalLib("testclasses");
|
loader.addLogicalLib("testclasses");
|
||||||
|
|
||||||
// reload this class via the child class loader
|
// reload this class via the child class loader
|
||||||
final Class testClass = loader.loadClass(thisClass.getName());
|
final Class<?> testClass = loader.loadClass(thisClass.getName());
|
||||||
|
|
||||||
// and return our custom TestSuite class
|
// and return our custom TestSuite class
|
||||||
return new PathableTestSuite(testClass, loader);
|
return new PathableTestSuite(testClass, loader);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class SecurityAllowedTestCase extends TestCase {
|
|||||||
parent.addLogicalLib("commons-logging");
|
parent.addLogicalLib("commons-logging");
|
||||||
parent.addLogicalLib("testclasses");
|
parent.addLogicalLib("testclasses");
|
||||||
|
|
||||||
final Class testClass = parent.loadClass(
|
final Class<?> testClass = parent.loadClass(
|
||||||
"org.apache.commons.logging.security.SecurityAllowedTestCase");
|
"org.apache.commons.logging.security.SecurityAllowedTestCase");
|
||||||
return new PathableTestSuite(testClass, parent);
|
return new PathableTestSuite(testClass, parent);
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ public class SecurityAllowedTestCase extends TestCase {
|
|||||||
try {
|
try {
|
||||||
// Use reflection so that we can control exactly when the static
|
// Use reflection so that we can control exactly when the static
|
||||||
// initializer for the LogFactory class is executed.
|
// initializer for the LogFactory class is executed.
|
||||||
final Class c = this.getClass().getClassLoader().loadClass(
|
final Class<?> c = this.getClass().getClassLoader().loadClass(
|
||||||
"org.apache.commons.logging.LogFactory");
|
"org.apache.commons.logging.LogFactory");
|
||||||
final Method m = c.getMethod("getLog", Class.class);
|
final Method m = c.getMethod("getLog", Class.class);
|
||||||
final Log log = (Log) m.invoke(null, this.getClass());
|
final Log log = (Log) m.invoke(null, this.getClass());
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class SecurityForbiddenTestCase extends TestCase {
|
|||||||
parent.addLogicalLib("commons-logging");
|
parent.addLogicalLib("commons-logging");
|
||||||
parent.addLogicalLib("testclasses");
|
parent.addLogicalLib("testclasses");
|
||||||
|
|
||||||
final Class testClass = parent.loadClass(
|
final Class<?> testClass = parent.loadClass(
|
||||||
"org.apache.commons.logging.security.SecurityForbiddenTestCase");
|
"org.apache.commons.logging.security.SecurityForbiddenTestCase");
|
||||||
return new PathableTestSuite(testClass, parent);
|
return new PathableTestSuite(testClass, parent);
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ public class SecurityForbiddenTestCase extends TestCase {
|
|||||||
*/
|
*/
|
||||||
private Object loadClass(final String name, final ClassLoader classLoader) {
|
private Object loadClass(final String name, final ClassLoader classLoader) {
|
||||||
try {
|
try {
|
||||||
final Class clazz = classLoader.loadClass(name);
|
final Class<?> clazz = classLoader.loadClass(name);
|
||||||
return clazz.getConstructor().newInstance();
|
return clazz.getConstructor().newInstance();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
final StringWriter sw = new StringWriter();
|
final StringWriter sw = new StringWriter();
|
||||||
@@ -135,7 +135,7 @@ public class SecurityForbiddenTestCase extends TestCase {
|
|||||||
try {
|
try {
|
||||||
// Use reflection so that we can control exactly when the static
|
// Use reflection so that we can control exactly when the static
|
||||||
// initializer for the LogFactory class is executed.
|
// initializer for the LogFactory class is executed.
|
||||||
final Class c = this.getClass().getClassLoader().loadClass(
|
final Class<?> c = this.getClass().getClassLoader().loadClass(
|
||||||
"org.apache.commons.logging.LogFactory");
|
"org.apache.commons.logging.LogFactory");
|
||||||
final Method m = c.getMethod("getLog", Class.class);
|
final Method m = c.getMethod("getLog", Class.class);
|
||||||
final Log log = (Log) m.invoke(null, this.getClass());
|
final Log log = (Log) m.invoke(null, this.getClass());
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class DummyLogFactory extends LogFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Log getInstance(final Class clazz) throws LogConfigurationException {
|
public Log getInstance(final Class<?> clazz) throws LogConfigurationException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class BasicServletTestCase extends TestCase {
|
|||||||
tccl.setParentFirst(false);
|
tccl.setParentFirst(false);
|
||||||
tccl.addLogicalLib("commons-logging");
|
tccl.addLogicalLib("commons-logging");
|
||||||
|
|
||||||
final Class testClass = child.loadClass(BasicServletTestCase.class.getName());
|
final Class<?> testClass = child.loadClass(BasicServletTestCase.class.getName());
|
||||||
return new PathableTestSuite(testClass, tccl);
|
return new PathableTestSuite(testClass, tccl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,14 +48,14 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
* Or we could fix SimpleLog to be sane...
|
* Or we could fix SimpleLog to be sane...
|
||||||
*/
|
*/
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = CustomConfigTestCase.class;
|
final Class<CustomConfigTestCase> thisClass = CustomConfigTestCase.class;
|
||||||
|
|
||||||
final PathableClassLoader loader = new PathableClassLoader(null);
|
final PathableClassLoader loader = new PathableClassLoader(null);
|
||||||
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
|
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
|
||||||
loader.addLogicalLib("testclasses");
|
loader.addLogicalLib("testclasses");
|
||||||
loader.addLogicalLib("commons-logging");
|
loader.addLogicalLib("commons-logging");
|
||||||
|
|
||||||
final Class testClass = loader.loadClass(thisClass.getName());
|
final Class<?> testClass = loader.loadClass(thisClass.getName());
|
||||||
return new PathableTestSuite(testClass, loader);
|
return new PathableTestSuite(testClass, loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,14 +44,14 @@ public class DateTimeCustomConfigTestCase extends CustomConfigTestCase {
|
|||||||
* Or we could fix SimpleLog to be sane...
|
* Or we could fix SimpleLog to be sane...
|
||||||
*/
|
*/
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = DateTimeCustomConfigTestCase.class;
|
final Class<DateTimeCustomConfigTestCase> thisClass = DateTimeCustomConfigTestCase.class;
|
||||||
|
|
||||||
final PathableClassLoader loader = new PathableClassLoader(null);
|
final PathableClassLoader loader = new PathableClassLoader(null);
|
||||||
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
|
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
|
||||||
loader.addLogicalLib("testclasses");
|
loader.addLogicalLib("testclasses");
|
||||||
loader.addLogicalLib("commons-logging");
|
loader.addLogicalLib("commons-logging");
|
||||||
|
|
||||||
final Class testClass = loader.loadClass(thisClass.getName());
|
final Class<?> testClass = loader.loadClass(thisClass.getName());
|
||||||
return new PathableTestSuite(testClass, loader);
|
return new PathableTestSuite(testClass, loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ public class DefaultConfigTestCase extends TestCase {
|
|||||||
* Or we could fix SimpleLog to be sane...
|
* Or we could fix SimpleLog to be sane...
|
||||||
*/
|
*/
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = DefaultConfigTestCase.class;
|
final Class<DefaultConfigTestCase> thisClass = DefaultConfigTestCase.class;
|
||||||
|
|
||||||
final PathableClassLoader loader = new PathableClassLoader(null);
|
final PathableClassLoader loader = new PathableClassLoader(null);
|
||||||
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
|
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
|
||||||
loader.addLogicalLib("testclasses");
|
loader.addLogicalLib("testclasses");
|
||||||
loader.addLogicalLib("commons-logging");
|
loader.addLogicalLib("commons-logging");
|
||||||
|
|
||||||
final Class testClass = loader.loadClass(thisClass.getName());
|
final Class<?> testClass = loader.loadClass(thisClass.getName());
|
||||||
return new PathableTestSuite(testClass, loader);
|
return new PathableTestSuite(testClass, loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class TcclDisabledTestCase extends TestCase {
|
|||||||
* Returns the tests included in this test suite.
|
* Returns the tests included in this test suite.
|
||||||
*/
|
*/
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = TcclDisabledTestCase.class;
|
final Class<TcclDisabledTestCase> thisClass = TcclDisabledTestCase.class;
|
||||||
|
|
||||||
// Determine the URL to this .class file, so that we can then
|
// Determine the URL to this .class file, so that we can then
|
||||||
// append the priority dirs to it. For tidiness, load this
|
// append the priority dirs to it. For tidiness, load this
|
||||||
@@ -80,7 +80,7 @@ public class TcclDisabledTestCase extends TestCase {
|
|||||||
final PathableClassLoader tcclLoader = new PathableClassLoader(parentLoader);
|
final PathableClassLoader tcclLoader = new PathableClassLoader(parentLoader);
|
||||||
tcclLoader.addLogicalLib("testclasses");
|
tcclLoader.addLogicalLib("testclasses");
|
||||||
|
|
||||||
final Class testClass = parentLoader.loadClass(thisClass.getName());
|
final Class<?> testClass = parentLoader.loadClass(thisClass.getName());
|
||||||
return new PathableTestSuite(testClass, tcclLoader);
|
return new PathableTestSuite(testClass, tcclLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ public class TcclDisabledTestCase extends TestCase {
|
|||||||
|
|
||||||
// MyLogFactoryImpl should not be loadable via parent loader
|
// MyLogFactoryImpl should not be loadable via parent loader
|
||||||
try {
|
try {
|
||||||
final Class clazz = thisClassLoader.loadClass(MY_LOG_FACTORY_IMPL);
|
final Class<?> clazz = thisClassLoader.loadClass(MY_LOG_FACTORY_IMPL);
|
||||||
fail("Unexpectedly able to load MyLogFactoryImpl via test class class loader");
|
fail("Unexpectedly able to load MyLogFactoryImpl via test class class loader");
|
||||||
assertNotNull(clazz); // silence warning about unused var
|
assertNotNull(clazz); // silence warning about unused var
|
||||||
} catch (final ClassNotFoundException ex) {
|
} catch (final ClassNotFoundException ex) {
|
||||||
@@ -122,7 +122,7 @@ public class TcclDisabledTestCase extends TestCase {
|
|||||||
|
|
||||||
// MyLogFactoryImpl should be loadable via TCCL loader
|
// MyLogFactoryImpl should be loadable via TCCL loader
|
||||||
try {
|
try {
|
||||||
final Class clazz = tcclLoader.loadClass(MY_LOG_FACTORY_IMPL);
|
final Class<?> clazz = tcclLoader.loadClass(MY_LOG_FACTORY_IMPL);
|
||||||
assertNotNull(clazz);
|
assertNotNull(clazz);
|
||||||
} catch (final ClassNotFoundException ex) {
|
} catch (final ClassNotFoundException ex) {
|
||||||
fail("Unexpectedly unable to load MyLogFactoryImpl via TCCL class loader");
|
fail("Unexpectedly unable to load MyLogFactoryImpl via TCCL class loader");
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class TcclEnabledTestCase extends TestCase {
|
|||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
*/
|
*/
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final Class thisClass = TcclEnabledTestCase.class;
|
final Class<TcclEnabledTestCase> thisClass = TcclEnabledTestCase.class;
|
||||||
|
|
||||||
// Determine the URL to this .class file, so that we can then
|
// Determine the URL to this .class file, so that we can then
|
||||||
// append the priority dirs to it. For tidiness, load this
|
// append the priority dirs to it. For tidiness, load this
|
||||||
@@ -74,7 +74,7 @@ public class TcclEnabledTestCase extends TestCase {
|
|||||||
final PathableClassLoader tcclLoader = new PathableClassLoader(parentLoader);
|
final PathableClassLoader tcclLoader = new PathableClassLoader(parentLoader);
|
||||||
tcclLoader.addLogicalLib("testclasses");
|
tcclLoader.addLogicalLib("testclasses");
|
||||||
|
|
||||||
final Class testClass = parentLoader.loadClass(thisClass.getName());
|
final Class<?> testClass = parentLoader.loadClass(thisClass.getName());
|
||||||
return new PathableTestSuite(testClass, tcclLoader);
|
return new PathableTestSuite(testClass, tcclLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ public class TcclEnabledTestCase extends TestCase {
|
|||||||
|
|
||||||
// MyLogFactoryImpl should not be loadable via parent loader
|
// MyLogFactoryImpl should not be loadable via parent loader
|
||||||
try {
|
try {
|
||||||
final Class clazz = thisClassLoader.loadClass(
|
final Class<?> clazz = thisClassLoader.loadClass(
|
||||||
"org.apache.commons.logging.tccl.custom.MyLogFactoryImpl");
|
"org.apache.commons.logging.tccl.custom.MyLogFactoryImpl");
|
||||||
fail("Unexpectedly able to load MyLogFactoryImpl via test class class loader");
|
fail("Unexpectedly able to load MyLogFactoryImpl via test class class loader");
|
||||||
assertNotNull(clazz); // silence warning about unused var
|
assertNotNull(clazz); // silence warning about unused var
|
||||||
@@ -117,7 +117,7 @@ public class TcclEnabledTestCase extends TestCase {
|
|||||||
|
|
||||||
// MyLogFactoryImpl should be loadable via TCCL loader
|
// MyLogFactoryImpl should be loadable via TCCL loader
|
||||||
try {
|
try {
|
||||||
final Class clazz = tcclLoader.loadClass(
|
final Class<?> clazz = tcclLoader.loadClass(
|
||||||
"org.apache.commons.logging.tccl.custom.MyLogFactoryImpl");
|
"org.apache.commons.logging.tccl.custom.MyLogFactoryImpl");
|
||||||
assertNotNull(clazz);
|
assertNotNull(clazz);
|
||||||
} catch (final ClassNotFoundException ex) {
|
} catch (final ClassNotFoundException ex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user