KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > archive > xtests > AddRemoveSjsasInstance4Test


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.archive.xtests;
20
21 import java.io.File JavaDoc;
22 import org.netbeans.junit.NbTestCase;
23 import org.netbeans.junit.NbTestSuite;
24 import org.netbeans.modules.j2ee.archive.wizard.*;
25 import org.netbeans.modules.j2ee.deployment.impl.ServerInstance;
26 import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
27 import org.netbeans.modules.j2ee.sun.ide.j2ee.ui.AddDomainWizardIterator;
28 import org.openide.WizardDescriptor;
29 import org.openide.WizardDescriptor.Panel;
30
31 /**
32  *
33  * @author Michal Mocnak
34  */

35 public class AddRemoveSjsasInstance4Test extends NbTestCase {
36     
37     private final int SLEEP = 10000;
38     
39     public AddRemoveSjsasInstance4Test(String JavaDoc testName) {
40         super(testName);
41     }
42     
43     public void addSjsasInstance() {
44         try {
45             AddDomainWizardIterator inst = new AddDomainWizardIterator();
46             WizardDescriptor wizard = new WizardDescriptor(new Panel[] {});
47             wizard.putProperty(TestUtil.PLATFORM_LOCATION, new File JavaDoc(TestUtil._PLATFORM_LOCATION));
48             wizard.putProperty(TestUtil.INSTALL_LOCATION, TestUtil._INSTALL_LOCATION);
49             wizard.putProperty(TestUtil.PROP_DISPLAY_NAME, TestUtil._DISPLAY_NAME);
50             wizard.putProperty(TestUtil.HOST, TestUtil._HOST);
51             wizard.putProperty(TestUtil.PORT, TestUtil._PORT);
52             wizard.putProperty(TestUtil.DOMAIN, TestUtil._DOMAIN);
53             wizard.putProperty(TestUtil.USER_NAME, TestUtil._USER_NAME);
54             wizard.putProperty(TestUtil.PASSWORD, TestUtil._PASSWORD);
55             
56             inst.initialize(wizard);
57             inst.instantiate();
58             
59             ServerRegistry.getInstance().checkInstanceExists(TestUtil._URL);
60             
61             TestUtil.sleep(SLEEP);
62         } catch(Exception JavaDoc e) {
63             fail(e.getMessage());
64         }
65     }
66     
67     public void removeSjsasInstance() {
68         try {
69             TestUtil.sleep(SLEEP);
70             
71             ServerInstance inst = ServerRegistry.getInstance().getServerInstance(TestUtil._URL);
72             inst.remove();
73             
74             try {
75                 ServerRegistry.getInstance().checkInstanceExists(TestUtil._URL);
76             } catch(Exception JavaDoc e) {
77                 return;
78             }
79             
80             fail("Sjsas instance still exists !");
81         } catch(Exception JavaDoc e) {
82             fail(e.getMessage());
83         }
84     }
85     
86     public static NbTestSuite suite() {
87         NbTestSuite suite = new NbTestSuite("AddRemoveSjsasInstanceTest");
88         suite.addTest(new AddRemoveSjsasInstance4Test("addSjsasInstance"));
89         suite.addTest(new AddRemoveSjsasInstance4Test("removeSjsasInstance"));
90         return suite;
91     }
92 }
Popular Tags