001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package gui.action;
043:
044: import gui.Utils;
045: import java.io.InputStream;
046: import java.net.URL;
047: import org.netbeans.jellytools.Bundle;
048: import org.netbeans.jellytools.MainWindowOperator;
049: import org.netbeans.jellytools.ProjectsTabOperator;
050: import org.netbeans.jellytools.RuntimeTabOperator;
051: import org.netbeans.jellytools.nodes.Node;
052: import org.netbeans.jellytools.nodes.ProjectRootNode;
053:
054: import org.netbeans.jemmy.operators.ComponentOperator;
055: import org.netbeans.jemmy.operators.JTreeOperator;
056: import org.netbeans.jemmy.operators.Operator;
057:
058: /**
059: * Test create projects
060: *
061: * @author lmartinek@netbeans.org
062: */
063: public class Deploy extends
064: org.netbeans.performance.test.utilities.PerformanceTestCase {
065:
066: private Node node;
067:
068: /**
069: * Creates a new instance of CreateJ2EEProject
070: * @param testName the name of the test
071: */
072: public Deploy(String testName) {
073: super (testName);
074: expectedTime = 60000;
075: WAIT_AFTER_OPEN = 240000;
076: }
077:
078: /**
079: * Creates a new instance of CreateJ2EEProject
080: * @param testName the name of the test
081: * @param performanceDataName measured values will be saved under this name
082: */
083: public Deploy(String testName, String performanceDataName) {
084: super (testName, performanceDataName);
085: expectedTime = 60000;
086: WAIT_AFTER_OPEN = 240000;
087: }
088:
089: public void initialize() {
090: Utils.startStopServer(true);
091:
092: JTreeOperator tree = ProjectsTabOperator.invoke().tree();
093: tree.setComparator(new Operator.DefaultStringComparator(true,
094: true));
095: node = new ProjectRootNode(tree, "DeployTest");
096: node.performPopupAction("Build");
097: MainWindowOperator.getDefault().getTimeouts().setTimeout(
098: "Waiter.WaitingTime", 120000);
099: MainWindowOperator.getDefault().waitStatusText(
100: "Finished building build.xml (dist)");
101: }
102:
103: public void shutdown() {
104: RuntimeTabOperator runtimeTab = RuntimeTabOperator.invoke();
105: Node node = new Node(
106: runtimeTab.getRootNode(),
107: Bundle
108: .getStringTrimmed(
109: "org.netbeans.modules.j2ee.deployment.impl.ui.Bundle",
110: "SERVER_REGISTRY_NODE")
111: + "|Glassfish V2|"
112: + Bundle
113: .getStringTrimmed(
114: "org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.nodes.Bundle",
115: "LBL_Applications")
116: + "|"
117: + Bundle
118: .getStringTrimmed(
119: "org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.nodes.Bundle",
120: "LBL_AppModules")
121: + "|"
122: + "DeployTest");
123: node
124: .performPopupAction(Bundle
125: .getStringTrimmed(
126: "org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.nodes.Bundle",
127: "LBL_Undeploy"));
128: node.waitNotPresent();
129:
130: Utils.startStopServer(false);
131: }
132:
133: public void prepare() {
134:
135: }
136:
137: public ComponentOperator open() {
138: node.performPopupAction("Undeploy and Deploy");
139: return null;
140: }
141:
142: public void close() {
143: MainWindowOperator.getDefault().waitStatusText(
144: "Finished building build.xml (run-deploy).");
145: try {
146: URL url = new URL(
147: "http://localhost:8080/DeployTest-WebModule/TestServlet");
148: InputStream stream = url.openStream();
149: stream.close();
150: } catch (Exception e) {
151: throw new RuntimeException(
152: "Deployed application unavailable.", e);
153: }
154: }
155:
156: }
|