KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.HashMap JavaDoc;
27 import java.util.Vector JavaDoc;
28 import java.util.Arrays JavaDoc;
29 import junit.framework.*;
30 /**
31  *
32  * @author <a HREF="mailto:toby.h.ferguson@sun.com">Toby H Ferguson</a>
33  * @version $Revision: 1.4 $
34  */

35
36 public class CommandValidatorTest extends TestCase {
37     public void testValidCommand3() throws Exception JavaDoc {
38         final Vector JavaDoc vos = new Vector JavaDoc();
39         vos.add(new ValidOption("vo", "foo", 0, "value"));
40         final Vector JavaDoc ros = new Vector JavaDoc();
41         ros.add(new ValidOption("ro", "fee", 1, "v"));
42         final Vector JavaDoc dos = new Vector JavaDoc();
43         final ValidCommand vc = new ValidCommand("name", "*", vos, ros, dos, "useage");
44         cv.validateCommandAndOptions(vc, new HashMap JavaDoc(), new Vector JavaDoc());
45     }
46         
47     public void testValidCommand2() throws Exception JavaDoc {
48         final Vector JavaDoc vos = new Vector JavaDoc();
49         vos.add(new ValidOption("vo", "foo", 0, "value"));
50         final Vector JavaDoc ros = new Vector JavaDoc();
51         ros.add(new ValidOption("ro", "fee", 1, "v"));
52         final Vector JavaDoc dos = new Vector JavaDoc();
53         final ValidCommand vc = new ValidCommand("name", "*", vos, ros, dos, "useage");
54         cv.validateCommandAndOptions(vc, new HashMap JavaDoc(), new Vector JavaDoc());
55     }
56         
57     public void testValidCommand1() throws Exception JavaDoc {
58         final Vector JavaDoc vos = new Vector JavaDoc();
59         vos.add(new ValidOption("vo", "String", 1, ""));
60         final Vector JavaDoc ros = new Vector JavaDoc();
61         ros.add(new ValidOption("ro", "Integer", 0, ""));
62         final Vector JavaDoc dos = new Vector JavaDoc();
63         final ValidCommand vc = new ValidCommand("name", "3", vos, ros, dos, "useage");
64         cv.validateCommandAndOptions(vc, new HashMap JavaDoc(),
65                                      new Vector JavaDoc(Arrays.asList(new String JavaDoc[] {"1", "2", "3"})));
66     }
67     
68     public void testValidCommandWithSimpleConstructors() throws Exception JavaDoc {
69         final ValidCommand vc = new ValidCommand();
70         //cv.validateCommandAndOptions(vc, new HashMap(), new Vector());
71
}
72
73     public CommandValidatorTest(String JavaDoc name){
74         super(name);
75     }
76     CommandValidator cv;
77     
78     protected void setUp() {
79          cv = new CommandValidator();
80     }
81
82     protected void tearDown() {
83     }
84
85     private void nyi(){
86         fail("Not Yet Implemented");
87     }
88
89     public static void main(String JavaDoc args[]){
90         if (args.length == 0){
91             junit.textui.TestRunner.run(CommandValidatorTest.class);
92         } else {
93             junit.textui.TestRunner.run(makeSuite(args));
94         }
95     }
96     private static TestSuite makeSuite(String JavaDoc args[]){
97         final TestSuite ts = new TestSuite();
98         for (int i = 0; i < args.length; i++){
99             ts.addTest(new CommandValidatorTest(args[i]));
100         }
101         return ts;
102     }
103 }
104
Popular Tags