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.lang;
018:
019: import junit.framework.Test;
020: import junit.framework.TestCase;
021: import junit.framework.TestSuite;
022: import junit.textui.TestRunner;
023:
024: /**
025: * JUnit tests.
026: *
027: * @author Matthew Hawthorne
028: * @version $Id: IllegalClassExceptionTest.java 437554 2006-08-28 06:21:41Z bayard $
029: * @see IllegalClassException
030: */
031: public class IllegalClassExceptionTest extends TestCase {
032:
033: public static void main(String[] args) {
034: TestRunner.run(suite());
035: }
036:
037: public static Test suite() {
038: return new TestSuite(IllegalClassExceptionTest.class);
039: }
040:
041: public IllegalClassExceptionTest(String testName) {
042: super (testName);
043: }
044:
045: // testConstructor_classArgs
046:
047: public void testConstructor_classArgs_allNullInput() {
048: new IllegalClassException(null, null);
049: }
050:
051: public void testConstructor_classArgs_nullExpected() {
052: new IllegalClassException(null, String.class);
053: }
054:
055: public void testConstructor_classArgs_nullActual() {
056: new IllegalClassException(String.class, null);
057: }
058:
059: // testConstructor_stringArg
060:
061: public void testConstructor_stringArg_nullInput() {
062: new IllegalClassException(null);
063: }
064:
065: // testConstructor_classObjectArgs
066:
067: public void testConstructor_classObjectArgs_allNullInput() {
068: new IllegalClassException(null, (Object) null);
069: }
070:
071: public void testConstructor_classObjectArgs_nullExpected() {
072: new IllegalClassException(null, new Object());
073: }
074:
075: public void testConstructor_classObjectArgs_nullActual() {
076: new IllegalClassException(String.class, (Object) null);
077: }
078:
079: // testGetMessage
080:
081: public void testGetMessage_classArgs_nullInput() {
082: final Throwable t = new IllegalClassException(null, null);
083: assertEquals("Expected: null, actual: null", t.getMessage());
084: }
085:
086: public void testGetMessage_classArgs_normalInput() {
087: final Throwable t = new IllegalClassException(String.class,
088: Integer.class);
089: assertEquals(
090: "Expected: java.lang.String, actual: java.lang.Integer",
091: t.getMessage());
092: }
093:
094: public void testGetMessage_classObjectArgs_nullInput() {
095: final Throwable t = new IllegalClassException(null,
096: (Object) null);
097: assertEquals("Expected: null, actual: null", t.getMessage());
098: }
099:
100: public void testGetMessage_classObjectArgs_normalInput() {
101: final Throwable t = new IllegalClassException(String.class,
102: new Object());
103: assertEquals(
104: "Expected: java.lang.String, actual: java.lang.Object",
105: t.getMessage());
106: }
107:
108: public void testGetMessage_stringArg_nullInput() {
109: final Throwable t = new IllegalClassException(null);
110: assertEquals(null, t.getMessage());
111: }
112:
113: public void testGetMessage_stringArg_validInput() {
114: final String message = "message";
115: final Throwable t = new IllegalClassException(message);
116: assertEquals(message, t.getMessage());
117: }
118:
119: } // IllegalClassExceptionTest
|