KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > lang > IllegalClassExceptionTest


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.lang;
17
18 import junit.framework.Test;
19 import junit.framework.TestCase;
20 import junit.framework.TestSuite;
21 import junit.textui.TestRunner;
22
23 /**
24  * JUnit tests.
25  *
26  * @author Matthew Hawthorne
27  * @version $Id: IllegalClassExceptionTest.java 161244 2005-04-14 06:16:36Z ggregory $
28  * @see IllegalClassException
29  */

30 public class IllegalClassExceptionTest extends TestCase {
31
32     public static void main(String JavaDoc[] args) {
33         TestRunner.run(suite());
34     }
35
36     public static Test suite() {
37         return new TestSuite(IllegalClassExceptionTest.class);
38     }
39
40     public IllegalClassExceptionTest(String JavaDoc testName) {
41         super(testName);
42     }
43
44     // testConstructor_classArgs
45

46     public void testConstructor_classArgs_allNullInput() {
47         new IllegalClassException(null, null);
48     }
49
50     public void testConstructor_classArgs_nullExpected() {
51         new IllegalClassException(null, String JavaDoc.class);
52     }
53
54     public void testConstructor_classArgs_nullActual() {
55         new IllegalClassException(String JavaDoc.class, null);
56     }
57
58     // testConstructor_stringArg
59

60     public void testConstructor_stringArg_nullInput() {
61         new IllegalClassException(null);
62     }
63
64     // testGetMessage
65

66     public void testGetMessage_classArgs_nullInput() {
67         final Throwable JavaDoc t = new IllegalClassException(null, null);
68         assertEquals("Expected: null, actual: null", t.getMessage());
69     }
70
71     public void testGetMessage_classArgs_normalInput() {
72         final Throwable JavaDoc t =
73             new IllegalClassException(String JavaDoc.class, Integer JavaDoc.class);
74         assertEquals(
75             "Expected: java.lang.String, actual: java.lang.Integer",
76             t.getMessage());
77     }
78
79     public void testGetMessage_stringArg_nullInput() {
80         final Throwable JavaDoc t = new IllegalClassException(null);
81         assertEquals(null, t.getMessage());
82     }
83
84     public void testGetMessage_stringArg_validInput() {
85         final String JavaDoc message = "message";
86         final Throwable JavaDoc t = new IllegalClassException(message);
87         assertEquals(message, t.getMessage());
88     }
89
90 } // IllegalClassExceptionTest
91
Popular Tags