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.lang;
18  
19  import junit.framework.Test;
20  import junit.framework.TestCase;
21  import junit.framework.TestSuite;
22  import junit.textui.TestRunner;
23  
24  /**
25   * JUnit tests.
26   * 
27   * @author Matthew Hawthorne
28   * @version $Id: IllegalClassExceptionTest.java 437554 2006-08-28 06:21:41Z bayard $
29   * @see IllegalClassException
30   */
31  public class IllegalClassExceptionTest extends TestCase {
32  
33      public static void main(String[] args) {
34          TestRunner.run(suite());
35      }
36  
37      public static Test suite() {
38          return new TestSuite(IllegalClassExceptionTest.class);
39      }
40  
41      public IllegalClassExceptionTest(String testName) {
42          super(testName);
43      }
44  
45      // testConstructor_classArgs
46  
47      public void testConstructor_classArgs_allNullInput() {
48          new IllegalClassException(null, null);
49      }
50  
51      public void testConstructor_classArgs_nullExpected() {
52          new IllegalClassException(null, String.class);
53      }
54  
55      public void testConstructor_classArgs_nullActual() {
56          new IllegalClassException(String.class, null);
57      }
58  
59      //  testConstructor_stringArg
60  
61      public void testConstructor_stringArg_nullInput() {
62          new IllegalClassException(null);
63      }
64  
65      // testConstructor_classObjectArgs
66  
67      public void testConstructor_classObjectArgs_allNullInput() {
68          new IllegalClassException(null, (Object) null);
69      }
70  
71      public void testConstructor_classObjectArgs_nullExpected() {
72          new IllegalClassException(null, new Object());
73      }
74  
75      public void testConstructor_classObjectArgs_nullActual() {
76          new IllegalClassException(String.class, (Object) null);
77      }
78  
79      // testGetMessage
80  
81      public void testGetMessage_classArgs_nullInput() {
82          final Throwable t = new IllegalClassException(null, null);
83          assertEquals("Expected: null, actual: null", t.getMessage());
84      }
85  
86      public void testGetMessage_classArgs_normalInput() {
87          final Throwable t =
88              new IllegalClassException(String.class, Integer.class);
89          assertEquals(
90              "Expected: java.lang.String, actual: java.lang.Integer",
91              t.getMessage());
92      }
93  
94      public void testGetMessage_classObjectArgs_nullInput() {
95          final Throwable t = new IllegalClassException(null, (Object) null);
96          assertEquals("Expected: null, actual: null", t.getMessage());
97      }
98  
99      public void testGetMessage_classObjectArgs_normalInput() {
100         final Throwable t =
101             new IllegalClassException(String.class, new Object());
102         assertEquals(
103             "Expected: java.lang.String, actual: java.lang.Object",
104             t.getMessage());
105     }
106 
107     public void testGetMessage_stringArg_nullInput() {
108         final Throwable t = new IllegalClassException(null);
109         assertEquals(null, t.getMessage());
110     }
111 
112     public void testGetMessage_stringArg_validInput() {
113         final String message = "message";
114         final Throwable t = new IllegalClassException(message);
115         assertEquals(message, t.getMessage());
116     }
117 
118 } // IllegalClassExceptionTest