TestDocRootLink.java revision 3233:b5d08bc0d224
1/* 2 * Copyright (c) 2011, 2015, 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 * @modules jdk.javadoc 31 * @build JavadocTester 32 * @run main TestDocRootLink 33 */ 34public class TestDocRootLink extends JavadocTester { 35 36 public static void main(String... args) throws Exception { 37 TestDocRootLink tester = new TestDocRootLink(); 38 tester.runTests(); 39 } 40 41 @Test 42 void test1() { 43 javadoc("-d", "out-1", 44 "-sourcepath", testSrc, 45 "pkg1", "pkg2"); 46 checkExit(Exit.OK); 47 48 checkOutput("pkg1/C1.html", true, 49 "Refer <a href=\"../../technotes/guides/index.html\">Here</a>", 50 "This <a href=\"../pkg2/C2.html\">Here</a> should not be replaced\n" + 51 " with an absolute link.", 52 "Testing <a href=\"../technotes/guides/index.html\">Link 1</a> and\n" + 53 " <a href=\"../pkg2/C2.html\">Link 2</a>."); 54 55 checkOutput("pkg1/package-summary.html", true, 56 "<a href=\"../../technotes/guides/index.html\">\n" + 57 " Test document 1</a>", 58 "<a href=\"../pkg2/C2.html\">\n" + 59 " Another Test document 1</a>", 60 "<a href=\"../technotes/guides/index.html\">\n" + 61 " Another Test document 2.</a>"); 62 63 // TODO: should this check *any* reference to http://download.oracle.com/ 64 checkOutput("pkg1/C1.html", false, 65 "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">", 66 "<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">"); 67 68 checkOutput("pkg1/package-summary.html", false, 69 "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">", 70 "<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">"); 71 } 72 73 @Test 74 void test2() { 75 javadoc("-d", "out-2", 76 "-Xdocrootparent", "http://download.oracle.com/javase/7/docs", 77 "-sourcepath", testSrc, 78 "pkg1", "pkg2"); 79 checkExit(Exit.OK); 80 81 checkOutput("pkg2/C2.html", true, 82 "Refer <a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">Here</a>", 83 "This <a href=\"../pkg1/C1.html\">Here</a> should not be replaced\n" + 84 " with an absolute link.", 85 "Testing <a href=\"../technotes/guides/index.html\">Link 1</a> and\n" + 86 " <a href=\"../pkg1/C1.html\">Link 2</a>."); 87 88 checkOutput("pkg2/package-summary.html", true, 89 "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">\n" + 90 " Test document 1</a>", 91 "<a href=\"../pkg1/C1.html\">\n" + 92 " Another Test document 1</a>", 93 "<a href=\"../technotes/guides/index.html\">\n" + 94 " Another Test document 2.</a>"); 95 96 checkOutput("pkg2/C2.html", false, 97 "<a href=\"../../technotes/guides/index.html\">", 98 "<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">"); 99 100 checkOutput("pkg2/package-summary.html", false, 101 "<a href=\"../../technotes/guides/index.html\">", 102 "<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">"); 103 } 104} 105