1 19 20 package org.netbeans.modules.apisupport.project.queries; 21 22 import java.io.File ; 23 import java.net.URL ; 24 import java.util.SortedSet ; 25 import java.util.TreeSet ; 26 import org.netbeans.api.java.classpath.ClassPath; 27 import org.netbeans.api.java.queries.JavadocForBinaryQuery; 28 import org.netbeans.modules.apisupport.project.TestBase; 29 import org.netbeans.modules.apisupport.project.Util; 30 import org.openide.filesystems.FileUtil; 31 32 37 public class JavadocForBinaryImplTest extends TestBase { 38 39 static { 40 JavadocForBinaryImpl.ignoreNonexistentRoots = false; 41 } 42 43 private File suite2, suite3; 44 45 public JavadocForBinaryImplTest(String name) { 46 super(name); 47 } 48 49 protected void setUp() throws Exception { 50 super.setUp(); 51 suite2 = resolveEEPFile("suite2"); 52 suite3 = resolveEEPFile("suite3"); 53 } 54 55 public void testJavadocForNetBeansOrgModules() throws Exception { 56 ClassPath.getClassPath(nbCVSRoot().getFileObject("ant/src"), ClassPath.COMPILE); 58 File classfileJar = file("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-classfile.jar"); 59 URL [] roots = JavadocForBinaryQuery.findJavadoc(Util.urlForJar(classfileJar)).getRoots(); 60 URL [] expectedRoots = new URL [] { 61 Util.urlForDir(file("nbbuild/build/javadoc/org-netbeans-modules-classfile")), 62 urlForJar(apisZip, "org-netbeans-modules-classfile/"), 63 }; 64 assertEquals("correct Javadoc roots for classfile", urlSet(expectedRoots), urlSet(roots)); 65 } 66 67 public void testJavadocForExternalModules() throws Exception { 68 ClassPath.getClassPath(resolveEEP("/suite2/misc-project/src"), ClassPath.COMPILE); 69 File miscJar = resolveEEPFile("/suite2/build/cluster/modules/org-netbeans-examples-modules-misc.jar"); 70 URL [] roots = JavadocForBinaryQuery.findJavadoc(Util.urlForJar(miscJar)).getRoots(); 71 URL [] expectedRoots = new URL [] { 72 Util.urlForDir(file(suite2, "misc-project/build/javadoc/org-netbeans-examples-modules-misc")), 73 urlForJar(apisZip, "org-netbeans-examples-modules-misc/"), 75 }; 76 assertEquals("correct Javadoc roots for misc", urlSet(expectedRoots), urlSet(roots)); 77 ClassPath.getClassPath(resolveEEP("/suite3/dummy-project/src"), ClassPath.COMPILE); 78 File dummyJar = file(suite3, "dummy-project/build/cluster/modules/org-netbeans-examples-modules-dummy.jar"); 79 roots = JavadocForBinaryQuery.findJavadoc(Util.urlForJar(dummyJar)).getRoots(); 80 expectedRoots = new URL [] { 81 Util.urlForDir(file(suite3, "dummy-project/build/javadoc/org-netbeans-examples-modules-dummy")), 82 }; 83 assertEquals("correct Javadoc roots for dummy", urlSet(expectedRoots), urlSet(roots)); 84 } 85 86 private static URL urlForJar(File jar, String path) throws Exception { 87 return new URL (Util.urlForJar(jar), path); 88 } 89 90 private static SortedSet urlSet(URL [] urls) { 91 SortedSet set = new TreeSet (); 92 for (int i = 0; i < urls.length; i++) { 93 set.add(urls[i].toExternalForm()); 94 } 95 return set; 96 } 97 98 } 99 | Popular Tags |