TestValueTag.java revision 797
232N/A/*
232N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
232N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
232N/A *
232N/A * This code is free software; you can redistribute it and/or modify it
232N/A * under the terms of the GNU General Public License version 2 only, as
232N/A * published by the Free Software Foundation.
232N/A *
232N/A * This code is distributed in the hope that it will be useful, but WITHOUT
232N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
232N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
232N/A * version 2 for more details (a copy is included in the LICENSE file that
232N/A * accompanied this code).
232N/A *
232N/A * You should have received a copy of the GNU General Public License version
232N/A * 2 along with this work; if not, write to the Free Software Foundation,
232N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
232N/A *
232N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
232N/A * or visit www.oracle.com if you need additional information or have any
232N/A * questions.
232N/A */
232N/A
232N/A/*
232N/A * @test
232N/A * @bug 4764045
232N/A * @summary This test ensures that the value tag works in all
243N/A * use cases. The explainations for each test case are written below.
232N/A * @author jamieh
232N/A * @library ../lib/
232N/A * @build JavadocTester
232N/A * @build TestValueTag
232N/A * @run main TestValueTag
232N/A */
232N/A
232N/Apublic class TestValueTag extends JavadocTester {
232N/A
232N/A //Test information.
243N/A private static final String BUG_ID = "4764045";
232N/A
232N/A //Javadoc arguments.
232N/A private static final String[] ARGS =
232N/A new String[] {
232N/A "-d", BUG_ID, "-sourcepath", SRC_DIR, "-tag",
232N/A "todo", "pkg1", "pkg2"
232N/A };
232N/A
232N/A //Input for string search tests.
232N/A private static final String[][] TEST = {
232N/A //Base case: using @value on a constant.
232N/A {BUG_ID + FS + "pkg1" + FS + "Class1.html",
232N/A "Result: \"Test 1 passes\""},
232N/A //Retrieve value of constant in same class.
232N/A {BUG_ID + FS + "pkg1" + FS + "Class1.html",
232N/A "Result: <a href=\"../pkg1/Class1.html#TEST_2_PASSES\">\"Test 2 passes\"</a>"},
232N/A {BUG_ID + FS + "pkg1" + FS + "Class1.html",
232N/A "Result: <a href=\"../pkg1/Class1.html#TEST_3_PASSES\">\"Test 3 passes\"</a>"},
243N/A {BUG_ID + FS + "pkg1" + FS + "Class1.html",
243N/A "Result: <a href=\"../pkg1/Class1.html#TEST_4_PASSES\">\"Test 4 passes\"</a>"},
243N/A {BUG_ID + FS + "pkg1" + FS + "Class1.html",
232N/A "Result: <a href=\"../pkg1/Class1.html#TEST_5_PASSES\">\"Test 5 passes\"</a>"},
232N/A {BUG_ID + FS + "pkg1" + FS + "Class1.html",
232N/A "Result: <a href=\"../pkg1/Class1.html#TEST_6_PASSES\">\"Test 6 passes\"</a>"},
232N/A //Retrieve value of constant in different class.
232N/A {BUG_ID + FS + "pkg1" + FS + "Class2.html",
232N/A "Result: <a href=\"../pkg1/Class1.html#TEST_7_PASSES\">\"Test 7 passes\"</a>"},
232N/A {BUG_ID + FS + "pkg1" + FS + "Class2.html",
232N/A "Result: <a href=\"../pkg1/Class1.html#TEST_8_PASSES\">\"Test 8 passes\"</a>"},
232N/A {BUG_ID + FS + "pkg1" + FS + "Class2.html",
232N/A "Result: <a href=\"../pkg1/Class1.html#TEST_9_PASSES\">\"Test 9 passes\"</a>"},
232N/A {BUG_ID + FS + "pkg1" + FS + "Class2.html",
232N/A "Result: <a href=\"../pkg1/Class1.html#TEST_10_PASSES\">\"Test 10 passes\"</a>"},
232N/A {BUG_ID + FS + "pkg1" + FS + "Class2.html",
232N/A "Result: <a href=\"../pkg1/Class1.html#TEST_11_PASSES\">\"Test 11 passes\"</a>"},
232N/A //Retrieve value of constant in different package
232N/A {BUG_ID + FS + "pkg1" + FS + "Class2.html",
232N/A "Result: <a href=\"../pkg2/Class3.html#TEST_12_PASSES\">\"Test 12 passes\"</a>"},
232N/A {BUG_ID + FS + "pkg1" + FS + "Class2.html",
232N/A "Result: <a href=\"../pkg2/Class3.html#TEST_13_PASSES\">\"Test 13 passes\"</a>"},
232N/A {BUG_ID + FS + "pkg1" + FS + "Class2.html",
232N/A "Result: <a href=\"../pkg2/Class3.html#TEST_14_PASSES\">\"Test 14 passes\"</a>"},
232N/A {BUG_ID + FS + "pkg1" + FS + "Class2.html",
232N/A "Result: <a href=\"../pkg2/Class3.html#TEST_15_PASSES\">\"Test 15 passes\"</a>"},
232N/A {BUG_ID + FS + "pkg1" + FS + "Class2.html",
232N/A "Result: <a href=\"../pkg2/Class3.html#TEST_16_PASSES\">\"Test 16 passes\"</a>"},
232N/A //Retrieve value of constant from a package page
232N/A {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
232N/A "Result: <a href=\"../pkg2/Class3.html#TEST_17_PASSES\">\"Test 17 passes\"</a>"},
232N/A //Test @value tag used with custom tag.
232N/A {BUG_ID + FS + "pkg1" + FS + "CustomTagUsage.html",
232N/A "<dt><span class=\"strong\">Todo:</span></dt>" + NL +
232N/A " <dd>the value of this constant is 55.</dd>"},
232N/A //Test @value warning printed when used with non-constant.
232N/A {WARNING_OUTPUT,"warning - @value tag (which references nonConstant) " +
232N/A "can only be used in constants."
232N/A },
232N/A //Test warning printed for bad reference.
232N/A {WARNING_OUTPUT,"warning - UnknownClass#unknownConstant (referenced by " +
232N/A "@value tag) is an unknown reference."
232N/A },
232N/A };
232N/A private static final String[][] NEGATED_TEST = NO_TEST;
232N/A
232N/A /**
232N/A * The entry point of the test.
232N/A * @param args the array of command line arguments.
232N/A */
232N/A public static void main(String[] args) {
232N/A TestValueTag tester = new TestValueTag();
232N/A run(tester, ARGS, TEST, NEGATED_TEST);
232N/A tester.printSummary();
232N/A }
232N/A
232N/A /**
232N/A * {@inheritDoc}
232N/A */
232N/A public String getBugId() {
232N/A return BUG_ID;
232N/A }
232N/A
232N/A /**
232N/A * {@inheritDoc}
232N/A */
232N/A public String getBugName() {
232N/A return getClass().getName();
232N/A }
232N/A}
232N/A