KickJava   Java API By Example, From Geeks To Geeks.

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


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 ValidOptionTest extends TestCase {
34     public static void assertFalse(boolean t) {
35         assertTrue(!t);
36     }
37
38     public void testName() {
39         assertNull(vo.getName());
40         vo.setName("foo");
41         assertEquals("foo", vo.getName());
42     }
43     public void testShortNames(){
44         assertTrue(vo.getShortNames().isEmpty());
45         assertFalse(vo.hasShortName());
46         vo.setShortName("foo");
47         assertEquals(1, vo.getShortNames().size());
48         assertTrue(vo.getShortNames().contains("foo"));
49         assertTrue(vo.hasShortName());
50     }
51
52     public void testType(){
53         assertNull(vo.getType());
54         vo.setType("t1");
55         assertEquals("t1", vo.getType());
56     }
57
58     public void testRequired(){
59         assertEquals(0, vo.isValueRequired());
60         vo.setRequired(12345);
61         assertEquals(12345, vo.isValueRequired());
62     }
63
64     public void testDefault(){
65         assertFalse(vo.hasDefaultValue());
66         vo.setDefaultValue("def");
67         assertEquals("def", vo.getDefaultValue());
68         assertTrue(vo.hasDefaultValue());
69     }
70
71     public void testToString(){
72         assertEquals("null null null", vo.toString());
73         vo.setShortName("foo");
74         assertEquals("null null foo, null", vo.toString());
75     }
76     
77     public ValidOptionTest(String JavaDoc name){
78         super(name);
79     }
80
81     ValidOption vo;
82     
83     protected void setUp() {
84         vo = new ValidOption();
85     }
86
87     protected void tearDown() {
88     }
89
90     private void nyi(){
91         fail("Not Yet Implemented");
92     }
93
94     public static void main(String JavaDoc args[]){
95         if (args.length == 0){
96             junit.textui.TestRunner.run(ValidOptionTest.class);
97         } else {
98             junit.textui.TestRunner.run(makeSuite(args));
99         }
100     }
101     private static TestSuite makeSuite(String JavaDoc args[]){
102         final TestSuite ts = new TestSuite();
103         for (int i = 0; i < args.length; i++){
104             ts.addTest(new ValidOptionTest(args[i]));
105         }
106         return ts;
107     }
108 }
109
Popular Tags