author | jjg |
Tue, 22 Apr 2014 17:57:40 -0700 | |
changeset 24072 | e7549dcbc4af |
parent 24065 | fc4022e50129 |
child 24399 | af1a0220d0fa |
permissions | -rw-r--r-- |
10 | 1 |
/* |
23971 | 2 |
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
20264
diff
changeset
|
26 |
* @bug 4764045 8004825 8026567 |
10 | 27 |
* @summary This test ensures that the value tag works in all |
28 |
* use cases. The explainations for each test case are written below. |
|
29 |
* @author jamieh |
|
30 |
* @library ../lib/ |
|
20264 | 31 |
* @build JavadocTester TestValueTag |
10 | 32 |
* @run main TestValueTag |
33 |
*/ |
|
34 |
||
35 |
public class TestValueTag extends JavadocTester { |
|
36 |
||
37 |
//Javadoc arguments. |
|
38 |
private static final String[] ARGS = |
|
39 |
new String[] { |
|
24072 | 40 |
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-tag", |
20264 | 41 |
"todo", "pkg1", "pkg2" |
42 |
}; |
|
43 |
||
44 |
private static final String[] ARGS1 = |
|
45 |
new String[] { |
|
15354 | 46 |
"-Xdoclint:none", |
24072 | 47 |
"-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "-tag", |
10 | 48 |
"todo", "pkg1", "pkg2" |
49 |
}; |
|
50 |
||
51 |
//Input for string search tests. |
|
52 |
private static final String[][] TEST = { |
|
53 |
//Base case: using @value on a constant. |
|
24072 | 54 |
{ "pkg1/Class1.html", |
10 | 55 |
"Result: \"Test 1 passes\""}, |
56 |
//Retrieve value of constant in same class. |
|
24072 | 57 |
{ "pkg1/Class1.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
58 |
"Result: <a href=\"../pkg1/Class1.html#TEST_2_PASSES\">\"Test 2 passes\"</a>"}, |
24072 | 59 |
{ "pkg1/Class1.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
60 |
"Result: <a href=\"../pkg1/Class1.html#TEST_3_PASSES\">\"Test 3 passes\"</a>"}, |
24072 | 61 |
{ "pkg1/Class1.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
62 |
"Result: <a href=\"../pkg1/Class1.html#TEST_4_PASSES\">\"Test 4 passes\"</a>"}, |
24072 | 63 |
{ "pkg1/Class1.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
64 |
"Result: <a href=\"../pkg1/Class1.html#TEST_5_PASSES\">\"Test 5 passes\"</a>"}, |
24072 | 65 |
{ "pkg1/Class1.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
66 |
"Result: <a href=\"../pkg1/Class1.html#TEST_6_PASSES\">\"Test 6 passes\"</a>"}, |
10 | 67 |
//Retrieve value of constant in different class. |
24072 | 68 |
{ "pkg1/Class2.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
69 |
"Result: <a href=\"../pkg1/Class1.html#TEST_7_PASSES\">\"Test 7 passes\"</a>"}, |
24072 | 70 |
{ "pkg1/Class2.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
71 |
"Result: <a href=\"../pkg1/Class1.html#TEST_8_PASSES\">\"Test 8 passes\"</a>"}, |
24072 | 72 |
{ "pkg1/Class2.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
73 |
"Result: <a href=\"../pkg1/Class1.html#TEST_9_PASSES\">\"Test 9 passes\"</a>"}, |
24072 | 74 |
{ "pkg1/Class2.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
75 |
"Result: <a href=\"../pkg1/Class1.html#TEST_10_PASSES\">\"Test 10 passes\"</a>"}, |
24072 | 76 |
{ "pkg1/Class2.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
77 |
"Result: <a href=\"../pkg1/Class1.html#TEST_11_PASSES\">\"Test 11 passes\"</a>"}, |
10 | 78 |
//Retrieve value of constant in different package |
24072 | 79 |
{ "pkg1/Class2.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
80 |
"Result: <a href=\"../pkg2/Class3.html#TEST_12_PASSES\">\"Test 12 passes\"</a>"}, |
24072 | 81 |
{ "pkg1/Class2.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
82 |
"Result: <a href=\"../pkg2/Class3.html#TEST_13_PASSES\">\"Test 13 passes\"</a>"}, |
24072 | 83 |
{ "pkg1/Class2.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
84 |
"Result: <a href=\"../pkg2/Class3.html#TEST_14_PASSES\">\"Test 14 passes\"</a>"}, |
24072 | 85 |
{ "pkg1/Class2.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
86 |
"Result: <a href=\"../pkg2/Class3.html#TEST_15_PASSES\">\"Test 15 passes\"</a>"}, |
24072 | 87 |
{ "pkg1/Class2.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
88 |
"Result: <a href=\"../pkg2/Class3.html#TEST_16_PASSES\">\"Test 16 passes\"</a>"}, |
10 | 89 |
//Retrieve value of constant from a package page |
24072 | 90 |
{ "pkg2/package-summary.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
91 |
"Result: <a href=\"../pkg2/Class3.html#TEST_17_PASSES\">\"Test 17 passes\"</a>"}, |
10 | 92 |
//Test @value tag used with custom tag. |
24072 | 93 |
{ "pkg1/CustomTagUsage.html", |
23971 | 94 |
"<dt><span class=\"simpleTagLabel\">Todo:</span></dt>\n" + |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
15354
diff
changeset
|
95 |
"<dd>the value of this constant is 55.</dd>"}, |
20264 | 96 |
//Test @value errors printed dues to invalid use or when used with |
97 |
//non-constant or with bad references. |
|
23971 | 98 |
{ERROR_OUTPUT,"error: value does not refer to a constant\n" + |
20264 | 99 |
" * Result: {@value TEST_12_ERROR}" |
100 |
}, |
|
23971 | 101 |
{ERROR_OUTPUT,"error: {@value} not allowed here\n" + |
20264 | 102 |
" * Result: {@value}" |
103 |
}, |
|
23971 | 104 |
{ERROR_OUTPUT,"error: value does not refer to a constant\n" + |
20264 | 105 |
" * Result: {@value NULL}" |
106 |
}, |
|
23971 | 107 |
{ERROR_OUTPUT,"error: {@value} not allowed here\n" + |
20264 | 108 |
" * Invalid (null): {@value}" |
109 |
}, |
|
23971 | 110 |
{ERROR_OUTPUT,"error: {@value} not allowed here\n" + |
20264 | 111 |
" * Invalid (non-constant field): {@value}" |
112 |
}, |
|
23971 | 113 |
{ERROR_OUTPUT,"error: value does not refer to a constant\n" + |
20264 | 114 |
" * Here is a bad value reference: {@value UnknownClass#unknownConstant}" |
115 |
}, |
|
23971 | 116 |
{ERROR_OUTPUT,"error: reference not found\n" + |
20264 | 117 |
" * Here is a bad value reference: {@value UnknownClass#unknownConstant}" |
118 |
}, |
|
23971 | 119 |
{ERROR_OUTPUT,"error: {@value} not allowed here\n" + |
20264 | 120 |
" * @todo the value of this constant is {@value}" |
121 |
} |
|
122 |
}; |
|
123 |
private static final String[][] TEST1 = { |
|
10 | 124 |
//Test @value warning printed when used with non-constant. |
125 |
{WARNING_OUTPUT,"warning - @value tag (which references nonConstant) " + |
|
126 |
"can only be used in constants." |
|
127 |
}, |
|
20264 | 128 |
{WARNING_OUTPUT,"warning - @value tag (which references NULL) " + |
129 |
"can only be used in constants." |
|
130 |
}, |
|
131 |
{WARNING_OUTPUT,"warning - @value tag (which references TEST_12_ERROR) " + |
|
132 |
"can only be used in constants." |
|
133 |
}, |
|
10 | 134 |
//Test warning printed for bad reference. |
135 |
{WARNING_OUTPUT,"warning - UnknownClass#unknownConstant (referenced by " + |
|
136 |
"@value tag) is an unknown reference." |
|
137 |
}, |
|
20264 | 138 |
//Test warning printed for invalid use of @value. |
139 |
{WARNING_OUTPUT,"warning - @value tag cannot be used here." |
|
140 |
} |
|
10 | 141 |
}; |
20264 | 142 |
private static final String[][] NEGATED_TEST = { |
143 |
//Base case: using @value on a constant. |
|
24072 | 144 |
{ "pkg1/Class1.html", |
20264 | 145 |
"Result: <a href=\"../pkg1/Class1.html#TEST_12_ERROR\">\"Test 12 " + |
146 |
"generates an error message\"</a>"}, |
|
147 |
}; |
|
10 | 148 |
|
149 |
/** |
|
150 |
* The entry point of the test. |
|
151 |
* @param args the array of command line arguments. |
|
152 |
*/ |
|
153 |
public static void main(String[] args) { |
|
154 |
TestValueTag tester = new TestValueTag(); |
|
24065
fc4022e50129
8041150: Avoid silly use of static methods in JavadocTester
jjg
parents:
23971
diff
changeset
|
155 |
tester.run(ARGS, TEST, NEGATED_TEST); |
20264 | 156 |
checkForException(tester); |
24065
fc4022e50129
8041150: Avoid silly use of static methods in JavadocTester
jjg
parents:
23971
diff
changeset
|
157 |
tester.run(ARGS1, TEST1, NO_TEST); |
20264 | 158 |
checkForException(tester); |
10 | 159 |
tester.printSummary(); |
160 |
} |
|
161 |
||
20264 | 162 |
public static void checkForException(TestValueTag tester) { |
163 |
if (tester.getErrorOutput().contains("DocletAbortException")) { |
|
164 |
throw new AssertionError("javadoc threw DocletAbortException"); |
|
165 |
} |
|
166 |
} |
|
10 | 167 |
} |