Minor test tidyups (including fixing incorrect comment due to copy-and-paste).
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@427418 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -62,13 +62,9 @@ public class FirstPriorityConfigTestCase extends TestCase {
|
|||||||
String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
|
String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
|
||||||
URL baseUrl = dummy.findResource(thisClassPath);
|
URL baseUrl = dummy.findResource(thisClassPath);
|
||||||
|
|
||||||
// Now set up the desired classloader hierarchy. We'll put a config
|
// Now set up the desired classloader hierarchy. We'll put JCL
|
||||||
// file of priority=10 in the container path, and ones of both
|
// in the container path, the testcase in a webapp path, and
|
||||||
// "no priority" and priority=20 in the webapp path.
|
// both config files into the webapp path too.
|
||||||
//
|
|
||||||
// A second properties file with priority=20 is also added,
|
|
||||||
// so we can check that the first one in the classpath is
|
|
||||||
// used.
|
|
||||||
PathableClassLoader containerLoader = new PathableClassLoader(null);
|
PathableClassLoader containerLoader = new PathableClassLoader(null);
|
||||||
containerLoader.useExplicitLoader("junit.", Test.class.getClassLoader());
|
containerLoader.useExplicitLoader("junit.", Test.class.getClassLoader());
|
||||||
containerLoader.addLogicalLib("commons-logging");
|
containerLoader.addLogicalLib("commons-logging");
|
||||||
@@ -110,6 +106,19 @@ public class FirstPriorityConfigTestCase extends TestCase {
|
|||||||
*/
|
*/
|
||||||
public void testPriority() throws Exception {
|
public void testPriority() throws Exception {
|
||||||
LogFactory instance = LogFactory.getFactory();
|
LogFactory instance = LogFactory.getFactory();
|
||||||
|
|
||||||
|
ClassLoader thisClassLoader = this.getClass().getClassLoader();
|
||||||
|
ClassLoader lfClassLoader = instance.getClass().getClassLoader();
|
||||||
|
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
||||||
|
// context classloader should be thisClassLoader
|
||||||
|
assertEquals(thisClassLoader, contextClassLoader);
|
||||||
|
|
||||||
|
// lfClassLoader should be parent of this classloader
|
||||||
|
assertEquals(lfClassLoader, thisClassLoader.getParent());
|
||||||
|
assertEquals(PathableClassLoader.class.getName(),
|
||||||
|
lfClassLoader.getClass().getName());
|
||||||
|
|
||||||
String id = (String) instance.getAttribute("configId");
|
String id = (String) instance.getAttribute("configId");
|
||||||
assertEquals("Correct config file loaded", "priority20", id );
|
assertEquals("Correct config file loaded", "priority20", id );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user