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-2007 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 footprint.VWPFootprintUtilities;
045: import gui.window.WebFormDesignerOperator;
046: import org.netbeans.jellytools.NbDialogOperator;
047: import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
048: import org.netbeans.jellytools.NewProjectWizardOperator;
049: import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
050: import org.netbeans.jemmy.JemmyProperties;
051: import org.netbeans.jemmy.TimeoutExpiredException;
052:
053: import org.netbeans.jemmy.operators.ComponentOperator;
054: import org.netbeans.jemmy.operators.JDialogOperator;
055: import org.netbeans.jemmy.operators.JTableOperator;
056:
057: /**
058: * Test create Web Pack projects
059: *
060: * @author mkhramov@netbeans.org, mmirilovic@netbeans.org
061: */
062: public class CreateWebPackProject extends
063: org.netbeans.performance.test.utilities.PerformanceTestCase {
064:
065: private NewProjectNameLocationStepOperator wizard_location;
066:
067: private String category, project, project_name, project_type;
068:
069: /**
070: * Creates a new instance of CreateWebPackProject
071: * @param testName the name of the test
072: */
073: public CreateWebPackProject(String testName) {
074: super (testName);
075: expectedTime = 10000;
076: WAIT_AFTER_OPEN = 20000;
077: }
078:
079: /**
080: * Creates a new instance of CreateWebPackProject
081: * @param testName the name of the test
082: * @param performanceDataName measured values will be saved under this name
083: */
084: public CreateWebPackProject(String testName,
085: String performanceDataName) {
086: super (testName, performanceDataName);
087: expectedTime = 10000;
088: WAIT_AFTER_OPEN = 20000;
089: }
090:
091: public void testCreateWebPackProject() {
092: category = org.netbeans.jellytools.Bundle.getStringTrimmed(
093: "org.netbeans.modules.web.project.ui.wizards.Bundle",
094: "Templates/Project/Web"); // Web
095: project = "Web Application";
096: project_type = "JSFWebProject";
097:
098: doMeasurement();
099: }
100:
101: public void initialize() {
102: log("::initialize::");
103: long oldTimeout = JemmyProperties.getCurrentTimeouts()
104: .getTimeout("ComponentOperator.WaitStateTimeout");
105: JemmyProperties.getCurrentTimeouts().setTimeout(
106: "ComponentOperator.WaitStateTimeout", 120000);
107:
108: waitProjectCreatingDialogClosed();
109:
110: JemmyProperties.getCurrentTimeouts().setTimeout(
111: "ComponentOperator.WaitStateTimeout", oldTimeout);
112:
113: }
114:
115: public void prepare() {
116: log("::prepare");
117: createProject();
118: }
119:
120: private void createProject() {
121: NewProjectWizardOperator wizard = NewProjectWizardOperator
122: .invoke();
123: wizard.selectCategory(category);
124: wizard.selectProject(project);
125: wizard.next();
126: wizard_location = new NewProjectNameLocationStepOperator();
127:
128: String directory = System.getProperty("xtest.tmpdir");
129: log("================= Destination directory={" + directory
130: + "}");
131: wizard_location.txtProjectLocation().setText("");
132: waitNoEvent(1000);
133: wizard_location.txtProjectLocation().setText(directory);
134:
135: project_name = project_type + "_" + System.currentTimeMillis();
136: log("================= Project name=" + project_name + "}");
137: wizard_location.txtProjectName().setText("");
138: waitNoEvent(1000);
139: wizard_location.txtProjectName().typeText(project_name);
140:
141: wizard_location.next();
142: wizard_location.next();
143:
144: JTableOperator frameworkselector = new JTableOperator(wizard);
145: frameworkselector.selectCell(0, 0);
146:
147: }
148:
149: public ComponentOperator open() {
150: log("::open");
151: wizard_location.finish();
152:
153: long oldTimeout = JemmyProperties.getCurrentTimeouts()
154: .getTimeout("ComponentOperator.WaitStateTimeout");
155: JemmyProperties.getCurrentTimeouts().setTimeout(
156: "ComponentOperator.WaitStateTimeout", 120000);
157: wizard_location.waitClosed();
158: waitProjectCreatingDialogClosed();
159:
160: JemmyProperties.getCurrentTimeouts().setTimeout(
161: "ComponentOperator.WaitStateTimeout", oldTimeout);
162:
163: WebFormDesignerOperator.findWebFormDesignerOperator("Page1");
164:
165: return null;
166: }
167:
168: private void waitProjectCreatingDialogClosed() {
169: String dlgName = org.netbeans.jellytools.Bundle.getString(
170: "org.netbeans.modules.visualweb.project.jsf.ui.Bundle",
171: "CAP_Opening_Projects");
172: try {
173: NbDialogOperator dlg = new NbDialogOperator(dlgName);
174: dlg.waitClosed();
175: } catch (TimeoutExpiredException tex) {
176: //
177: }
178:
179: }
180:
181: public void close() {
182: log("::close");
183:
184: try {
185: new CloseAllDocumentsAction().performAPI(); //avoid issue 68671 - editors are not closed after closing project by ProjectSupport
186: } catch (Exception ex) {
187: log("Exception catched on CloseAllDocuments action: "
188: + ex.getMessage());
189: }
190: try {
191: VWPFootprintUtilities.deleteProject(project_name);
192: } catch (Exception ee) {
193: log("Exception during project deletion: " + ee.getMessage());
194: }
195: }
196:
197: public static void main(java.lang.String[] args) {
198: junit.textui.TestRunner.run(new CreateWebPackProject(
199: "testCreateWebPackProject"));
200: }
201:
202: }
|