Mon, 23 Jan 2017 17:03:12 -0800
Merge
1 /*
2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 import java.text.SimpleDateFormat;
25 import java.util.Date;
27 /*
28 * @test
29 * @bug 4034096 4764726 6235799
30 * @summary Add support for HTML keywords via META tag for
31 * class and member names to improve API search
32 * @author dkramer
33 * @library ../lib/
34 * @build JavadocTester
35 * @build MetaTag
36 * @run main MetaTag
37 */
39 public class MetaTag extends JavadocTester {
41 //Test information.
42 private static final String BUG_ID = "4034096-4764726-6235799";
43 private static final String OUTPUT_DIR = "docs-" + BUG_ID;
44 private static final SimpleDateFormat m_dateFormat = new SimpleDateFormat("yyyy-MM-dd");
46 //Javadoc arguments.
47 private static final String[] ARGS = new String[] {
48 "-d", OUTPUT_DIR,
49 "-sourcepath", SRC_DIR,
50 "-keywords",
51 "-doctitle", "Sample Packages",
52 "p1", "p2"
53 };
55 private static final String[] ARGS_NO_TIMESTAMP_NO_KEYWORDS = new String[] {
56 "-d", OUTPUT_DIR + "-2",
57 "-sourcepath", SRC_DIR,
58 "-notimestamp",
59 "-doctitle", "Sample Packages",
60 "p1", "p2"
61 };
63 //Input for string search tests.
64 private static final String[][] TEST = {
66 { OUTPUT_DIR + FS + "p1" + FS + "C1.html",
67 "<meta name=\"keywords\" content=\"p1.C1 class\">" },
69 { OUTPUT_DIR + FS + "p1" + FS + "C1.html",
70 "<meta name=\"keywords\" content=\"field1\">" },
72 { OUTPUT_DIR + FS + "p1" + FS + "C1.html",
73 "<meta name=\"keywords\" content=\"field2\">" },
75 { OUTPUT_DIR + FS + "p1" + FS + "C1.html",
76 "<meta name=\"keywords\" content=\"method1()\">" },
78 { OUTPUT_DIR + FS + "p1" + FS + "C1.html",
79 "<meta name=\"keywords\" content=\"method2()\">" },
81 { OUTPUT_DIR + FS + "p1" + FS + "package-summary.html",
82 "<meta name=\"keywords\" content=\"p1 package\">" },
84 { OUTPUT_DIR + FS + "overview-summary.html",
85 "<meta name=\"keywords\" content=\"Overview, Sample Packages\">" },
87 //NOTE: Hopefully, this regression test is not run at midnight. If the output
88 //was generated yesterday and this test is run today, the test will fail.
89 {OUTPUT_DIR + FS + "overview-summary.html",
90 "<meta name=\"date\" "
91 + "content=\"" + m_dateFormat.format(new Date()) + "\">"},
92 };
94 private static final String[][] NEGATED_TEST = NO_TEST;
96 private static final String[][] TEST2 = NO_TEST;
97 private static final String[][] NEGATED_TEST2 = {
98 //No keywords when -keywords is not used.
99 { OUTPUT_DIR + "-2" + FS + "p1" + FS + "C1.html",
100 "<META NAME=\"keywords\" CONTENT=\"p1.C1 class\">" },
102 { OUTPUT_DIR + "-2" + FS + "p1" + FS + "C1.html",
103 "<META NAME=\"keywords\" CONTENT=\"field1\">" },
105 { OUTPUT_DIR + "-2" + FS + "p1" + FS + "C1.html",
106 "<META NAME=\"keywords\" CONTENT=\"field2\">" },
108 { OUTPUT_DIR + "-2" + FS + "p1" + FS + "C1.html",
109 "<META NAME=\"keywords\" CONTENT=\"method1()\">" },
111 { OUTPUT_DIR + "-2" + FS + "p1" + FS + "C1.html",
112 "<META NAME=\"keywords\" CONTENT=\"method2()\">" },
114 { OUTPUT_DIR + "-2" + FS + "p1" + FS + "package-summary.html",
115 "<META NAME=\"keywords\" CONTENT=\"p1 package\">" },
117 { OUTPUT_DIR + "-2" + FS + "overview-summary.html",
118 "<META NAME=\"keywords\" CONTENT=\"Overview Summary, Sample Packages\">" },
120 //The date metatag should not show up when -notimestamp is used.
122 //NOTE: Hopefully, this regression test is not run at midnight. If the output
123 //was generated yesterday and this test is run today, the test will fail.
124 {OUTPUT_DIR + "-2" + FS + "overview-summary.html",
125 "<META NAME=\"date\" "
126 + "CONTENT=\"" + m_dateFormat.format(new Date()) + "\">"},
127 };
129 /**
130 * The entry point of the test.
131 * @param args the array of command line arguments.
132 */
133 public static void main(String[] args) {
134 MetaTag tester = new MetaTag();
135 run(tester, ARGS, TEST, NEGATED_TEST);
136 run(tester, ARGS_NO_TIMESTAMP_NO_KEYWORDS, TEST2, NEGATED_TEST2);
137 tester.printSummary();
138 }
140 /**
141 * {@inheritDoc}
142 */
143 public String getBugId() {
144 return BUG_ID;
145 }
147 /**
148 * {@inheritDoc}
149 */
150 public String getBugName() {
151 return getClass().getName();
152 }
153 }