1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.commons.logging.jdk14;
19
20 import junit.framework.Test;
21
22 import org.apache.commons.logging.PathableClassLoader;
23 import org.apache.commons.logging.PathableTestSuite;
24
25 /**
26 * TestCase for Jdk14 logging when the commons-logging-api jar file is in
27 * the parent classpath and commons-logging.jar is in the child.
28 */
29
30 public class CustomConfigAPITestCase extends CustomConfigTestCase {
31
32 /**
33 * Return the tests included in this test suite.
34 */
35 public static Test suite() throws Exception {
36 final PathableClassLoader parent = new PathableClassLoader(null);
37 parent.useExplicitLoader("junit.", Test.class.getClassLoader());
38
39 // the TestHandler class must be accessible from the System class loader
40 // in order for java.util.logging.LogManager.readConfiguration to
41 // be able to instantiate it. And this test case must see the same
42 // class in order to be able to access its data. Yes this is ugly
43 // but the whole jdk14 API is a ******* mess anyway.
44 final ClassLoader scl = ClassLoader.getSystemClassLoader();
45 loadTestHandler(HANDLER_NAME, scl);
46 parent.useExplicitLoader(HANDLER_NAME, scl);
47 parent.addLogicalLib("commons-logging-api");
48
49 final PathableClassLoader child = new PathableClassLoader(parent);
50 child.addLogicalLib("testclasses");
51 child.addLogicalLib("commons-logging");
52
53 final Class<?> testClass = child.loadClass(CustomConfigAPITestCase.class.getName());
54 return new PathableTestSuite(testClass, child);
55 }
56
57 public CustomConfigAPITestCase(final String name) {
58 super(name);
59 }
60 }