View Javadoc
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  package org.apache.commons.logging;
18  
19  import junit.framework.TestCase;
20  
21  /**
22    * Generic tests that can be applied to any log adapter by
23    * subclassing this class and defining method getLogObject
24    * appropriately.
25    */
26  public abstract class AbstractLogTest extends TestCase {
27  
28      public abstract Log getLogObject();
29  
30      public void testLoggingWithNullParameters()
31      {
32          final Log log = this.getLogObject();
33          assertNotNull(log);
34  
35          log.debug(null);
36          log.debug(null, null);
37          log.debug(log.getClass().getName() + ": debug statement");
38          log.debug(log.getClass().getName() + ": debug statement w/ null exception", new RuntimeException());
39  
40          log.error(null);
41          log.error(null, null);
42          log.error(log.getClass().getName() + ": error statement");
43          log.error(log.getClass().getName() + ": error statement w/ null exception", new RuntimeException());
44  
45          log.fatal(null);
46          log.fatal(null, null);
47          log.fatal(log.getClass().getName() + ": fatal statement");
48          log.fatal(log.getClass().getName() + ": fatal statement w/ null exception", new RuntimeException());
49  
50          log.info(null);
51          log.info(null, null);
52          log.info(log.getClass().getName() + ": info statement");
53          log.info(log.getClass().getName() + ": info statement w/ null exception", new RuntimeException());
54  
55          log.trace(null);
56          log.trace(null, null);
57          log.trace(log.getClass().getName() + ": trace statement");
58          log.trace(log.getClass().getName() + ": trace statement w/ null exception", new RuntimeException());
59  
60          log.warn(null);
61          log.warn(null, null);
62          log.warn(log.getClass().getName() + ": warn statement");
63          log.warn(log.getClass().getName() + ": warn statement w/ null exception", new RuntimeException());
64      }
65  }