KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > cli > commands > DeployCommandTest


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 package com.sun.enterprise.cli.commands;
24
25 /**
26    Note that this test requires resources for testing. These resources
27    are construct4ed from the two files P1 & P2 located in the current
28    directory. If these file names are changed then the corresponding
29    names in this submodules build.xml file should be changed also
30 */

31 import com.sun.enterprise.cli.framework.*;
32 //import java.util.ArrayList;
33
//import java.util.Arrays;
34
//import java.util.HashMap;
35
//import java.util.List;
36
//import java.util.Properties;
37
import junit.framework.*;
38 import junit.textui.TestRunner;
39 import java.util.Vector JavaDoc;
40 /**
41  *
42  * @author prashanth.abbagani@sun.com
43  * @version $Revision: 1.2 $
44  */

45
46 /**
47    Execute these tests using gmake (and Ant) by:
48    cd <commands>
49    gmake ANT_TARGETS=CommandTest.java
50 */

51
52 public class DeployCommandTest extends TestCase {
53
54     public void testValidateOptionsInvalidOptions() throws Exception JavaDoc{
55         try{
56             testCommand.setOption("createtables", "true");
57             testCommand.setOption("dropandcreatetables", "true");
58             testCommand.validateOptions();
59         }
60         catch (CommandValidationException cve){
61             assertEquals(cve.getMessage(),
62             "CLI169 Options createtables and dropandcreatetables are mutually exclusive. You must specify one or the other but not both.");
63         }
64     }
65
66     public void testValidateOptionsValidOptions() throws Exception JavaDoc{
67             Vector JavaDoc operands = new Vector JavaDoc();
68             operands.add("earFile");
69             testCommand.setOperands(operands);
70             testCommand.validateOptions();
71     }
72
73     public DeployCommandTest(String JavaDoc name){
74         super(name);
75     }
76
77     DeployCommand testCommand = null;
78
79     protected void setUp() throws Exception JavaDoc{
80         //Properties systemProperties = new java.util.Propertis();
81
//systemProperties.put("com.sun.aas.configRoot",)
82
//String configProperty = SystemPropertyConstants.CONFIG_ROOT_PROPERTY;
83
//System.out.println(configProperty + " = " + System.getProperty(configProperty));
84
final CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance();
85         ValidCommand validCommand = cliDescriptorsReader.getCommand(null);
86         LocalStringsManagerFactory.setCommandLocalStringsManagerProperties(
87             CLIDescriptorsReader.getInstance().getProperties());
88         testCommand = new DeployCommand();
89         testCommand.setName("sampleCommand");
90     }
91   
92   
93
94     protected void tearDown() {
95     }
96
97     private void nyi(){
98         fail("Not Yet Implemented");
99     }
100
101     public static Test suite(){
102         TestSuite suite = new TestSuite(BackupCommandsTest.class);
103         return suite;
104     }
105
106     public static void main(String JavaDoc args[]) throws Exception JavaDoc {
107         final TestRunner runner= new TestRunner();
108         final TestResult result = runner.doRun(BackupCommandsTest.suite(), false);
109         System.exit(result.errorCount() + result.failureCount());
110     }
111 }
112
113
Popular Tags