KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > action > Deploy


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.action;
21
22 import gui.Utils;
23 import java.io.InputStream JavaDoc;
24 import java.net.URL JavaDoc;
25 import org.netbeans.jellytools.Bundle;
26 import org.netbeans.jellytools.MainWindowOperator;
27 import org.netbeans.jellytools.ProjectsTabOperator;
28 import org.netbeans.jellytools.RuntimeTabOperator;
29 import org.netbeans.jellytools.nodes.Node;
30 import org.netbeans.jellytools.nodes.ProjectRootNode;
31
32 import org.netbeans.jemmy.operators.ComponentOperator;
33 import org.netbeans.jemmy.operators.JTreeOperator;
34 import org.netbeans.jemmy.operators.Operator;
35
36
37 /**
38  * Test create projects
39  *
40  * @author lmartinek@netbeans.org
41  */

42 public class Deploy extends org.netbeans.performance.test.utilities.PerformanceTestCase {
43     
44     private Node node;
45     
46     /**
47      * Creates a new instance of CreateJ2EEProject
48      * @param testName the name of the test
49      */

50     public Deploy(String JavaDoc testName) {
51         super(testName);
52         expectedTime = 60000;
53         WAIT_AFTER_OPEN=240000;
54     }
55     
56     /**
57      * Creates a new instance of CreateJ2EEProject
58      * @param testName the name of the test
59      * @param performanceDataName measured values will be saved under this name
60      */

61     public Deploy(String JavaDoc testName, String JavaDoc performanceDataName) {
62         super(testName, performanceDataName);
63         expectedTime = 60000;
64         WAIT_AFTER_OPEN=240000;
65     }
66     
67     
68     public void initialize(){
69         Utils.startStopServer(true);
70         
71         JTreeOperator tree = ProjectsTabOperator.invoke().tree();
72         tree.setComparator(new Operator.DefaultStringComparator(true, true));
73         node = new ProjectRootNode(tree, "DeployTest");
74         node.performPopupAction("Build Project");
75         MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 120000);
76         MainWindowOperator.getDefault().waitStatusText("Finished building build.xml (dist)");
77     }
78     
79     public void shutdown() {
80         RuntimeTabOperator runtimeTab = RuntimeTabOperator.invoke();
81         Node node = new Node(runtimeTab.getRootNode(), Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.Bundle", "SERVER_REGISTRY_NODE")
82                 +"|Application Server|"
83                 + Bundle.getStringTrimmed("org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.nodes.Bundle", "LBL_Applications") + "|"
84                 + Bundle.getStringTrimmed("org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.nodes.Bundle", "LBL_AppModules") + "|"
85                 + "DeployTest");
86         node.performPopupAction(Bundle.getStringTrimmed("org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.nodes.Bundle", "LBL_Undeploy"));
87         node.waitNotPresent();
88         
89         Utils.startStopServer(false);
90     }
91     
92     public void prepare(){
93         
94     }
95     
96     public ComponentOperator open(){
97         node.performPopupAction("Deploy Project");
98         return null;
99     }
100     
101     public void close() {
102         MainWindowOperator.getDefault().waitStatusText("Finished building build.xml (run-deploy)");
103         try {
104             URL JavaDoc url = new URL JavaDoc("http://localhost:8080/DeployTest-WebModule/TestServlet");
105             InputStream JavaDoc stream = url.openStream();
106             stream.close();
107         } catch (Exception JavaDoc e) {
108             throw new RuntimeException JavaDoc("Deployed application unavailable.",e);
109         }
110     }
111     
112     
113 }
114
Popular Tags