KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > queries > ClassPathProviderImplTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.project.queries;
21
22 import java.io.File JavaDoc;
23 import java.io.FileOutputStream JavaDoc;
24 import java.io.OutputStream JavaDoc;
25 import java.net.URL JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.Arrays JavaDoc;
28 import java.util.Collections JavaDoc;
29 import java.util.HashSet JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.List JavaDoc;
32 import java.util.Properties JavaDoc;
33 import java.util.Set JavaDoc;
34 import java.util.TreeSet JavaDoc;
35 import org.netbeans.api.java.classpath.ClassPath;
36 import org.netbeans.api.project.FileOwnerQuery;
37 import org.netbeans.api.project.Project;
38 import org.netbeans.api.project.ProjectManager;
39 import org.netbeans.modules.apisupport.project.NbModuleProject;
40 import org.netbeans.modules.apisupport.project.NbModuleProjectType;
41 import org.netbeans.modules.apisupport.project.ProjectXMLManager;
42 import org.netbeans.modules.apisupport.project.TestBase;
43 import org.netbeans.modules.apisupport.project.Util;
44 import org.netbeans.modules.apisupport.project.suite.SuiteProjectTest;
45 import org.netbeans.modules.apisupport.project.ui.customizer.ModuleDependency;
46 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
47 import org.netbeans.spi.project.support.ant.AntProjectHelper;
48 import org.netbeans.spi.project.support.ant.EditableProperties;
49 import org.netbeans.spi.project.support.ant.PropertyUtils;
50 import org.openide.filesystems.FileObject;
51 import org.openide.filesystems.FileUtil;
52 import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
53 import org.openide.xml.XMLUtil;
54 import org.w3c.dom.Document JavaDoc;
55 import org.w3c.dom.Element JavaDoc;
56 import org.w3c.dom.NodeList JavaDoc;
57 import org.xml.sax.InputSource JavaDoc;
58
59 // XXX test GPR usage
60

61 /**
62  * Test functionality of {@link ClassPathProviderImpl}.
63  * @author Jesse Glick
64  */

