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.deploymentdiagram;
043:
044: import java.io.BufferedReader;
045: import java.io.File;
046: import java.io.FileNotFoundException;
047: import java.io.FileOutputStream;
048: import java.io.FileReader;
049: import java.io.IOException;
050: import java.io.PrintStream;
051: import org.netbeans.jemmy.JemmyProperties;
052: import org.netbeans.jemmy.TestOut;
053: import org.netbeans.jemmy.TimeoutExpiredException;
054: import org.netbeans.jemmy.operators.JDialogOperator;
055: import org.netbeans.jemmy.operators.JTextAreaOperator;
056: import org.netbeans.junit.NbTestSuite;
057: import org.netbeans.test.uml.deploymentdiagram.utils.DPDUtils;
058: import org.netbeans.test.umllib.DiagramOperator;
059: import org.netbeans.test.umllib.ElementTypes;
060: import org.netbeans.test.umllib.LinkTypes;
061: import org.netbeans.test.umllib.NewDiagramWizardOperator;
062: import org.netbeans.test.umllib.exceptions.NotFoundException;
063: import org.netbeans.test.umllib.testcases.UMLTestCase;
064: import org.netbeans.test.umllib.vrf.LinkVerifier;
065:
066: /**
067: *
068: * @author yaa
069: * @spec UML/DeploymentDiagram.xml
070: */
071: public class DPD_PermissionLink extends UMLTestCase {
072:
073: private static String prName = "UMLProjectDPD13";
074: private static String dpdName = "DPD";
075:
076: private static final String workDir = System
077: .getProperty("xtest.workdir");
078: private static String OUT_LOG_FILE = "";
079: private static String ERR_LOG_FILE = "";
080: private static PrintStream myOut = null;
081: private static PrintStream myErr = null;
082: private static BufferedReader myIn = null;
083:
084: /** Need to be defined because of JUnit */
085: public DPD_PermissionLink(String name) {
086: super (name);
087: }
088:
089: public static NbTestSuite suite() {
090: NbTestSuite suite = new NbTestSuite(
091: org.netbeans.test.uml.deploymentdiagram.DPD_PermissionLink.class);
092: return suite;
093: }
094:
095: //------------------------------------------------------------------------------
096:
097: /**
098: * @caseblock Permission link
099: * @usecase Delete a Permission link from a diagram by popup menu
100: */
101: public void testDeleteByPopup() throws NotFoundException {
102: boolean result = verifier.checkDeleteByPopup(
103: ElementTypes.COMPONENT, ElementTypes.COMPONENT);
104: if (!result) {
105: fail("Test failed. Details in log file.");
106: }
107: }
108:
109: /**
110: * @caseblock Permission link
111: * @usecase Delete a Permission link from a diagram by shortcut
112: */
113: public void testDeleteByShortcut() throws NotFoundException {
114: boolean result = verifier.checkDeleteByShortcut(
115: ElementTypes.COMPONENT, ElementTypes.INTERFACE);
116: if (!result) {
117: fail("Test failed. Details in log file.");
118: }
119: }
120:
121: /**
122: * @caseblock Permission link
123: * @usecase Select all on a diagram by popup menu of a Permission link
124: */
125: public void testSelectAllByPopup() throws NotFoundException {
126: boolean result = verifier.checkSelectAllByPopup(
127: ElementTypes.COMPONENT, ElementTypes.NODE,
128: LinkTypes.DEPENDENCY);
129: if (!result) {
130: fail("Test failed. Details in log file.");
131: }
132: }
133:
134: /**
135: * @caseblock Permission link
136: * @usecase Invert selection of a Permission link
137: */
138: public void testInvertSelection() throws NotFoundException {
139: boolean result = verifier.checkInvertSelection(
140: ElementTypes.COMPONENT, ElementTypes.ARTIFACT,
141: LinkTypes.DEPENDENCY);
142: if (!result) {
143: fail("Test failed. Details in log file.");
144: }
145: }
146:
147: /**
148: * @caseblock Permission link
149: * @usecase Find source element of a Permission link
150: */
151: public void testFindSourceElement() throws NotFoundException {
152: boolean result = verifier.checkFindSourceElement(
153: ElementTypes.INTERFACE, ElementTypes.INTERFACE);
154: if (!result) {
155: fail("Test failed. Details in log file.");
156: }
157: }
158:
159: /**
160: * @caseblock Permission link
161: * @usecase Find target element of a Permission link
162: */
163: public void testFindTargetElement() throws NotFoundException {
164: boolean result = verifier.checkFindTargetElement(
165: ElementTypes.ARTIFACT, ElementTypes.NODE);
166: if (!result) {
167: fail("Test failed. Details in log file.");
168: }
169: }
170:
171: /**
172: * @caseblock Permission link
173: * @usecase Redirect source element of a Permission link
174: */
175: public void testRedirectSourceElement1() throws NotFoundException {
176: boolean result = verifier.checkRedirectSourceElement(
177: ElementTypes.COMPONENT, ElementTypes.COMPONENT,
178: ElementTypes.INTERFACE);
179: if (!result) {
180: fail("Test failed. Details in log file.");
181: }
182: }
183:
184: /**
185: * @caseblock Permission link
186: * @usecase Redirect source element of a Permission link
187: */
188: public void testRedirectSourceElement2() throws NotFoundException {
189: boolean result = verifier.checkRedirectSourceElement(
190: ElementTypes.INTERFACE, ElementTypes.INTERFACE,
191: ElementTypes.ARTIFACT);
192: if (!result) {
193: fail("Test failed. Details in log file.");
194: }
195: }
196:
197: /**
198: * @caseblock Permission link
199: * @usecase Redirect source element of a Permission link
200: */
201: public void testRedirectSourceElement3() throws NotFoundException {
202: boolean result = verifier.checkRedirectSourceElement(
203: ElementTypes.ARTIFACT, ElementTypes.ARTIFACT,
204: ElementTypes.NODE);
205: if (!result) {
206: fail("Test failed. Details in log file.");
207: }
208: }
209:
210: /**
211: * @caseblock Permission link
212: * @usecase Redirect source element of a Permission link
213: */
214: public void testRedirectSourceElement4() throws NotFoundException {
215: boolean result = verifier.checkRedirectSourceElement(
216: ElementTypes.NODE, ElementTypes.NODE,
217: ElementTypes.PACKAGE);
218: if (!result) {
219: fail("Test failed. Details in log file.");
220: }
221: }
222:
223: /**
224: * @caseblock Permission link
225: * @usecase Redirect source element of a Permission link
226: */
227: public void testRedirectSourceElement5() throws NotFoundException {
228: boolean result = verifier.checkRedirectSourceElement(
229: ElementTypes.PACKAGE, ElementTypes.PACKAGE,
230: ElementTypes.DEPLOYMENT_SPECIFICATION);
231: if (!result) {
232: fail("Test failed. Details in log file.");
233: }
234: }
235:
236: /**
237: * @caseblock Permission link
238: * @usecase Redirect source element of a Permission link
239: */
240: public void testRedirectSourceElement6() throws NotFoundException {
241: boolean result = verifier.checkRedirectSourceElement(
242: ElementTypes.DEPLOYMENT_SPECIFICATION,
243: ElementTypes.DEPLOYMENT_SPECIFICATION,
244: ElementTypes.COMPONENT);
245: if (!result) {
246: fail("Test failed. Details in log file.");
247: }
248: }
249:
250: /**
251: * @caseblock Permission link
252: * @usecase Redirect source element of a Permission link
253: */
254: public void testRedirectSourceElement7() throws NotFoundException {
255: boolean result = verifier.checkRedirectSourceElement(
256: ElementTypes.COMPONENT, ElementTypes.ARTIFACT,
257: ElementTypes.INTERFACE);
258: if (!result) {
259: fail("Test failed. Details in log file.");
260: }
261: }
262:
263: /**
264: * @caseblock Permission link
265: * @usecase Redirect source element of a Permission link
266: */
267: public void testRedirectSourceElement8() throws NotFoundException {
268: boolean result = verifier.checkRedirectSourceElement(
269: ElementTypes.INTERFACE, ElementTypes.NODE,
270: ElementTypes.ARTIFACT);
271: if (!result) {
272: fail("Test failed. Details in log file.");
273: }
274: }
275:
276: /**
277: * @caseblock Permission link
278: * @usecase Redirect source element of a Permission link
279: */
280: public void testRedirectSourceElement9() throws NotFoundException {
281: boolean result = verifier.checkRedirectSourceElement(
282: ElementTypes.ARTIFACT, ElementTypes.PACKAGE,
283: ElementTypes.COMPONENT);
284: if (!result) {
285: fail("Test failed. Details in log file.");
286: }
287: }
288:
289: /**
290: * @caseblock Permission link
291: * @usecase Redirect target element of a Permission link
292: */
293: public void testRedirectTargetElement1() throws NotFoundException {
294: boolean result = verifier.checkRedirectTargetElement(
295: ElementTypes.COMPONENT, ElementTypes.INTERFACE,
296: ElementTypes.NODE);
297: if (!result) {
298: fail("Test failed. Details in log file.");
299: }
300: }
301:
302: /**
303: * @caseblock Permission link
304: * @usecase Redirect target element of a Permission link
305: */
306: public void testRedirectTargetElement2() throws NotFoundException {
307: boolean result = verifier.checkRedirectTargetElement(
308: ElementTypes.NODE, ElementTypes.PACKAGE,
309: ElementTypes.DEPLOYMENT_SPECIFICATION);
310: if (!result) {
311: fail("Test failed. Details in log file.");
312: }
313: }
314:
315: /**
316: * @caseblock Permission link
317: * @usecase Redirect target element of a Permission link
318: */
319: public void testRedirectTargetElement3() throws NotFoundException {
320: boolean result = verifier.checkRedirectTargetElement(
321: ElementTypes.INTERFACE, ElementTypes.PACKAGE,
322: ElementTypes.DEPLOYMENT_SPECIFICATION);
323: if (!result) {
324: fail("Test failed. Details in log file.");
325: }
326: }
327:
328: /**
329: * @caseblock Permission link
330: * @usecase Redirect target element of a Permission link
331: */
332: public void testRedirectTargetElement4() throws NotFoundException {
333: boolean result = verifier.checkRedirectTargetElement(
334: ElementTypes.ARTIFACT, ElementTypes.COMPONENT,
335: ElementTypes.DEPLOYMENT_SPECIFICATION);
336: if (!result) {
337: fail("Test failed. Details in log file.");
338: }
339: }
340:
341: /**
342: * @caseblock Permission link
343: * @usecase Redirect target element of a Permission link
344: */
345: public void testRedirectTargetElement5() throws NotFoundException {
346: boolean result = verifier.checkRedirectTargetElement(
347: ElementTypes.NODE, ElementTypes.COMPONENT,
348: ElementTypes.INTERFACE);
349: if (!result) {
350: fail("Test failed. Details in log file.");
351: }
352: }
353:
354: /**
355: * @caseblock Permission link
356: * @usecase Redirect target element of a Permission link
357: */
358: public void testRedirectTargetElement6() throws NotFoundException {
359: boolean result = verifier.checkRedirectTargetElement(
360: ElementTypes.PACKAGE, ElementTypes.COMPONENT,
361: ElementTypes.INTERFACE);
362: if (!result) {
363: fail("Test failed. Details in log file.");
364: }
365: }
366:
367: /**
368: * @caseblock Permission link
369: * @usecase Redirect target element of a Permission link
370: */
371: public void testRedirectTargetElement7() throws NotFoundException {
372: boolean result = verifier.checkRedirectTargetElement(
373: ElementTypes.PACKAGE, ElementTypes.ARTIFACT,
374: ElementTypes.DEPLOYMENT_SPECIFICATION);
375: if (!result) {
376: fail("Test failed. Details in log file.");
377: }
378: }
379:
380: /**
381: * @caseblock Permission link
382: * @usecase Redirect target element of a Permission link
383: */
384: public void testRedirectTargetElement8() throws NotFoundException {
385: boolean result = verifier.checkRedirectTargetElement(
386: ElementTypes.DEPLOYMENT_SPECIFICATION,
387: ElementTypes.COMPONENT, ElementTypes.INTERFACE);
388: if (!result) {
389: fail("Test failed. Details in log file.");
390: }
391: }
392:
393: /**
394: * @caseblock Permission link
395: * @usecase Redirect target element of a Permission link
396: */
397: public void testRedirectTargetElement9() throws NotFoundException {
398: boolean result = verifier.checkRedirectTargetElement(
399: ElementTypes.DEPLOYMENT_SPECIFICATION,
400: ElementTypes.ARTIFACT, ElementTypes.NODE);
401: if (!result) {
402: fail("Test failed. Details in log file.");
403: }
404: }
405:
406: //------------------------------------------------------------------------------
407:
408: protected void setUp() throws FileNotFoundException {
409: System.out.println("######## " + getName() + " #######");
410: JemmyProperties.setCurrentTimeout(
411: "DialogWaiter.WaitDialogTimeout", 5000);
412: JemmyProperties.setCurrentTimeout("Waiter.WaitingTime", 3000);
413: JemmyProperties.setCurrentTimeout(
414: "DiagramElementOperator.WaitDiagramElementTime", 5000);
415:
416: OUT_LOG_FILE = workDir + File.separator + "jout_" + getName()
417: + ".log";
418: ERR_LOG_FILE = workDir + File.separator + "jerr_" + getName()
419: + ".log";
420:
421: myOut = new PrintStream(new FileOutputStream(OUT_LOG_FILE),
422: true);
423: myErr = new PrintStream(new FileOutputStream(ERR_LOG_FILE),
424: true);
425: JemmyProperties.setCurrentOutput(new TestOut(System.in, myOut,
426: myErr));
427:
428: diagram = DPDUtils.openDiagram(prName, dpdName,
429: NewDiagramWizardOperator.DEPLOYMENT_DIAGRAM, workDir);
430: if (diagram == null) {
431: fail("Can't open diagram '" + dpdName + "', project '"
432: + prName + "'.");
433: }
434: verifier = new LinkVerifier(diagram, LinkTypes.PERMISSION, "",
435: getLog());
436: }
437:
438: public void tearDown() throws FileNotFoundException, IOException {
439: org.netbeans.test.umllib.util.Utils.tearDown();
440: try {
441: JDialogOperator dlgError = new JDialogOperator(
442: "Unexpected Exception");
443: JTextAreaOperator textarea = new JTextAreaOperator(dlgError);
444: String str = textarea.getDisplayedText();
445: int pos = str.indexOf("\n");
446: if (pos != -1) {
447: str = str.substring(1, pos - 1);
448: }
449: dlgError.close();
450: fail(" " + str);
451: } catch (TimeoutExpiredException e1) {
452: }
453:
454: myIn = new BufferedReader(new FileReader(ERR_LOG_FILE));
455: String line;
456: do {
457: line = myIn.readLine();
458: if (line != null && line.indexOf("Exception") != -1) {
459: if ((line.indexOf("Unexpected Exception") == -1)
460: && (line.indexOf("TimeoutExpiredException") == -1)) {
461: //fail(line);
462: }
463: }
464: } while (line != null);
465: }
466:
467: private DiagramOperator diagram = null;
468: private LinkVerifier verifier = null;
469: }
|