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.DiagramElementVerifier;
065:
066: /**
067: *
068: * @author yaa
069: * @spec UML/DeploymentDiagram.xml
070: */
071: public class DPD_Package extends UMLTestCase {
072:
073: private static String prName = "UMLProjectDPD3";
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_Package(String name) {
086: super (name);
087: }
088:
089: public static NbTestSuite suite() {
090: NbTestSuite suite = new NbTestSuite(
091: org.netbeans.test.uml.deploymentdiagram.DPD_Package.class);
092: return suite;
093: }
094:
095: /**
096: * @caseblock Package Symbol
097: * @usecase Copy and Paste a Package symbol on a diagram by popup menu
098: */
099: public void testCopyAndPasteByPopup() {
100: boolean result = verifier.checkCopyPasteByPopup();
101: if (!result) {
102: fail("Test failed. Details in log file.");
103: }
104: }
105:
106: /**
107: * @caseblock Package Symbol
108: * @usecase Copy and Paste a Package symbol on a diagram by shortcuts
109: */
110: public void testCopyAndPasteByShortcut() {
111: boolean result = verifier.checkCopyPasteByShortcut();
112: if (!result) {
113: fail("Test failed. Details in log file.");
114: }
115: }
116:
117: /**
118: * @caseblock Package Symbol
119: * @usecase Cut and Paste a Package symbol on a diagram by popup menu
120: */
121: public void testCutAndPasteByPopup() {
122: boolean result = verifier.checkCutPasteByPopup();
123: if (!result) {
124: fail("Test failed. Details in log file.");
125: }
126: }
127:
128: /**
129: * @caseblock Package Symbol
130: * @usecase Cut and Paste a Package symbol on a diagram by shortcuts
131: */
132: public void testCutAndPasteByShortcut() {
133: boolean result = verifier.checkCutPasteByShortcut();
134: if (!result) {
135: fail("Test failed. Details in log file.");
136: }
137: }
138:
139: /**
140: * @caseblock Package Symbol
141: * @usecase Delete a Package symbol from a diagram by popup menu
142: */
143: public void testDeleteByPopup() throws NotFoundException {
144: boolean result = verifier.checkDeleteByPopup();
145: if (!result) {
146: fail("Test failed. Details in log file.");
147: }
148: }
149:
150: /**
151: * @caseblock Package Symbol
152: * @usecase Delete a Package symbol from a diagram by shortcut
153: */
154: public void testDeleteByShortcut() throws NotFoundException {
155: boolean result = verifier.checkDeleteByShortcut();
156: if (!result) {
157: fail("Test failed. Details in log file.");
158: }
159: }
160:
161: /**
162: * @caseblock Package Symbol
163: * @usecase Lock edit of a Package
164: */
165: public void testLockEdit() throws NotFoundException {
166: boolean result = verifier.checkLockEdit();
167: if (!result) {
168: fail("Test failed. Details in log file.");
169: }
170: }
171:
172: /**
173: * @caseblock Package Symbol
174: * @usecase Select all on a diagram by popup menu of a Package
175: */
176: public void testSelectAllByPopup() throws NotFoundException {
177: boolean result = verifier
178: .checkSelectAllByPopup(new ElementTypes[] {
179: ElementTypes.INTERFACE, ElementTypes.ARTIFACT });
180: if (!result) {
181: fail("Test failed. Details in log file.");
182: }
183: }
184:
185: /**
186: * @caseblock Package Symbol
187: * @usecase Select all on a diagram by shortcut
188: */
189: public void testSelectAllByShortcut() throws NotFoundException {
190: boolean result = verifier
191: .checkSelectAllByShortcut(new ElementTypes[] {
192: ElementTypes.INTERFACE, ElementTypes.ARTIFACT });
193: if (!result) {
194: fail("Test failed. Details in log file.");
195: }
196: }
197:
198: /**
199: * @caseblock Package Symbol
200: * @usecase Select All Similar Elements of a Package
201: */
202: public void testSelectAllSimilar() throws NotFoundException {
203: boolean result = verifier
204: .checkSelectAllSimilar(new ElementTypes[] {
205: ElementTypes.PACKAGE, ElementTypes.COMPONENT });
206: if (!result) {
207: fail("Test failed. Details in log file.");
208: }
209: }
210:
211: /**
212: * @caseblock Package Symbol
213: * @usecase Invert selection of a Package
214: */
215: public void testInvertSelection() throws NotFoundException {
216: boolean result = verifier.checkInvertSelection(
217: new ElementTypes[] { ElementTypes.COMPONENT },
218: new ElementTypes[] { ElementTypes.INTERFACE,
219: ElementTypes.PACKAGE });
220: if (!result) {
221: fail("Test failed. Details in log file.");
222: }
223: }
224:
225: /**
226: * @caseblock Package Symbol
227: * @usecase Hide Children one level of a Package
228: */
229: public void testHideChildrenOneLevel() throws NotFoundException {
230: boolean result = verifier.checkHideChildrenOneLevel(2, 2,
231: LinkTypes.DEPENDENCY, ElementTypes.PACKAGE);
232: if (!result) {
233: fail("Test failed. Details in log file.");
234: }
235: }
236:
237: /**
238: * @caseblock Package Symbol
239: * @usecase Hide Children All levels of a Package
240: */
241: public void testHideChildrenAllLevels() throws NotFoundException {
242: boolean result = verifier.checkHideChildrenAllLevels(2, 2,
243: LinkTypes.DEPENDENCY, ElementTypes.PACKAGE);
244: if (!result) {
245: fail("Test failed. Details in log file.");
246: }
247: }
248:
249: /**
250: * @caseblock Package Symbol
251: * @usecase Hide Parents one level of a Package
252: */
253: public void testHideParentsOneLevel() throws NotFoundException {
254: boolean result = verifier.checkHideParentsOneLevel(2, 2,
255: LinkTypes.DEPENDENCY, ElementTypes.PACKAGE);
256: if (!result) {
257: fail("Test failed. Details in log file.");
258: }
259: }
260:
261: /**
262: * @caseblock Package Symbol
263: * @usecase Hide Parents All levels of a Package
264: */
265: public void testHideParentsAllLevels() throws NotFoundException {
266: boolean result = verifier.checkHideParentsAllLevels(2, 2,
267: LinkTypes.DEPENDENCY, ElementTypes.PACKAGE);
268: if (!result) {
269: fail("Test failed. Details in log file.");
270: }
271: }
272:
273: /**
274: * @caseblock Package Symbol
275: * @usecase Show Children one level of a Package
276: */
277: public void testShowChildrenOneLevel() throws NotFoundException {
278: boolean result = verifier.checkShowChildrenOneLevel(2, 2,
279: LinkTypes.DEPENDENCY, ElementTypes.PACKAGE);
280: if (!result) {
281: fail("Test failed. Details in log file.");
282: }
283: }
284:
285: /**
286: * @caseblock Package Symbol
287: * @usecase Show Children All levels of a Package
288: */
289: public void testShowChildrenAllLevels() throws NotFoundException {
290: boolean result = verifier.checkShowChildrenAllLevels(2, 2,
291: LinkTypes.DEPENDENCY, ElementTypes.PACKAGE);
292: if (!result) {
293: fail(78350, "Test failed. Details in log file.");
294: }
295: }
296:
297: /**
298: * @caseblock Package Symbol
299: * @usecase Show Parents one level of a Package
300: */
301: public void testShowParentsOneLevel() throws NotFoundException {
302: boolean result = verifier.checkShowParentsOneLevel(2, 2,
303: LinkTypes.DEPENDENCY, ElementTypes.PACKAGE);
304: if (!result) {
305: fail("Test failed. Details in log file.");
306: }
307: }
308:
309: /**
310: * @caseblock Package Symbol
311: * @usecase Show Parents All levels of a Package
312: */
313: public void testShowParentsAllLevels() throws NotFoundException {
314: boolean result = verifier.checkShowParentsAllLevels(2, 2,
315: LinkTypes.DEPENDENCY, ElementTypes.PACKAGE);
316: if (!result) {
317: fail(78350, "Test failed. Details in log file.");
318: }
319: }
320:
321: /**
322: * @caseblock Package Symbol
323: * @usecase Border color of a Package
324: */
325: public void testBorderColor() throws NotFoundException {
326: boolean result = verifier.checkBorderColor(255, 0, 0);
327: if (!result) {
328: fail("Test failed. Details in log file.");
329: }
330: }
331:
332: /**
333: * @caseblock Package Symbol
334: * @usecase Background color of a Package
335: */
336: public void testBackgroundColor() throws NotFoundException {
337: boolean result = verifier.checkBackgroundColor(0, 255, 0);
338: if (!result) {
339: fail("Test failed. Details in log file.");
340: }
341: }
342:
343: /**
344: * @caseblock Package Symbol
345: * @usecase Text font of a Package
346: */
347: public void testFont() throws NotFoundException {
348: boolean result = verifier.checkFont();
349: if (!result) {
350: fail("Test failed. Details in log file.");
351: }
352: }
353:
354: /**
355: * @caseblock Package Symbol
356: * @usecase Text color of a Package
357: */
358: public void testFontColor() throws NotFoundException {
359: boolean result = verifier.checkFontColor(100, 100, 100);
360: if (!result) {
361: fail("Test failed. Details in log file.");
362: }
363: }
364:
365: //------------------------------------------------------------------------------
366:
367: protected void setUp() throws FileNotFoundException {
368: System.out.println("######## " + getName() + " #######");
369: JemmyProperties.setCurrentTimeout(
370: "DialogWaiter.WaitDialogTimeout", 5000);
371: JemmyProperties.setCurrentTimeout("Waiter.WaitingTime", 3000);
372: JemmyProperties.setCurrentTimeout(
373: "DiagramElementOperator.WaitDiagramElementTime", 5000);
374:
375: OUT_LOG_FILE = workDir + File.separator + "jout_" + getName()
376: + ".log";
377: ERR_LOG_FILE = workDir + File.separator + "jerr_" + getName()
378: + ".log";
379:
380: myOut = new PrintStream(new FileOutputStream(OUT_LOG_FILE),
381: true);
382: myErr = new PrintStream(new FileOutputStream(ERR_LOG_FILE),
383: true);
384: JemmyProperties.setCurrentOutput(new TestOut(System.in, myOut,
385: myErr));
386:
387: diagram = DPDUtils.openDiagram(prName, dpdName,
388: NewDiagramWizardOperator.DEPLOYMENT_DIAGRAM, workDir);
389: if (diagram == null) {
390: fail("Can't open diagram '" + dpdName + "', project '"
391: + prName + "'.");
392: }
393: verifier = new DiagramElementVerifier(diagram,
394: ElementTypes.PACKAGE, "", getLog());
395: }
396:
397: public void tearDown() throws FileNotFoundException, IOException {
398: org.netbeans.test.umllib.util.Utils.tearDown();
399: try {
400: JDialogOperator dlgError = new JDialogOperator(
401: "Unexpected Exception");
402: JTextAreaOperator textarea = new JTextAreaOperator(dlgError);
403: String str = textarea.getDisplayedText();
404: int pos = str.indexOf("\n");
405: if (pos != -1) {
406: str = str.substring(1, pos - 1);
407: }
408: dlgError.close();
409: fail(" " + str);
410: } catch (TimeoutExpiredException e1) {
411: }
412:
413: myIn = new BufferedReader(new FileReader(ERR_LOG_FILE));
414: String line;
415: do {
416: line = myIn.readLine();
417: if (line != null && line.indexOf("Exception") != -1) {
418: if ((line.indexOf("Unexpected Exception") == -1)
419: && (line.indexOf("TimeoutExpiredException") == -1)) {
420: //fail(line);
421: }
422: }
423: } while (line != null);
424: }
425:
426: private DiagramOperator diagram = null;
427: private DiagramElementVerifier verifier = null;
428: }
|