65 public class ClassPathProviderImplTest extends TestBase {
66     
67     public ClassPathProviderImplTest(String JavaDoc name) {
68         super(name);
69     }
70     
71     private File JavaDoc copyOfSuite2;
72     private FileObject copyOfMiscDir;
73     private NbModuleProject copyOfMiscProject;
74     private ProjectXMLManager copyOfMiscXMLManager;
75     
76     protected void setUp() throws Exception JavaDoc {
77         super.setUp();
78         copyOfSuite2 = copyFolder(resolveEEPFile("/suite2"));
79         File JavaDoc miscF = new File JavaDoc(copyOfSuite2, "misc-project");
80         copyOfMiscDir = FileUtil.toFileObject(miscF);
81         copyOfMiscProject = (NbModuleProject) ProjectManager.getDefault().findProject(copyOfMiscDir);
82         assertNotNull(copyOfMiscProject);
83         copyOfMiscXMLManager = new ProjectXMLManager(copyOfMiscProject);
84         // make sure its platform-private.properties is correct:
85
Project copyOfSuite2P = ProjectManager.getDefault().findProject(FileUtil.toFileObject(copyOfSuite2));
86         SuiteProjectTest.openSuite(copyOfSuite2P);
87     }
88     
89     private String JavaDoc urlForJar(String JavaDoc path) {
90         return Util.urlForJar(PropertyUtils.resolveFile(nbCVSRootFile(), path)).toExternalForm();
91     }
92     
93     private String JavaDoc urlForDir(String JavaDoc path) {
94         return Util.urlForDir(file(path)).toExternalForm();
95     }
96     
97     private Set JavaDoc/*<String>*/ urlsOfCp(ClassPath cp) {
98         Set JavaDoc/*<String>*/ s = new TreeSet JavaDoc();
99         Iterator JavaDoc it = cp.entries().iterator();
100         while (it.hasNext()) {
101             s.add(((ClassPath.Entry) it.next()).getURL().toExternalForm());
102         }
103         return s;
104     }
105     
106     private static final Set JavaDoc/*<String>*/ TESTLIBS = new HashSet JavaDoc(Arrays.asList(new String JavaDoc[] {
107         "junit.jar", "nbjunit.jar", "nbjunit-ide.jar", "insanelib.jar",
108         "org-netbeans-modules-nbjunit.jar",
109         "org-netbeans-modules-nbjunit-ide.jar",
110     }));
111     
112     private void assertSets(String JavaDoc message,Set JavaDoc set1, Set JavaDoc set2 ) {
113         StringBuffer JavaDoc result = new StringBuffer JavaDoc();
114         boolean pass = true;
115         for (Iterator JavaDoc it = set1.iterator() ; it.hasNext() ; ) {
116             Object JavaDoc obj = it.next();
117             if (!set2.contains(obj)) {
118                 pass = false;
119                 result.append("- " + obj + "\n");
120             }
121         }
122         for (Iterator JavaDoc it = set2.iterator() ; it.hasNext() ; ) {
123             Object JavaDoc obj = it.next();
124             if (!set1.contains(obj)) {
125                 pass = false;
126                 result.append("+ " + obj + "\n");
127             }
128         }
129         assertTrue(message + "\n" + result,pass);
130     }
131  
132     private Set JavaDoc/*<String>*/ urlsOfCp4Tests(ClassPath cp) {
133         Set JavaDoc/*<String>*/ s = new TreeSet JavaDoc();
134         Iterator JavaDoc it = cp.entries().iterator();
135         while (it.hasNext()) {
136             String JavaDoc url = ((ClassPath.Entry) it.next()).getURL().toExternalForm();
137             if (url.indexOf("$%7B") != -1) {
138                 // Unevaluated Ant reference (after octet escaping), so skip.
139
continue;
140             }
141             String JavaDoc simplifiedJarName = url.replaceFirst("^.+/([^/]+?)[0-9_.-]*\\.jar!/$", "$1.jar");
142             if (TESTLIBS.contains(simplifiedJarName)) {
143                 s.add(simplifiedJarName);
144             } else {
145                 s.add(url);
146             }
147         }
148         return s;
149     }
150     
151     public void testMainClasspath() throws Exception JavaDoc {
152         FileObject src = nbCVSRoot().getFileObject("ant/src");
153         assertNotNull("have ant/src", src);
154         ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
155         assertNotNull("have a COMPILE classpath", cp);
156         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
157         // Keep up to date w/ changes in ant/nbproject/project.{xml,properties}:
158
// ${module.classpath}:
159
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-api-xml.jar"));
160         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/org-openide-filesystems.jar"));
161         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
162         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-modules.jar"));
163         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-nodes.jar"));
164         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-awt.jar"));
165         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-dialogs.jar"));
166         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-windows.jar"));
167         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-text.jar"));
168         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-actions.jar"));
169         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-execution.jar"));
170         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-io.jar"));
171         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"));
172         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-explorer.jar"));
173         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-spi-navigator.jar"));
174         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-jdesktop-layout.jar"));
175         expectedRoots.add(urlForJar("libs/external/swing-layout-1.0.1.jar"));
176         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-options-api.jar"));
177         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-api-progress.jar"));
178         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-projectapi.jar"));
179         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-projectuiapi.jar"));
180         assertEquals("right COMPILE classpath for ant/src", expectedRoots.toString(), urlsOfCp(cp).toString());
181         cp = ClassPath.getClassPath(src, ClassPath.EXECUTE);
182         assertNotNull("have an EXECUTE classpath", cp);
183         // #48099: need to include build/classes here too
184
expectedRoots.add(urlForDir("ant/build/classes"));
185         // And #70206: transitive runtime deps too.
186
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-queries.jar"));
187         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-editor-mimelookup.jar"));
188         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-options.jar"));
189         assertEquals("right EXECUTE classpath (COMPILE plus classes)", expectedRoots.toString(), urlsOfCp(cp).toString());
190         cp = ClassPath.getClassPath(src, ClassPath.SOURCE);
191         assertNotNull("have a SOURCE classpath", cp);
192         assertEquals("right SOURCE classpath", Collections.singleton(src), new HashSet JavaDoc(Arrays.asList(cp.getRoots())));
193         // XXX test BOOT
194
}
195
196     public void testMainClasspathExternalModules() throws Exception JavaDoc {
197         FileObject src = resolveEEP("suite3/dummy-project/src");
198         assertNotNull("have .../dummy-project/src", src);
199         ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
200         assertNotNull("have a COMPILE classpath", cp);
201         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
202         expectedRoots.add(urlForJar(resolveEEPPath("/suite3/nbplatform/random/modules/random.jar")));
203         expectedRoots.add(urlForJar(resolveEEPPath("/suite3/nbplatform/random/modules/ext/stuff.jar")));
204         assertEquals("right COMPILE classpath", expectedRoots, urlsOfCp(cp));
205     }
206     
207     /**
208      * #52354: interpret <class-path-extension>s both in myself and in dependent modules.
209      */

210     public void testClasspathExtensions() throws Exception JavaDoc {
211         // java/javacore has its own <class-path-extension> and uses others from dependents.
212
FileObject src = nbCVSRoot().getFileObject("java/javacore/src");
213         assertNotNull("have java/javacore/src", src);
214         ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
215         assertNotNull("have a COMPILE classpath", cp);
216         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
217         // Keep up to date w/ changes in java/javacore/nbproject/project.xml:
218
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-api-java.jar"));
219         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-classfile.jar"));
220         expectedRoots.add(urlForJar("nbbuild/netbeans/extra/modules/org-netbeans-jmi-javamodel.jar"));
221         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/javax-jmi-reflect.jar"));
222         expectedRoots.add(urlForJar("mdr/external/jmi.jar"));
223         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/javax-jmi-model.jar"));
224         expectedRoots.add(urlForJar("mdr/external/mof.jar"));
225         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-api-mdr.jar"));
226         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-projectapi.jar"));
227         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-api-progress.jar"));
228         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-mdr.jar"));
229         expectedRoots.add(urlForJar("mdr/dist/mdr.jar"));
230         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-jmiutils.jar"));
231         expectedRoots.add(urlForJar("mdr/jmiutils/dist/jmiutils.jar"));
232         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"));
233         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/org-openide-filesystems.jar"));
234         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
235         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-modules.jar"));
236         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-nodes.jar"));
237         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-awt.jar"));
238         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-dialogs.jar"));
239         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-windows.jar"));
240         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-text.jar"));
241         expectedRoots.add(urlForJar("java/parser/dist/java-parser.jar"));
242         assertEquals("right COMPILE classpath", expectedRoots.toString(), urlsOfCp(cp).toString());
243         assertTrue("#76341: EXECUTE classpath also has extension",
244                 urlsOfCp(ClassPath.getClassPath(src, ClassPath.EXECUTE)).contains(urlForJar("java/parser/dist/java-parser.jar")));
245     }
246     
247     public void testExtraCompilationUnits() throws Exception JavaDoc {
248         FileObject srcbridge = nbCVSRoot().getFileObject("ant/src-bridge");
249         assertNotNull("have ant/src-bridge", srcbridge);
250         ClassPath cp = ClassPath.getClassPath(srcbridge, ClassPath.COMPILE);
251         assertNotNull("have a COMPILE classpath", cp);
252         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
253         // Keep up to date w/ changes in ant/nbproject/project.{xml,properties}:
254
expectedRoots.add(urlForDir("ant/build/classes"));
255         expectedRoots.add(urlForJar("ant/external/lib/ant.jar"));
256         // ${module.classpath}:
257
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-api-xml.jar"));
258         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/org-openide-filesystems.jar"));
259         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
260         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-modules.jar"));
261         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-nodes.jar"));
262         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-awt.jar"));
263         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-dialogs.jar"));
264         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-windows.jar"));
265         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-text.jar"));
266         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-actions.jar"));
267         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-execution.jar"));
268         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-io.jar"));
269         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"));
270         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-explorer.jar"));
271         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-spi-navigator.jar"));
272         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-jdesktop-layout.jar"));
273         expectedRoots.add(urlForJar("libs/external/swing-layout-1.0.1.jar"));
274         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-options-api.jar"));
275         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-api-progress.jar"));
276         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-projectapi.jar"));
277         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-projectuiapi.jar"));
278         assertEquals("right COMPILE classpath for ant/src-bridge", expectedRoots.toString(), urlsOfCp(cp).toString());
279         cp = ClassPath.getClassPath(srcbridge, ClassPath.EXECUTE);
280         assertNotNull("have an EXECUTE classpath", cp);
281         expectedRoots.add(urlForDir("ant/build/bridge-classes"));
282         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/ant/nblib/bridge.jar"));
283         assertEquals("right EXECUTE classpath (COMPILE plus classes plus JAR)", expectedRoots, urlsOfCp(cp));
284         cp = ClassPath.getClassPath(srcbridge, ClassPath.SOURCE);
285         assertNotNull("have a SOURCE classpath", cp);
286         assertEquals("right SOURCE classpath", Collections.singleton(srcbridge), new HashSet JavaDoc(Arrays.asList(cp.getRoots())));
287         // XXX test BOOT
288
}
289     
290     public void testUnitTestClasspaths() throws Exception JavaDoc {
291         FileObject src = nbCVSRoot().getFileObject("autoupdate/test/unit/src");
292         assertNotNull("have autoupdate/test/unit/src", src);
293         ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
294         assertNotNull("have a COMPILE classpath", cp);
295         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
296         // Keep up to date w/ changes in autoupdate/nbproject/project.{xml,properties}:
297
// module.classpath:
298
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/org-openide-filesystems.jar"));
299         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
300         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-modules.jar"));
301         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/boot.jar"));
302         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-nodes.jar"));
303         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-explorer.jar"));
304         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-awt.jar"));
305         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-dialogs.jar"));
306         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-options.jar"));
307         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-windows.jar"));
308         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-actions.jar"));
309         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"));
310         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-core.jar"));
311         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-api-progress.jar"));
312         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/core.jar"));
313         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-editor-mimelookup.jar"));
314         // cp.extra:
315
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/ext/updater.jar"));
316         // module JAR:
317
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-autoupdate.jar"));
318         expectedRoots.add("junit.jar");
319         expectedRoots.add("nbjunit.jar");
320         expectedRoots.add("nbjunit-ide.jar");
321         expectedRoots.add("insanelib.jar");
322         // recursive dependencies
323
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-swing-plaf.jar"));
324         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-text.jar"));
325         
326         assertSets("right COMPILE classpath", expectedRoots, urlsOfCp4Tests(cp));
327         
328         cp = ClassPath.getClassPath(src, ClassPath.EXECUTE);
329         assertNotNull("have an EXECUTE classpath", cp);
330         expectedRoots.add(urlForDir("autoupdate/build/test/unit/classes"));
331         // test.unit.run.cp.extra:
332
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/boot.jar"));
333         assertSets("right EXECUTE classpath (COMPILE plus classes)", expectedRoots, urlsOfCp4Tests(cp));
334         cp = ClassPath.getClassPath(src, ClassPath.SOURCE);
335         assertNotNull("have a SOURCE classpath", cp);
336         assertEquals("right SOURCE classpath", Collections.singleton(src), new HashSet JavaDoc(Arrays.asList(cp.getRoots())));
337         // XXX test BOOT
338
}
339    
340     public void testUnitTestClasspathsExternalModules() throws Exception JavaDoc {
341         FileObject src = resolveEEP("suite1/support/lib-project/test/unit/src");
342         ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
343         assertNotNull("have a COMPILE classpath", cp);
344         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
345         expectedRoots.add(urlForJar(resolveEEPPath("/suite1/build/cluster/modules/org-netbeans-examples-modules-lib.jar")));
346         expectedRoots.add("junit.jar");
347         expectedRoots.add("nbjunit.jar");
348         expectedRoots.add("insanelib.jar");
349         expectedRoots.add("org-netbeans-modules-nbjunit.jar");
350         expectedRoots.add("org-netbeans-modules-nbjunit-ide.jar");
351         assertEquals("right COMPILE classpath", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
352         // Now test in suite3, where there is no source...
353
src = resolveEEP("suite3/dummy-project/test/unit/src");
354         cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
355         assertNotNull("have a COMPILE classpath", cp);
356         expectedRoots = new TreeSet JavaDoc();
357         expectedRoots.add(urlForJar(resolveEEPPath("/suite3/dummy-project/build/cluster/modules/org-netbeans-examples-modules-dummy.jar")));
358         expectedRoots.add(urlForJar(resolveEEPPath("/suite3/nbplatform/random/modules/random.jar")));
359         expectedRoots.add(urlForJar(resolveEEPPath("/suite3/nbplatform/random/modules/ext/stuff.jar")));
360         expectedRoots.add("junit.jar");
361         expectedRoots.add("nbjunit.jar");
362         expectedRoots.add("insanelib.jar");
363         expectedRoots.add("org-netbeans-modules-nbjunit.jar");
364         expectedRoots.add("org-netbeans-modules-nbjunit-ide.jar");
365         assertEquals("right COMPILE classpath", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
366         
367         // test dependencies
368
expectedRoots.clear();
369         src = resolveEEP("/suite4/module2/test/unit/src");
370         expectedRoots.add(urlForJar(resolveEEPPath("/suite4/build/testdist/unit/cluster/module1/tests.jar")));
371         expectedRoots.add(urlForJar(resolveEEPPath("/suite4/build/cluster/modules/module1.jar")));
372         expectedRoots.add(urlForJar(resolveEEPPath("/suite4/build/cluster/modules/module2.jar")));
373         expectedRoots.add("junit.jar");
374         expectedRoots.add("nbjunit.jar");
375         expectedRoots.add("insanelib.jar");
376         expectedRoots.add("org-netbeans-modules-nbjunit.jar");
377         expectedRoots.add("org-netbeans-modules-nbjunit-ide.jar");
378         cp = ClassPath.getClassPath(src,ClassPath.COMPILE);
379         FileObject roots[] = cp.getRoots();
380         assertSets("right compileclasspath",expectedRoots, urlsOfCp4Tests(cp));
381     }
382     
383     public void testQaFunctionalTestClasspath() throws Exception JavaDoc {
384         FileObject qaftsrc = nbCVSRoot().getFileObject("performance/test/qa-functional/src");
385         if (qaftsrc == null) {
386             System.err.println("Skipping testQaFunctionalTestClasspath since performance not checked out");
387             return;
388         }
389         ClassPath cp = ClassPath.getClassPath(qaftsrc, ClassPath.COMPILE);
390         assertNotNull("have a COMPILE classpath", cp);
391         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
392         // Keep up to date w/ changes in /space/src/nb_all/performance/nbproject/project.properties
393
// & nbbuild/templates/xtest-qa-functional.xml:
394
expectedRoots.add("junit.jar");
395         expectedRoots.add("nbjunit.jar");
396         expectedRoots.add("nbjunit-ide.jar");
397         expectedRoots.add("insanelib.jar");
398         // jemmy.and.jelly.path:
399
expectedRoots.add(urlForJar("jemmy/builds/jemmy.jar"));
400         expectedRoots.add(urlForJar("jellytools/builds/jelly2-nb.jar"));
401         // test.qa-functional.cp.extra currently empty
402
assertEquals("right COMPILE classpath", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
403         cp = ClassPath.getClassPath(qaftsrc, ClassPath.EXECUTE);
404         assertNotNull("have an EXECUTE classpath", cp);
405         expectedRoots.add(urlForDir("performance/build/test/qa-functional/classes"));
406         assertEquals("right EXECUTE classpath (COMPILE plus classes)", expectedRoots, urlsOfCp4Tests(cp));
407         cp = ClassPath.getClassPath(qaftsrc, ClassPath.SOURCE);
408         assertNotNull("have a SOURCE classpath", cp);
409         assertEquals("right SOURCE classpath", Collections.singleton(qaftsrc), new HashSet JavaDoc(Arrays.asList(cp.getRoots())));
410         // XXX test BOOT
411
}
412     
413     public void testQaFunctionalTestClasspathExternalModules() throws Exception JavaDoc {
414         FileObject qaftsrc = resolveEEP("suite1/action-project/test/qa-functional/src");
415         assertNotNull("have action-project/test/qa-functional/src", qaftsrc);
416         ClassPath cp = ClassPath.getClassPath(qaftsrc, ClassPath.COMPILE);
417         assertNotNull("have a COMPILE classpath", cp);
418         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
419         expectedRoots.add("junit.jar");
420         expectedRoots.add("nbjunit.jar");
421         expectedRoots.add("nbjunit-ide.jar");
422         expectedRoots.add("insanelib.jar");
423         expectedRoots.add(urlForJar("jemmy/builds/jemmy.jar"));
424         expectedRoots.add(urlForJar("jellytools/builds/jelly2-nb.jar"));
425         expectedRoots.add("org-netbeans-modules-nbjunit.jar");
426         expectedRoots.add("org-netbeans-modules-nbjunit-ide.jar");
427         assertEquals("right COMPILE classpath", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
428         TestBase.TestPCL l = new TestBase.TestPCL();
429         cp.addPropertyChangeListener(l);
430         NbModuleProject p = (NbModuleProject) FileOwnerQuery.getOwner(qaftsrc);
431         EditableProperties ep = p.getHelper().getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
432         File JavaDoc added = file("xtest/lib/xtest.jar");
433         ep.setProperty("test.qa-functional.cp.extra", added.getAbsolutePath());
434         p.getHelper().putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
435         // do not save! just want to test change, not actually make it...
436
assertTrue("got changes", l.changed.contains(ClassPath.PROP_ROOTS));
437         expectedRoots.add(urlForJar("xtest/lib/xtest.jar"));
438         assertEquals("right COMPILE classpath after added to .extra", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
439     }
440     
441     public void testBuildClassPath () throws Exception JavaDoc {
442         FileObject srcRoot = nbCVSRoot().getFileObject("ant/project/src/");
443         assertNotNull("have ant/project/src",srcRoot);
444         ClassPath ccp = ClassPath.getClassPath(srcRoot, ClassPath.COMPILE);
445         assertNotNull("No compile ClassPath for sources",ccp);
446         FileObject buildClasses = nbCVSRoot().getFileObject("ant/project/build/classes/");
447         assertNotNull("have ant/project/build/classes",buildClasses);
448                 
449         assertNull ("ClassPath.SOURCE for build must be null",ClassPath.getClassPath(buildClasses, ClassPath.SOURCE));
450         assertNull ("ClassPath.COMPILE for build must be null",ClassPath.getClassPath(buildClasses, ClassPath.COMPILE));
451         ClassPath cp = ClassPath.getClassPath(buildClasses, ClassPath.EXECUTE);
452         assertNotNull("ClassPath.EXECUTE for build must NOT be null",cp);
453         ClassPath expectedCp = ClassPathSupport.createProxyClassPath(new ClassPath[] {
454                 ClassPathSupport.createClassPath(new FileObject[] {buildClasses}),
455                 ccp
456         });
457         assertClassPathsHaveTheSameResources(cp, expectedCp);
458         
459         FileObject testSrcRoot = nbCVSRoot().getFileObject("ant/project/test/unit/src/");
460         assertNotNull("have ant/project/test/unit/src/",testSrcRoot);
461         ClassPath tccp = ClassPath.getClassPath(testSrcRoot, ClassPath.COMPILE);
462         assertNotNull("No compile ClassPath for tests",tccp);
463         Project prj = FileOwnerQuery.getOwner(testSrcRoot);
464         assertNotNull("No project found",prj);
465         assertTrue("Invalid project type", prj instanceof NbModuleProject);
466         FileObject testBuildClasses = nbCVSRoot().getFileObject ("ant/project/build/test/unit/classes/");
467         if (testBuildClasses == null) {
468             // Have to have it, so we can call CP.gCP on it:
469
testBuildClasses = FileUtil.createFolder(nbCVSRoot(), "ant/project/build/test/unit/classes");
470         }
471         assertNull ("ClassPath.SOURCE for build/test must be null",ClassPath.getClassPath(testBuildClasses, ClassPath.SOURCE));
472         assertNull ("ClassPath.COMPILE for build/test must be null",ClassPath.getClassPath(testBuildClasses, ClassPath.COMPILE));
473         cp = ClassPath.getClassPath(testBuildClasses, ClassPath.EXECUTE);
474         
475         String JavaDoc path = ((NbModuleProject)prj).evaluator().getProperty("test.unit.run.cp.extra"); //NOI18N
476
List JavaDoc trExtra = new ArrayList JavaDoc ();
477         if (path != null) {
478             String JavaDoc[] pieces = PropertyUtils.tokenizePath(path);
479             for (int i = 0; i < pieces.length; i++) {
480                 File JavaDoc f = ((NbModuleProject)prj).getHelper().resolveFile(pieces[i]);
481                 URL JavaDoc url = f.toURI().toURL();
482                 if (FileUtil.isArchiveFile(url)) {
483                     url = FileUtil.getArchiveRoot (url);
484                 }
485                 else {
486                     String JavaDoc stringifiedURL = url.toString ();
487                     if (!stringifiedURL.endsWith("/")) { //NOI18N
488
url = new URL JavaDoc (stringifiedURL+"/"); //NOI18N
489
}
490                 }
491                 trExtra.add(ClassPathSupport.createResource(url));
492             }
493         }
494         assertNotNull("ClassPath.EXECUTE for build/test must NOT be null", cp);
495         expectedCp = ClassPathSupport.createProxyClassPath(new ClassPath[] {
496                 ClassPathSupport.createClassPath(new FileObject[] {testBuildClasses}),
497                 tccp,
498                 ClassPathSupport.createClassPath(trExtra),
499                 ClassPathSupport.createClassPath(new URL JavaDoc[] {new URL JavaDoc(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-masterfs.jar"))})
500         });
501         assertClassPathsHaveTheSameResources(cp, expectedCp);
502
503         File JavaDoc jarFile = ((NbModuleProject) prj).getModuleJarLocation();
504         FileObject jarFO = FileUtil.toFileObject(jarFile);
505         assertNotNull("No module jar", jarFO);
506         FileObject jarRoot = FileUtil.getArchiveRoot(jarFO);
507 // assertEquals(prj, FileOwnerQuery.getOwner(jarRoot));
508
assertNull("ClassPath.SOURCE for module jar must be null", ClassPath.getClassPath(jarRoot, ClassPath.SOURCE));
509         assertNull("ClassPath.COMPILE for module jar must be null", ClassPath.getClassPath(jarRoot, ClassPath.COMPILE));
510         cp = ClassPath.getClassPath(jarRoot, ClassPath.EXECUTE);
511         assertNotNull("ClassPath.EXECUTE for module jar must NOT be null", cp);
512         expectedCp = ClassPathSupport.createProxyClassPath(new ClassPath[] {
513             ClassPathSupport.createClassPath(new FileObject[] {jarRoot}),
514             ccp
515         });
516         assertClassPathsHaveTheSameResources(cp, expectedCp);
517     }
518     
519     public void testCompileClasspathChanges() throws Exception JavaDoc {
520         ClassPath cp = ClassPath.getClassPath(copyOfMiscDir.getFileObject("src"), ClassPath.COMPILE);
521         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
522         assertEquals("right initial COMPILE classpath", expectedRoots, urlsOfCp(cp));
523         TestBase.TestPCL l = new TestBase.TestPCL();
524         cp.addPropertyChangeListener(l);
525         ModuleEntry ioEntry = copyOfMiscProject.getModuleList().getEntry("org.openide.io");
526         assertNotNull(ioEntry);
527         copyOfMiscXMLManager.addDependencies(Collections.singleton(new ModuleDependency(ioEntry)));
528         assertTrue("got changes", l.changed.contains(ClassPath.PROP_ROOTS));
529         l.changed.clear();
530         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-io.jar"));
531         assertEquals("right COMPILE classpath after changing project.xml", expectedRoots, urlsOfCp(cp));
532         ModuleEntry utilEntry = copyOfMiscProject.getModuleList().getEntry("org.openide.util");
533         assertNotNull(utilEntry);
534         copyOfMiscXMLManager.addDependencies(Collections.singleton(new ModuleDependency(utilEntry)));
535         assertTrue("got changes again", l.changed.contains(ClassPath.PROP_ROOTS));
536         l.changed.clear();
537         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
538         assertEquals("right COMPILE classpath after changing project.xml again", expectedRoots, urlsOfCp(cp));
539     }
540     
541     public void testExecuteClasspathChanges() throws Exception JavaDoc {
542         ClassPath cp = ClassPath.getClassPath(copyOfMiscDir.getFileObject("src"), ClassPath.EXECUTE);
543         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
544         expectedRoots.add(Util.urlForDir(file(FileUtil.toFile(copyOfMiscDir), "build/classes")).toExternalForm());
545         assertEquals("right initial EXECUTE classpath", expectedRoots, urlsOfCp(cp));
546         TestBase.TestPCL l = new TestBase.TestPCL();
547         cp.addPropertyChangeListener(l);
548         ModuleEntry ioEntry = copyOfMiscProject.getModuleList().getEntry("org.openide.io");
549         assertNotNull(ioEntry);
550         copyOfMiscXMLManager.addDependencies(Collections.singleton(new ModuleDependency(ioEntry)));
551         assertTrue("got changes", l.changed.contains(ClassPath.PROP_ROOTS));
552         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-io.jar"));
553         // #70206: transitive deps added too:
554
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
555         assertEquals("right EXECUTE classpath after changing project.xml", expectedRoots.toString(), urlsOfCp(cp).toString());
556     }
557     
558     public void testUnitTestCompileClasspathChanges() throws Exception JavaDoc {
559         ClassPath cp = ClassPath.getClassPath(copyOfMiscDir.getFileObject("test/unit/src"), ClassPath.COMPILE);
560         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
561         expectedRoots.add(Util.urlForJar(file(copyOfSuite2, "build/cluster/modules/org-netbeans-examples-modules-misc.jar")).toExternalForm());
562         expectedRoots.add("junit.jar");
563         expectedRoots.add("nbjunit.jar");
564         expectedRoots.add("insanelib.jar");
565         expectedRoots.add("org-netbeans-modules-nbjunit.jar");
566         expectedRoots.add("org-netbeans-modules-nbjunit-ide.jar");
567         assertEquals("right initial COMPILE classpath", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
568         TestBase.TestPCL l = new TestBase.TestPCL();
569         cp.addPropertyChangeListener(l);
570         ModuleEntry ioEntry = copyOfMiscProject.getModuleList().getEntry("org.openide.io");
571         assertNotNull(ioEntry);
572         copyOfMiscXMLManager.addDependencies(Collections.singleton(new ModuleDependency(ioEntry)));
573         assertTrue("got changes", l.changed.contains(ClassPath.PROP_ROOTS));
574         l.changed.clear();
575         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-io.jar"));
576         assertEquals("right COMPILE classpath after changing project.xml", expectedRoots, urlsOfCp4Tests(cp));
577         EditableProperties props = copyOfMiscProject.getHelper().getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
578         props.setProperty("test.unit.cp.extra", "${netbeans.dest.dir}/lib/fnord.jar");
579         copyOfMiscProject.getHelper().putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
580         assertTrue("got changes again", l.changed.contains(ClassPath.PROP_ROOTS));
581         expectedRoots.add(urlForJar("nbbuild/netbeans/lib/fnord.jar"));
582         assertEquals("right COMPILE classpath after changing project.properties", expectedRoots, urlsOfCp4Tests(cp));
583     }
584     
585     public void testBinaryOriginAbsolutePath() throws Exception JavaDoc {
586         File JavaDoc jmfhome = new File JavaDoc(getWorkDir(), "jmfhome");
587         File JavaDoc audioFiles = file("platform/samples/audio-files");
588         if (!audioFiles.isDirectory()) {
589             System.err.println("Skipping testBinaryOriginAbsolutePath since platform not checked out");
590             return;
591         }
592         File JavaDoc audioviewer = copyFolder(audioFiles);
593         // Make it a standalone module so we can copy it:
594
File JavaDoc pp = new File JavaDoc(audioviewer, "nbproject/private/private.properties".replace('/', File.separatorChar));
595         pp.getParentFile().mkdirs();
596         OutputStream JavaDoc os = new FileOutputStream JavaDoc(pp);
597         try {
598             Properties JavaDoc p = new Properties JavaDoc();
599             p.setProperty("jmf.home", jmfhome.getAbsolutePath());
600             p.store(os, null);
601         } finally {
602             os.close();
603         }
604         pp = new File JavaDoc(audioviewer, "nbproject/private/platform-private.properties".replace('/', File.separatorChar));
605         pp.getParentFile().mkdirs();
606         os = new FileOutputStream JavaDoc(pp);
607         try {
608             Properties JavaDoc p = new Properties JavaDoc();
609             p.setProperty("netbeans.dest.dir", file("nbbuild/netbeans").getAbsolutePath());
610             p.store(os, null);
611         } finally {
612             os.close();
613         }
614         File JavaDoc px = new File JavaDoc(audioviewer, "nbproject/project.xml".replace('/', File.separatorChar));
615         Document JavaDoc doc = XMLUtil.parse(new InputSource JavaDoc(px.toURI().toString()), false, true, null, null);
616         NodeList JavaDoc nl = doc.getDocumentElement().getElementsByTagNameNS(NbModuleProjectType.NAMESPACE_SHARED_2, "data");
617         assertEquals(1, nl.getLength());
618         Element JavaDoc data = (Element JavaDoc) nl.item(0);
619         // XXX insert at position 1, between <c-n-b> and <m-d>:
620
data.appendChild(doc.createElementNS(NbModuleProjectType.NAMESPACE_SHARED_2, "standalone"));
621         os = new FileOutputStream JavaDoc(px);
622         try {
623             XMLUtil.write(doc, os, "UTF-8");
624         } finally {
625             os.close();
626         }
627         FileObject audioviewerFO = FileUtil.toFileObject(audioviewer);
628         Project p = ProjectManager.getDefault().findProject(audioviewerFO);
629         assertNotNull(p);
630         FileObject src = audioviewerFO.getFileObject("src");
631         ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
632         assertNotNull("have a COMPILE classpath", cp);
633         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
634         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-actions.jar"));
635         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-dialogs.jar"));
636         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/core/org-openide-filesystems.jar"));
637         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"));
638         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-nodes.jar"));
639         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-text.jar"));
640         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
641         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-windows.jar"));
642         File JavaDoc lib = new File JavaDoc(jmfhome, "lib");
643         expectedRoots.add(Util.urlForJar(new File JavaDoc(lib, "jmf.jar")).toExternalForm());
644         expectedRoots.add(Util.urlForJar(new File JavaDoc(lib, "mediaplayer.jar")).toExternalForm());
645         assertEquals("right COMPILE classpath incl. absolute locations of JARs",
646             expectedRoots.toString(), urlsOfCp(cp).toString());
647     }
648     
649     private void assertClassPathsHaveTheSameResources(ClassPath actual, ClassPath expected) {
650         assertSets("cls: ",urlsOfCp(expected), urlsOfCp(actual));
651     }
652     
653     public void testTransitiveExecuteClasspath() throws Exception JavaDoc { // #70206
654
NbModuleProject p = TestBase.generateStandaloneModule(getWorkDir(), "prj");
655         Util.addDependency(p, "org.openide.windows");
656         ProjectManager.getDefault().saveProject(p);
657         ClassPath cp = ClassPath.getClassPath(p.getSourceDirectory(), ClassPath.EXECUTE);
658         Set JavaDoc/*<String>*/ expectedRoots = new TreeSet JavaDoc();
659         // What we just added:
660
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-windows.jar"));
661         // And its transitive deps:
662
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-dialogs.jar"));
663         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-nodes.jar"));
664         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-awt.jar"));
665         expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/org-openide-util.jar"));
666         // Dialogs API depends on Progress API
667
expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-api-progress.jar"));
668         // And the usual:
669
expectedRoots.add(Util.urlForDir(new File JavaDoc(p.getProjectDirectoryFile(), "build/classes")).toExternalForm());
670         assertEquals("right EXECUTE classpath incl. transitive deps",
671             expectedRoots.toString(), urlsOfCp(cp).toString());
672     }
673     
674 }
675
Popular Tags