uml.kit/test/qa-functional/src/org/netbeans/test/uml/validation/UMLValidationTests.java
author jskrivanek@netbeans.org
Fri Jan 25 17:53:44 2008 +0000 (5 months ago)
changeset 64821 1f1d3334622b
parent 647516e64615b1cdc
permissions -rw-r--r--
uml/test moved to uml/kit/test (see http://wiki.netbeans.org/HgMigration) - undoing unwanted changes during the move.
        1 /*
        2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
        3  *
        4  * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
        5  *
        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]"
       23  *
       24  * Contributor(s):
       25  *
       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.
       29  *
       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.
       40  */
       41 
       42 
       43 /*
       44  * UMLValidation.java
       45  * Created on Jul 31, 2007, 9:49:19 PM
       46  */
       47 
       48 package org.netbeans.test.uml.validation;
       49 
       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;
       70  
       71 /**
       72  *
       73  * @author Sherry Zhou
       74  */
       75 
       76 
       77 public class UMLValidationTests extends UMLTestCase {
       78 
       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";
       83 
       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";
       87 
       88 
       89     /** Creates a new instance of DevelopingApplications */
       90     public UMLValidationTests(String name) {
       91         super(name);
       92     }
       93 
       94 
       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"));
      101         return suite;
      102     }
      103 
      104 
      105     protected void setUp() {
      106         System.setOut(getLog());
      107         Utils.waitScanningClassPath();
      108     }
      109 
      110 
      111     /* 
      112      * Verify UML related main menus
      113      */
      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();
      118         
      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();
      122        
      123         // Select main menu Windows->Other->UML Documentation
      124         new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenu("Window|Other|UML Documentation");
      125         try {
      126 
      127             new TopComponentOperator(TopComponentOperator.findTopComponent("UML Documentation", 0));
      128         } catch (Exception ex) {
      129         }
      130 
      131         // Select main menu Windows->Other->UML Documentation UML Design Center
      132         new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenu("Window|Other|UML Design Center");
      133         try {
      134 
      135             new TopComponentOperator(TopComponentOperator.findTopComponent("UML Design Center", 0));
      136         } catch (Exception ex) {
      137         }
      138     }
      139  
      140     /* 
      141      * Create   Java-Platform Model Project
      142      */
      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");
      146 
      147         DiagramOperator classDiagram = DiagramOperator.createDiagram(DIAGRAM_CLASS_NAME1, DiagramTypes.CLASS, umlModelNode);
      148         new TopComponentOperator(DIAGRAM_CLASS_NAME1);
      149         try {
      150             Thread.sleep(3000);
      151         } catch (Exception e) {
      152             e.printStackTrace();
      153         }
      154         new TopComponentOperator(DIAGRAM_CLASS_NAME1);
      155     }
      156 
      157     /* 
      158      * Create Platform Independent Model Project
      159      */
      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");
      163 
      164         DiagramOperator classDiagram = DiagramOperator.createDiagram(DIAGRAM_CLASS_NAME2, DiagramTypes.CLASS, umlModelNode);
      165         new TopComponentOperator(DIAGRAM_CLASS_NAME2);
      166         try {
      167             Thread.sleep(3000);
      168         } catch (Exception e) {
      169             e.printStackTrace();
      170         }
      171         new TopComponentOperator(DIAGRAM_CLASS_NAME2);
      172     }
      173 
      174     /*
      175      * Create Reversed Engineering project
      176      */
      177     public void testCreateREJavaPlatformProject() {
      178         Project.openProject(XTEST_PROJECT_DIR + "/Projects-Tutorials/REJavaApplication/BankApp");
      179 
      180         JavaProject javaProject = new JavaProject(PROJECT_NAME_JAVA, ProjectType.JAVA_APPLICATION);
      181 
      182         UMLProject umlProject = UMLProject.createProject(PROJECT_NAME_UML3, ProjectType.UML_JAVA_REVERSE_ENGINEERING, javaProject);
      183 
      184         try {
      185             Thread.sleep(3000);
      186         } catch (Exception e) {
      187         }
      188         Node root = umlProject.getProjectNode();
      189 
      190         Node modelNode = new Node(umlProject.getProjectNode(), "Model");
      191         Node banckpackNode = new Node(modelNode, "bankpack");
      192 
      193 
      194         //DiagramOperator bankClassDiagram = DiagramOperator.createDiagram("BankClassDiagram", DiagramTypes.CLASS, banckpackNode);
      195         DiagramOperator bankClassDiagram = createDiagramFromSelectedElements(DIAGRAM_CLASS_NAME3, DiagramTypes.CLASS, banckpackNode);
      196         try {
      197             Thread.sleep(3000);
      198         } catch (Exception e) {
      199             e.printStackTrace();
      200         }
      201         new TopComponentOperator(DIAGRAM_CLASS_NAME3);
      202     }
      203 
      204     protected static DiagramOperator createDiagramFromSelectedElements(String diagramName, DiagramTypes diagramType, Node projectNode) {
      205 
      206         projectNode.callPopup().pushMenuNoBlock("Create Diagram From Selected Elements...");
      207         NewDiagramWizardOperator dw = new NewDiagramWizardOperator();
      208         dw.setDiagramType(diagramType.toString());
      209         dw.setDiagramName(diagramName);
      210         dw.clickFinish();
      211 
      212         JDialogOperator createFromSelected = new JDialogOperator("Create Diagram From Selected");
      213         new JButtonOperator(createFromSelected, "Yes").push();
      214 
      215         return new DiagramOperator(diagramName);
      216     }
      217 }