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.actions;
043:
044: import org.netbeans.jellytools.Bundle;
045: import org.netbeans.jellytools.NewFileNameLocationStepOperator;
046: import org.netbeans.jellytools.NewFileWizardOperator;
047: import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
048: import org.netbeans.jellytools.NewProjectWizardOperator;
049: import org.netbeans.jellytools.ProjectsTabOperator;
050: import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
051: import org.netbeans.jellytools.nodes.Node;
052:
053: import org.netbeans.jemmy.EventTool;
054: import org.netbeans.jemmy.operators.ComponentOperator;
055:
056: import org.netbeans.junit.ide.ProjectSupport;
057:
058: /**
059: *
060: * @author mkhramov@netbeans.org
061: */
062: public class SchemaViewSwitchTest extends
063: org.netbeans.performance.test.utilities.PerformanceTestCase {
064:
065: private XMLSchemaComponentOperator schema;
066: private static String category = Bundle.getStringTrimmed(
067: "org.netbeans.modules.bpel.project.wizards.Bundle",
068: "Templates/Project/SOA"); // "Service Oriented Architecture";
069: private static String project = Bundle.getStringTrimmed(
070: "org.netbeans.modules.bpel.project.wizards.Bundle",
071: "Templates/Project/SOA/emptyBpelpro.xml"); // "BPEL Module"
072: private static String testProjectName = "TestProject2";
073: private static String testSchemaName = "XMLTestSchema2";
074:
075: /** Creates a new instance of SchemaViewSwitch */
076: public SchemaViewSwitchTest(String testName) {
077: super (testName);
078: //TODO: Adjust expectedTime value
079: expectedTime = WINDOW_OPEN;
080: WAIT_AFTER_OPEN = 2000;
081: }
082:
083: public SchemaViewSwitchTest(String testName,
084: String performanceDataName) {
085: super (testName, performanceDataName);
086: //TODO: Adjust expectedTime value
087: expectedTime = WINDOW_OPEN;
088: WAIT_AFTER_OPEN = 2000;
089: }
090:
091: public void initialize() {
092: log(":: initialize");
093: String ParentPath = System.getProperty("xtest.tmpdir")
094: + java.io.File.separator + "createdProjects";
095:
096: createProject(ParentPath, testProjectName);
097: addSchemaDoc(testProjectName, testSchemaName);
098: }
099:
100: private void createProject(String path, String projectName) {
101: NewProjectWizardOperator wizard = NewProjectWizardOperator
102: .invoke();
103: log(":: selecting category: " + category);
104: wizard.selectCategory(category);
105:
106: log(":: selecting project: " + project);
107: wizard.selectProject(project);
108:
109: wizard.next();
110:
111: NewProjectNameLocationStepOperator wizard_location = new NewProjectNameLocationStepOperator();
112:
113: wizard_location.txtProjectName().setText("");
114: new EventTool().waitNoEvent(1000);
115: wizard_location.txtProjectName().typeText(projectName);
116: new EventTool().waitNoEvent(1000);
117:
118: wizard_location.txtProjectLocation().setText("");
119: new EventTool().waitNoEvent(1000);
120: wizard_location.txtProjectLocation().typeText(path);
121:
122: new EventTool().waitNoEvent(1000);
123:
124: wizard_location.finish();
125: }
126:
127: private void addSchemaDoc(String projectName, String SchemaName) {
128: Node pfn = new Node(new ProjectsTabOperator()
129: .getProjectRootNode(projectName),
130: org.netbeans.jellytools.Bundle.getString(
131: "org.netbeans.modules.bpel.project.ui.Bundle",
132: "LBL_Node_Sources"));
133: pfn.select();
134: NewFileWizardOperator wizard = NewFileWizardOperator.invoke();
135: wizard.selectCategory("XML");
136: wizard.selectFileType("XML Schema");
137:
138: wizard.next();
139:
140: NewFileNameLocationStepOperator location = new NewFileNameLocationStepOperator();
141: location.setObjectName(SchemaName);
142: location.finish();
143: }
144:
145: public void prepare() {
146: log(":: prepare");
147: String schemaDocPath = org.netbeans.jellytools.Bundle
148: .getString(
149: "org.netbeans.modules.bpel.project.ui.Bundle",
150: "LBL_Node_Sources")
151: + "|" + testSchemaName + ".xsd";
152: Node schemaNode = new Node(new ProjectsTabOperator()
153: .getProjectRootNode(testProjectName), schemaDocPath);
154: schemaNode.performPopupActionNoBlock("Open");
155: schema = XMLSchemaComponentOperator
156: .findXMLSchemaComponentOperator(testSchemaName + ".xsd");
157: }
158:
159: public ComponentOperator open() {
160: schema.getDesignButton().pushNoBlock();
161: return schema;
162: }
163:
164: public void close() {
165: schema.getSchemaButton().pushNoBlock();
166: }
167:
168: protected void shutdown() {
169: log("::shutdown");
170:
171: new CloseAllDocumentsAction().performAPI();
172: ProjectSupport.closeProject(testProjectName);
173: }
174: }
|