uml.kit/test/qa-functional/src/org/netbeans/test/uml/validation/UMLValidationTests.java
uml/test moved to uml/kit/test (see http://wiki.netbeans.org/HgMigration) - undoing unwanted changes during the move.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common
8 * Development and Distribution License("CDDL") (collectively, the
9 * "License"). You may not use this file except in compliance with the
10 * License. You can obtain a copy of the License at
11 * http://www.netbeans.org/cddl-gplv2.html
12 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13 * specific language governing permissions and limitations under the
14 * License. When distributing the software, include this License Header
15 * Notice in each file and include the License file at
16 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17 * particular file as subject to the "Classpath" exception as provided
18 * by Sun in the GPL Version 2 section of the License file that
19 * accompanied this code. If applicable, add the following below the
20 * License Header, with the fields enclosed by brackets [] replaced by
21 * your own identifying information:
22 * "Portions Copyrighted [year] [name of copyright owner]"
26 * The Original Software is NetBeans. The Initial Developer of the Original
27 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
28 * Microsystems, Inc. All Rights Reserved.
30 * If you wish your version of this file to be governed by only the CDDL
31 * or only the GPL Version 2, indicate your decision by adding
32 * "[Contributor] elects to include this software in this distribution
33 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34 * single choice of license, a recipient has the option to distribute
35 * your version of this file under either the CDDL, the GPL Version 2 or
36 * to extend the choice of license to its licensees as provided above.
37 * However, if you add GPL Version 2 code and therefore, elected the GPL
38 * Version 2 license, then the option applies only if the new code is
39 * made subject to such option by the copyright holder.
45 * Created on Jul 31, 2007, 9:49:19 PM
48 package org.netbeans.test.uml.validation;
50 import java.util.LinkedList;
51 import org.netbeans.jellytools.TopComponentOperator;
52 import org.netbeans.jemmy.operators.JMenuBarOperator;
53 import org.netbeans.jemmy.operators.JButtonOperator;
54 import org.netbeans.jemmy.operators.JDialogOperator;
55 import org.netbeans.jellytools.MainWindowOperator;
56 import org.netbeans.junit.NbTestSuite;
57 import org.netbeans.test.umllib.DiagramElementOperator;
58 import org.netbeans.test.umllib.DiagramOperator;
59 import org.netbeans.test.umllib.DiagramTypes;
60 import org.netbeans.test.umllib.ElementTypes;
61 import org.netbeans.test.umllib.project.JavaProject;
62 import org.netbeans.test.umllib.project.ProjectType;
63 import org.netbeans.test.umllib.project.UMLProject;
64 import org.netbeans.test.umllib.NewDiagramWizardOperator;
65 import org.netbeans.test.umllib.testcases.UMLTestCase;
66 import org.netbeans.test.umllib.project.Project;
67 import org.netbeans.test.umllib.util.Utils;
68 import org.netbeans.test.umllib.values.Arg;
69 import org.netbeans.jellytools.nodes.Node;
77 public class UMLValidationTests extends UMLTestCase {
79 public static final String PROJECT_NAME_JAVA = "BankApp";
80 public static final String PROJECT_NAME_UML1 = "UMLPrj1";
81 public static final String PROJECT_NAME_UML2 = "UMLPrj2";
82 public static final String PROJECT_NAME_UML3 = "UMLPrj3";
84 public static final String DIAGRAM_CLASS_NAME1 = "JavaPlatformClassDiagram";
85 public static final String DIAGRAM_CLASS_NAME2 = "PlatformIndependentClassDiagram";
86 public static final String DIAGRAM_CLASS_NAME3 = "REClassDiagram";
89 /** Creates a new instance of DevelopingApplications */
90 public UMLValidationTests(String name) {
95 public static NbTestSuite suite() {
96 NbTestSuite suite = new NbTestSuite();
97 suite.addTest(new UMLValidationTests("testCreateJavaPlatformProject"));
98 suite.addTest(new UMLValidationTests("testCreatePlatformIndependentProject"));
99 suite.addTest(new UMLValidationTests("testCreateREJavaPlatformProject"));
100 suite.addTest(new UMLValidationTests("testUMLMainMenu"));
105 protected void setUp() {
106 System.setOut(getLog());
107 Utils.waitScanningClassPath();
112 * Verify UML related main menus
114 public void testUMLMainMenu() {
115 // Select main menu Edit->Find in UML model
116 new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenu("Edit|Find in UML Model");
117 new JButtonOperator(new JDialogOperator("Find"), "Close").pushNoBlock();
119 // Select main menu Edit->Replace in UML model
120 new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenu("Edit|Replace in UML Model");
121 new JButtonOperator(new JDialogOperator("Replace"), "Close").pushNoBlock();
123 // Select main menu Windows->Other->UML Documentation
124 new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenu("Window|Other|UML Documentation");
127 new TopComponentOperator(TopComponentOperator.findTopComponent("UML Documentation", 0));
128 } catch (Exception ex) {
131 // Select main menu Windows->Other->UML Documentation UML Design Center
132 new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenu("Window|Other|UML Design Center");
135 new TopComponentOperator(TopComponentOperator.findTopComponent("UML Design Center", 0));
136 } catch (Exception ex) {
141 * Create Java-Platform Model Project
143 public void testCreateJavaPlatformProject() {
144 UMLProject umlProject = UMLProject.createProject(PROJECT_NAME_UML1, ProjectType.UML_JAVA_PLATFORM_MODEL);
145 Node umlModelNode = new Node(umlProject.getProjectNode(), "Model");
147 DiagramOperator classDiagram = DiagramOperator.createDiagram(DIAGRAM_CLASS_NAME1, DiagramTypes.CLASS, umlModelNode);
148 new TopComponentOperator(DIAGRAM_CLASS_NAME1);
151 } catch (Exception e) {
154 new TopComponentOperator(DIAGRAM_CLASS_NAME1);
158 * Create Platform Independent Model Project
160 public void testCreatePlatformIndependentProject() {
161 UMLProject umlProject = UMLProject.createProject(PROJECT_NAME_UML2, ProjectType.UML_PLATFORM_INDEPENDET_MODEL);
162 Node umlModelNode = new Node(umlProject.getProjectNode(), "Model");
164 DiagramOperator classDiagram = DiagramOperator.createDiagram(DIAGRAM_CLASS_NAME2, DiagramTypes.CLASS, umlModelNode);
165 new TopComponentOperator(DIAGRAM_CLASS_NAME2);
168 } catch (Exception e) {
171 new TopComponentOperator(DIAGRAM_CLASS_NAME2);
175 * Create Reversed Engineering project
177 public void testCreateREJavaPlatformProject() {
178 Project.openProject(XTEST_PROJECT_DIR + "/Projects-Tutorials/REJavaApplication/BankApp");
180 JavaProject javaProject = new JavaProject(PROJECT_NAME_JAVA, ProjectType.JAVA_APPLICATION);
182 UMLProject umlProject = UMLProject.createProject(PROJECT_NAME_UML3, ProjectType.UML_JAVA_REVERSE_ENGINEERING, javaProject);
186 } catch (Exception e) {
188 Node root = umlProject.getProjectNode();
190 Node modelNode = new Node(umlProject.getProjectNode(), "Model");
191 Node banckpackNode = new Node(modelNode, "bankpack");
194 //DiagramOperator bankClassDiagram = DiagramOperator.createDiagram("BankClassDiagram", DiagramTypes.CLASS, banckpackNode);
195 DiagramOperator bankClassDiagram = createDiagramFromSelectedElements(DIAGRAM_CLASS_NAME3, DiagramTypes.CLASS, banckpackNode);
198 } catch (Exception e) {
201 new TopComponentOperator(DIAGRAM_CLASS_NAME3);
204 protected static DiagramOperator createDiagramFromSelectedElements(String diagramName, DiagramTypes diagramType, Node projectNode) {
206 projectNode.callPopup().pushMenuNoBlock("Create Diagram From Selected Elements...");
207 NewDiagramWizardOperator dw = new NewDiagramWizardOperator();
208 dw.setDiagramType(diagramType.toString());
209 dw.setDiagramName(diagramName);
212 JDialogOperator createFromSelected = new JDialogOperator("Create Diagram From Selected");
213 new JButtonOperator(createFromSelected, "Yes").push();
215 return new DiagramOperator(diagramName);