KickJava   Java API By Example, From Geeks To Geeks.

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


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: NotImplementedExceptionTest.java 161244 2005-04-14 06:16:36Z ggregory $
28  * @see NotImplementedException
29  */

30 public class NotImplementedExceptionTest 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(NotImplementedExceptionTest.class);
38     }
39
40     public NotImplementedExceptionTest(String JavaDoc testName) {
41         super(testName);
42     }
43
44     //-----------------------------------------------------------------------
45
public void testConstructor_() {
46         NotImplementedException ex = new NotImplementedException();
47         assertEquals("Code is not implemented", ex.getMessage());
48         assertEquals(null, ex.getCause());
49     }
50
51     public void testConstructor_String1() {
52         NotImplementedException ex = new NotImplementedException((String JavaDoc) null);
53         assertEquals("Code is not implemented", ex.getMessage());
54         assertEquals(null, ex.getCause());
55     }
56     public void testConstructor_String2() {
57         NotImplementedException ex = new NotImplementedException("msg");
58         assertEquals("msg", ex.getMessage());
59         assertEquals(null, ex.getCause());
60     }
61
62     public void testConstructor_Throwable1() {
63         NotImplementedException ex = new NotImplementedException((Throwable JavaDoc) null);
64         assertEquals("Code is not implemented", ex.getMessage());
65         assertEquals(null, ex.getCause());
66     }
67     public void testConstructor_Throwable2() {
68         Exception JavaDoc npe = new NullPointerException JavaDoc();
69         NotImplementedException ex = new NotImplementedException(npe);
70         assertEquals("Code is not implemented", ex.getMessage());
71         assertSame(npe, ex.getCause());
72     }
73
74     public void testConstructor_StringThrowable1() {
75         NotImplementedException ex = new NotImplementedException((String JavaDoc) null, (Throwable JavaDoc) null);
76         assertEquals("Code is not implemented", ex.getMessage());
77         assertEquals(null, ex.getCause());
78     }
79     public void testConstructor_StringThrowable2() {
80         Exception JavaDoc npe = new NullPointerException JavaDoc();
81         NotImplementedException ex = new NotImplementedException("msg", npe);
82         assertEquals("msg", ex.getMessage());
83         assertSame(npe, ex.getCause());
84     }
85
86     public void testConstructor_Class1() {
87         NotImplementedException ex = new NotImplementedException((Class JavaDoc) null);
88         assertEquals("Code is not implemented", ex.getMessage());
89         assertEquals(null, ex.getCause());
90     }
91     public void testConstructor_Class2() {
92         NotImplementedException ex = new NotImplementedException(String JavaDoc.class);
93         assertEquals("Code is not implemented in class java.lang.String", ex.getMessage());
94         assertEquals(null, ex.getCause());
95     }
96
97 }
98
Popular Tags