diff --git a/src/test/java/org/apache/commons/logging/AltHashtable.java b/src/test/java/org/apache/commons/logging/AltHashtable.java index 231cda7..94c0633 100644 --- a/src/test/java/org/apache/commons/logging/AltHashtable.java +++ b/src/test/java/org/apache/commons/logging/AltHashtable.java @@ -25,7 +25,7 @@ public class AltHashtable extends Hashtable { * Generated serial version ID. */ private static final long serialVersionUID = 8927996458633688095L; - + public static Object lastKey; public static Object lastValue; diff --git a/src/test/java/org/apache/commons/logging/LoadTestCase.java b/src/test/java/org/apache/commons/logging/LoadTestCase.java index c43aeea..3c910fd 100644 --- a/src/test/java/org/apache/commons/logging/LoadTestCase.java +++ b/src/test/java/org/apache/commons/logging/LoadTestCase.java @@ -27,7 +27,7 @@ public class LoadTestCase extends TestCase{ //TODO: need some way to add service provider packages static private String LOG_PCKG[] = {"org.apache.commons.logging", "org.apache.commons.logging.impl"}; - + /** * A custom classloader which "duplicates" logging classes available * in the parent classloader into itself. @@ -38,51 +38,51 @@ public class LoadTestCase extends TestCase{ * as the classloader that loaded it. */ static class AppClassLoader extends ClassLoader{ - + java.util.Map classes = new java.util.HashMap(); - + AppClassLoader(ClassLoader parent){ super(parent); } - + private Class def(String name)throws ClassNotFoundException{ - + Class result = (Class)classes.get(name); if(result != null){ return result; } - + try{ - + ClassLoader cl = this.getClass().getClassLoader(); String classFileName = name.replace('.','/') + ".class"; java.io.InputStream is = cl.getResourceAsStream(classFileName); java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream(); - + while(is.available() > 0){ out.write(is.read()); } - + byte data [] = out.toByteArray(); - + result = super.defineClass(name, data, 0, data.length ); classes.put(name,result); - + return result; - + }catch(java.io.IOException ioe){ - + throw new ClassNotFoundException( name + " caused by " + ioe.getMessage() ); } - - + + } - + // not very trivial to emulate we must implement "findClass", // but it will delegete to junit class loder first public Class loadClass(String name)throws ClassNotFoundException{ - + //isolates all logging classes, application in the same classloader too. //filters exeptions to simlify handling in test for(int i = 0; i < LOG_PCKG.length; i++ ){ @@ -93,9 +93,9 @@ public class LoadTestCase extends TestCase{ } return super.loadClass(name); } - + } - + /** * Call the static setAllowFlawedContext method on the specified class @@ -116,26 +116,26 @@ public class LoadTestCase extends TestCase{ * are available via the system classpath. */ public void testInContainer()throws Exception{ - + //problem can be in this step (broken app container or missconfiguration) //1. Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader()); //2. Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); // we expect this : // 1. Thread.currentThread().setContextClassLoader(appLoader); // 2. Thread.currentThread().setContextClassLoader(null); - + // Context classloader is same as class calling into log Class cls = reload(); Thread.currentThread().setContextClassLoader(cls.getClassLoader()); execute(cls); - + // Context classloader is the "bootclassloader". This is technically // bad, but LogFactoryImpl.ALLOW_FLAWED_CONTEXT defaults to true so // this test should pass. cls = reload(); Thread.currentThread().setContextClassLoader(null); execute(cls); - + // Context classloader is the "bootclassloader". This is same as above // except that ALLOW_FLAWED_CONTEXT is set to false; an error should // now be reported. @@ -148,7 +148,7 @@ public class LoadTestCase extends TestCase{ } catch(LogConfigurationException ex) { // expected; the boot classloader doesn't *have* JCL available } - + // Context classloader is the system classloader. // // This is expected to cause problems, as LogFactoryImpl will attempt @@ -159,9 +159,9 @@ public class LoadTestCase extends TestCase{ cls = reload(); Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader()); execute(cls); - + // Context classloader is the system classloader. This is the same - // as above except that ALLOW_FLAWED_CONTEXT is set to false; an error + // as above except that ALLOW_FLAWED_CONTEXT is set to false; an error // should now be reported. cls = reload(); Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader()); @@ -171,7 +171,7 @@ public class LoadTestCase extends TestCase{ fail("Error: somehow downcast a Logger loaded via system classloader" + " to the Log interface loaded via a custom classloader"); } catch(LogConfigurationException ex) { - // expected + // expected } } @@ -180,46 +180,46 @@ public class LoadTestCase extends TestCase{ * the classloader used to load this test class. */ private Class reload()throws Exception{ - + Class testObjCls = null; - - AppClassLoader appLoader = new AppClassLoader( + + AppClassLoader appLoader = new AppClassLoader( this.getClass().getClassLoader()); try{ - + testObjCls = appLoader.loadClass(UserClass.class.getName()); - + }catch(ClassNotFoundException cnfe){ throw cnfe; }catch(Throwable t){ t.printStackTrace(); fail("AppClassLoader failed "); } - + assertTrue( "app isolated" ,testObjCls.getClassLoader() == appLoader ); - - + + return testObjCls; - - + + } - - + + private void execute(Class cls)throws Exception{ - + cls.newInstance(); - + } - + public void setUp() { // save state before test starts so we can restore it when test ends origContextClassLoader = Thread.currentThread().getContextClassLoader(); } - + public void tearDown() { // restore original state so a test can't stuff up later tests. Thread.currentThread().setContextClassLoader(origContextClassLoader); } - + private ClassLoader origContextClassLoader; } diff --git a/src/test/java/org/apache/commons/logging/NullClassLoaderTestCase.java b/src/test/java/org/apache/commons/logging/NullClassLoaderTestCase.java index 0e84c1c..012a720 100644 --- a/src/test/java/org/apache/commons/logging/NullClassLoaderTestCase.java +++ b/src/test/java/org/apache/commons/logging/NullClassLoaderTestCase.java @@ -26,8 +26,8 @@ import junit.framework.TestCase; */ public class NullClassLoaderTestCase extends TestCase { - //---------------------- unit tests --------------------------------- - + //---------------------- unit tests --------------------------------- + /** * This tests that when getContextClassLoader returns null, the * LogFactory.getLog(name) method still correctly returns the same diff --git a/src/test/java/org/apache/commons/logging/PathableClassLoader.java b/src/test/java/org/apache/commons/logging/PathableClassLoader.java index 830f652..04afda8 100644 --- a/src/test/java/org/apache/commons/logging/PathableClassLoader.java +++ b/src/test/java/org/apache/commons/logging/PathableClassLoader.java @@ -48,9 +48,9 @@ import java.util.Map; */ public class PathableClassLoader extends URLClassLoader { - + private static final URL[] NO_URLS = new URL[0]; - + /** * A map of package-prefix to ClassLoader. Any class which is in * this map is looked up via the specified classloader instead of @@ -60,7 +60,7 @@ public class PathableClassLoader extends URLClassLoader { * with classes loaded via a custom classloader. As an example, junit * testcases which are loaded via a custom classloader needs to see * the same junit classes as the code invoking the testcase, otherwise - * they can't pass result objects back. + * they can't pass result objects back. *
* Normally, only a classloader created with a null parent needs to * have any lookasides defined. @@ -96,7 +96,7 @@ public class PathableClassLoader extends URLClassLoader { public PathableClassLoader(ClassLoader parent) { super(NO_URLS, parent); } - + /** * Allow caller to explicitly add paths. Generally this not a good idea; * use addLogicalLib instead, then define the location for that logical @@ -110,9 +110,9 @@ public class PathableClassLoader extends URLClassLoader { * Specify whether this classloader should ask the parent classloader * to resolve a class first, before trying to resolve it via its own * classpath. - *
+ *
* Checking with the parent first is the normal approach for java, but - * components within containers such as servlet engines can use + * components within containers such as servlet engines can use * child-first lookup instead, to allow the components to override libs * which are visible in shared classloaders provided by the container. *
@@ -140,7 +140,7 @@ public class PathableClassLoader extends URLClassLoader { */ public void useSystemLoader(String prefix) { useExplicitLoader(prefix, ClassLoader.getSystemClassLoader()); - + } /** @@ -148,7 +148,7 @@ public class PathableClassLoader extends URLClassLoader { *
* The specified classloader is normally a loader that is NOT * an ancestor of this classloader. In particular, this loader - * may have the bootloader as its parent, but be configured to + * may have the bootloader as its parent, but be configured to * see specific other classes (eg the junit library loaded * via the system classloader). *
@@ -186,7 +186,7 @@ public class PathableClassLoader extends URLClassLoader { /** * Specify a logical library to be included in the classpath used to - * locate classes. + * locate classes. *
* The specified lib name is used as a key into the system properties; * there is expected to be a system property defined with that name @@ -198,11 +198,11 @@ public class PathableClassLoader extends URLClassLoader { * this class is a URLClassLoader then the set of URLs that the * classloader uses for its classpath is scanned; any jar in the * URL set whose name starts with the specified string is added to - * the classpath managed by this instance. + * the classpath managed by this instance. *
* Using logical library names allows the calling code to specify its
* desired classpath without knowing the exact location of the necessary
- * classes.
+ * classes.
*/
public void addLogicalLib(String logicalLib) {
// first, check the system properties
@@ -255,14 +255,14 @@ public class PathableClassLoader extends URLClassLoader {
if (cl instanceof URLClassLoader == false) {
return null;
}
-
+
URLClassLoader ucl = (URLClassLoader) cl;
URL[] path = ucl.getURLs();
URL shortestMatch = null;
int shortestMatchLen = Integer.MAX_VALUE;
for(int i=0; i
- * For each explicitly mapped package prefix, if the name matches the
- * prefix associated with that entry then attempt to load the class via
+ * For each explicitly mapped package prefix, if the name matches the
+ * prefix associated with that entry then attempt to load the class via
* that entries' classloader.
*/
- protected Class loadClass(String name, boolean resolve)
+ protected Class loadClass(String name, boolean resolve)
throws ClassNotFoundException {
// just for performance, check java and javax
if (name.startsWith("java.") || name.startsWith("javax.")) {
@@ -312,17 +312,17 @@ public class PathableClassLoader extends URLClassLoader {
}
}
}
-
+
if (parentFirst) {
return super.loadClass(name, resolve);
} else {
- // Implement child-first.
+ // Implement child-first.
//
// It appears that the findClass method doesn't check whether the
// class has already been loaded. This seems odd to me, but without
// first checking via findLoadedClass we can get java.lang.LinkageError
// with message "duplicate class definition" which isn't good.
-
+
try {
Class clazz = findLoadedClass(name);
if (clazz == null) {
@@ -337,7 +337,7 @@ public class PathableClassLoader extends URLClassLoader {
}
}
}
-
+
/**
* Same as parent class method except that when parentFirst is false
* the resource is looked for in the local classpath before the parent
@@ -354,7 +354,7 @@ public class PathableClassLoader extends URLClassLoader {
return super.getResource(name);
}
}
-
+
/**
* Emulate a proper implementation of getResources which respects the
* setting for parentFirst.
@@ -368,7 +368,7 @@ public class PathableClassLoader extends URLClassLoader {
return super.getResources(name);
} else {
Enumeration localUrls = super.findResources(name);
-
+
ClassLoader parent = getParent();
if (parent == null) {
// Alas, there is no method to get matching resources
@@ -391,11 +391,11 @@ public class PathableClassLoader extends URLClassLoader {
return Collections.enumeration(localItems);
}
}
-
+
/**
- *
- * Clean implementation of list function of
- * {@link java.utils.Collection} added in JDK 1.4
+ *
+ * Clean implementation of list function of
+ * {@link java.utils.Collection} added in JDK 1.4
* @param en
* The use of PathableClassLoader is not required to use this class, but it
@@ -59,7 +59,7 @@ import junit.framework.TestSuite;
* This class will run each test methods within the specified TestCase using
* the specified context classloader and system classloader. If different
* tests within the same class require different context classloaders,
- * then the context classloader passed to the constructor should be the
+ * then the context classloader passed to the constructor should be the
* "lowest" one available, and tests that need the context set to some parent
* of this "lowest" classloader can call
*
* This class does not provide facilities for manipulating system properties;
* tests that need specific system properties can simply set them in the
* fixture or at the start of a test method.
*
* Important! When the test case is run, "this.getClass()" refers of
- * course to the Class object passed to the constructor of this class - which
+ * course to the Class object passed to the constructor of this class - which
* is different from the class whose suite() method was executed to determine
* the classpath. This means that the suite method cannot communicate with
* the test cases simply by setting static variables (for example to make the
@@ -87,7 +87,7 @@ import junit.framework.TestSuite;
*
*
- * This class cannot control the system classloader (ie what method
+ * This class cannot control the system classloader (ie what method
* ClassLoader.getSystemClassLoader returns) because Java provides no
* mechanism for setting the system classloader. In this case, the only
* option is to invoke the unit test in a separate JVM with the appropriate
@@ -112,10 +112,10 @@ public class PathableTestSuite extends TestSuite {
/**
* Constructor.
- *
+ *
* @param testClass is the TestCase that is to be run, as loaded by
* the appropriate ClassLoader.
- *
+ *
* @param contextClassLoader is the loader that should be returned by
* calls to Thread.currentThread.getContextClassLoader from test methods
* (or any method called by test methods).
diff --git a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
index f9bf452..3aaa407 100644
--- a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
+++ b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
@@ -65,28 +65,28 @@ public class ParentFirstTestCase extends TestCase {
// this class, so use that as the source for future access to classes
// from the junit package.
parent.useExplicitLoader("junit.", thisClassLoader);
-
+
// make the commons-logging.jar classes visible via the parent
parent.addLogicalLib("commons-logging");
-
+
// create a child classloader to load the test case through
PathableClassLoader child = new PathableClassLoader(parent);
-
+
// obviously, the child classloader needs to have the test classes
// in its path!
child.addLogicalLib("testclasses");
child.addLogicalLib("commons-logging-adapters");
-
+
// create a third classloader to be the context classloader.
PathableClassLoader context = new PathableClassLoader(child);
// reload this class via the child classloader
Class testClass = child.loadClass(thisClass.getName());
-
+
// and return our custom TestSuite class
return new PathableTestSuite(testClass, context);
}
-
+
/**
* Utility method to return the set of all classloaders in the
* parent chain starting from the one that loaded the class for
@@ -115,14 +115,14 @@ public class ParentFirstTestCase extends TestCase {
assertEquals("Context classloader has unexpected type",
PathableClassLoader.class.getName(),
contextLoader.getClass().getName());
-
+
// the classloader that loaded this class is obviously not null
ClassLoader thisLoader = this.getClass().getClassLoader();
assertNotNull("thisLoader is null", thisLoader);
assertEquals("thisLoader has unexpected type",
PathableClassLoader.class.getName(),
thisLoader.getClass().getName());
-
+
// the suite method specified that the context classloader's parent
// is the loader that loaded this test case.
assertSame("Context classloader is not child of thisLoader",
@@ -134,7 +134,7 @@ public class ParentFirstTestCase extends TestCase {
assertEquals("Parent classloader has unexpected type",
PathableClassLoader.class.getName(),
parentLoader.getClass().getName());
-
+
// parent should have a parent of null
assertNull("Parent classloader has non-null parent", parentLoader.getParent());
@@ -152,7 +152,7 @@ public class ParentFirstTestCase extends TestCase {
// though it is accessable due to trickery in the PathableClassLoader.
Class junitTest = contextLoader.loadClass("junit.framework.Test");
Set ancestorCLs = getAncestorCLs();
- assertFalse("Junit not loaded by ancestor classloader",
+ assertFalse("Junit not loaded by ancestor classloader",
ancestorCLs.contains(junitTest.getClassLoader()));
// jcl api classes should be visible only via the parent
@@ -163,14 +163,14 @@ public class ParentFirstTestCase extends TestCase {
// jcl adapter classes should be visible via both parent and child. However
// as the classloaders are parent-first we should see the parent one.
Class log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
- assertSame("Log4JLogger not loaded via parent",
+ assertSame("Log4JLogger not loaded via parent",
log4jClass.getClassLoader(), parentLoader);
-
+
// test classes should be visible via the child only
Class testClass = contextLoader.loadClass("org.apache.commons.logging.PathableTestSuite");
- assertSame("PathableTestSuite not loaded via child",
+ assertSame("PathableTestSuite not loaded via child",
testClass.getClassLoader(), thisLoader);
-
+
// test loading of class that is not available
try {
Class noSuchClass = contextLoader.loadClass("no.such.class");
@@ -185,16 +185,16 @@ public class ParentFirstTestCase extends TestCase {
assertNull("String class classloader is not null!",
stringClass.getClassLoader());
}
-
+
/**
* Test that the various flavours of ClassLoader.getResource work as expected.
*/
public void testResource() {
URL resource;
-
+
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
ClassLoader childLoader = contextLoader.getParent();
-
+
// getResource where it doesn't exist
resource = childLoader.getResource("nosuchfile");
assertNull("Non-null URL returned for invalid resource name", resource);
@@ -202,7 +202,7 @@ public class ParentFirstTestCase extends TestCase {
// getResource where it is accessable only to parent classloader
resource = childLoader.getResource("org/apache/commons/logging/Log.class");
assertNotNull("Unable to locate Log.class resource", resource);
-
+
// getResource where it is accessable only to child classloader
resource = childLoader.getResource("org/apache/commons/logging/PathableTestSuite.class");
assertNotNull("Unable to locate PathableTestSuite.class resource", resource);
@@ -216,42 +216,42 @@ public class ParentFirstTestCase extends TestCase {
assertTrue("Incorrect source for Log4JLogger class",
resource.toString().indexOf("/commons-logging-1.") > 0);
}
-
+
/**
* Test that the various flavours of ClassLoader.getResources work as expected.
*/
public void testResources() throws Exception {
Enumeration resources;
URL[] urls;
-
+
// verify the classloader hierarchy
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
ClassLoader childLoader = contextLoader.getParent();
ClassLoader parentLoader = childLoader.getParent();
ClassLoader bootLoader = parentLoader.getParent();
assertNull("Unexpected classloader hierarchy", bootLoader);
-
+
// getResources where no instances exist
resources = childLoader.getResources("nosuchfile");
urls = toURLArray(resources);
assertEquals("Non-null URL returned for invalid resource name", 0, urls.length);
-
+
// getResources where the resource only exists in the parent
resources = childLoader.getResources("org/apache/commons/logging/Log.class");
urls = toURLArray(resources);
assertEquals("Unexpected number of Log.class resources found", 1, urls.length);
-
+
// getResources where the resource only exists in the child
resources = childLoader.getResources("org/apache/commons/logging/PathableTestSuite.class");
urls = toURLArray(resources);
assertEquals("Unexpected number of PathableTestSuite.class resources found", 1, urls.length);
-
+
// getResources where the resource exists in both.
// resources should be returned in order (parent-resource, child-resource)
resources = childLoader.getResources("org/apache/commons/logging/impl/Log4JLogger.class");
urls = toURLArray(resources);
assertEquals("Unexpected number of Log4JLogger.class resources found", 2, urls.length);
-
+
// There is no gaurantee about the ordering of results returned from getResources
// To make this test portable across JVMs, sort the string to give them a known order
String[] urlsToStrings = new String[2];
@@ -262,7 +262,7 @@ public class ParentFirstTestCase extends TestCase {
urlsToStrings[0].indexOf("/commons-logging-1.") > 0);
assertTrue("Incorrect source for Log4JLogger class",
urlsToStrings[1].indexOf("/commons-logging-adapters-1.") > 0);
-
+
}
/**
@@ -283,23 +283,23 @@ public class ParentFirstTestCase extends TestCase {
*/
public void testResourceAsStream() throws Exception {
java.io.InputStream is;
-
+
// verify the classloader hierarchy
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
ClassLoader childLoader = contextLoader.getParent();
ClassLoader parentLoader = childLoader.getParent();
ClassLoader bootLoader = parentLoader.getParent();
assertNull("Unexpected classloader hierarchy", bootLoader);
-
+
// getResourceAsStream where no instances exist
is = childLoader.getResourceAsStream("nosuchfile");
assertNull("Invalid resource returned non-null stream", is);
-
+
// getResourceAsStream where resource does exist
is = childLoader.getResourceAsStream("org/apache/commons/logging/Log.class");
assertNotNull("Null returned for valid resource", is);
is.close();
-
+
// It would be nice to test parent-first ordering here, but that would require
// having a resource with the same name in both the parent and child loaders,
// but with different contents. That's a little tricky to set up so we'll
diff --git a/src/test/java/org/apache/commons/logging/security/MockSecurityManager.java b/src/test/java/org/apache/commons/logging/security/MockSecurityManager.java
index 0d9b4de..4d7d3ba 100644
--- a/src/test/java/org/apache/commons/logging/security/MockSecurityManager.java
+++ b/src/test/java/org/apache/commons/logging/security/MockSecurityManager.java
@@ -101,7 +101,7 @@ public class MockSecurityManager extends SecurityManager {
// requiring RuntimePermission: "accessClassInPackage.sun.util.logging.resources"
return;
}
-
+
if (cname.equals("java.security.AccessController")) {
// Presumably method name equals "doPrivileged"
//
diff --git a/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java b/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java
index d8071d4..0967bb9 100644
--- a/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java
+++ b/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java
@@ -76,11 +76,11 @@ public class SecurityForbiddenTestCase extends TestCase
public void setUp() {
// save security manager so it can be restored in tearDown
oldSecMgr = System.getSecurityManager();
-
+
PathableClassLoader classLoader = new PathableClassLoader(null);
classLoader.addLogicalLib("commons-logging");
classLoader.addLogicalLib("testclasses");
-
+
otherClassLoader = classLoader;
}
@@ -142,7 +142,7 @@ public class SecurityForbiddenTestCase extends TestCase
/**
* Test what happens when JCL is run with absolutely no security
* privileges at all and a class loaded with a different classloader
- * than the context classloader of the current thread tries to log something.
+ * than the context classloader of the current thread tries to log something.
*/
public void testContextClassLoader() {
System.setProperty(
diff --git a/src/test/java/org/apache/commons/logging/simple/CustomConfigTestCase.java b/src/test/java/org/apache/commons/logging/simple/CustomConfigTestCase.java
index f78804e..e2efbd7 100644
--- a/src/test/java/org/apache/commons/logging/simple/CustomConfigTestCase.java
+++ b/src/test/java/org/apache/commons/logging/simple/CustomConfigTestCase.java
@@ -113,7 +113,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
loader.addLogicalLib("testclasses");
loader.addLogicalLib("commons-logging");
-
+
Class testClass = loader.loadClass(thisClass.getName());
return new PathableTestSuite(testClass, loader);
}
@@ -192,18 +192,18 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
assertTrue(((DecoratedSimpleLog) log).getShowShortName());
}
-
+
/** Hook for subclassses */
protected void checkShowDateTime() {
assertTrue(!((DecoratedSimpleLog) log).getShowDateTime());
}
-
+
/** Hook for subclasses */
protected void checkDecoratedDateTime() {
assertEquals("yyyy/MM/dd HH:mm:ss:SSS zzz",
((DecoratedSimpleLog) log).getDateTimeFormat());
}
-
+
// Check the actual log records against the expected ones
diff --git a/src/test/java/org/apache/commons/logging/simple/DefaultConfigTestCase.java b/src/test/java/org/apache/commons/logging/simple/DefaultConfigTestCase.java
index f5bccdb..f8f25b5 100644
--- a/src/test/java/org/apache/commons/logging/simple/DefaultConfigTestCase.java
+++ b/src/test/java/org/apache/commons/logging/simple/DefaultConfigTestCase.java
@@ -81,7 +81,7 @@ public class DefaultConfigTestCase extends TestCase {
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
loader.addLogicalLib("testclasses");
loader.addLogicalLib("commons-logging");
-
+
Class testClass = loader.loadClass(thisClass.getName());
return new PathableTestSuite(testClass, loader);
}
diff --git a/src/test/java/org/apache/commons/logging/simple/LogRecord.java b/src/test/java/org/apache/commons/logging/simple/LogRecord.java
index 0c6d784..e366025 100644
--- a/src/test/java/org/apache/commons/logging/simple/LogRecord.java
+++ b/src/test/java/org/apache/commons/logging/simple/LogRecord.java
@@ -29,7 +29,7 @@ public class LogRecord implements Serializable {
* Generated serial version ID.
*/
private static final long serialVersionUID = -5254831759209770665L;
-
+
public LogRecord(int type, Object message, Throwable t) {
this.type = type;
this.message = message;
diff --git a/src/test/java/org/apache/commons/logging/tccl/BadTCCLTestCase.java b/src/test/java/org/apache/commons/logging/tccl/BadTCCLTestCase.java
index 7211156..d19cd7b 100644
--- a/src/test/java/org/apache/commons/logging/tccl/BadTCCLTestCase.java
+++ b/src/test/java/org/apache/commons/logging/tccl/BadTCCLTestCase.java
@@ -37,7 +37,7 @@ public class BadTCCLTestCase extends TestCase {
}
// test methods
-
+
/**
* This test just tests that a log implementation can be found
* by the LogFactory.
diff --git a/src/test/java/org/apache/commons/logging/tccl/NullTCCLTestCase.java b/src/test/java/org/apache/commons/logging/tccl/NullTCCLTestCase.java
index ae5ab4a..2b687c9 100644
--- a/src/test/java/org/apache/commons/logging/tccl/NullTCCLTestCase.java
+++ b/src/test/java/org/apache/commons/logging/tccl/NullTCCLTestCase.java
@@ -34,7 +34,7 @@ public class NullTCCLTestCase extends TestCase {
}
// test methods
-
+
/**
* This test just tests that a log implementation can be found
* by the LogFactory.
diff --git a/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java
index 152af3c..32f88bf 100644
--- a/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java
+++ b/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java
@@ -36,7 +36,7 @@ import org.apache.commons.logging.PathableTestSuite;
public class TcclDisabledTestCase extends TestCase {
- public static final String MY_LOG_PKG =
+ public static final String MY_LOG_PKG =
"org.apache.commons.logging.tccl.custom";
public static final String MY_LOG_IMPL =
@@ -58,7 +58,7 @@ public class TcclDisabledTestCase extends TestCase {
dummy.useExplicitLoader("junit.", Test.class.getClassLoader());
dummy.addLogicalLib("testclasses");
dummy.addLogicalLib("commons-logging");
-
+
String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
URL baseUrl = dummy.findResource(thisClassPath);
@@ -69,7 +69,7 @@ public class TcclDisabledTestCase extends TestCase {
// Log class. Therefore if that class can be found, then the
// TCCL must have been used to load it.
PathableClassLoader emptyLoader = new PathableClassLoader(null);
-
+
PathableClassLoader parentLoader = new PathableClassLoader(null);
parentLoader.useExplicitLoader("junit.", Test.class.getClassLoader());
parentLoader.addLogicalLib("commons-logging");
@@ -77,7 +77,7 @@ public class TcclDisabledTestCase extends TestCase {
// hack to ensure that the testcase classloader can't see
// the custom MyLog
parentLoader.useExplicitLoader(MY_LOG_PKG + ".", emptyLoader);
-
+
URL propsEnableUrl = new URL(baseUrl, "props_disable_tccl/");
parentLoader.addURL(propsEnableUrl);
@@ -108,7 +108,7 @@ public class TcclDisabledTestCase extends TestCase {
* Verify that MyLog is only loadable via the tccl.
*/
public void testLoader() throws Exception {
-
+
ClassLoader thisClassLoader = this.getClass().getClassLoader();
ClassLoader tcclLoader = Thread.currentThread().getContextClassLoader();
@@ -123,7 +123,7 @@ public class TcclDisabledTestCase extends TestCase {
} catch(ClassNotFoundException ex) {
// ok, expected
}
-
+
// MyLog should be loadable via tccl loader
try {
Class clazz = tcclLoader.loadClass(MY_LOG_IMPL);
@@ -142,7 +142,7 @@ public class TcclDisabledTestCase extends TestCase {
public void testTcclLoading() throws Exception {
LogFactory instance = LogFactory.getFactory();
assertEquals(
- "Correct LogFactory loaded",
+ "Correct LogFactory loaded",
"org.apache.commons.logging.impl.LogFactoryImpl",
instance.getClass().getName());
diff --git a/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java
index 692b53e..e65cde4 100644
--- a/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java
+++ b/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java
@@ -36,7 +36,7 @@ import org.apache.commons.logging.PathableTestSuite;
public class TcclEnabledTestCase extends TestCase {
- public static final String MY_LOG_PKG =
+ public static final String MY_LOG_PKG =
"org.apache.commons.logging.tccl.custom";
public static final String MY_LOG_IMPL =
@@ -58,7 +58,7 @@ public class TcclEnabledTestCase extends TestCase {
dummy.useExplicitLoader("junit.", Test.class.getClassLoader());
dummy.addLogicalLib("testclasses");
dummy.addLogicalLib("commons-logging");
-
+
String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
URL baseUrl = dummy.findResource(thisClassPath);
@@ -69,7 +69,7 @@ public class TcclEnabledTestCase extends TestCase {
// Log class. Therefore if that class can be found, then the
// TCCL must have been used to load it.
PathableClassLoader emptyLoader = new PathableClassLoader(null);
-
+
PathableClassLoader parentLoader = new PathableClassLoader(null);
parentLoader.useExplicitLoader("junit.", Test.class.getClassLoader());
parentLoader.addLogicalLib("commons-logging");
@@ -77,7 +77,7 @@ public class TcclEnabledTestCase extends TestCase {
// hack to ensure that the testcase classloader can't see
// the custom MyLogFactoryImpl
parentLoader.useExplicitLoader(MY_LOG_PKG + ".", emptyLoader);
-
+
URL propsEnableUrl = new URL(baseUrl, "props_enable_tccl/");
parentLoader.addURL(propsEnableUrl);
@@ -108,10 +108,10 @@ public class TcclEnabledTestCase extends TestCase {
* Verify that MyLogFactoryImpl is only loadable via the tccl.
*/
public void testLoader() throws Exception {
-
+
ClassLoader thisClassLoader = this.getClass().getClassLoader();
ClassLoader tcclLoader = Thread.currentThread().getContextClassLoader();
-
+
// the tccl loader should NOT be the same as the loader that loaded this test class.
assertNotSame("tccl not same as test classloader", thisClassLoader, tcclLoader);
@@ -123,7 +123,7 @@ public class TcclEnabledTestCase extends TestCase {
} catch(ClassNotFoundException ex) {
// ok, expected
}
-
+
// MyLog should be loadable via tccl loader
try {
Class clazz = tcclLoader.loadClass(MY_LOG_IMPL);
@@ -140,9 +140,9 @@ public class TcclEnabledTestCase extends TestCase {
*/
public void testTcclLoading() throws Exception {
LogFactory instance = LogFactory.getFactory();
-
+
assertEquals(
- "Correct LogFactory loaded",
+ "Correct LogFactory loaded",
"org.apache.commons.logging.impl.LogFactoryImpl",
instance.getClass().getName());
diff --git a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java
index fc577e3..1868f06 100644
--- a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java
+++ b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java
@@ -35,7 +35,7 @@ import org.apache.commons.logging.PathableTestSuite;
public class TcclDisabledTestCase extends TestCase {
- public static final String MY_LOG_FACTORY_PKG =
+ public static final String MY_LOG_FACTORY_PKG =
"org.apache.commons.logging.tccl.custom";
public static final String MY_LOG_FACTORY_IMPL =
@@ -58,7 +58,7 @@ public class TcclDisabledTestCase extends TestCase {
dummy.useExplicitLoader("junit.", Test.class.getClassLoader());
dummy.addLogicalLib("testclasses");
dummy.addLogicalLib("commons-logging");
-
+
String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
URL baseUrl = dummy.findResource(thisClassPath);
@@ -70,7 +70,7 @@ public class TcclDisabledTestCase extends TestCase {
// LogFactory class. Therefore if that class can be found, then the
// TCCL must have been used to load it.
PathableClassLoader emptyLoader = new PathableClassLoader(null);
-
+
PathableClassLoader parentLoader = new PathableClassLoader(null);
parentLoader.useExplicitLoader("junit.", Test.class.getClassLoader());
parentLoader.addLogicalLib("commons-logging");
@@ -79,7 +79,7 @@ public class TcclDisabledTestCase extends TestCase {
// the custom MyLogFactoryImpl
parentLoader.useExplicitLoader(
MY_LOG_FACTORY_PKG + ".", emptyLoader);
-
+
URL propsEnableUrl = new URL(baseUrl, "props_disable_tccl/");
parentLoader.addURL(propsEnableUrl);
@@ -110,7 +110,7 @@ public class TcclDisabledTestCase extends TestCase {
* Verify that MyLogFactoryImpl is only loadable via the tccl.
*/
public void testLoader() throws Exception {
-
+
ClassLoader thisClassLoader = this.getClass().getClassLoader();
ClassLoader tcclLoader = Thread.currentThread().getContextClassLoader();
@@ -125,7 +125,7 @@ public class TcclDisabledTestCase extends TestCase {
} catch(ClassNotFoundException ex) {
// ok, expected
}
-
+
// MyLogFactoryImpl should be loadable via tccl loader
try {
Class clazz = tcclLoader.loadClass(MY_LOG_FACTORY_IMPL);
diff --git a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java
index 58d746b..f4c94e8 100644
--- a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java
+++ b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java
@@ -52,7 +52,7 @@ public class TcclEnabledTestCase extends TestCase {
dummy.useExplicitLoader("junit.", Test.class.getClassLoader());
dummy.addLogicalLib("testclasses");
dummy.addLogicalLib("commons-logging");
-
+
String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
URL baseUrl = dummy.findResource(thisClassPath);
@@ -64,7 +64,7 @@ public class TcclEnabledTestCase extends TestCase {
// LogFactory class. Therefore if that class can be found, then the
// TCCL must have been used to load it.
PathableClassLoader emptyLoader = new PathableClassLoader(null);
-
+
PathableClassLoader parentLoader = new PathableClassLoader(null);
parentLoader.useExplicitLoader("junit.", Test.class.getClassLoader());
parentLoader.addLogicalLib("commons-logging");
@@ -73,7 +73,7 @@ public class TcclEnabledTestCase extends TestCase {
// the cust MyLogFactoryImpl
parentLoader.useExplicitLoader(
"org.apache.commons.logging.tccl.custom.", emptyLoader);
-
+
URL propsEnableUrl = new URL(baseUrl, "props_enable_tccl/");
parentLoader.addURL(propsEnableUrl);
@@ -104,7 +104,7 @@ public class TcclEnabledTestCase extends TestCase {
* Verify that MyLogFactoryImpl is only loadable via the tccl.
*/
public void testLoader() throws Exception {
-
+
ClassLoader thisClassLoader = this.getClass().getClassLoader();
ClassLoader tcclLoader = Thread.currentThread().getContextClassLoader();
@@ -120,7 +120,7 @@ public class TcclEnabledTestCase extends TestCase {
} catch(ClassNotFoundException ex) {
// ok, expected
}
-
+
// MyLogFactoryImpl should be loadable via tccl loader
try {
Class clazz = tcclLoader.loadClass(
@@ -138,9 +138,9 @@ public class TcclEnabledTestCase extends TestCase {
*/
public void testTcclLoading() throws Exception {
LogFactory instance = LogFactory.getFactory();
-
+
assertEquals(
- "Correct LogFactory loaded",
+ "Correct LogFactory loaded",
"org.apache.commons.logging.tccl.custom.MyLogFactoryImpl",
instance.getClass().getName());
}
Enumeration, possibly null
* @return ArrayList containing the enumerated
* elements in the enumerated order, not null
@@ -410,7 +410,7 @@ public class PathableClassLoader extends URLClassLoader {
}
return results;
}
-
+
/**
* Same as parent class method except that when parentFirst is false
* the resource is looked for in the local classpath before the parent
diff --git a/src/test/java/org/apache/commons/logging/PathableTestSuite.java b/src/test/java/org/apache/commons/logging/PathableTestSuite.java
index 3a71676..4b8805c 100644
--- a/src/test/java/org/apache/commons/logging/PathableTestSuite.java
+++ b/src/test/java/org/apache/commons/logging/PathableTestSuite.java
@@ -33,24 +33,24 @@ import junit.framework.TestSuite;
* public static Test suite() throws Exception {
* PathableClassLoader parent = new PathableClassLoader(null);
* parent.useSystemLoader("junit.");
- *
+ *
* PathableClassLoader child = new PathableClassLoader(parent);
* child.addLogicalLib("testclasses");
* child.addLogicalLib("log4j12");
* child.addLogicalLib("commons-logging");
- *
+ *
* Class testClass = child.loadClass(SomeTestCase.class.getName());
* ClassLoader contextClassLoader = child;
- *
+ *
* PathableTestSuite suite = new PathableTestSuite(testClass, child);
* return suite;
* }
- *
+ *
* // test methods go here
* }
*
* Note that if the suite method throws an exception then this will be handled
- * reasonable gracefully by junit; it will report that the suite method for
+ * reasonable gracefully by junit; it will report that the suite method for
* a test case failed with exception yyy.
*
@@ -70,14 +70,14 @@ import junit.framework.TestSuite;
* is undone after the test is run, so tests don't need to worry about
* restoring the context classloader on exit. This class also ensures that
* the system properties are restored to their original settings after each
- * test, so tests that manipulate those don't need to worry about resetting them.
+ * test, so tests that manipulate those don't need to worry about resetting them.
*
Limitations
*