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.cdfs;
043:
044: import org.netbeans.test.uml.cdfs.utils.CDFSUtil;
045: import org.netbeans.jellytools.nodes.Node;
046: import org.netbeans.jemmy.EventTool;
047: import org.netbeans.jemmy.TimeoutExpiredException;
048: import org.netbeans.junit.NbTestSuite;
049: import org.netbeans.test.umllib.DiagramElementOperator;
050: import org.netbeans.test.umllib.DiagramOperator;
051: import org.netbeans.test.umllib.LinkOperator;
052: import org.netbeans.test.umllib.LinkTypes;
053: import org.netbeans.test.umllib.NewDiagramWizardOperator;
054: import org.netbeans.test.umllib.project.Project;
055: import org.netbeans.test.umllib.testcases.UMLTestCase;
056:
057: public class ActivityElementsCDFSTests extends UMLTestCase {
058:
059: private EventTool eventTool = new EventTool();
060:
061: public ActivityElementsCDFSTests(String name) {
062: super (name);
063: }
064:
065: public static NbTestSuite suite() {
066: NbTestSuite suite = new NbTestSuite(
067: ActivityElementsCDFSTests.class);
068: return suite;
069: }
070:
071: /******************const section*************************/
072: private String PROJECT_NAME = "CDFS_uml";
073: private String EXCEPTION_DLG = "Exception";
074: /********************************************************/
075:
076: private static boolean isNotInitialized = true;
077: CDFSUtil util = new CDFSUtil(PROJECT_NAME);
078:
079: public void testCDFSComplex() {
080: final String PATH_TO_OBJ1 = "Model|ActivityDiagram|InitialNode";
081: final String PATH_TO_OBJ2 = "Model|ActivityDiagram|ActivityGroup";
082: final String OBJ_NAME1 = "InitialNode";
083: final String OBJ_NAME2 = "ActivityGroup";
084: final String DIA_NAME = "Act_Cmplx";
085: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
086: util = new CDFSUtil(PROJECT_NAME, this );
087:
088: Node node1 = util.getNode(PATH_TO_OBJ1);
089: Node node2 = util.getNode(PATH_TO_OBJ2);
090: util.createDiagram(new Node[] { node1, node2 },
091: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
092:
093: //checking diagram was opened
094: DiagramOperator dia = new DiagramOperator(DIA_NAME);
095: DiagramElementOperator comp = new DiagramElementOperator(dia,
096: OBJ_NAME1);
097: DiagramElementOperator comp2 = new DiagramElementOperator(dia,
098: OBJ_NAME2);
099: LinkOperator.waitForUndirectedLink(comp, comp2,
100: LinkTypes.ACTIVITY_EDGE);
101: //checking only required elements are present on diagram
102: if (!util.diagramHasExactElements(new DiagramElementOperator[] {
103: comp, comp2 }, dia)) {
104: fail("testCDFSComplex verification failed");
105: }
106:
107: //checking diagram node was created
108: /*
109: if (!util.nodeExists(DIA_PATH)){
110: eventTool.waitNoEvent(5000);
111: fail("testCreateChoice verification failed");
112: }
113: */
114:
115: }
116:
117: public void testCDFSActivityFinalNode() {
118: final String PATH_TO_OBJ = "Model|ActivityDiagram|ActivityFinalNode";
119: final String OBJ_NAME = "ActivityFinalNode";
120: final String DIA_NAME = "Act_ActFinalNode";
121: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
122: util = new CDFSUtil(PROJECT_NAME, this );
123:
124: Node node = util.getNode(PATH_TO_OBJ);
125: util.createDiagram(new Node[] { node },
126: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
127:
128: //checking diagram was opened
129: DiagramOperator dia = new DiagramOperator(DIA_NAME);
130: DiagramElementOperator comp = new DiagramElementOperator(dia,
131: OBJ_NAME);
132:
133: //checking only required elements are present on diagram
134: if (!util.diagramHasExactElements(
135: new DiagramElementOperator[] { comp }, dia)) {
136: fail("testCDFSActivityFinalNode verification failed");
137: }
138:
139: //checking diagram node was created
140: /*
141: if (!util.nodeExists(DIA_PATH)){
142: eventTool.waitNoEvent(5000);
143: fail("testCreateActivityDiagramFromClass verification failed");
144: }
145: */
146:
147: }
148:
149: public void testCDFSPartition() {
150: final String PATH_TO_OBJ = "Model|ActivityDiagram|Partition";
151: final String OBJ_NAME = "Partition";
152: final String DIA_NAME = "Act_Partition";
153: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
154:
155: Node node = util.getNode(PATH_TO_OBJ);
156: util.createDiagram(new Node[] { node },
157: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
158:
159: //checking diagram was opened
160: DiagramOperator dia = new DiagramOperator(DIA_NAME);
161: DiagramElementOperator comp = new DiagramElementOperator(dia,
162: OBJ_NAME);
163:
164: //checking only required elements are present on diagram
165: if (!util.diagramHasExactElements(
166: new DiagramElementOperator[] { comp }, dia)) {
167: fail("testCDFSPartition verification failed");
168: }
169:
170: //checking diagram node was created
171: /*
172: if (!util.nodeExists(DIA_PATH)){
173: eventTool.waitNoEvent(5000);
174: fail("testCreateActivityDiagramFromClass verification failed");
175: }
176: */
177:
178: }
179:
180: public void testCDFSActivityGroup() {
181: final String PATH_TO_OBJ = "Model|ActivityDiagram|ActivityGroup";
182: final String OBJ_NAME = "ActivityGroup";
183: final String DIA_NAME = "Act_ActGrp";
184: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
185: util = new CDFSUtil(PROJECT_NAME, this );
186: Node node = util.getNode(PATH_TO_OBJ);
187: util.createDiagram(new Node[] { node },
188: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
189:
190: //checking diagram was opened
191: DiagramOperator dia = new DiagramOperator(DIA_NAME);
192: DiagramElementOperator comp = new DiagramElementOperator(dia,
193: OBJ_NAME);
194:
195: //checking only required elements are present on diagram
196: if (!util.diagramHasExactElements(
197: new DiagramElementOperator[] { comp }, dia)) {
198: fail("testCDFSActivityGroup verification failed");
199: }
200:
201: //checking diagram node was created
202: /*
203: if (!util.nodeExists(DIA_PATH)){
204: eventTool.waitNoEvent(5000);
205: fail("testCreateActivityGroup verification failed");
206: }
207: */
208:
209: }
210:
211: public void testCDFSChoice() {
212: final String PATH_TO_OBJ = "Model|ActivityDiagram|Choice";
213: final String OBJ_NAME = "Choice";
214: final String DIA_NAME = "Act_Choice";
215: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
216: util = new CDFSUtil(PROJECT_NAME, this );
217:
218: Node node = util.getNode(PATH_TO_OBJ);
219: util.createDiagram(new Node[] { node },
220: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
221:
222: //checking diagram was opened
223: DiagramOperator dia = new DiagramOperator(DIA_NAME);
224: DiagramElementOperator comp = new DiagramElementOperator(dia,
225: OBJ_NAME);
226:
227: //checking only required elements are present on diagram
228: if (!util.diagramHasExactElements(
229: new DiagramElementOperator[] { comp }, dia)) {
230: fail("testCDFSChoice verification failed");
231: }
232:
233: //checking diagram node was created
234: /*
235: if (!util.nodeExists(DIA_PATH)){
236: eventTool.waitNoEvent(5000);
237: fail("testCreateChoice verification failed");
238: }
239: */
240:
241: }
242:
243: public void testCDFSDataStore() {
244: final String PATH_TO_OBJ = "Model|ActivityDiagram|DataStore";
245: final String OBJ_NAME = "DataStore";
246: final String DIA_NAME = "Act_DataStore";
247: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
248: util = new CDFSUtil(PROJECT_NAME, this );
249:
250: Node node = util.getNode(PATH_TO_OBJ);
251: util.createDiagram(new Node[] { node },
252: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
253:
254: //checking diagram was opened
255: DiagramOperator dia = new DiagramOperator(DIA_NAME);
256: DiagramElementOperator comp = new DiagramElementOperator(dia,
257: OBJ_NAME);
258:
259: //checking only required elements are present on diagram
260: if (!util.diagramHasExactElements(
261: new DiagramElementOperator[] { comp }, dia)) {
262: fail("testCDFSDataStore verification failed");
263: }
264:
265: //checking diagram node was created
266: /*
267: if (!util.nodeExists(DIA_PATH)){
268: eventTool.waitNoEvent(5000);
269: fail("testCreateChoice verification failed");
270: }
271: */
272:
273: }
274:
275: public void testCDFSFlowFinalNode() {
276: final String PATH_TO_OBJ = "Model|ActivityDiagram|FlowFinalNode";
277: final String OBJ_NAME = "FlowFinalNode";
278: final String DIA_NAME = "Act_FlowFinalNode";
279: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
280: util = new CDFSUtil(PROJECT_NAME, this );
281:
282: Node node = util.getNode(PATH_TO_OBJ);
283: util.createDiagram(new Node[] { node },
284: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
285:
286: //checking diagram was opened
287: DiagramOperator dia = new DiagramOperator(DIA_NAME);
288: DiagramElementOperator comp = new DiagramElementOperator(dia,
289: OBJ_NAME);
290:
291: //checking only required elements are present on diagram
292: if (!util.diagramHasExactElements(
293: new DiagramElementOperator[] { comp }, dia)) {
294: fail("testCDFSFlowFinalNode verification failed");
295: }
296:
297: //checking diagram node was created
298: /*
299: if (!util.nodeExists(DIA_PATH)){
300: eventTool.waitNoEvent(5000);
301: fail("testCreateChoice verification failed");
302: }
303: */
304:
305: }
306:
307: public void testCDFSInitialNode() {
308: final String PATH_TO_OBJ = "Model|ActivityDiagram|InitialNode";
309: final String OBJ_NAME = "InitialNode";
310: final String DIA_NAME = "Act_InitNode";
311: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
312: util = new CDFSUtil(PROJECT_NAME, this );
313:
314: Node node = util.getNode(PATH_TO_OBJ);
315: util.createDiagram(new Node[] { node },
316: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
317:
318: //checking diagram was opened
319: DiagramOperator dia = new DiagramOperator(DIA_NAME);
320: DiagramElementOperator comp = new DiagramElementOperator(dia,
321: OBJ_NAME);
322:
323: //checking only required elements are present on diagram
324: if (!util.diagramHasExactElements(
325: new DiagramElementOperator[] { comp }, dia)) {
326: fail("testCDFSInitialNode verification failed");
327: }
328:
329: //checking diagram node was created
330: /*
331: if (!util.nodeExists(DIA_PATH)){
332: eventTool.waitNoEvent(5000);
333: fail("testCreateChoice verification failed");
334: }
335: */
336:
337: }
338:
339: public void testCDFSInvocation() {
340: final String PATH_TO_OBJ = "Model|ActivityDiagram|Invocation";
341: final String OBJ_NAME = "Invocation";
342: final String DIA_NAME = "Act_Invocation";
343: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
344: util = new CDFSUtil(PROJECT_NAME, this );
345:
346: Node node = util.getNode(PATH_TO_OBJ);
347: util.createDiagram(new Node[] { node },
348: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
349:
350: //checking diagram was opened
351: DiagramOperator dia = new DiagramOperator(DIA_NAME);
352: DiagramElementOperator comp = new DiagramElementOperator(dia,
353: OBJ_NAME);
354:
355: //checking only required elements are present on diagram
356: if (!util.diagramHasExactElements(
357: new DiagramElementOperator[] { comp }, dia)) {
358: fail("testCDFSInvocation verification failed");
359: }
360:
361: //checking diagram node was created
362: /*
363: if (!util.nodeExists(DIA_PATH)){
364: eventTool.waitNoEvent(5000);
365: fail("testCreateChoice verification failed");
366: }
367: */
368:
369: }
370:
371: public void testCDFSParameterUsage() {
372: final String PATH_TO_OBJ = "Model|ActivityDiagram|ParameterUsage";
373: final String OBJ_NAME = "ParameterUsage";
374: final String DIA_NAME = "Act_ParameterUsage";
375: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
376: util = new CDFSUtil(PROJECT_NAME, this );
377:
378: Node node = util.getNode(PATH_TO_OBJ);
379: util.createDiagram(new Node[] { node },
380: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
381:
382: //checking diagram was opened
383: DiagramOperator dia = new DiagramOperator(DIA_NAME);
384: DiagramElementOperator comp = new DiagramElementOperator(dia,
385: OBJ_NAME);
386:
387: //checking only required elements are present on diagram
388: if (!util.diagramHasExactElements(
389: new DiagramElementOperator[] { comp }, dia)) {
390: fail("testCDFSParameterUsage verification failed");
391: }
392:
393: //checking diagram node was created
394: /*
395: if (!util.nodeExists(DIA_PATH)){
396: eventTool.waitNoEvent(5000);
397: fail("testCreateChoice verification failed");
398: }
399: */
400:
401: }
402:
403: public void testCDFSSignal() {
404: final String PATH_TO_OBJ = "Model|ActivityDiagram|Signal";
405: final String OBJ_NAME = "Signal";
406: final String DIA_NAME = "Act_Signal";
407: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
408: util = new CDFSUtil(PROJECT_NAME, this );
409:
410: Node node = util.getNode(PATH_TO_OBJ);
411: util.createDiagram(new Node[] { node },
412: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
413:
414: //checking diagram was opened
415: DiagramOperator dia = new DiagramOperator(DIA_NAME);
416: DiagramElementOperator comp = new DiagramElementOperator(dia,
417: OBJ_NAME);
418:
419: //checking only required elements are present on diagram
420: if (!util.diagramHasExactElements(
421: new DiagramElementOperator[] { comp }, dia)) {
422: fail("testCDFSSignal verification failed");
423: }
424:
425: //checking diagram node was created
426: /*
427: if (!util.nodeExists(DIA_PATH)){
428: eventTool.waitNoEvent(5000);
429: fail("testCreateChoice verification failed");
430: }
431: */
432:
433: }
434:
435: public void testCDFSVerticalFork() {
436: final String PATH_TO_OBJ = "Model|ActivityDiagram|VerticalFork";
437: final String OBJ_NAME = "VerticalFork";
438: final String DIA_NAME = "Act_VerticalFork";
439: final String DIA_PATH = "Model|ActivityDiagram|" + DIA_NAME;
440: util = new CDFSUtil(PROJECT_NAME, this );
441:
442: Node node = util.getNode(PATH_TO_OBJ);
443: util.createDiagram(new Node[] { node },
444: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
445:
446: //checking diagram was opened
447: DiagramOperator dia = new DiagramOperator(DIA_NAME);
448: DiagramElementOperator comp = new DiagramElementOperator(dia,
449: OBJ_NAME);
450:
451: //checking only required elements are present on diagram
452: if (!util.diagramHasExactElements(
453: new DiagramElementOperator[] { comp }, dia)) {
454: fail("testCDFSVerticalFork verification failed");
455: }
456:
457: //checking diagram node was created
458: /*
459: if (!util.nodeExists(DIA_PATH)){
460: eventTool.waitNoEvent(5000);
461: fail("testCreateChoice verification failed");
462: }
463: */
464:
465: }
466:
467: protected void setUp() {
468: if (isNotInitialized) {
469: Project.openProject(CDFSUtil.CDFS_XTEST_PROJECT_DIR + "/"
470: + PROJECT_NAME);
471: isNotInitialized = false;
472: }
473: }
474:
475: public void tearDown() {
476: closeAllModal();
477: org.netbeans.test.umllib.util.Utils.tearDown();
478: new EventTool().waitNoEvent(1000);
479: try {
480: DiagramOperator d = new DiagramOperator("Act");
481: d.closeAllDocuments();
482: } catch (TimeoutExpiredException tee) {
483: }
484:
485: new EventTool().waitNoEvent(1000);
486: }
487:
488: }
|