Source Code Cross Referenced for DesignDocumentTest.java in  » IDE-Netbeans » vmd.analyzer » org » netbeans » modules » vmd » api » model » 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 » vmd.analyzer » org.netbeans.modules.vmd.api.model 
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-2006 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:        package org.netbeans.modules.vmd.api.model;
042:
043:        import java.util.Collection;
044:        import java.util.HashSet;
045:
046:        import junit.framework.Test;
047:        import junit.framework.TestCase;
048:        import junit.framework.TestSuite;
049:
050:        import org.netbeans.modules.vmd.api.model.descriptors.FirstCD;
051:        import org.netbeans.modules.vmd.api.model.descriptors.SecondCD;
052:        import org.netbeans.modules.vmd.api.model.utils.ModelTestUtil;
053:
054:        /**
055:         *
056:         * @author Karol Harezlak
057:         */
058:        public class DesignDocumentTest extends TestCase {
059:
060:            private DesignDocument document;
061:
062:            public DesignDocumentTest(String testName) {
063:                super (testName);
064:            }
065:
066:            protected void setUp() throws Exception {
067:                document = ModelTestUtil.createTestDesignDocument();
068:            }
069:
070:            protected void tearDown() throws Exception {
071:            }
072:
073:            public static Test suite() {
074:                TestSuite suite = new TestSuite(DesignDocumentTest.class);
075:
076:                return suite;
077:            }
078:
079:            /**
080:             * Test of getDescriptorRegistry method, of class org.netbeans.modules.vmd.api.model.DesignDocument.
081:             */
082:            public void testGetDescriptorRegistry() {
083:                System.out.println("getDescriptorRegistry"); // NOI18N
084:
085:                final DescriptorRegistry result = document
086:                        .getDescriptorRegistry();
087:
088:                assertNotNull(result);
089:            }
090:
091:            /**
092:             * Test of getListenerManager method, of class org.netbeans.modules.vmd.api.model.DesignDocument.
093:             */
094:            public void testGetListenerManager() {
095:                System.out.println("getListenerManager"); // NOI18N
096:
097:                ListenerManager listenerManager = document.getListenerManager();
098:                assertNotNull(listenerManager);
099:                DesignListener listener = new DesignListener() {
100:                    public void designChanged(DesignEvent event) {
101:                        //TODO Fill it with code
102:                    }
103:                };
104:
105:                assertNotNull(listenerManager);
106:
107:                //Additional test
108:                //TODO Expand this part of some real situatuon with listeneres, documents and components
109:                listenerManager.addDesignListener(listener,
110:                        new DesignEventFilter());
111:                listenerManager.removeDesignListener(listener);
112:
113:            }
114:
115:            /**
116:             * Test of getTransactionManager method, of class org.netbeans.modules.vmd.api.model.DesignDocument.
117:             */
118:            public void testGetTransactionManager() {
119:                System.out.println("getTransactionManager"); // NOI18N1
120:
121:                final long compID = 0;
122:                TransactionManager result = document.getTransactionManager();
123:                assertNotNull(result);
124:                result.writeAccess(new Runnable() {
125:                    public void run() {
126:                        document.createComponent(FirstCD.TYPEID_CLASS);
127:                    }
128:                });
129:                result.readAccess(new Runnable() {
130:                    public void run() {
131:                        document.getComponentByUID(compID);
132:                    }
133:                });
134:            }
135:
136:            /**
137:             * Test of getDeleteComponent method, of class org.netbeans.modules.vmd.api.model.DesignDocument.
138:             */
139:
140:            @SuppressWarnings("deprecation")
141:            // NOI18N
142:            public void testDeleteComponent() {
143:                //TODO Right now there is no way to tested if document is deleted or not. This test only check if there is any exception rise when component is deleted
144:                System.out.println("deleteComponent"); // NOI18N
145:
146:                document.getTransactionManager().writeAccess(new Runnable() {
147:                    public void run() {
148:                        //createComponent
149:                        DesignComponent comp = document
150:                                .createComponent(FirstCD.TYPEID_CLASS);
151:                        DesignComponent comp2 = document
152:                                .createComponent(SecondCD.TYPEID_CLASS);
153:                        document.setRootComponent(comp);
154:                        comp.addComponent(comp2);
155:
156:                        document.deleteComponent(comp2);
157:                    }
158:                });
159:            }
160:
161:            /**
162:             * Test of getSelectedComponents method, of class org.netbeans.modules.vmd.api.model.DesignDocument.
163:             */
164:            public void testGetSetSelectedComponents() {
165:                System.out
166:                        .println("getSetSelectedComponents, setSelectedComponents, getSelectionSourceID"); // NOI18N
167:
168:                document.getTransactionManager().writeAccess(new Runnable() {
169:                    public void run() {
170:                        String sourceID = "TestSorceId"; // NOI18N
171:                        DesignComponent comp1 = document
172:                                .createComponent(FirstCD.TYPEID_CLASS);
173:                        DesignComponent comp2 = document
174:                                .createComponent(SecondCD.TYPEID_CLASS);
175:
176:                        Collection<DesignComponent> selectedComponents = new HashSet<DesignComponent>();
177:                        selectedComponents.add(comp1);
178:                        selectedComponents.add(comp2);
179:                        document.setSelectedComponents(sourceID,
180:                                selectedComponents); // NOI18N
181:                        for (DesignComponent comp : selectedComponents) {
182:                            boolean result = document.getSelectedComponents()
183:                                    .contains(comp);
184:                            assertTrue(result);
185:                        }
186:                        String result = document.getSelectionSourceID();
187:                        String expResult = sourceID;
188:                        assertEquals(expResult, result);
189:                    }
190:                });
191:            }
192:
193:            /**
194:             * Complex test (addDocument, addComponent, getRootComponent, setRootComponent, createComponent, of class org.netbeans.modules.vmd.api.model.DesignDocument.
195:             */
196:            public void testComplex() {
197:                System.out
198:                        .println("addDocument, addComponent, getRootComponent, setRootComponent,"
199:                                + //NOI18N
200:                                " createComponent,getComponentByID"
201:                                + "getComponentByID"); // NOI18N
202:
203:                final DesignDocument instance = ModelTestUtil
204:                        .createTestDesignDocument(ModelTestUtil.PROJECT_ID);
205:
206:                instance.getTransactionManager().writeAccess(new Runnable() {
207:                    public void run() {
208:                        DesignComponent comp1 = instance
209:                                .createComponent(FirstCD.TYPEID_CLASS);
210:                        DesignComponent comp2 = instance
211:                                .createComponent(SecondCD.TYPEID_CLASS);
212:
213:                        //setRooComponent, addComponent
214:                        instance.setRootComponent(comp1);
215:                        comp1.addComponent(comp2);
216:                        //getComponentByID
217:                        DesignComponent resultComp2ByID = instance
218:                                .getComponentByUID(comp2.getComponentID());
219:                        DesignComponent expComp2 = comp2;
220:                        assertEquals(expComp2, resultComp2ByID);
221:                        //setRootComponent getRootComponent
222:                        DesignComponent expGetComp = comp1;
223:                        DesignComponent resultGetComp = instance
224:                                .getRootComponent();
225:                        assertEquals(expGetComp, resultGetComp);
226:                        // writeProperty to Component
227:                        comp1.writeProperty(FirstCD.PROPERTY_REFERENCE,
228:                                PropertyValue.createComponentReference(comp2));
229:                    }
230:                });
231:            }
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.