KickJava   Java API By Example, From Geeks To Geeks.

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


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.net.URL JavaDoc;
24 import java.util.SortedSet JavaDoc;
25 import java.util.TreeSet JavaDoc;
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 /**
33  * Test {@link JavadocForBinaryImpl}.
34  *
35  * @author Jesse Glick
36  */

37 public class JavadocForBinaryImplTest extends TestBase {
38
39     static {
40         JavadocForBinaryImpl.ignoreNonexistentRoots = false;
41     }
42     
43     private File JavaDoc suite2, suite3;
44     
45     public JavadocForBinaryImplTest(String JavaDoc name) {
46         super(name);
47     }
48     
49     protected void setUp() throws Exception JavaDoc {
50         super.setUp();
51         suite2 = resolveEEPFile("suite2");
52         suite3 = resolveEEPFile("suite3");
53     }
54     
55     public void testJavadocForNetBeansOrgModules() throws Exception JavaDoc {
56         // Have to load at least one module to get the scan going.
57
ClassPath.getClassPath(nbCVSRoot().getFileObject("ant/src"), ClassPath.COMPILE);
58         File JavaDoc classfileJar = file("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-classfile.jar");
59         URL JavaDoc[] roots = JavadocForBinaryQuery.findJavadoc(Util.urlForJar(classfileJar)).getRoots();
60         URL JavaDoc[] expectedRoots = new URL JavaDoc[] {
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 JavaDoc {
68         ClassPath.getClassPath(resolveEEP("/suite2/misc-project/src"), ClassPath.COMPILE);
69         File JavaDoc miscJar = resolveEEPFile("/suite2/build/cluster/modules/org-netbeans-examples-modules-misc.jar");
70         URL JavaDoc[] roots = JavadocForBinaryQuery.findJavadoc(Util.urlForJar(miscJar)).getRoots();
71         URL JavaDoc[] expectedRoots = new URL JavaDoc[] {
72             Util.urlForDir(file(suite2, "misc-project/build/javadoc/org-netbeans-examples-modules-misc")),
73             // It is inside ${netbeans.home}/.. so read this.
74
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 JavaDoc 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 JavaDoc[] {
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 JavaDoc urlForJar(File JavaDoc jar, String JavaDoc path) throws Exception JavaDoc {
87         return new URL JavaDoc(Util.urlForJar(jar), path);
88     }
89     
90     private static SortedSet JavaDoc/*<String>*/ urlSet(URL JavaDoc[] urls) {
91         SortedSet JavaDoc/*<String>*/ set = new TreeSet JavaDoc();
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