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 /** 27 * TestCase for Jdk14 logging when the commons-logging-api jar file is in 28 * the parent classpath and commons-logging.jar is in the child. 29 */ 30 31 public class CustomConfigAPITestCase extends CustomConfigTestCase { 32 33 public CustomConfigAPITestCase(String name) { 34 super(name); 35 } 36 37 /** 38 * Return the tests included in this test suite. 39 */ 40 public static Test suite() throws Exception { 41 PathableClassLoader parent = new PathableClassLoader(null); 42 parent.useExplicitLoader("junit.", Test.class.getClassLoader()); 43 44 // the TestHandler class must be accessable from the System classloader 45 // in order for java.util.logging.LogManager.readConfiguration to 46 // be able to instantiate it. And this test case must see the same 47 // class in order to be able to access its data. Yes this is ugly 48 // but the whole jdk14 API is a ******* mess anyway. 49 ClassLoader scl = ClassLoader.getSystemClassLoader(); 50 loadTestHandler(HANDLER_NAME, scl); 51 parent.useExplicitLoader(HANDLER_NAME, scl); 52 parent.addLogicalLib("commons-logging-api"); 53 54 PathableClassLoader child = new PathableClassLoader(parent); 55 child.addLogicalLib("testclasses"); 56 child.addLogicalLib("commons-logging"); 57 58 Class testClass = child.loadClass(CustomConfigAPITestCase.class.getName()); 59 return new PathableTestSuite(testClass, child); 60 } 61 }