Source Code Cross Referenced for SuiteUtilsTest.java in  » IDE-Netbeans » api » org » netbeans » modules » apisupport » project » ui » customizer » 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 » api » org.netbeans.modules.apisupport.project.ui.customizer 
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:
042:        package org.netbeans.modules.apisupport.project.ui.customizer;
043:
044:        import java.io.File;
045:        import org.netbeans.api.project.Project;
046:        import org.netbeans.api.project.ProjectManager;
047:        import org.netbeans.modules.apisupport.project.NbModuleProject;
048:        import org.netbeans.modules.apisupport.project.ProjectXMLManager;
049:        import org.netbeans.modules.apisupport.project.SuiteProvider;
050:        import org.netbeans.modules.apisupport.project.TestBase;
051:        import org.netbeans.modules.apisupport.project.Util;
052:        import org.netbeans.modules.apisupport.project.suite.SuiteProject;
053:        import org.netbeans.spi.project.SubprojectProvider;
054:        import org.netbeans.spi.project.support.ant.EditableProperties;
055:        import org.openide.filesystems.FileObject;
056:        import org.openide.filesystems.FileUtil;
057:        import org.openide.loaders.DataFolder;
058:
059:        /**
060:         * Tests {@link SuiteUtils}
061:         *
062:         * @author Martin Krauskopf
063:         */
064:        public class SuiteUtilsTest extends TestBase {
065:
066:            public SuiteUtilsTest(String name) {
067:                super (name);
068:            }
069:
070:            public void testAddModule() throws Exception {
071:                SuiteProject suite1 = generateSuite("suite1");
072:                NbModuleProject module1 = generateStandaloneModule("module1");
073:                SuiteProvider suiteProvider = module1.getLookup().lookup(
074:                        SuiteProvider.class);
075:                assertNull(
076:                        "module1 is standalone module - doesn't have valid SuiteProvider",
077:                        suiteProvider.getSuiteDirectory());
078:
079:                SuiteUtils.addModule(suite1, module1);
080:                SubprojectProvider spp = SuitePropertiesTest
081:                        .getSubProjectProvider(suite1);
082:                assertEquals("one module suite component", 1, spp
083:                        .getSubprojects().size());
084:                suiteProvider = module1.getLookup().lookup(SuiteProvider.class);
085:                assertNotNull(
086:                        "module1 became suite component - has valid SuiteProvider",
087:                        suiteProvider.getSuiteDirectory());
088:
089:                NbModuleProject module2 = generateStandaloneModule("module2");
090:                NbModuleProject module3 = generateStandaloneModule("module3");
091:                SuiteUtils.addModule(suite1, module2);
092:                SuiteUtils.addModule(suite1, module3);
093:
094:                assertEquals("three module suite components", 3, spp
095:                        .getSubprojects().size());
096:            }
097:
098:            public void testRemoveModuleFromSuite() throws Exception {
099:                SuiteProject suite1 = generateSuite("suite1");
100:                NbModuleProject module1 = TestBase.generateSuiteComponent(
101:                        suite1, "module1");
102:                SubprojectProvider spp = SuitePropertiesTest
103:                        .getSubProjectProvider(suite1);
104:                assertEquals("one module suite component", 1, spp
105:                        .getSubprojects().size());
106:
107:                SuiteProvider suiteProvider = module1.getLookup().lookup(
108:                        SuiteProvider.class);
109:                assertNotNull(
110:                        "module1 is suite component - has valid SuiteProvider",
111:                        suiteProvider.getSuiteDirectory());
112:
113:                assertNull("user.properites.file property doesn't exist",
114:                        module1.evaluator().getProperty("user.properties.file"));
115:                SuiteUtils.removeModuleFromSuite(module1);
116:                assertEquals(
117:                        "user.properties.file resolved for standalone module",
118:                        FileUtil.normalizeFile(
119:                                new File(getWorkDirPath(), "build.properties"))
120:                                .getAbsolutePath(), module1.evaluator()
121:                                .getProperty("user.properties.file"));
122:                spp = SuitePropertiesTest.getSubProjectProvider(suite1);
123:                assertEquals("doesn't have suite component", 0, spp
124:                        .getSubprojects().size());
125:                suiteProvider = module1.getLookup().lookup(SuiteProvider.class);
126:                assertNull(
127:                        "module1 became standalone module - doesn't have valid SuiteProvider",
128:                        suiteProvider.getSuiteDirectory());
129:            }
130:
131:            public void testRemoveModuleFromSuiteWithDependencies()
132:                    throws Exception {
133:                SuiteProject suite1 = generateSuite("suite1");
134:                NbModuleProject module1 = TestBase.generateSuiteComponent(
135:                        suite1, "module1");
136:                NbModuleProject module2 = TestBase.generateSuiteComponent(
137:                        suite1, "module2");
138:
139:                SubprojectProvider spp = SuitePropertiesTest
140:                        .getSubProjectProvider(suite1);
141:                assertEquals("two suite components", 2, spp.getSubprojects()
142:                        .size());
143:
144:                Util.addDependency(module2, module1);
145:                ProjectManager.getDefault().saveProject(module2);
146:                ProjectXMLManager pxm2 = new ProjectXMLManager(module2);
147:                assertEquals("one dependency", 1, pxm2.getDirectDependencies()
148:                        .size());
149:
150:                SuiteUtils.removeModuleFromSuiteWithDependencies(module1);
151:                spp = SuitePropertiesTest.getSubProjectProvider(suite1);
152:                assertEquals("one suite component", 1, spp.getSubprojects()
153:                        .size());
154:                SuiteProvider suiteProvider = module1.getLookup().lookup(
155:                        SuiteProvider.class);
156:                assertNull(
157:                        "module1 became standalone module - doesn't have valid SuiteProvider",
158:                        suiteProvider.getSuiteDirectory());
159:
160:                pxm2 = new ProjectXMLManager(module2);
161:                assertEquals("dependency was removed", 0, pxm2
162:                        .getDirectDependencies().size());
163:            }
164:
165:            /** Simulates scenario when deadlock occurs when playing with 64582. */
166:            public void testPreventDeadLockWhenAddThenRemoveModule_64582()
167:                    throws Exception {
168:                SuiteProject suite1 = generateSuite("suite1");
169:                NbModuleProject module1 = TestBase.generateStandaloneModule(
170:                        getWorkDir(), "module1");
171:                SuiteUtils.addModule(suite1, module1);
172:                SuiteUtils.removeModuleFromSuite(module1);
173:            }
174:
175:            public void testAddTwoModulesWithTheSameCNB_62819()
176:                    throws Exception {
177:                SuiteProject suite1 = generateSuite("suite1");
178:                NbModuleProject module1a = generateStandaloneModule("module1");
179:                File otherDir = new File(getWorkDir(), "otherDir");
180:                otherDir.mkdir();
181:                NbModuleProject module1b = TestBase.generateStandaloneModule(
182:                        otherDir, "module1");
183:
184:                SuiteUtils.addModule(suite1, module1a);
185:                SuiteUtils.addModule(suite1, module1b);
186:                SubprojectProvider spp = SuitePropertiesTest
187:                        .getSubProjectProvider(suite1);
188:                assertEquals(
189:                        "cannot add two suite components with the same cnb", 1,
190:                        spp.getSubprojects().size());
191:
192:                SuiteProvider suiteProvider = module1a.getLookup().lookup(
193:                        SuiteProvider.class);
194:                assertNotNull(
195:                        "module1a became suite component - has valid SuiteProvider",
196:                        suiteProvider.getSuiteDirectory());
197:                suiteProvider = module1b.getLookup()
198:                        .lookup(SuiteProvider.class);
199:                assertNull(
200:                        "module1b remains standalone - has not valid SuiteProvider",
201:                        suiteProvider.getSuiteDirectory());
202:            }
203:
204:            public void testGeneratingOfUniqAntProperty_62819()
205:                    throws Exception {
206:                SuiteProject suite1 = generateSuite("suite1");
207:                NbModuleProject module1 = generateStandaloneModule("module1");
208:                NbModuleProject module2 = generateStandaloneModule("module2");
209:
210:                SuiteUtils.addModule(suite1, module1);
211:                FileObject propsFO = suite1.getProjectDirectory()
212:                        .getFileObject("nbproject/project.properties");
213:                EditableProperties props = Util.loadProperties(propsFO);
214:                assertEquals("modules property",
215:                        "${project.org.example.module1}", props
216:                                .getProperty("modules"));
217:                assertEquals("module1 property", "../module1", props
218:                        .getProperty("project.org.example.module1"));
219:
220:                // user is free to do this, although in more sensible way
221:                assertEquals("module1 project removed (sanity check)",
222:                        "../module1", props
223:                                .remove("project.org.example.module1"));
224:                props.setProperty("modules", "${project.org.example.module2}");
225:                props.setProperty("project.org.example.module2", "../module1");
226:                Util.storeProperties(propsFO, props);
227:
228:                SuiteUtils.addModule(suite1, module2);
229:                SubprojectProvider spp = SuitePropertiesTest
230:                        .getSubProjectProvider(suite1);
231:                assertEquals("one module suite component", 2, spp
232:                        .getSubprojects().size());
233:
234:                SuiteProvider suiteProvider = module1.getLookup().lookup(
235:                        SuiteProvider.class);
236:                assertNotNull(
237:                        "module1 became suite component - has valid SuiteProvider",
238:                        suiteProvider.getSuiteDirectory());
239:                suiteProvider = module2.getLookup().lookup(SuiteProvider.class);
240:                assertNotNull(
241:                        "module2 became suite component - has valid SuiteProvider",
242:                        suiteProvider.getSuiteDirectory());
243:            }
244:
245:            public void testIsSuite() throws Exception {
246:                SuiteProject suite = generateSuite("suite");
247:                generateSuiteComponent(suite, "suiteComponent");
248:                generateStandaloneModuleDirectory(getWorkDir(), "module");
249:                File suiteF = new File(getWorkDir(), "suite");
250:                assertTrue(suite + " is a suite", SuiteUtils.isSuite(suiteF));
251:                assertFalse(suite + " is not a suite", SuiteUtils
252:                        .isSuite(new File(suiteF, "suiteComponent")));
253:                assertFalse(suite + " is not a suite", SuiteUtils
254:                        .isSuite(new File(getWorkDir(), "module")));
255:            }
256:
257:            public void testFindSuiteNotSuiteProject80786() throws Exception {
258:                // Check that SuiteUtils.findSuite gracefully ignores a project which is not a suite project.
259:                SuiteProject suite = generateSuite("suite");
260:                NbModuleProject module = generateSuiteComponent(suite,
261:                        "suiteComponent");
262:                FileObject copy = suite.getProjectDirectory().getParent()
263:                        .createFolder("copy");
264:                DataFolder.findFolder(module.getProjectDirectory()).copy(
265:                        DataFolder.findFolder(copy));
266:                generateStandaloneModuleDirectory(getWorkDir(), "copy");
267:                Project modulecopy = ProjectManager.getDefault().findProject(
268:                        copy.getFileObject("suiteComponent"));
269:                assertNotNull(modulecopy);
270:                assertNull(SuiteUtils.findSuite(modulecopy));
271:            }
272:
273:        }
w_w__w___._j___av__a2___s_._c___o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.