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 021 import junit.framework.Test; 022 023 import org.apache.commons.logging.PathableTestSuite; 024 import org.apache.commons.logging.PathableClassLoader; 025 026 027 /** 028 * TestCase for Jdk14 logging when the commons-logging jar file is in 029 * the parent classpath. 030 */ 031 032 public class CustomConfigFullTestCase extends CustomConfigTestCase { 033 034 035 public CustomConfigFullTestCase(String name) { 036 super(name); 037 } 038 039 040 /** 041 * Return the tests included in this test suite. 042 */ 043 public static Test suite() throws Exception { 044 PathableClassLoader parent = new PathableClassLoader(null); 045 parent.useExplicitLoader("junit.", Test.class.getClassLoader()); 046 047 // the TestHandler class must be accessable from the System classloader 048 // in order for java.util.logging.LogManager.readConfiguration to 049 // be able to instantiate it. And this test case must see the same 050 // class in order to be able to access its data. Yes this is ugly 051 // but the whole jdk14 API is a ******* mess anyway. 052 ClassLoader scl = ClassLoader.getSystemClassLoader(); 053 loadTestHandler(HANDLER_NAME, scl); 054 parent.useExplicitLoader(HANDLER_NAME, scl); 055 parent.addLogicalLib("commons-logging"); 056 057 PathableClassLoader child = new PathableClassLoader(parent); 058 child.addLogicalLib("testclasses"); 059 060 Class testClass = child.loadClass(CustomConfigFullTestCase.class.getName()); 061 return new PathableTestSuite(testClass, child); 062 } 063 }