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.jemmy.TimeoutExpiredException;
047: import org.netbeans.junit.NbTestSuite;
048: import org.netbeans.test.uml.dependencydiagram.utils.DependencyDiagramVerifier;
049: import org.netbeans.test.uml.dependencydiagram.utils.DependencyUtils;
050: import org.netbeans.test.umllib.DiagramOperator;
051: import org.netbeans.test.umllib.ElementTypes;
052: import org.netbeans.test.umllib.LinkTypes;
053: import org.netbeans.test.umllib.NewDiagramWizardOperator;
054: import org.netbeans.test.umllib.testcases.UMLTestCase;
055:
056: public class DeploymentDiagramTests extends UMLTestCase {
057: private final String projectName = "Depend_uml_dpd";
058: private final String diagramNamePrefix = "test_diagram";
059: public static int COUNT = 0;
060: //public static boolean initialized = false;
061:
062: private static final String workDir = System
063: .getProperty("xtest.workdir");
064: private DiagramOperator diagram = null;
065: private DependencyDiagramVerifier verifier = null;
066:
067: private EventTool eventTool = new EventTool();
068:
069: public DeploymentDiagramTests(String name) {
070: super (name);
071: }
072:
073: public static NbTestSuite suite() {
074: NbTestSuite suite = new NbTestSuite(
075: DeploymentDiagramTests.class);
076: return suite;
077: }
078:
079: // GEneralization link tests
080:
081: public void testSrcComponentComponentGeneralization() {
082:
083: verifier.testSrcOf2LinkedElements(ElementTypes.COMPONENT,
084: ElementTypes.COMPONENT, LinkTypes.GENERALIZATION);
085:
086: }
087:
088: public void testSrcNodeNodeGeneralization() {
089:
090: verifier.testSrcOf2LinkedElements(ElementTypes.NODE,
091: ElementTypes.NODE, LinkTypes.GENERALIZATION);
092:
093: }
094:
095: public void testSrcInterfaceInterfaceGeneralization() {
096:
097: verifier.testSrcOf2LinkedElements(ElementTypes.INTERFACE,
098: ElementTypes.INTERFACE, LinkTypes.GENERALIZATION);
099:
100: }
101:
102: public void testSrcArtifactArtifactGeneralization() {
103:
104: verifier.testSrcOf2LinkedElements(ElementTypes.ARTIFACT,
105: ElementTypes.ARTIFACT, LinkTypes.GENERALIZATION);
106:
107: }
108:
109: public void testSrcComponentNodeGeneralization() {
110:
111: verifier.testSrcOf2LinkedElements(ElementTypes.COMPONENT,
112: ElementTypes.NODE, LinkTypes.GENERALIZATION);
113:
114: }
115:
116: public void testSrcComponentInterfaceGeneralization() {
117: try {
118: verifier.testSrcOf2LinkedElements(ElementTypes.COMPONENT,
119: ElementTypes.INTERFACE, LinkTypes.GENERALIZATION);
120: } catch (TimeoutExpiredException e) {
121: // It is expected to have no link created between component and interface
122: assertTrue(
123: "There should not be generalization link between component and interface",
124: e
125: .getMessage()
126: .startsWith(
127: "Wait with link chooser: Chooser for link of type Generalization"));
128: }
129:
130: }
131:
132: public void testSrcComponentArtifactGeneralization() {
133:
134: verifier.testSrcOf2LinkedElements(ElementTypes.COMPONENT,
135: ElementTypes.ARTIFACT, LinkTypes.GENERALIZATION);
136:
137: }
138:
139: public void testSrcArtifactInterfaceGeneralization() {
140: try {
141: verifier.testSrcOf2LinkedElements(ElementTypes.ARTIFACT,
142: ElementTypes.INTERFACE, LinkTypes.GENERALIZATION);
143: } catch (TimeoutExpiredException e) {
144: // It is expected to have no link created between component and interface
145: assertTrue(
146: "There should not be generalization link between artifact and interface",
147: e
148: .getMessage()
149: .startsWith(
150: "Wait with link chooser: Chooser for link of type Generalization"));
151: }
152:
153: }
154:
155: public void testSrcNodeArtifactGeneralization() {
156:
157: verifier.testSrcOf2LinkedElements(ElementTypes.NODE,
158: ElementTypes.ARTIFACT, LinkTypes.GENERALIZATION);
159:
160: }
161:
162: // Implementation link tests
163: public void testSrcComponentInterfaceImplementation() {
164:
165: verifier.testSrcOf2LinkedElements(ElementTypes.COMPONENT,
166: ElementTypes.INTERFACE, LinkTypes.IMPLEMENTATION);
167:
168: }
169:
170: //Assiciation
171: public void testSrcComponentComponentAssociation() {
172:
173: verifier.testSrcOf2LinkedElements(ElementTypes.COMPONENT,
174: ElementTypes.COMPONENT, LinkTypes.ASSOCIATION);
175:
176: }
177:
178: public void testSrcNodeNodeAssociation() {
179:
180: verifier.testSrcOf2LinkedElements(ElementTypes.NODE,
181: ElementTypes.NODE, LinkTypes.ASSOCIATION);
182:
183: }
184:
185: public void testSrcInterfaceInterfaceAssociation() {
186:
187: verifier.testSrcOf2LinkedElements(ElementTypes.INTERFACE,
188: ElementTypes.INTERFACE, LinkTypes.ASSOCIATION);
189:
190: }
191:
192: public void testSrcArtifactArtifactAssociation() {
193:
194: verifier.testSrcOf2LinkedElements(ElementTypes.ARTIFACT,
195: ElementTypes.ARTIFACT, LinkTypes.ASSOCIATION);
196:
197: }
198:
199: public void testSrcComponentNodeAssociation() {
200:
201: verifier.testSrcOf2LinkedElements(ElementTypes.COMPONENT,
202: ElementTypes.NODE, LinkTypes.ASSOCIATION);
203:
204: }
205:
206: public void testSrcComponentInterfaceAssociation() {
207:
208: verifier.testSrcOf2LinkedElements(ElementTypes.COMPONENT,
209: ElementTypes.INTERFACE, LinkTypes.ASSOCIATION);
210:
211: }
212:
213: public void testSrcComponentArtifactAssociation() {
214:
215: verifier.testSrcOf2LinkedElements(ElementTypes.INTERFACE,
216: ElementTypes.ARTIFACT, LinkTypes.ASSOCIATION);
217:
218: }
219:
220: // several elements with links
221: public void testMultipleLinks1() {
222: try {
223: verifier.testSrcOf4LinkedElements(ElementTypes.NODE,
224: ElementTypes.NODE, LinkTypes.GENERALIZATION,
225: ElementTypes.INTERFACE, LinkTypes.GENERALIZATION,
226: ElementTypes.NODE, LinkTypes.ASSOCIATION);
227: } catch (TimeoutExpiredException e) {
228: // It is expected to have no link created between component and interface
229: assertTrue(
230: "There should not be generalization link between node and interface",
231: e
232: .getMessage()
233: .startsWith(
234: "Wait with link chooser: Chooser for link of type Generalization"));
235: }
236:
237: }
238:
239: public void testMultipleLinks2() {
240:
241: verifier.testSrcOf4LinkedElements(ElementTypes.COMPONENT,
242: ElementTypes.COMPONENT, LinkTypes.GENERALIZATION,
243: ElementTypes.INTERFACE, LinkTypes.IMPLEMENTATION,
244: ElementTypes.NODE, LinkTypes.GENERALIZATION);
245:
246: }
247:
248: public void testMultipleLinks3() {
249: try {
250: verifier.testSrcOf4LinkedElements(ElementTypes.ARTIFACT,
251: ElementTypes.NODE, LinkTypes.ASSOCIATION,
252: ElementTypes.INTERFACE, LinkTypes.GENERALIZATION,
253: ElementTypes.COMPONENT, LinkTypes.ASSOCIATION);
254: } catch (TimeoutExpiredException e) {
255: // It is expected to have no link created between component and interface
256: assertTrue(
257: "There should not be generalization link between artifact and interface",
258: e
259: .getMessage()
260: .startsWith(
261: "Wait with link chooser: Chooser for link of type Generalization"));
262: }
263:
264: }
265:
266: public void testMultipleLinks4() {
267:
268: verifier.testSrcOf4LinkedElements(ElementTypes.ARTIFACT,
269: ElementTypes.NODE, LinkTypes.ASSOCIATION,
270: ElementTypes.INTERFACE, LinkTypes.ASSOCIATION,
271: ElementTypes.COMPONENT, LinkTypes.ASSOCIATION);
272:
273: }
274:
275: protected void setUp() {
276: JemmyProperties.setCurrentTimeout(
277: "DialogWaiter.WaitDialogTimeout", 5000);
278: JemmyProperties.setCurrentTimeout("Waiter.WaitingTime", 3000);
279: JemmyProperties.setCurrentTimeout(
280: "DiagramElementOperator.WaitDiagramElementTime", 5000);
281: //if (!initialized) { DependencyUtils.setDefaultPreferences(); initialized=true;}
282: COUNT++;
283: String diagramName = this .diagramNamePrefix + COUNT;
284: diagram = DependencyUtils.openDiagram(projectName, diagramName,
285: NewDiagramWizardOperator.DEPLOYMENT_DIAGRAM, workDir);
286: if (diagram == null)
287: fail("Can't open diagram '" + diagramName + "', project '"
288: + projectName + "'.");
289:
290: verifier = new DependencyDiagramVerifier(diagram, this .getLog());
291: }
292:
293: public void tearDown() {
294: closeAllModal();
295: org.netbeans.test.umllib.util.Utils.tearDown();
296: new EventTool().waitNoEvent(1000);
297:
298: //close opened diagrams
299: diagram.closeAllDocuments();
300:
301: new EventTool().waitNoEvent(1000);
302: }
303:
304: }
|