Source Code Cross Referenced for ClassPathProviderImplTest.java in  » IDE-Netbeans » api » org » netbeans » modules » apisupport » project » queries » 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.queries 
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.queries;
043:
044:        import java.io.File;
045:        import java.io.FileOutputStream;
046:        import java.io.OutputStream;
047:        import java.util.Arrays;
048:        import java.util.Collections;
049:        import java.util.HashSet;
050:        import java.util.Properties;
051:        import java.util.Set;
052:        import java.util.TreeSet;
053:        import org.netbeans.api.java.classpath.ClassPath;
054:        import org.netbeans.api.project.FileOwnerQuery;
055:        import org.netbeans.api.project.Project;
056:        import org.netbeans.api.project.ProjectManager;
057:        import org.netbeans.modules.apisupport.project.NbModuleProject;
058:        import org.netbeans.modules.apisupport.project.NbModuleProjectType;
059:        import org.netbeans.modules.apisupport.project.ProjectXMLManager;
060:        import org.netbeans.modules.apisupport.project.TestBase;
061:        import org.netbeans.modules.apisupport.project.Util;
062:        import org.netbeans.modules.apisupport.project.suite.SuiteProject;
063:        import org.netbeans.modules.apisupport.project.ui.customizer.ModuleDependency;
064:        import org.netbeans.spi.project.support.ant.AntProjectHelper;
065:        import org.netbeans.spi.project.support.ant.EditableProperties;
066:        import org.netbeans.spi.project.support.ant.PropertyUtils;
067:        import org.openide.filesystems.FileObject;
068:        import org.openide.filesystems.FileUtil;
069:        import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
070:        import org.openide.xml.XMLUtil;
071:        import org.w3c.dom.Document;
072:        import org.w3c.dom.Element;
073:        import org.w3c.dom.NodeList;
074:        import org.xml.sax.InputSource;
075:
076:        // XXX test GPR usage
077:
078:        /**
079:         * Test functionality of {@link ClassPathProviderImpl}.
080:         * @author Jesse Glick
081:         */
082:        public class ClassPathProviderImplTest extends TestBase {
083:
084:            public ClassPathProviderImplTest(String name) {
085:                super (name);
086:            }
087:
088:            private File copyOfSuite2;
089:            private FileObject copyOfMiscDir;
090:            private NbModuleProject copyOfMiscProject;
091:            private ProjectXMLManager copyOfMiscXMLManager;
092:
093:            protected @Override
094:            void setUp() throws Exception {
095:                super .setUp();
096:                copyOfSuite2 = copyFolder(resolveEEPFile("/suite2"));
097:                File miscF = new File(copyOfSuite2, "misc-project");
098:                copyOfMiscDir = FileUtil.toFileObject(miscF);
099:                copyOfMiscProject = (NbModuleProject) ProjectManager
100:                        .getDefault().findProject(copyOfMiscDir);
101:                assertNotNull(copyOfMiscProject);
102:                copyOfMiscXMLManager = new ProjectXMLManager(copyOfMiscProject);
103:                // make sure its platform-private.properties is correct:
104:                Project copyOfSuite2P = ProjectManager.getDefault()
105:                        .findProject(FileUtil.toFileObject(copyOfSuite2));
106:                ((SuiteProject) copyOfSuite2P).open();
107:            }
108:
109:            private String urlForJar(String path) {
110:                return Util.urlForJar(
111:                        PropertyUtils.resolveFile(nbRootFile(), path))
112:                        .toExternalForm();
113:            }
114:
115:            private String urlForDir(String path) {
116:                return Util.urlForDir(file(path)).toExternalForm();
117:            }
118:
119:            private Set<String> urlsOfCp(ClassPath cp) {
120:                Set<String> s = new TreeSet<String>();
121:                for (ClassPath.Entry entry : cp.entries()) {
122:                    s.add(entry.getURL().toExternalForm());
123:                }
124:                return s;
125:            }
126:
127:            private static final Set<String> TESTLIBS = new HashSet<String>(
128:                    Arrays.asList("junit.jar", "nbjunit.jar",
129:                            "nbjunit-ide.jar", "insanelib.jar",
130:                            "org-netbeans-modules-nbjunit.jar",
131:                            "org-netbeans-modules-nbjunit-ide.jar"));
132:
133:            private Set<String> urlsOfCp4Tests(ClassPath cp) {
134:                Set<String> s = new TreeSet<String>();
135:                for (ClassPath.Entry entry : cp.entries()) {
136:                    String url = entry.getURL().toExternalForm();
137:                    if (url.indexOf("$%7B") != -1) {
138:                        // Unevaluated Ant reference (after octet escaping), so skip.
139:                        continue;
140:                    }
141:                    String simplifiedJarName = url.replaceFirst(
142:                            "^.+/([^/]+?)[0-9_.-]*\\.jar!/$", "$1.jar");
143:                    if (TESTLIBS.contains(simplifiedJarName)) {
144:                        s.add(simplifiedJarName);
145:                    } else {
146:                        s.add(url);
147:                    }
148:                }
149:                return s;
150:            }
151:
152:            public void testMainClasspath() throws Exception {
153:                FileObject src = nbRoot().getFileObject(
154:                        "o.apache.tools.ant.module/src");
155:                assertNotNull("have o.apache.tools.ant.module/src", src);
156:                ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
157:                assertNotNull("have a COMPILE classpath", cp);
158:                Set<String> expectedRoots = new TreeSet<String>();
159:                // Keep up to date w/ changes in o.apache.tools.ant.module/nbproject/project.{xml,properties}:
160:                // ${module.classpath}:
161:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
162:                        + TestBase.CLUSTER_IDE
163:                        + "/modules/org-netbeans-api-xml.jar"));
164:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
165:                        + TestBase.CLUSTER_PLATFORM
166:                        + "/core/org-openide-filesystems.jar"));
167:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
168:                        + TestBase.CLUSTER_PLATFORM
169:                        + "/lib/org-openide-util.jar"));
170:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
171:                        + TestBase.CLUSTER_PLATFORM
172:                        + "/lib/org-openide-modules.jar"));
173:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
174:                        + TestBase.CLUSTER_PLATFORM
175:                        + "/modules/org-openide-nodes.jar"));
176:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
177:                        + TestBase.CLUSTER_PLATFORM
178:                        + "/modules/org-openide-awt.jar"));
179:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
180:                        + TestBase.CLUSTER_PLATFORM
181:                        + "/modules/org-openide-dialogs.jar"));
182:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
183:                        + TestBase.CLUSTER_PLATFORM
184:                        + "/modules/org-openide-windows.jar"));
185:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
186:                        + TestBase.CLUSTER_PLATFORM
187:                        + "/modules/org-openide-text.jar"));
188:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
189:                        + TestBase.CLUSTER_PLATFORM
190:                        + "/modules/org-openide-actions.jar"));
191:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
192:                        + TestBase.CLUSTER_PLATFORM
193:                        + "/modules/org-openide-execution.jar"));
194:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
195:                        + TestBase.CLUSTER_PLATFORM
196:                        + "/modules/org-openide-io.jar"));
197:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
198:                        + TestBase.CLUSTER_PLATFORM
199:                        + "/modules/org-openide-loaders.jar"));
200:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
201:                        + TestBase.CLUSTER_PLATFORM
202:                        + "/modules/org-openide-explorer.jar"));
203:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
204:                        + TestBase.CLUSTER_IDE
205:                        + "/modules/org-netbeans-spi-navigator.jar"));
206:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
207:                        + TestBase.CLUSTER_PLATFORM
208:                        + "/modules/org-jdesktop-layout.jar"));
209:                expectedRoots
210:                        .add(urlForJar("o.jdesktop.layout/external/swing-layout-1.0.3.jar"));
211:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
212:                        + TestBase.CLUSTER_PLATFORM
213:                        + "/modules/org-netbeans-modules-options-api.jar"));
214:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
215:                        + TestBase.CLUSTER_PLATFORM
216:                        + "/modules/org-netbeans-api-progress.jar"));
217:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
218:                        + TestBase.CLUSTER_IDE
219:                        + "/modules/org-netbeans-modules-projectapi.jar"));
220:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
221:                        + TestBase.CLUSTER_IDE
222:                        + "/modules/org-netbeans-modules-projectuiapi.jar"));
223:                assertEquals(
224:                        "right COMPILE classpath for o.apache.tools.ant.module/src",
225:                        expectedRoots.toString(), urlsOfCp(cp).toString());
226:                cp = ClassPath.getClassPath(src, ClassPath.EXECUTE);
227:                assertNotNull("have an EXECUTE classpath", cp);
228:                // #48099: need to include build/classes here too
229:                expectedRoots
230:                        .add(urlForDir("o.apache.tools.ant.module/build/classes"));
231:                // And #70206: transitive runtime deps too.
232:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
233:                        + TestBase.CLUSTER_PLATFORM
234:                        + "/modules/org-netbeans-modules-queries.jar"));
235:                expectedRoots
236:                        .add(urlForJar("nbbuild/netbeans/"
237:                                + TestBase.CLUSTER_PLATFORM
238:                                + "/modules/org-netbeans-modules-editor-mimelookup.jar"));
239:                assertEquals("right EXECUTE classpath (COMPILE plus classes)",
240:                        expectedRoots.toString(), urlsOfCp(cp).toString());
241:                cp = ClassPath.getClassPath(src, ClassPath.SOURCE);
242:                assertNotNull("have a SOURCE classpath", cp);
243:                assertEquals("right SOURCE classpath", Collections
244:                        .singleton(src), new HashSet<FileObject>(Arrays
245:                        .asList(cp.getRoots())));
246:                // XXX test BOOT
247:            }
248:
249:            public void testMainClasspathExternalModules() throws Exception {
250:                FileObject src = resolveEEP("suite3/dummy-project/src");
251:                assertNotNull("have .../dummy-project/src", src);
252:                ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
253:                assertNotNull("have a COMPILE classpath", cp);
254:                Set<String> expectedRoots = new TreeSet<String>();
255:                expectedRoots
256:                        .add(urlForJar(resolveEEPPath("/suite3/nbplatform/random/modules/random.jar")));
257:                expectedRoots
258:                        .add(urlForJar(resolveEEPPath("/suite3/nbplatform/random/modules/ext/stuff.jar")));
259:                assertEquals("right COMPILE classpath", expectedRoots,
260:                        urlsOfCp(cp));
261:            }
262:
263:            /**
264:             * #52354: interpret <class-path-extension>s both in myself and in dependent modules.
265:             */
266:            /* XXX uses obsolete module:
267:            public void testClasspathExtensions() throws Exception {
268:                // java/javacore has its own <class-path-extension> and uses others from dependents.
269:                FileObject src = nbCVSRoot().getFileObject("java/javacore/src");
270:                assertNotNull("have java/javacore/src", src);
271:                ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
272:                assertNotNull("have a COMPILE classpath", cp);
273:                Set<String> expectedRoots = new TreeSet<String>();
274:                // Keep up to date w/ changes in java/javacore/nbproject/project.xml:
275:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-api-java.jar"));
276:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-classfile.jar"));
277:                expectedRoots.add(urlForJar("nbbuild/netbeans/extra/modules/org-netbeans-jmi-javamodel.jar"));
278:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/javax-jmi-reflect.jar"));
279:                expectedRoots.add(urlForJar("mdr/external/jmi.jar"));
280:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/javax-jmi-model.jar"));
281:                expectedRoots.add(urlForJar("mdr/external/mof.jar"));
282:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-api-mdr.jar"));
283:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-projectapi.jar"));
284:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-api-progress.jar"));
285:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-mdr.jar"));
286:                expectedRoots.add(urlForJar("mdr/dist/mdr.jar"));
287:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-jmiutils.jar"));
288:                expectedRoots.add(urlForJar("mdr/jmiutils/dist/jmiutils.jar"));
289:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"));
290:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/org-openide-filesystems.jar"));
291:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
292:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-modules.jar"));
293:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-nodes.jar"));
294:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-awt.jar"));
295:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-dialogs.jar"));
296:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-windows.jar"));
297:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-text.jar"));
298:                expectedRoots.add(urlForJar("java/parser/dist/java-parser.jar"));
299:                assertEquals("right COMPILE classpath", expectedRoots.toString(), urlsOfCp(cp).toString());
300:                assertTrue("#76341: EXECUTE classpath also has extension",
301:                        urlsOfCp(ClassPath.getClassPath(src, ClassPath.EXECUTE)).contains(urlForJar("java/parser/dist/java-parser.jar")));
302:            }
303:             */
304:
305:            /* XXX would need to include ${ant.core.lib}, never mind:
306:            public void testExtraCompilationUnits() throws Exception {
307:                FileObject srcbridge = nbRoot().getFileObject("o.apache.tools.ant.module/src-bridge");
308:                assertNotNull("have o.apache.tools.ant.module/src-bridge", srcbridge);
309:                ClassPath cp = ClassPath.getClassPath(srcbridge, ClassPath.COMPILE);
310:                assertNotNull("have a COMPILE classpath", cp);
311:                Set<String> expectedRoots = new TreeSet<String>();
312:                // Keep up to date w/ changes in o.apache.tools.ant.module/nbproject/project.{xml,properties}:
313:                expectedRoots.add(urlForDir("o.apache.tools.ant.module/build/classes"));
314:                expectedRoots.add(urlForJar("o.apache.tools.ant.module/external/lib/ant.jar"));
315:                // ${module.classpath}:
316:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-api-xml.jar"));
317:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/org-openide-filesystems.jar"));
318:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
319:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-modules.jar"));
320:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-nodes.jar"));
321:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-awt.jar"));
322:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-dialogs.jar"));
323:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-windows.jar"));
324:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-text.jar"));
325:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-actions.jar"));
326:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-execution.jar"));
327:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-io.jar"));
328:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"));
329:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-explorer.jar"));
330:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-spi-navigator.jar"));
331:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-jdesktop-layout.jar"));
332:                expectedRoots.add(urlForJar("o.jdesktop.layout/external/swing-layout-1.0.3.jar"));
333:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-options-api.jar"));
334:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-api-progress.jar"));
335:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-projectapi.jar"));
336:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-projectuiapi.jar"));
337:                assertEquals("right COMPILE classpath for o.apache.tools.ant.module/src-bridge", expectedRoots.toString(), urlsOfCp(cp).toString());
338:                cp = ClassPath.getClassPath(srcbridge, ClassPath.EXECUTE);
339:                assertNotNull("have an EXECUTE classpath", cp);
340:                expectedRoots.add(urlForDir("o.apache.tools.ant.module/build/bridge-classes"));
341:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_JAVA + "/ant/nblib/bridge.jar"));
342:                assertEquals("right EXECUTE classpath (COMPILE plus classes plus JAR)", expectedRoots, urlsOfCp(cp));
343:                cp = ClassPath.getClassPath(srcbridge, ClassPath.SOURCE);
344:                assertNotNull("have a SOURCE classpath", cp);
345:                assertEquals("right SOURCE classpath", Collections.singleton(srcbridge), new HashSet<FileObject>(Arrays.asList(cp.getRoots())));
346:                // XXX test BOOT
347:            }
348:             */
349:
350:            /* XXX failing, should be rewritten to use generated module:
351:            public void testUnitTestClasspaths() throws Exception {
352:                FileObject src = nbCVSRoot().getFileObject("autoupdate/test/unit/src");
353:                assertNotNull("have autoupdate/test/unit/src", src);
354:                ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
355:                assertNotNull("have a COMPILE classpath", cp);
356:                Set<String> expectedRoots = new TreeSet<String>();
357:                // Keep up to date w/ changes in autoupdate/nbproject/project.{xml,properties}:
358:                // module.classpath:
359:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/org-openide-filesystems.jar"));
360:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
361:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-modules.jar"));
362:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/boot.jar"));
363:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-nodes.jar"));
364:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-explorer.jar"));
365:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-awt.jar"));
366:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-dialogs.jar"));
367:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-options.jar"));
368:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-windows.jar"));
369:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-actions.jar"));
370:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"));
371:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-core.jar"));
372:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-api-progress.jar"));
373:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/core.jar"));
374:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-editor-mimelookup.jar"));
375:                // cp.extra:
376:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/ext/updater.jar"));
377:                // module JAR:
378:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-autoupdate.jar"));
379:                expectedRoots.add("junit.jar");
380:                expectedRoots.add("nbjunit.jar");
381:                expectedRoots.add("nbjunit-ide.jar");
382:                expectedRoots.add("insanelib.jar");
383:                // recursive dependencies
384:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-swing-plaf.jar"));
385:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-text.jar"));
386:                
387:                assertSets("right COMPILE classpath", expectedRoots, urlsOfCp4Tests(cp));
388:                
389:                cp = ClassPath.getClassPath(src, ClassPath.EXECUTE);
390:                assertNotNull("have an EXECUTE classpath", cp);
391:                expectedRoots.add(urlForDir("autoupdate/build/test/unit/classes"));
392:                // test.unit.run.cp.extra:
393:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/boot.jar"));
394:                assertSets("right EXECUTE classpath (COMPILE plus classes)", expectedRoots, urlsOfCp4Tests(cp));
395:                cp = ClassPath.getClassPath(src, ClassPath.SOURCE);
396:                assertNotNull("have a SOURCE classpath", cp);
397:                assertEquals("right SOURCE classpath", Collections.singleton(src), new HashSet(Arrays.asList(cp.getRoots())));
398:                // XXX test BOOT
399:            }
400:             */
401:
402:            public void testUnitTestClasspathsExternalModules()
403:                    throws Exception {
404:                FileObject src = resolveEEP("suite1/support/lib-project/test/unit/src");
405:                ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
406:                assertNotNull("have a COMPILE classpath", cp);
407:                Set<String> expectedRoots = new TreeSet<String>();
408:                expectedRoots
409:                        .add(urlForJar(resolveEEPPath("/suite1/build/cluster/modules/org-netbeans-examples-modules-lib.jar")));
410:                expectedRoots.add("junit.jar");
411:                expectedRoots.add("nbjunit.jar");
412:                expectedRoots.add("insanelib.jar");
413:                expectedRoots.add("org-netbeans-modules-nbjunit.jar");
414:                expectedRoots.add("org-netbeans-modules-nbjunit-ide.jar");
415:                assertEquals("right COMPILE classpath", expectedRoots
416:                        .toString(), urlsOfCp4Tests(cp).toString());
417:                // Now test in suite3, where there is no source...
418:                src = resolveEEP("suite3/dummy-project/test/unit/src");
419:                cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
420:                assertNotNull("have a COMPILE classpath", cp);
421:                expectedRoots = new TreeSet<String>();
422:                expectedRoots
423:                        .add(urlForJar(resolveEEPPath("/suite3/dummy-project/build/cluster/modules/org-netbeans-examples-modules-dummy.jar")));
424:                expectedRoots
425:                        .add(urlForJar(resolveEEPPath("/suite3/nbplatform/random/modules/random.jar")));
426:                expectedRoots
427:                        .add(urlForJar(resolveEEPPath("/suite3/nbplatform/random/modules/ext/stuff.jar")));
428:                expectedRoots.add("junit.jar");
429:                expectedRoots.add("nbjunit.jar");
430:                expectedRoots.add("insanelib.jar");
431:                expectedRoots.add("org-netbeans-modules-nbjunit.jar");
432:                expectedRoots.add("org-netbeans-modules-nbjunit-ide.jar");
433:                assertEquals("right COMPILE classpath", expectedRoots
434:                        .toString(), urlsOfCp4Tests(cp).toString());
435:
436:                // test dependencies
437:                expectedRoots.clear();
438:                src = resolveEEP("/suite4/module2/test/unit/src");
439:                expectedRoots
440:                        .add(urlForJar(resolveEEPPath("/suite4/build/testdist/unit/cluster/module1/tests.jar")));
441:                expectedRoots
442:                        .add(urlForJar(resolveEEPPath("/suite4/build/cluster/modules/module1.jar")));
443:                expectedRoots
444:                        .add(urlForJar(resolveEEPPath("/suite4/build/cluster/modules/module2.jar")));
445:                expectedRoots.add("junit.jar");
446:                expectedRoots.add("nbjunit.jar");
447:                expectedRoots.add("insanelib.jar");
448:                expectedRoots.add("org-netbeans-modules-nbjunit.jar");
449:                expectedRoots.add("org-netbeans-modules-nbjunit-ide.jar");
450:                cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
451:                FileObject roots[] = cp.getRoots();
452:                assertEquals("right compileclasspath", expectedRoots,
453:                        urlsOfCp4Tests(cp));
454:            }
455:
456:            /* XXX failing, should be rewritten to use generated module:
457:            public void testQaFunctionalTestClasspath() throws Exception {
458:                FileObject qaftsrc = nbCVSRoot().getFileObject("performance/test/qa-functional/src");
459:                if (qaftsrc == null) {
460:                    System.err.println("Skipping testQaFunctionalTestClasspath since performance not checked out");
461:                    return;
462:                }
463:                ClassPath cp = ClassPath.getClassPath(qaftsrc, ClassPath.COMPILE);
464:                assertNotNull("have a COMPILE classpath", cp);
465:                Set<String> expectedRoots = new TreeSet<String>();
466:                // Keep up to date w/ changes in /space/src/nb_all/performance/nbproject/project.properties
467:                // & nbbuild/templates/xtest-qa-functional.xml:
468:                expectedRoots.add("junit.jar");
469:                expectedRoots.add("nbjunit.jar");
470:                expectedRoots.add("nbjunit-ide.jar");
471:                expectedRoots.add("insanelib.jar");
472:                // jemmy.and.jelly.path:
473:                expectedRoots.add(urlForJar("jemmy/builds/jemmy.jar"));
474:                expectedRoots.add(urlForJar("jellytools/builds/jelly2-nb.jar"));
475:                // test.qa-functional.cp.extra currently empty
476:                assertEquals("right COMPILE classpath", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
477:                cp = ClassPath.getClassPath(qaftsrc, ClassPath.EXECUTE);
478:                assertNotNull("have an EXECUTE classpath", cp);
479:                expectedRoots.add(urlForDir("performance/build/test/qa-functional/classes"));
480:                assertEquals("right EXECUTE classpath (COMPILE plus classes)", expectedRoots, urlsOfCp4Tests(cp));
481:                cp = ClassPath.getClassPath(qaftsrc, ClassPath.SOURCE);
482:                assertNotNull("have a SOURCE classpath", cp);
483:                assertEquals("right SOURCE classpath", Collections.singleton(qaftsrc), new HashSet<FileObject>(Arrays.asList(cp.getRoots())));
484:                // XXX test BOOT
485:            }
486:             */
487:
488:            public void testQaFunctionalTestClasspathExternalModules()
489:                    throws Exception {
490:                FileObject qaftsrc = resolveEEP("suite1/action-project/test/qa-functional/src");
491:                assertNotNull("have action-project/test/qa-functional/src",
492:                        qaftsrc);
493:                ClassPath cp = ClassPath.getClassPath(qaftsrc,
494:                        ClassPath.COMPILE);
495:                assertNotNull("have a COMPILE classpath", cp);
496:                Set<String> expectedRoots = new TreeSet<String>();
497:                expectedRoots.add("junit.jar");
498:                expectedRoots.add("nbjunit.jar");
499:                expectedRoots.add("nbjunit-ide.jar");
500:                expectedRoots.add("insanelib.jar");
501:                expectedRoots.add(urlForJar("jemmy/builds/jemmy.jar"));
502:                expectedRoots.add(urlForJar("jellytools/builds/jelly2-nb.jar"));
503:                expectedRoots.add("org-netbeans-modules-nbjunit.jar");
504:                expectedRoots.add("org-netbeans-modules-nbjunit-ide.jar");
505:                assertEquals("right COMPILE classpath", expectedRoots
506:                        .toString(), urlsOfCp4Tests(cp).toString());
507:                TestBase.TestPCL l = new TestBase.TestPCL();
508:                cp.addPropertyChangeListener(l);
509:                NbModuleProject p = (NbModuleProject) FileOwnerQuery
510:                        .getOwner(qaftsrc);
511:                EditableProperties ep = p.getHelper().getProperties(
512:                        AntProjectHelper.PRIVATE_PROPERTIES_PATH);
513:                File added = file("xtest/lib/xtest.jar");
514:                ep.setProperty("test.qa-functional.cp.extra", added
515:                        .getAbsolutePath());
516:                p.getHelper().putProperties(
517:                        AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
518:                // do not save! just want to test change, not actually make it...
519:                assertTrue("got changes", l.changed
520:                        .contains(ClassPath.PROP_ROOTS));
521:                expectedRoots.add(urlForJar("xtest/lib/xtest.jar"));
522:                assertEquals("right COMPILE classpath after added to .extra",
523:                        expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
524:            }
525:
526:            /* XXX failing, but what was it supposed to be testing? I cannot decipher this. -jglick
527:            public void testBuildClassPath () throws Exception {
528:                FileObject srcRoot = nbCVSRoot().getFileObject("ant/project/src/");
529:                assertNotNull("have ant/project/src",srcRoot);
530:                ClassPath ccp = ClassPath.getClassPath(srcRoot, ClassPath.COMPILE);
531:                assertNotNull("No compile ClassPath for sources",ccp);
532:                FileObject  buildClasses = nbCVSRoot().getFileObject("ant/project/build/classes/");
533:                assertNotNull("have ant/project/build/classes",buildClasses);
534:                        
535:                assertNull ("ClassPath.SOURCE for build must be null",ClassPath.getClassPath(buildClasses, ClassPath.SOURCE));
536:                assertNull ("ClassPath.COMPILE for build must be null",ClassPath.getClassPath(buildClasses, ClassPath.COMPILE));
537:                ClassPath cp = ClassPath.getClassPath(buildClasses, ClassPath.EXECUTE);
538:                assertNotNull("ClassPath.EXECUTE for build must NOT be null",cp);
539:                ClassPath expectedCp = ClassPathSupport.createProxyClassPath(new ClassPath[] {
540:                        ClassPathSupport.createClassPath(new FileObject[] {buildClasses}),
541:                        ccp
542:                });
543:                assertClassPathsHaveTheSameResources(cp, expectedCp);
544:                
545:                FileObject testSrcRoot = nbCVSRoot().getFileObject("ant/project/test/unit/src/");
546:                assertNotNull("have ant/project/test/unit/src/",testSrcRoot);
547:                ClassPath tccp = ClassPath.getClassPath(testSrcRoot, ClassPath.COMPILE);
548:                assertNotNull("No compile ClassPath for tests",tccp);
549:                Project prj = FileOwnerQuery.getOwner(testSrcRoot);
550:                assertNotNull("No project found",prj);
551:                assertTrue("Invalid project type", prj instanceof NbModuleProject);
552:                FileObject testBuildClasses = nbCVSRoot().getFileObject ("ant/project/build/test/unit/classes/");
553:                if (testBuildClasses == null) {
554:                    // Have to have it, so we can call CP.gCP on it:
555:                    testBuildClasses = FileUtil.createFolder(nbCVSRoot(), "ant/project/build/test/unit/classes");
556:                }
557:                assertNull ("ClassPath.SOURCE for build/test must be null",ClassPath.getClassPath(testBuildClasses, ClassPath.SOURCE));
558:                assertNull ("ClassPath.COMPILE for build/test must be null",ClassPath.getClassPath(testBuildClasses, ClassPath.COMPILE));
559:                cp = ClassPath.getClassPath(testBuildClasses, ClassPath.EXECUTE);
560:                
561:                String path = ((NbModuleProject)prj).evaluator().getProperty("test.unit.run.cp.extra");     //NOI18N
562:                List<PathResourceImplementation> trExtra = new ArrayList<PathResourceImplementation>();
563:                if (path != null) {
564:                    String[] pieces = PropertyUtils.tokenizePath(path);
565:                    for (int i = 0; i < pieces.length; i++) {
566:                        File f = ((NbModuleProject)prj).getHelper().resolveFile(pieces[i]);
567:                        URL url = f.toURI().toURL();
568:                        if (FileUtil.isArchiveFile(url)) {
569:                            url = FileUtil.getArchiveRoot (url);
570:                        }
571:                        else {
572:                            String stringifiedURL = url.toString ();
573:                            if (!stringifiedURL.endsWith("/")) {        //NOI18N
574:                                url = new URL (stringifiedURL+"/");     //NOI18N
575:                            }
576:                        }
577:                        trExtra.add(ClassPathSupport.createResource(url));
578:                    }
579:                }        
580:                assertNotNull("ClassPath.EXECUTE for build/test must NOT be null", cp);
581:                expectedCp = ClassPathSupport.createProxyClassPath(
582:                        ClassPathSupport.createClassPath(testBuildClasses),
583:                        tccp,
584:                        ClassPathSupport.createClassPath(trExtra),
585:                        ClassPathSupport.createClassPath(new URL(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-masterfs.jar"))));
586:                assertClassPathsHaveTheSameResources(expectedCp, cp);
587:
588:                File jarFile = ((NbModuleProject) prj).getModuleJarLocation();
589:                FileObject jarFO = FileUtil.toFileObject(jarFile);
590:                assertNotNull("No module jar", jarFO);
591:                FileObject jarRoot = FileUtil.getArchiveRoot(jarFO);
592:            //        assertEquals(prj, FileOwnerQuery.getOwner(jarRoot));
593:                assertNull("ClassPath.SOURCE for module jar must be null", ClassPath.getClassPath(jarRoot, ClassPath.SOURCE));
594:                assertNull("ClassPath.COMPILE for module jar must be null", ClassPath.getClassPath(jarRoot, ClassPath.COMPILE));
595:                cp = ClassPath.getClassPath(jarRoot, ClassPath.EXECUTE);
596:                assertNotNull("ClassPath.EXECUTE for module jar must NOT be null", cp);
597:                expectedCp = ClassPathSupport.createProxyClassPath(ClassPathSupport.createClassPath(jarRoot), ccp);
598:                assertClassPathsHaveTheSameResources(expectedCp, cp);
599:            }
600:             */
601:
602:            public void testCompileClasspathChanges() throws Exception {
603:                ClassPath cp = ClassPath.getClassPath(copyOfMiscDir
604:                        .getFileObject("src"), ClassPath.COMPILE);
605:                Set<String> expectedRoots = new TreeSet<String>();
606:                assertEquals("right initial COMPILE classpath", expectedRoots,
607:                        urlsOfCp(cp));
608:                TestBase.TestPCL l = new TestBase.TestPCL();
609:                cp.addPropertyChangeListener(l);
610:                ModuleEntry ioEntry = copyOfMiscProject.getModuleList()
611:                        .getEntry("org.openide.io");
612:                assertNotNull(ioEntry);
613:                copyOfMiscXMLManager.addDependencies(Collections
614:                        .singleton(new ModuleDependency(ioEntry)));
615:                assertTrue("got changes", l.changed
616:                        .contains(ClassPath.PROP_ROOTS));
617:                l.changed.clear();
618:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
619:                        + TestBase.CLUSTER_PLATFORM
620:                        + "/modules/org-openide-io.jar"));
621:                assertEquals(
622:                        "right COMPILE classpath after changing project.xml",
623:                        expectedRoots, urlsOfCp(cp));
624:                ModuleEntry utilEntry = copyOfMiscProject.getModuleList()
625:                        .getEntry("org.openide.util");
626:                assertNotNull(utilEntry);
627:                copyOfMiscXMLManager.addDependencies(Collections
628:                        .singleton(new ModuleDependency(utilEntry)));
629:                assertTrue("got changes again", l.changed
630:                        .contains(ClassPath.PROP_ROOTS));
631:                l.changed.clear();
632:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
633:                        + TestBase.CLUSTER_PLATFORM
634:                        + "/lib/org-openide-util.jar"));
635:                assertEquals(
636:                        "right COMPILE classpath after changing project.xml again",
637:                        expectedRoots, urlsOfCp(cp));
638:            }
639:
640:            public void testExecuteClasspathChanges() throws Exception {
641:                ClassPath cp = ClassPath.getClassPath(copyOfMiscDir
642:                        .getFileObject("src"), ClassPath.EXECUTE);
643:                Set<String> expectedRoots = new TreeSet<String>();
644:                expectedRoots.add(Util.urlForDir(
645:                        file(FileUtil.toFile(copyOfMiscDir), "build/classes"))
646:                        .toExternalForm());
647:                assertEquals("right initial EXECUTE classpath", expectedRoots,
648:                        urlsOfCp(cp));
649:                TestBase.TestPCL l = new TestBase.TestPCL();
650:                cp.addPropertyChangeListener(l);
651:                ModuleEntry ioEntry = copyOfMiscProject.getModuleList()
652:                        .getEntry("org.openide.io");
653:                assertNotNull(ioEntry);
654:                copyOfMiscXMLManager.addDependencies(Collections
655:                        .singleton(new ModuleDependency(ioEntry)));
656:                assertTrue("got changes", l.changed
657:                        .contains(ClassPath.PROP_ROOTS));
658:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
659:                        + TestBase.CLUSTER_PLATFORM
660:                        + "/modules/org-openide-io.jar"));
661:                // #70206: transitive deps added too:
662:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
663:                        + TestBase.CLUSTER_PLATFORM
664:                        + "/lib/org-openide-util.jar"));
665:                assertEquals(
666:                        "right EXECUTE classpath after changing project.xml",
667:                        expectedRoots.toString(), urlsOfCp(cp).toString());
668:            }
669:
670:            public void testUnitTestCompileClasspathChanges() throws Exception {
671:                ClassPath cp = ClassPath.getClassPath(copyOfMiscDir
672:                        .getFileObject("test/unit/src"), ClassPath.COMPILE);
673:                Set<String> expectedRoots = new TreeSet<String>();
674:                expectedRoots
675:                        .add(Util
676:                                .urlForJar(
677:                                        file(copyOfSuite2,
678:                                                "build/cluster/modules/org-netbeans-examples-modules-misc.jar"))
679:                                .toExternalForm());
680:                expectedRoots.add("junit.jar");
681:                expectedRoots.add("nbjunit.jar");
682:                expectedRoots.add("insanelib.jar");
683:                expectedRoots.add("org-netbeans-modules-nbjunit.jar");
684:                expectedRoots.add("org-netbeans-modules-nbjunit-ide.jar");
685:                assertEquals("right initial COMPILE classpath", expectedRoots
686:                        .toString(), urlsOfCp4Tests(cp).toString());
687:                TestBase.TestPCL l = new TestBase.TestPCL();
688:                cp.addPropertyChangeListener(l);
689:                ModuleEntry ioEntry = copyOfMiscProject.getModuleList()
690:                        .getEntry("org.openide.io");
691:                assertNotNull(ioEntry);
692:                copyOfMiscXMLManager.addDependencies(Collections
693:                        .singleton(new ModuleDependency(ioEntry)));
694:                assertTrue("got changes", l.changed
695:                        .contains(ClassPath.PROP_ROOTS));
696:                l.changed.clear();
697:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
698:                        + TestBase.CLUSTER_PLATFORM
699:                        + "/modules/org-openide-io.jar"));
700:                assertEquals(
701:                        "right COMPILE classpath after changing project.xml",
702:                        expectedRoots, urlsOfCp4Tests(cp));
703:                EditableProperties props = copyOfMiscProject
704:                        .getHelper()
705:                        .getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
706:                props.setProperty("test.unit.cp.extra",
707:                        "${netbeans.dest.dir}/lib/fnord.jar");
708:                copyOfMiscProject.getHelper().putProperties(
709:                        AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
710:                assertTrue("got changes again", l.changed
711:                        .contains(ClassPath.PROP_ROOTS));
712:                expectedRoots.add(urlForJar("nbbuild/netbeans/lib/fnord.jar"));
713:                assertEquals(
714:                        "right COMPILE classpath after changing project.properties",
715:                        expectedRoots, urlsOfCp4Tests(cp));
716:            }
717:
718:            /* XXX no longer available here
719:            public void testBinaryOriginAbsolutePath() throws Exception {
720:                File jmfhome = new File(getWorkDir(), "jmfhome");
721:                File audioFiles = file("platform/samples/audio-files");
722:                if (!audioFiles.isDirectory()) {
723:                    System.err.println("Skipping testBinaryOriginAbsolutePath since platform not checked out");
724:                    return;
725:                }
726:                File audioviewer = copyFolder(audioFiles);
727:                // Make it a standalone module so we can copy it:
728:                File pp = new File(audioviewer, "nbproject/private/private.properties".replace('/', File.separatorChar));
729:                pp.getParentFile().mkdirs();
730:                OutputStream os = new FileOutputStream(pp);
731:                try {
732:                    Properties p = new Properties();
733:                    p.setProperty("jmf.home", jmfhome.getAbsolutePath());
734:                    p.store(os, null);
735:                } finally {
736:                    os.close();
737:                }
738:                pp = new File(audioviewer, "nbproject/private/platform-private.properties".replace('/', File.separatorChar));
739:                pp.getParentFile().mkdirs();
740:                os = new FileOutputStream(pp);
741:                try {
742:                    Properties p = new Properties();
743:                    p.setProperty("netbeans.dest.dir", file("nbbuild/netbeans").getAbsolutePath());
744:                    p.store(os, null);
745:                } finally {
746:                    os.close();
747:                }
748:                File px = new File(audioviewer, "nbproject/project.xml".replace('/', File.separatorChar));
749:                Document doc = XMLUtil.parse(new InputSource(px.toURI().toString()), false, true, null, null);
750:                NodeList nl = doc.getDocumentElement().getElementsByTagNameNS(NbModuleProjectType.NAMESPACE_SHARED_2, "data");
751:                assertEquals(1, nl.getLength());
752:                Element data = (Element) nl.item(0);
753:                // XXX insert at position 1, between <c-n-b> and <m-d>:
754:                data.appendChild(doc.createElementNS(NbModuleProjectType.NAMESPACE_SHARED_2, "standalone"));
755:                os = new FileOutputStream(px);
756:                try {
757:                    XMLUtil.write(doc, os, "UTF-8");
758:                } finally {
759:                    os.close();
760:                }
761:                FileObject audioviewerFO = FileUtil.toFileObject(audioviewer);
762:                Project p = ProjectManager.getDefault().findProject(audioviewerFO);
763:                assertNotNull(p);
764:                FileObject src = audioviewerFO.getFileObject("src");
765:                ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
766:                assertNotNull("have a COMPILE classpath", cp);
767:                Set<String> expectedRoots = new TreeSet<String>();
768:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-actions.jar"));
769:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-dialogs.jar"));
770:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/org-openide-filesystems.jar"));
771:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"));
772:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-nodes.jar"));
773:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-text.jar"));
774:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
775:                expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-windows.jar"));
776:                File lib = new File(jmfhome, "lib");
777:                expectedRoots.add(Util.urlForJar(new File(lib, "jmf.jar")).toExternalForm());
778:                expectedRoots.add(Util.urlForJar(new File(lib, "mediaplayer.jar")).toExternalForm());
779:                assertEquals("right COMPILE classpath incl. absolute locations of JARs",
780:                    expectedRoots.toString(), urlsOfCp(cp).toString());
781:            }
782:            
783:            private void assertClassPathsHaveTheSameResources(ClassPath actual, ClassPath expected) {
784:                assertEquals(urlsOfCp(expected).toString(), urlsOfCp(actual).toString());
785:            }
786:             */
787:
788:            public void testTransitiveExecuteClasspath() throws Exception { // #70206
789:                NbModuleProject p = TestBase.generateStandaloneModule(
790:                        getWorkDir(), "prj");
791:                Util.addDependency(p, "org.openide.windows");
792:                ProjectManager.getDefault().saveProject(p);
793:                ClassPath cp = ClassPath.getClassPath(p.getSourceDirectory(),
794:                        ClassPath.EXECUTE);
795:                Set<String> expectedRoots = new TreeSet<String>();
796:                // What we just added:
797:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
798:                        + TestBase.CLUSTER_PLATFORM
799:                        + "/modules/org-openide-windows.jar"));
800:                // And its transitive deps:
801:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
802:                        + TestBase.CLUSTER_PLATFORM
803:                        + "/modules/org-openide-dialogs.jar"));
804:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
805:                        + TestBase.CLUSTER_PLATFORM
806:                        + "/modules/org-openide-nodes.jar"));
807:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
808:                        + TestBase.CLUSTER_PLATFORM
809:                        + "/modules/org-openide-awt.jar"));
810:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
811:                        + TestBase.CLUSTER_PLATFORM
812:                        + "/lib/org-openide-util.jar"));
813:                // Dialogs API depends on Progress API
814:                expectedRoots.add(urlForJar("nbbuild/netbeans/"
815:                        + TestBase.CLUSTER_PLATFORM
816:                        + "/modules/org-netbeans-api-progress.jar"));
817:                // And the usual:
818:                expectedRoots.add(Util.urlForDir(
819:                        new File(p.getProjectDirectoryFile(), "build/classes"))
820:                        .toExternalForm());
821:                assertEquals("right EXECUTE classpath incl. transitive deps",
822:                        expectedRoots.toString(), urlsOfCp(cp).toString());
823:            }
824:
825:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.