001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     * 
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     * 
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */ 
017    
018    package org.apache.commons.logging.jdk14;
019    
020    import junit.framework.Test;
021    
022    import org.apache.commons.logging.PathableClassLoader;
023    import org.apache.commons.logging.PathableTestSuite;
024    
025    
026    /**
027     * TestCase for Jdk14 logging when the commons-logging-api jar file is in
028     * the parent classpath and commons-logging.jar is in the child.
029     */
030    
031    public class CustomConfigAPITestCase extends CustomConfigTestCase {
032    
033        public CustomConfigAPITestCase(String name) {
034            super(name);
035        }
036    
037        /**
038         * Return the tests included in this test suite.
039         */
040        public static Test suite() throws Exception {
041            PathableClassLoader parent = new PathableClassLoader(null);
042            parent.useExplicitLoader("junit.", Test.class.getClassLoader());
043    
044            // the TestHandler class must be accessable from the System classloader
045            // in order for java.util.logging.LogManager.readConfiguration to
046            // be able to instantiate it. And this test case must see the same
047            // class in order to be able to access its data. Yes this is ugly
048            // but the whole jdk14 API is a ******* mess anyway.
049            ClassLoader scl = ClassLoader.getSystemClassLoader();
050            loadTestHandler(HANDLER_NAME, scl);
051            parent.useExplicitLoader(HANDLER_NAME, scl);
052            parent.addLogicalLib("commons-logging-api");
053    
054            PathableClassLoader child = new PathableClassLoader(parent);
055            child.addLogicalLib("testclasses");
056            child.addLogicalLib("commons-logging");
057            
058            Class testClass = child.loadClass(CustomConfigAPITestCase.class.getName());
059            return new PathableTestSuite(testClass, child);
060        }
061    }