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 package org.apache.commons.logging; 018 019 import junit.framework.TestCase; 020 021 /** 022 * Test cases for situations where getClassLoader or getContextClassLoader 023 * return null. This can happen when using JDK 1.1. It can also happen when 024 * JCL is deployed via the bootclassloader - something that could be done when 025 * using java in embedded systems. 026 */ 027 public class NullClassLoaderTestCase extends TestCase { 028 029 //---------------------- Main --------------------------------- 030 031 /** 032 * Main method so this test case can be run direct from the command line. 033 */ 034 public static void main(String[] args){ 035 String[] testCaseName = { NullClassLoaderTestCase.class.getName() }; 036 junit.textui.TestRunner.main(testCaseName); 037 } 038 039 //---------------------- unit tests --------------------------------- 040 041 /** 042 * This tests that when getContextClassLoader returns null, the 043 * LogFactory.getLog(name) method still correctly returns the same 044 * log object when called multiple times with the same name. 045 */ 046 public void testSameLogObject() throws Exception { 047 // unfortunately, there just isn't any way to emulate JCL being 048 // accessable via the null classloader in "standard" systems, so 049 // we can't include this test in our standard unit tests. 050 } 051 }