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 org.netbeans.test.uml.dependencydiagram;
043:
044: import org.netbeans.jemmy.EventTool;
045: import org.netbeans.jemmy.JemmyProperties;
046: import org.netbeans.junit.NbTestSuite;
047: import org.netbeans.test.uml.dependencydiagram.utils.DependencyDiagramVerifier;
048: import org.netbeans.test.uml.dependencydiagram.utils.DependencyUtils;
049: import org.netbeans.test.umllib.DiagramOperator;
050: import org.netbeans.test.umllib.ElementTypes;
051: import org.netbeans.test.umllib.LinkTypes;
052: import org.netbeans.test.umllib.NewDiagramWizardOperator;
053: import org.netbeans.test.umllib.testcases.UMLTestCase;
054:
055: public class UseCaseDiagramTests extends UMLTestCase {
056: private final String projectName = "Depend_uml_usd";
057: private final String diagramNamePrefix = "test_diagram";
058: public static int COUNT = 0;
059: //public static boolean initialized = false;
060:
061: private static final String workDir = System
062: .getProperty("xtest.workdir");
063: private DiagramOperator diagram = null;
064: private DependencyDiagramVerifier verifier = null;
065:
066: private EventTool eventTool = new EventTool();
067:
068: public UseCaseDiagramTests(String name) {
069: super (name);
070: }
071:
072: public static NbTestSuite suite() {
073: NbTestSuite suite = new NbTestSuite(UseCaseDiagramTests.class);
074: return suite;
075: }
076:
077: // GEneralization link tests
078: public void testSrcUsecaseUsecaseGeneralization() {
079:
080: verifier.testSrcOf2LinkedElements(ElementTypes.USE_CASE,
081: ElementTypes.USE_CASE, LinkTypes.GENERALIZATION);
082:
083: }
084:
085: public void testSrcActorActorGeneralization() {
086:
087: verifier.testSrcOf2LinkedElements(ElementTypes.ACTOR,
088: ElementTypes.ACTOR, LinkTypes.GENERALIZATION);
089:
090: }
091:
092: public void testSrcUsecaseActorGeneralization() {
093:
094: verifier.testSrcOf2LinkedElements(ElementTypes.USE_CASE,
095: ElementTypes.ACTOR, LinkTypes.GENERALIZATION);
096:
097: }
098:
099: public void testSrcActorUsecaseGeneralization() {
100:
101: verifier.testSrcOf2LinkedElements(ElementTypes.ACTOR,
102: ElementTypes.USE_CASE, LinkTypes.GENERALIZATION);
103:
104: }
105:
106: // Association link
107: public void testSrcUsecaseUsecaseAssociation() {
108:
109: verifier.testSrcOf2LinkedElements(ElementTypes.USE_CASE,
110: ElementTypes.USE_CASE, LinkTypes.ASSOCIATION);
111:
112: }
113:
114: public void testSrcActorActorAssociation() {
115:
116: verifier.testSrcOf2LinkedElements(ElementTypes.ACTOR,
117: ElementTypes.ACTOR, LinkTypes.ASSOCIATION);
118:
119: }
120:
121: public void testSrcUsecaseActorAssociation() {
122:
123: verifier.testSrcOf2LinkedElements(ElementTypes.USE_CASE,
124: ElementTypes.ACTOR, LinkTypes.ASSOCIATION);
125:
126: }
127:
128: // Extend link
129: public void testSrcUsecaseUsecaseExtend() {
130:
131: verifier.testSrcOf2LinkedElements(ElementTypes.USE_CASE,
132: ElementTypes.USE_CASE, LinkTypes.EXTEND);
133:
134: }
135:
136: // Include link
137: public void testSrcUsecaseUsecaseInclude() {
138:
139: verifier.testSrcOf2LinkedElements(ElementTypes.USE_CASE,
140: ElementTypes.USE_CASE, LinkTypes.INCLUDE);
141:
142: }
143:
144: // several elements with links
145: public void testMultipleLinks1() {
146:
147: verifier.testSrcOf4LinkedElements(ElementTypes.USE_CASE,
148: ElementTypes.USE_CASE, LinkTypes.GENERALIZATION,
149: ElementTypes.USE_CASE, LinkTypes.ASSOCIATION,
150: ElementTypes.ACTOR, LinkTypes.GENERALIZATION);
151:
152: }
153:
154: public void testMultipleLinks2() {
155:
156: verifier.testSrcOf4LinkedElements(ElementTypes.ACTOR,
157: ElementTypes.USE_CASE, LinkTypes.ASSOCIATION,
158: ElementTypes.ACTOR, LinkTypes.ASSOCIATION,
159: ElementTypes.USE_CASE, LinkTypes.ASSOCIATION);
160:
161: }
162:
163: public void testMultipleLinks3() {
164:
165: verifier.testSrcOf4LinkedElements(ElementTypes.USE_CASE,
166: ElementTypes.ACTOR, LinkTypes.GENERALIZATION,
167: ElementTypes.USE_CASE, LinkTypes.GENERALIZATION,
168: ElementTypes.ACTOR, LinkTypes.ASSOCIATION);
169:
170: }
171:
172: public void testMultipleLinks4() {
173:
174: verifier.testSrcOf4LinkedElements(ElementTypes.USE_CASE,
175: ElementTypes.ACTOR, LinkTypes.ASSOCIATION,
176: ElementTypes.USE_CASE, LinkTypes.EXTEND,
177: ElementTypes.USE_CASE, LinkTypes.INCLUDE);
178:
179: }
180:
181: protected void setUp() {
182: JemmyProperties.setCurrentTimeout(
183: "DialogWaiter.WaitDialogTimeout", 5000);
184: JemmyProperties.setCurrentTimeout("Waiter.WaitingTime", 3000);
185: JemmyProperties.setCurrentTimeout(
186: "DiagramElementOperator.WaitDiagramElementTime", 5000);
187: //if (!initialized) { DependencyUtils.setDefaultPreferences(); initialized=true;}
188: COUNT++;
189: String diagramName = this .diagramNamePrefix + COUNT;
190: diagram = DependencyUtils.openDiagram(projectName, diagramName,
191: NewDiagramWizardOperator.USECASE_DIAGRAM, workDir);
192: if (diagram == null)
193: fail("Can't open diagram '" + diagramName + "', project '"
194: + projectName + "'.");
195:
196: verifier = new DependencyDiagramVerifier(diagram, this .getLog());
197: }
198:
199: public void tearDown() {
200: closeAllModal();
201: org.netbeans.test.umllib.util.Utils.tearDown();
202: new EventTool().waitNoEvent(1000);
203:
204: //close opened diagrams
205: diagram.closeAllDocuments();
206:
207: new EventTool().waitNoEvent(1000);
208: }
209:
210: }
|