/* * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 8141492 * @summary Test the search feature of javadoc. * @author bpatel * @library ../lib * @modules jdk.javadoc * @build JavadocTester * @run main TestSearch */ public class TestSearch extends JavadocTester { public static void main(String... args) throws Exception { TestSearch tester = new TestSearch(); tester.runTests(); } @Test void test1() { javadoc("-d", "out-1", "-sourcepath", "-use", testSrc("UnnamedPkgClass.java")); checkExit(Exit.OK); checkSearchOutput("UnnamedPkgClass.html", true); checkJqueryAndImageFiles(true); checkFiles(false, "package-search-index.zip", "tag-search-index.zip"); checkFiles(true, "member-search-index.zip", "type-search-index.zip"); } @Test void test2() { javadoc("-d", "out-2", "-Xdoclint:none", "-sourcepath", testSrc, "-use", "pkg", "pkg1", "pkg2", "pkg3"); checkExit(Exit.OK); checkInvalidUsageIndexTag(); checkSearchOutput(true); checkSingleIndex(true); checkJqueryAndImageFiles(true); checkFiles(true, "member-search-index.zip", "package-search-index.zip", "tag-search-index.zip", "type-search-index.zip"); } @Test void test2a() { javadoc("-d", "out-2a", "-Xdoclint:all", "-sourcepath", testSrc, "-use", "pkg", "pkg1", "pkg2", "pkg3"); checkExit(Exit.FAILED); checkDocLintErrors(); checkSearchOutput(true); checkSingleIndex(true); checkJqueryAndImageFiles(true); checkFiles(true, "member-search-index.zip", "package-search-index.zip", "tag-search-index.zip", "type-search-index.zip"); } @Test void test3() { javadoc("-d", "out-3", "-noindex", "-Xdoclint:none", "-sourcepath", testSrc, "-use", "pkg", "pkg1", "pkg2", "pkg3"); checkExit(Exit.OK); checkSearchOutput(false); checkJqueryAndImageFiles(false); checkFiles(false, "member-search-index.zip", "package-search-index.zip", "tag-search-index.zip", "type-search-index.zip", "index-all.html"); } @Test void test4() { javadoc("-d", "out-4", "-html5", "-Xdoclint:none", "-sourcepath", testSrc, "-use", "pkg", "pkg1", "pkg2", "pkg3"); checkExit(Exit.OK); checkSearchOutput(true); checkSingleIndex(true); checkJqueryAndImageFiles(true); checkFiles(true, "member-search-index.zip", "package-search-index.zip", "tag-search-index.zip", "type-search-index.zip"); } @Test void test5() { javadoc("-d", "out-5", "-noindex", "-html5", "-Xdoclint:none", "-sourcepath", testSrc, "-use", "pkg", "pkg1", "pkg2", "pkg3"); checkExit(Exit.OK); checkSearchOutput(false); checkJqueryAndImageFiles(false); checkFiles(false, "member-search-index.zip", "package-search-index.zip", "tag-search-index.zip", "type-search-index.zip", "index-all.html"); } @Test void test6() { javadoc("-d", "out-6", "-nocomment", "-Xdoclint:none", "-sourcepath", testSrc, "-use", "pkg", "pkg1", "pkg2", "pkg3"); checkExit(Exit.OK); checkSearchOutput(true); checkIndexNoComment(); checkJqueryAndImageFiles(true); checkFiles(true, "member-search-index.zip", "package-search-index.zip", "tag-search-index.zip", "type-search-index.zip"); } @Test void test7() { javadoc("-d", "out-7", "-nodeprecated", "-Xdoclint:none", "-sourcepath", testSrc, "-use", "pkg", "pkg1", "pkg2", "pkg3"); checkExit(Exit.OK); checkSearchOutput(true); checkIndexNoDeprecated(); checkJqueryAndImageFiles(true); checkFiles(true, "member-search-index.zip", "package-search-index.zip", "tag-search-index.zip", "type-search-index.zip"); } @Test void test8() { javadoc("-d", "out-8", "-splitindex", "-Xdoclint:none", "-sourcepath", testSrc, "-use", "pkg", "pkg1", "pkg2", "pkg3"); checkExit(Exit.OK); checkInvalidUsageIndexTag(); checkSearchOutput(true); checkSplitIndex(); checkJqueryAndImageFiles(true); checkFiles(true, "member-search-index.zip", "package-search-index.zip", "tag-search-index.zip", "type-search-index.zip"); } @Test void test9() { javadoc("-d", "out-9", "-sourcepath", testSrc, "-javafx", "-package", "-use", "pkgfx", "pkg3"); checkExit(Exit.OK); checkSearchOutput(true); checkJavaFXOutput(); checkJqueryAndImageFiles(true); checkFiles(false, "tag-search-index.zip"); checkFiles(true, "member-search-index.zip", "package-search-index.zip", "type-search-index.zip"); } void checkDocLintErrors() { checkOutput(Output.OUT, true, "A sample method. Testing search tag for {@index \"unclosed quote}.", "Another test class. Testing empty {@index }.", "Constant field. Testing no text in index tag {@index}.", "A test field. Testing only white-spaces in index tag text {@index }."); } void checkSearchOutput(boolean expectedOutput) { checkSearchOutput("overview-summary.html", expectedOutput); } void checkSearchOutput(String fileName, boolean expectedOutput) { // Test for search related markup checkOutput(fileName, expectedOutput, "\n", "\n", "\n", "\n", "\n", "", "var pathtoroot = \"./\";loadScripts(document, 'script');", "