TestDocRootLink.java revision 2365:6207608205b8
1/*
2 * Copyright (c) 2011, 2014, 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 */
23
24/*
25 * @test
26 * @bug 6553182 8025416 8029504
27 * @summary This test verifies the -Xdocrootparent option.
28 * @author Bhavesh Patel
29 * @library ../lib/
30 * @build JavadocTester TestDocRootLink
31 * @run main TestDocRootLink
32 */
33public class TestDocRootLink extends JavadocTester {
34
35    private static final String BUG_ID = "6553182";
36    private static final String[][] TEST1 = {
37        {BUG_ID + "/pkg1/C1.html",
38            "Refer <a href=\"../../technotes/guides/index.html\">Here</a>"
39        },
40        {BUG_ID + "/pkg1/C1.html",
41            "This <a href=\"../pkg2/C2.html\">Here</a> should not be replaced\n" +
42            " with an absolute link."
43        },
44        {BUG_ID + "/pkg1/C1.html",
45            "Testing <a href=\"../technotes/guides/index.html\">Link 1</a> and\n" +
46            " <a href=\"../pkg2/C2.html\">Link 2</a>."
47        },
48        {BUG_ID + "/pkg1/package-summary.html",
49            "<a href=\"../../technotes/guides/index.html\">\n" +
50            "            Test document 1</a>"
51        },
52        {BUG_ID + "/pkg1/package-summary.html",
53            "<a href=\"../pkg2/C2.html\">\n" +
54            "            Another Test document 1</a>"
55        },
56        {BUG_ID + "/pkg1/package-summary.html",
57            "<a href=\"../technotes/guides/index.html\">\n" +
58            "            Another Test document 2.</a>"
59        }
60    };
61    private static final String[][] NEGATED_TEST1 = {
62        {BUG_ID + "/pkg1/C1.html",
63            "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">"
64        },
65        {BUG_ID + "/pkg1/C1.html",
66            "<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">"
67        },
68        {BUG_ID + "/pkg1/package-summary.html",
69            "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">"
70        },
71        {BUG_ID + "/pkg1/package-summary.html",
72            "<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">"
73        }
74    };
75    private static final String[][] TEST2 = {
76        {BUG_ID + "-1/pkg2/C2.html",
77            "Refer <a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">Here</a>"
78        },
79        {BUG_ID + "-1/pkg2/C2.html",
80            "This <a href=\"../pkg1/C1.html\">Here</a> should not be replaced\n" +
81            " with an absolute link."
82        },
83        {BUG_ID + "-1/pkg2/C2.html",
84            "Testing <a href=\"../technotes/guides/index.html\">Link 1</a> and\n" +
85            " <a href=\"../pkg1/C1.html\">Link 2</a>."
86        },
87        {BUG_ID + "-1/pkg2/package-summary.html",
88            "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">\n" +
89            "            Test document 1</a>"
90        },
91        {BUG_ID + "-1/pkg2/package-summary.html",
92            "<a href=\"../pkg1/C1.html\">\n" +
93            "            Another Test document 1</a>"
94        },
95        {BUG_ID + "-1/pkg2/package-summary.html",
96            "<a href=\"../technotes/guides/index.html\">\n" +
97            "            Another Test document 2.</a>"
98        }
99    };
100    private static final String[][] NEGATED_TEST2 = {
101        {BUG_ID + "-1/pkg2/C2.html",
102            "<a href=\"../../technotes/guides/index.html\">"
103        },
104        {BUG_ID + "-1/pkg2/C2.html",
105            "<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">"
106        },
107        {BUG_ID + "-1/pkg2/package-summary.html",
108            "<a href=\"../../technotes/guides/index.html\">"
109        },
110        {BUG_ID + "-1/pkg2/package-summary.html",
111            "<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">"
112        }
113    };
114    private static final String[] ARGS1 =
115            new String[]{
116        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1", "pkg2"
117    };
118    private static final String[] ARGS2 =
119            new String[]{
120        "-d", BUG_ID + "-1", "-Xdocrootparent",
121        "http://download.oracle.com/javase/7/docs", "-sourcepath",
122        SRC_DIR, "pkg1", "pkg2"
123    };
124
125    /**
126     * The entry point of the test.
127     * @param args the array of command line arguments.
128     */
129    public static void main(String[] args) {
130        TestDocRootLink tester = new TestDocRootLink();
131        run(tester, ARGS1, TEST1, NEGATED_TEST1);
132        run(tester, ARGS2, TEST2, NEGATED_TEST2);
133        tester.printSummary();
134    }
135
136    /**
137     * {@inheritDoc}
138     */
139    public String getBugId() {
140        return BUG_ID;
141    }
142
143    /**
144     * {@inheritDoc}
145     */
146    public String getBugName() {
147        return getClass().getName();
148    }
149}
150