1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.logging.log4j.log4j12;
18
19 import junit.framework.Test;
20 import junit.framework.TestCase;
21
22 import org.apache.commons.logging.PathableClassLoader;
23 import org.apache.commons.logging.PathableTestSuite;
24 import org.apache.commons.logging.impl.ServletContextCleaner;
25
26
27 /***
28 * Tests for ServletContextCleaner utility class.
29 */
30
31 public class BasicServletTestCase extends TestCase {
32
33 /***
34 * Return the tests included in this test suite.
35 */
36 public static Test suite() throws Exception {
37
38
39
40
41
42
43
44
45 PathableClassLoader parent = new PathableClassLoader(null);
46 parent.useSystemLoader("junit.");
47 parent.addLogicalLib("commons-logging");
48 parent.addLogicalLib("servletapi");
49
50 PathableClassLoader child = new PathableClassLoader(parent);
51 child.setParentFirst(false);
52 child.addLogicalLib("commons-logging");
53 child.addLogicalLib("testclasses");
54
55 PathableClassLoader tccl = new PathableClassLoader(child);
56 tccl.setParentFirst(false);
57 tccl.addLogicalLib("commons-logging");
58
59 Class testClass = child.loadClass(BasicServletTestCase.class.getName());
60 return new PathableTestSuite(testClass, tccl);
61 }
62
63 /***
64 * Test that calling ServletContextCleaner.contextDestroyed doesn't crash.
65 * Testing anything else is rather difficult...
66 */
67 public void testBasics() {
68 ServletContextCleaner scc = new ServletContextCleaner();
69 scc.contextDestroyed(null);
70 }
71 }