* Fix bug where unit tests weren't getting executed at all (wrong test class name)
* Put both resources in child classloader rather than using parent, to avoid confusion with parentFirst not being supported by PathableClassLoader.getResources. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@394603 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -34,11 +34,10 @@ import org.apache.commons.logging.PathableTestSuite;
|
|||||||
* This test sets up a classpath where:
|
* This test sets up a classpath where:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li> first file found has priority=20
|
* <li> first file found has priority=20
|
||||||
* <li> second file (in parent path) has priority=10 (parentFirst=false)
|
* <li> second file found has priority=10
|
||||||
* </ul>
|
* </ul>
|
||||||
* The result should be that the first file is used.
|
* The result should be that the first file is used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FirstPriorityConfigTestCase extends TestCase {
|
public class FirstPriorityConfigTestCase extends TestCase {
|
||||||
|
|
||||||
// ------------------------------------------- JUnit Infrastructure Methods
|
// ------------------------------------------- JUnit Infrastructure Methods
|
||||||
@@ -48,7 +47,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 {
|
||||||
Class thisClass = PriorityConfigTestCase.class;
|
Class 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
|
||||||
@@ -73,16 +72,15 @@ public class FirstPriorityConfigTestCase extends TestCase {
|
|||||||
containerLoader.useSystemLoader("junit.");
|
containerLoader.useSystemLoader("junit.");
|
||||||
containerLoader.addLogicalLib("commons-logging");
|
containerLoader.addLogicalLib("commons-logging");
|
||||||
|
|
||||||
URL pri10URL = new URL(baseUrl, "priority10/");
|
|
||||||
containerLoader.addURL(pri10URL);
|
|
||||||
|
|
||||||
PathableClassLoader webappLoader = new PathableClassLoader(containerLoader);
|
PathableClassLoader webappLoader = new PathableClassLoader(containerLoader);
|
||||||
webappLoader.setParentFirst(false);
|
|
||||||
webappLoader.addLogicalLib("testclasses");
|
webappLoader.addLogicalLib("testclasses");
|
||||||
|
|
||||||
URL pri20URL = new URL(baseUrl, "priority20/");
|
URL pri20URL = new URL(baseUrl, "priority20/");
|
||||||
webappLoader.addURL(pri20URL);
|
webappLoader.addURL(pri20URL);
|
||||||
|
|
||||||
|
URL pri10URL = new URL(baseUrl, "priority10/");
|
||||||
|
webappLoader.addURL(pri10URL);
|
||||||
|
|
||||||
// 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.
|
||||||
Class testClass = webappLoader.loadClass(thisClass.getName());
|
Class testClass = webappLoader.loadClass(thisClass.getName());
|
||||||
@@ -113,7 +111,5 @@ public class FirstPriorityConfigTestCase extends TestCase {
|
|||||||
LogFactory instance = LogFactory.getFactory();
|
LogFactory instance = LogFactory.getFactory();
|
||||||
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 );
|
||||||
|
|
||||||
fail("deliberate failure");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user