Source Code Cross Referenced for CreateClassDiagramTests.java in  » IDE-Netbeans » uml » org » netbeans » test » uml » cdfs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » uml » org.netbeans.test.uml.cdfs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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 java.awt.event.KeyEvent;
046:        import org.netbeans.jellytools.nodes.Node;
047:        import org.netbeans.jemmy.EventTool;
048:        import org.netbeans.jemmy.TimeoutExpiredException;
049:        import org.netbeans.jemmy.operators.JButtonOperator;
050:        import org.netbeans.jemmy.operators.JDialogOperator;
051:        import org.netbeans.jemmy.operators.JPopupMenuOperator;
052:        import org.netbeans.junit.NbTestSuite;
053:        import org.netbeans.test.umllib.DiagramElementOperator;
054:        import org.netbeans.test.umllib.DiagramOperator;
055:        import org.netbeans.test.umllib.LinkOperator;
056:        import org.netbeans.test.umllib.LinkTypes;
057:        import org.netbeans.test.umllib.NewDiagramWizardOperator;
058:        import org.netbeans.test.umllib.project.JavaProject;
059:        import org.netbeans.test.umllib.project.Project;
060:        import org.netbeans.test.umllib.project.ProjectType;
061:        import org.netbeans.test.umllib.project.UMLProject;
062:        import org.netbeans.test.umllib.testcases.UMLTestCase;
063:
064:        public class CreateClassDiagramTests extends UMLTestCase {
065:
066:            private EventTool eventTool = new EventTool();
067:
068:            public CreateClassDiagramTests(String name) {
069:                super (name);
070:            }
071:
072:            public static NbTestSuite suite() {
073:                NbTestSuite suite = new NbTestSuite(
074:                        CreateClassDiagramTests.class);
075:                return suite;
076:            }
077:
078:            /******************const section*************************/
079:            private String PROJECT_NAME = "CDFS_uml_Class";
080:            private String JAVA_PROJECT_NAME = "CDFS_java";
081:            private final static String PROJECT_PATH = System
082:                    .getProperty("xtest.workdir");
083:
084:            /********************************************************/
085:
086:            private static boolean isNotInitialized = true;
087:            CDFSUtil util = new CDFSUtil(PROJECT_NAME);
088:
089:            public void testCreateDiagramFromClass() {
090:                final String PATH_TO_CLASS = "Model|cdfs|Customer";
091:                final String CLASS_NAME = "Customer";
092:                final String DIA_NAME = "DGCD_1";
093:                util = new CDFSUtil(PROJECT_NAME, this );
094:                Node node = util.getNode(PATH_TO_CLASS);
095:
096:                util.createDiagram(new Node[] { node },
097:                        NewDiagramWizardOperator.CLASS_DIAGRAM, DIA_NAME);
098:
099:                //checking diagram was opened
100:                DiagramOperator dia = new DiagramOperator(DIA_NAME);
101:
102:                //checking only required elements are present on diagram
103:                if (!util.diagramHasExactElements(new String[] { CLASS_NAME },
104:                        dia)) {
105:                    fail("testCreateDiagramFromClass verification failed");
106:                }
107:
108:                //checking a node was created
109:                //TODO: add later
110:
111:            }
112:
113:            public void testCreateDiagramFromManyClasses() {
114:                final String PATH_TO_CLASSES = "Model|cdfs|";
115:                final String[] classNames = new String[] { "Address",
116:                        "Customer", "CustomerAccount", "GovermentCustomer" };
117:                final String DIA_NAME = "DGAllCLD";
118:                util = new CDFSUtil(PROJECT_NAME, this );
119:
120:                Node[] nodes = new Node[classNames.length];
121:                for (int i = 0; i < classNames.length; i++) {
122:                    nodes[i] = util.getNode(PATH_TO_CLASSES + classNames[i]);
123:                }
124:
125:                util.createDiagram(nodes,
126:                        NewDiagramWizardOperator.CLASS_DIAGRAM, DIA_NAME);
127:
128:                //checking diagram was opened
129:                DiagramOperator dia = new DiagramOperator(DIA_NAME);
130:
131:                //checking only required elements are present on diagram
132:                if (!util.diagramHasExactElements(classNames, dia)) {
133:                    fail("testCreateDiagramFromManyClasses verification failed");
134:                }
135:
136:                //checking links were created on the diagram
137:                DiagramElementOperator customer = new DiagramElementOperator(
138:                        dia, "Customer");
139:                DiagramElementOperator account = new DiagramElementOperator(
140:                        dia, "CustomerAccount");
141:                DiagramElementOperator govCustomer = new DiagramElementOperator(
142:                        dia, "GovermentCustomer");
143:                DiagramElementOperator address = new DiagramElementOperator(
144:                        dia, "Address");
145:                new LinkOperator(govCustomer, customer,
146:                        LinkTypes.GENERALIZATION);
147:                LinkOperator.waitForUndirectedLink(customer, account,
148:                        LinkTypes.AGGREGATION);
149:                LinkOperator.waitForUndirectedLink(customer, address,
150:                        LinkTypes.AGGREGATION);
151:
152:                //checking a node was created
153:                //TODO: add later
154:
155:            }
156:
157:            public void testCreateDiagramForInnerClasses() {
158:                final String PATH_TO_CLASS = "Model|cdfs|";
159:                final String CLASS_NAME = "Order";
160:                final String DIA_NAME = "DG_CD2";
161:                util = new CDFSUtil(PROJECT_NAME, this );
162:
163:                Node node = util.getNode(PATH_TO_CLASS + CLASS_NAME);
164:
165:                new Thread(new Runnable() {
166:                    public void run() {
167:                        JDialogOperator confDlg = new JDialogOperator(
168:                                util.CDFS_COMPLEX_OBJ_TTL);
169:                        new JButtonOperator(confDlg, util.YES_BTN)
170:                                .pushNoBlock();
171:                    }
172:                }).start();
173:                util.createDiagram(new Node[] { node },
174:                        NewDiagramWizardOperator.CLASS_DIAGRAM, DIA_NAME);
175:
176:                //checking diagram was opened
177:                DiagramOperator dia = new DiagramOperator(DIA_NAME);
178:
179:                //checking only required elements are present on diagram
180:                if (!util.diagramHasExactElements(new String[] { CLASS_NAME,
181:                        "IDGenerator", "OrderItem" }, dia)) {
182:                    fail("testCreateDiagramForInnerClasses verification failed");
183:                }
184:                //checking liks exist
185:                DiagramElementOperator idGen = new DiagramElementOperator(dia,
186:                        "IDGenerator");
187:                DiagramElementOperator item = new DiagramElementOperator(dia,
188:                        "OrderItem");
189:                DiagramElementOperator order = new DiagramElementOperator(dia,
190:                        CLASS_NAME);
191:                new LinkOperator(idGen, order, LinkTypes.CLASS);
192:                new LinkOperator(item, order, LinkTypes.CLASS);
193:
194:                //checking a node was created
195:                //TODO: add later
196:
197:            }
198:
199:            public void testCreateDiagramForInnerClassesNotDisplayed() {
200:                final String PATH_TO_CLASS = "Model|cdfs|";
201:                final String CLASS_NAME = "Order";
202:                final String DIA_NAME = "DGNOInner";
203:                util = new CDFSUtil(PROJECT_NAME, this );
204:
205:                Node node = util.getNode(PATH_TO_CLASS + CLASS_NAME);
206:
207:                new Thread(new Runnable() {
208:                    public void run() {
209:                        JDialogOperator confDlg = new JDialogOperator(
210:                                util.CDFS_COMPLEX_OBJ_TTL);
211:                        new JButtonOperator(confDlg, util.NO_BTN).pushNoBlock();
212:                    }
213:                }).start();
214:                util.createDiagram(new Node[] { node },
215:                        NewDiagramWizardOperator.CLASS_DIAGRAM, DIA_NAME);
216:
217:                //checking diagram was opened
218:                DiagramOperator dia = new DiagramOperator(DIA_NAME);
219:
220:                //checking only required elements are present on diagram
221:                if (!util.diagramHasExactElements(new String[] { CLASS_NAME },
222:                        dia)) {
223:                    fail("testCreateDiagramForInnerClassesNotDisplayed verification failed");
224:                }
225:
226:                //checking a node was created
227:                //TODO: add later
228:
229:            }
230:
231:            public void testCreateDiagramFromPackage() {
232:                final String PATH_TO_CLASSES = "Model|cdfs|";
233:                final String PATH_TO_PACKAGE = "Model|cdfs";
234:                final String[] packageElements = new String[] { "Address",
235:                        "Customer", "CustomerAccount", "GovermentCustomer",
236:                        "Order", "employees" };
237:                //final String[] packageElements = new String[]{"Address", "Customer", "CustomerAccount", "GovermentCustomer", "Order", "employees","int"};
238:                final String DIA_NAME = "DGPckgCLD";
239:                util = new CDFSUtil(PROJECT_NAME, this );
240:
241:                Node node = util.getNode(PATH_TO_PACKAGE);
242:
243:                new Thread(new Runnable() {
244:                    public void run() {
245:                        JDialogOperator confDlg = new JDialogOperator(
246:                                util.CDFS_COMPLEX_OBJ_TTL);
247:                        new JButtonOperator(confDlg, util.YES_BTN)
248:                                .pushNoBlock();
249:                    }
250:                }).start();
251:                util.createDiagram(new Node[] { node },
252:                        NewDiagramWizardOperator.CLASS_DIAGRAM, DIA_NAME);
253:
254:                //checking diagram was opened
255:                DiagramOperator dia = new DiagramOperator(DIA_NAME);
256:
257:                //checking only required elements are present on diagram
258:                if (!util.diagramHasExactElements(packageElements, dia)) {
259:                    fail("testCreateDiagramFromManyClasses verification failed");
260:                }
261:
262:                //checking links were created on the diagram
263:                DiagramElementOperator customer = new DiagramElementOperator(
264:                        dia, "Customer");
265:                DiagramElementOperator account = new DiagramElementOperator(
266:                        dia, "CustomerAccount");
267:                DiagramElementOperator govCustomer = new DiagramElementOperator(
268:                        dia, "GovermentCustomer");
269:                DiagramElementOperator address = new DiagramElementOperator(
270:                        dia, "Address");
271:                DiagramElementOperator order = new DiagramElementOperator(dia,
272:                        "Order");
273:                new LinkOperator(govCustomer, customer,
274:                        LinkTypes.GENERALIZATION);
275:                LinkOperator.waitForUndirectedLink(customer, account,
276:                        LinkTypes.AGGREGATION);
277:                LinkOperator.waitForUndirectedLink(customer, address,
278:                        LinkTypes.AGGREGATION);
279:                //LinkOperator.waitForUndirectedLink(customer, order, LinkTypes.ASSOCIATION);
280:
281:                //checking a node was created
282:                //TODO: add later
283:
284:            }
285:
286:            public void testCreateDiagramForPackageScopedElementsNotDisplayed() {
287:                final String PATH_TO_PKG = "Model|cdfs";
288:                final String PKG_NAME = "cdfs";
289:                final String DIA_NAME = "DGPkgNoScoped";
290:                util = new CDFSUtil(PROJECT_NAME, this );
291:
292:                Node node = util.getNode(PATH_TO_PKG);
293:
294:                new Thread(new Runnable() {
295:                    public void run() {
296:                        JDialogOperator confDlg = new JDialogOperator(
297:                                util.CDFS_COMPLEX_OBJ_TTL);
298:                        new JButtonOperator(confDlg, util.NO_BTN).pushNoBlock();
299:                    }
300:                }).start();
301:
302:                util.createDiagram(new Node[] { node },
303:                        NewDiagramWizardOperator.CLASS_DIAGRAM, DIA_NAME);
304:
305:                //checking diagram was opened
306:                DiagramOperator dia = new DiagramOperator(DIA_NAME);
307:
308:                //checking only required elements are present on diagram
309:                if (!util.diagramHasExactElements(new String[] { PKG_NAME },
310:                        dia)) {
311:                    fail("testCreateDiagramForPackageScopedElementsNotDisplayed verification failed");
312:                }
313:
314:                //checking a node was created
315:                //TODO: add later
316:
317:            }
318:
319:            public void testCreateClassDiagramFromAggregation() {
320:                final String PATH_TO_ASSOC = "Model|cdfs|Customer|Relationships|Associations|Aggregation";
321:                final String DIA_NAME = "DGASSOC";
322:                util = new CDFSUtil(PROJECT_NAME, this );
323:
324:                Node node = util.getNode(PATH_TO_ASSOC);
325:                JPopupMenuOperator jPopup = node.callPopup();
326:                if (util.isPopupMenuItemExist(jPopup, util.CDFS_MENU))
327:                    fail("Menu Item " + util.CDFS_MENU + " should not exist ");
328:                jPopup.pushKey(KeyEvent.VK_ESCAPE);
329:            }
330:
331:            public void testCreateClassDiagramFromGeneralization() {
332:                final String PATH_TO_GEN = "Model|cdfs|Customer|Relationships|Generalization";
333:                final String DIA_NAME = "DGGEN";
334:                util = new CDFSUtil(PROJECT_NAME, this );
335:
336:                Node node = util.getNode(PATH_TO_GEN);
337:                JPopupMenuOperator jPopup = node.callPopup();
338:                if (util.isPopupMenuItemExist(jPopup, util.CDFS_MENU))
339:                    fail("Menu Item " + util.CDFS_MENU + " should not exist ");
340:                jPopup.pushKey(KeyEvent.VK_ESCAPE);
341:
342:            }
343:
344:            public void testCreateClassDiagramFromOperation() {
345:                final String PATH_TO_OPER = "Model|cdfs|Customer|Operations|getAddresses";
346:                final String DIA_NAME = "DGOper";
347:                util = new CDFSUtil(PROJECT_NAME, this );
348:
349:                Node node = util.getNode(PATH_TO_OPER);
350:                node.performPopupActionNoBlock(util.CDFS_MENU);
351:
352:                NewDiagramWizardOperator wizard = new NewDiagramWizardOperator();
353:                if (wizard
354:                        .isDiagramAllowed(NewDiagramWizardOperator.CLASS_DIAGRAM)) {
355:                    fail("testCreateClassDiagramFromOperation failed because of KNOWN BUG: Class diagram should not be allowed to be created from Associations");
356:                }
357:
358:            }
359:
360:            protected void setUp() {
361:                if (isNotInitialized) {
362:                    Project.openProject(CDFSUtil.CDFS_XTEST_PROJECT_DIR + "/"
363:                            + JAVA_PROJECT_NAME);
364:                    UMLProject.createProject(PROJECT_NAME,
365:                            ProjectType.UML_JAVA_REVERSE_ENGINEERING,
366:                            new JavaProject(JAVA_PROJECT_NAME));
367:                    isNotInitialized = false;
368:                }
369:            }
370:
371:            public void tearDown() {
372:                closeAllModal();
373:                org.netbeans.test.umllib.util.Utils.tearDown();
374:                new EventTool().waitNoEvent(1000);
375:
376:                try {
377:                    DiagramOperator d = new DiagramOperator("DG");
378:                    d.closeAllDocuments();
379:                } catch (TimeoutExpiredException tee) {
380:                }
381:
382:                new EventTool().waitNoEvent(1000);
383:            }
384:
385:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.