KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > cli > framework > CommandExceptionTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.cli.framework;
25
26 import junit.framework.*;
27 /**
28  *
29  * @author <a HREF="mailto:toby.h.ferguson@sun.com">Toby H Ferguson</a>
30  * @version $Revision: 1.4 $
31  */

32
33 public class CommandExceptionTest extends TestCase {
34     public void testFullConstructor(){
35         final String JavaDoc message = "m";
36         final Throwable JavaDoc t = new Throwable JavaDoc();
37         CommandException ce = new CommandException(message, t);
38         assertEquals(message, ce.getMessage());
39         assertEquals(t, ce.getCause());
40     }
41     
42 public void testEmptyConstructor(){
43         CommandException ce = new CommandException();
44         assertNull(ce.getMessage());
45     }
46     
47     public void testEncapsulatedException() {
48         final NullPointerException JavaDoc npe = new NullPointerException JavaDoc("a null pointer");
49         CommandException ce = new CommandException(npe);
50         assertEquals("java.lang.NullPointerException: a null pointer", ce.getMessage());
51         assertEquals(npe, ce.getCause());
52     }
53     
54     public void testSimple() {
55         CommandException ce = new CommandException("this is the message");
56         assertEquals("this is the message", ce.getMessage());
57     }
58
59     public CommandExceptionTest(String JavaDoc name){
60         super(name);
61     }
62
63     protected void setUp() {
64     }
65
66     protected void tearDown() {
67     }
68
69     private void nyi(){
70         fail("Not Yet Implemented");
71     }
72
73     public static void main(String JavaDoc args[]){
74         if (args.length == 0){
75             junit.textui.TestRunner.run(CommandExceptionTest.class);
76         } else {
77             junit.textui.TestRunner.run(makeSuite(args));
78         }
79     }
80     private static TestSuite makeSuite(String JavaDoc args[]){
81         final TestSuite ts = new TestSuite();
82         for (int i = 0; i < args.length; i++){
83             ts.addTest(new CommandExceptionTest(args[i]));
84         }
85         return ts;
86     }
87 }
88
Popular Tags