KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > setup > EJBSetupTest


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
20 package gui.setup;
21
22 import org.netbeans.jellytools.*;
23 import org.netbeans.jellytools.nodes.Node;
24 import org.netbeans.jemmy.operators.*;
25 import org.netbeans.junit.ide.ProjectSupport;
26 import org.netbeans.jellytools.Bundle;
27 import org.netbeans.jellytools.NbDialogOperator;
28 import org.netbeans.jellytools.TopComponentOperator;
29 import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
30
31
32
33 public class EJBSetupTest extends org.netbeans.junit.NbTestCase {
34     
35     public EJBSetupTest(java.lang.String JavaDoc testName) {
36         super(testName);
37     }
38
39     public void testOpenEJBProject() {
40         ProjectSupport.openProject(System.getProperty("xtest.tmpdir")+"/perf/TestApplication");
41         ProjectSupport.waitScanFinished();
42         ProjectSupport.openProject(System.getProperty("xtest.tmpdir")+"/perf/TestApplication/TestApplication-ejb");
43         ProjectSupport.waitScanFinished();
44         ProjectSupport.openProject(System.getProperty("xtest.tmpdir")+"/perf/TestApplication/TestApplication-war");
45         ProjectSupport.waitScanFinished();
46         ProjectSupport.openProject(System.getProperty("xtest.tmpdir")+"/perf/DeployTest");
47         ProjectSupport.waitScanFinished();
48         ProjectSupport.openProject(System.getProperty("xtest.tmpdir")+"/perf/DeployTest/DeployTest-ejb");
49         ProjectSupport.waitScanFinished();
50         ProjectSupport.openProject(System.getProperty("xtest.tmpdir")+"/perf/DeployTest/DeployTest-war");
51         ProjectSupport.waitScanFinished();
52         //waitForScan();
53
}
54     
55     public void testAddAppServer() {
56         String JavaDoc path = System.getProperty("j2ee.appserver.path");
57         if (path == null) {
58             if (System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0) {
59                 path = "E:\\space\\AppServer";
60                 //path = "E:\\Sun\\AppServer-8.1_01_b04";
61
} else {
62                 path = "/space/appserver";
63             }
64         }
65         String JavaDoc username = System.getProperty("j2ee.appserver.username","admin");
66         String JavaDoc password = System.getProperty("j2ee.appserver.password","adminadmin");
67                     
68         Node node = new Node(new RuntimeTabOperator().getRootNode(),"Servers");
69         node.performPopupActionNoBlock("Add Server...");
70         NbDialogOperator dialog = new NbDialogOperator("Add Server");
71         new JComboBoxOperator(dialog).selectItem("Application Server");
72         new JButtonOperator(dialog,"Next").push();
73         
74         //"Enter the Application Server location" or "Define Application Server Instance Properties"
75
if (new JLabelOperator(dialog,1).getText().equalsIgnoreCase("Enter the Application Server location")) {
76             new JTextFieldOperator(dialog).setText("");
77             new JTextFieldOperator(dialog).typeText(path);
78             new JButtonOperator(dialog,"Next").push();
79         }
80         new JTextFieldOperator(dialog,0).setText("");
81         new JTextFieldOperator(dialog,1).setText("");
82         new JTextFieldOperator(dialog,0).typeText(username);
83         new JTextFieldOperator(dialog,1).typeText(password);
84         new JButtonOperator(dialog,"Finish").push();
85         new ProjectsTabOperator();
86     }
87     
88         
89     public void closeAllDocuments(){
90         new CloseAllDocumentsAction().perform();
91     }
92     
93     public void closeNavigator() {
94         new TopComponentOperator("Navigator").close();
95     }
96     
97     public void testCloseMemoryToolbar(){
98         String JavaDoc MENU =
99             org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.core.Bundle","Menu/View") + "|" +
100             org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.core.windows.actions.Bundle","CTL_ToolbarsListAction") + "|" +
101             org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.core.Bundle","Toolbars/Memory");
102                                                                                                       
103         MainWindowOperator mainWindow = MainWindowOperator.getDefault();
104         JMenuBarOperator menuBar = new JMenuBarOperator(mainWindow.getJMenuBar());
105         JMenuItemOperator menuItem = menuBar.showMenuItem(MENU,"|");
106                                                                                                       
107         if(menuItem.isSelected())
108             menuItem.push();
109         else {
110             menuItem.pushKey(java.awt.event.KeyEvent.VK_ESCAPE);
111             mainWindow.pushKey(java.awt.event.KeyEvent.VK_ESCAPE);
112         }
113                                                                                                       
114     }
115
116     
117     private void waitForScan() {
118         // "Scanning Project Classpaths"
119
String JavaDoc titleScanning = Bundle.getString("org.netbeans.modules.javacore.Bundle", "TXT_ApplyingPathsTitle");
120         NbDialogOperator scanningDialogOper = new NbDialogOperator(titleScanning);
121         // scanning can last for a long time => wait max. 5 minutes
122
scanningDialogOper.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 300000);
123         scanningDialogOper.waitClosed();
124     }
125
126 }
127
Popular Tags