KickJava   Java API By Example, From Geeks To Geeks.

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


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

30 public class IncompleteArgumentExceptionTest 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(IncompleteArgumentExceptionTest.class);
38     }
39
40     public IncompleteArgumentExceptionTest(String JavaDoc testName) {
41         super(testName);
42     }
43
44     // testConstructor
45

46     public void test1arg_nullInput() {
47         final Throwable JavaDoc t = new IncompleteArgumentException(null);
48         assertEquals("null is incomplete.", t.getMessage());
49     }
50
51     public void test1arg_validInput() {
52         final String JavaDoc name = "argument";
53         final Throwable JavaDoc t = new IncompleteArgumentException(name);
54         assertEquals(name + " is incomplete.", t.getMessage());
55     }
56
57     public void test2arg_allNullInput() {
58         final Throwable JavaDoc t = new IncompleteArgumentException(null, null);
59         assertEquals(
60             "null is missing the following items: null",
61             t.getMessage());
62     }
63
64     public void test2arg_nullString() {
65         final Throwable JavaDoc t =
66             new IncompleteArgumentException(
67                 null,
68                 new String JavaDoc[] { "one", "two" });
69         assertEquals(
70             "null is missing the following items: [one, two]",
71             t.getMessage());
72     }
73
74     public void test2arg_nullArray() {
75         final String JavaDoc name = "one";
76         final Throwable JavaDoc t = new IncompleteArgumentException(name, null);
77         assertEquals(
78             name + " is missing the following items: null",
79             t.getMessage());
80     }
81
82     public void test2arg_validInput() {
83         final String JavaDoc name = "input";
84         final Throwable JavaDoc t =
85             new IncompleteArgumentException(
86                 name,
87                 new String JavaDoc[] { "one", "two" });
88         assertEquals(
89             name + " is missing the following items: [one, two]",
90             t.getMessage());
91     }
92
93 } // IncompleteArgumentExceptionTest
94
Popular Tags