1 19 20 package org.netbeans.modules.java.freeform; 21 22 import java.net.URL ; 23 import java.util.Arrays ; 24 import java.util.Collections ; 25 import java.util.List ; 26 import org.netbeans.api.java.queries.JavadocForBinaryQuery; 27 import org.netbeans.modules.ant.freeform.TestBase; 28 import org.openide.filesystems.FileUtil; 29 30 34 public class JavadocQueryTest extends TestBase { 35 36 public JavadocQueryTest(String name) { 37 super(name); 38 } 39 40 private URL classes1Dir, classes1Jar, classes2Dir, javadoc1Dir, javadoc2Zip; 41 42 protected void setUp() throws Exception { 43 super.setUp(); 44 classes1Dir = asDir("classes1"); 45 classes1Jar = asJar("classes1.jar"); 46 classes2Dir = asDir("classes2"); 47 javadoc1Dir = asDir("javadoc1"); 48 javadoc2Zip = asJar("javadoc2.zip"); 49 } 50 51 private URL asDir(String path) throws Exception { 52 URL u = simple2.helper().resolveFile(path).toURI().toURL(); 53 String us = u.toExternalForm(); 54 if (us.endsWith("/")) { 55 return u; 56 } else { 57 return new URL (us + "/"); 58 } 59 } 60 61 private URL asJar(String path) throws Exception { 62 return FileUtil.getArchiveRoot(simple2.helper().resolveFile(path).toURI().toURL()); 63 } 64 65 private List <URL > javadocFor(URL binary) { 66 return Arrays.asList(JavadocForBinaryQuery.findJavadoc(binary).getRoots()); 67 } 68 69 public void testFindJavadoc() throws Exception { 70 List <URL > both = Arrays.asList(new URL [] {javadoc1Dir, javadoc2Zip}); 71 assertEquals("both Javadoc found for " + classes1Dir, both, javadocFor(classes1Dir)); 72 assertEquals("both Javadoc found for " + classes1Jar, both, javadocFor(classes1Jar)); 73 assertEquals("no Javadoc found for " + classes2Dir, Collections.EMPTY_LIST, javadocFor(classes2Dir)); 74 } 75 76 78 } 79 | Popular Tags |