Lines 18-25
Link Here
|
18 |
import java.util.Arrays; |
18 |
import java.util.Arrays; |
19 |
import java.util.Collections; |
19 |
import java.util.Collections; |
20 |
import java.util.HashSet; |
20 |
import java.util.HashSet; |
|
|
21 |
import java.util.Iterator; |
21 |
import java.util.List; |
22 |
import java.util.List; |
22 |
import java.util.Set; |
23 |
import java.util.Set; |
|
|
24 |
import java.util.TreeSet; |
23 |
import java.util.regex.Matcher; |
25 |
import java.util.regex.Matcher; |
24 |
import java.util.regex.Pattern; |
26 |
import java.util.regex.Pattern; |
25 |
import org.netbeans.api.java.classpath.ClassPath; |
27 |
import org.netbeans.api.java.classpath.ClassPath; |
Lines 27-32
Link Here
|
27 |
import org.netbeans.spi.project.support.ant.EditableProperties; |
29 |
import org.netbeans.spi.project.support.ant.EditableProperties; |
28 |
import org.openide.filesystems.FileLock; |
30 |
import org.openide.filesystems.FileLock; |
29 |
import org.openide.filesystems.FileObject; |
31 |
import org.openide.filesystems.FileObject; |
|
|
32 |
import org.openide.filesystems.FileUtil; |
30 |
|
33 |
|
31 |
// XXX testClasspathsOfBuildProducts |
34 |
// XXX testClasspathsOfBuildProducts |
32 |
// - should have BOOT and EXECUTE |
35 |
// - should have BOOT and EXECUTE |
Lines 85-100
Link Here
|
85 |
} |
88 |
} |
86 |
|
89 |
|
87 |
public void testExecuteClasspath() throws Exception { |
90 |
public void testExecuteClasspath() throws Exception { |
88 |
// For now, just the same as COMPILE. |
|
|
89 |
// XXX should include built-to paths |
90 |
ClassPath cp = ClassPath.getClassPath(myAppJava, ClassPath.EXECUTE); |
91 |
ClassPath cp = ClassPath.getClassPath(myAppJava, ClassPath.EXECUTE); |
91 |
assertNotNull("have some EXECUTE classpath for src/", cp); |
92 |
assertNotNull("have some EXECUTE classpath for src/", cp); |
92 |
assertEquals("have two entries in " + cp, 2, cp.getRoots().length); |
93 |
Set/*<String>*/ roots = new TreeSet(); |
93 |
assertNotNull("found WeakSet in " + cp, cp.findResource("org/openide/util/WeakSet.class")); |
94 |
roots.add(urlForJar("lib/lib1.jar")); |
94 |
assertNotNull("found NullInputStream", cp.findResource("org/openide/util/io/NullInputStream.class")); |
95 |
roots.add(urlForJar("lib/lib2.jar")); |
|
|
96 |
// #49113: includes built-to dirs as well. |
97 |
roots.add(urlForJar("build/simple-app.jar")); |
98 |
roots.add(urlForFolder("build/classes")); |
99 |
assertEquals("right EXECUTE cp for src/", roots.toString(), urlsOfCp(cp).toString()); |
95 |
cp = ClassPath.getClassPath(specialTaskJava, ClassPath.EXECUTE); |
100 |
cp = ClassPath.getClassPath(specialTaskJava, ClassPath.EXECUTE); |
96 |
assertNotNull("have some EXECUTE classpath for antsrc/", cp); |
101 |
assertNotNull("have some EXECUTE classpath for antsrc/", cp); |
97 |
assertEquals("have one entry", 1, cp.getRoots().length); |
102 |
// Just check number of entries here... could instead find ${ant.home}/lib/ant.jar. |
|
|
103 |
assertEquals("have two entries (ant.jar + build/antclasses) in " + cp, 2, cp.entries().size()); |
98 |
assertNotNull("found Task", cp.findResource("org/apache/tools/ant/Task.class")); |
104 |
assertNotNull("found Task", cp.findResource("org/apache/tools/ant/Task.class")); |
99 |
cp = ClassPath.getClassPath(buildProperties, ClassPath.EXECUTE); |
105 |
cp = ClassPath.getClassPath(buildProperties, ClassPath.EXECUTE); |
100 |
assertNull("have no EXECUTE classpath for build.properties", cp); |
106 |
assertNull("have no EXECUTE classpath for build.properties", cp); |
Lines 207-212
Link Here
|
207 |
assertEquals("have one root in " + cp, 1, cp.getRoots().length); |
213 |
assertEquals("have one root in " + cp, 1, cp.getRoots().length); |
208 |
assertNotNull("found WeakSet in " + cp, cp.findResource("org/openide/util/WeakSet.class")); |
214 |
assertNotNull("found WeakSet in " + cp, cp.findResource("org/openide/util/WeakSet.class")); |
209 |
assertNull("did not find NullInputStream", cp.findResource("org/openide/util/io/NullInputStream.class")); |
215 |
assertNull("did not find NullInputStream", cp.findResource("org/openide/util/io/NullInputStream.class")); |
|
|
216 |
} |
217 |
|
218 |
// Copied from org.netbeans.modules.apisupport.project.ClassPathProviderImplTest: |
219 |
private String urlForJar(String path) throws Exception { |
220 |
return FileUtil.getArchiveRoot(simple.helper().resolveFile(path).toURI().toURL()).toExternalForm(); |
221 |
} |
222 |
private String urlForFolder(String path) throws Exception { |
223 |
String s = simple.helper().resolveFile(path).toURI().toURL().toExternalForm(); |
224 |
if (s.endsWith("/")) { |
225 |
return s; |
226 |
} else { |
227 |
return s + "/"; |
228 |
} |
229 |
} |
230 |
private Set/*<String>*/ urlsOfCp(ClassPath cp) { |
231 |
Set/*<String>*/ s = new TreeSet(); |
232 |
Iterator it = cp.entries().iterator(); |
233 |
while (it.hasNext()) { |
234 |
s.add(((ClassPath.Entry) it.next()).getURL().toExternalForm()); |
235 |
} |
236 |
return s; |
210 |
} |
237 |
} |
211 |
|
238 |
|
212 |
} |
239 |
} |