1 /* 2 * Copyright (c) 2003, 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 4460354 8014636 8043186 27 * @summary Test to make sure that relative paths are redirected in the 28 * output so that they are not broken. 29 * @author jamieh 30 * @library ../lib 31 * @modules jdk.javadoc 32 * @build JavadocTester 33 * @run main TestRelativeLinks 34 */ 35 36 public class TestRelativeLinks extends JavadocTester { 37 38 public static void main(String... args) throws Exception { 39 TestRelativeLinks tester = new TestRelativeLinks(); 40 tester.runTests(); 41 } 42 43 @Test 44 void test() { 45 javadoc("-d", "out", 46 "-use", 47 "-sourcepath", testSrc, 48 "pkg", "pkg2"); 49 checkExit(Exit.OK); 50 51 // These relative paths should stay relative because they appear 52 // in the right places. 53 checkOutput("pkg/C.html", true, 54 "<a href=\"relative-class-link.html\">relative class link</a>", 55 "<a href=\"relative-field-link.html\">relative field link</a>", 56 "<a href=\"relative-method-link.html\">relative method link</a>", 57 " <a href=\"relative-multi-line-link.html\">relative-multi-line-link</a>."); 58 checkOutput("pkg/package-summary.html", true, 59 "<a href=\"relative-package-link.html\">relative package link</a>"); 60 61 // These relative paths should be redirected because they are in different 62 // places. 63 64 // INDEX PAGE 65 checkOutput("index-all.html", true, 66 "<a href=\"./pkg/relative-class-link.html\">relative class link</a>", 67 "<a href=\"./pkg/relative-field-link.html\">relative field link</a>", 68 "<a href=\"./pkg/relative-method-link.html\">relative method link</a>", 69 "<a href=\"./pkg/relative-package-link.html\">relative package link</a>", 70 " <a href=\"./pkg/relative-multi-line-link.html\">relative-multi-line-link</a>.", 71 "<div class=\"block\"><a name=\"./pkg/masters\"></a>"); 72 73 // PACKAGE USE 74 checkOutput("pkg/package-use.html", true, 75 "<a href=\"../pkg/relative-package-link.html\">relative package link</a>.", 76 "<a href=\"../pkg/relative-class-link.html\">relative class link</a>"); 77 78 // CLASS_USE 79 checkOutput("pkg/class-use/C.html", true, 80 "<a href=\"../../pkg/relative-field-link.html\">relative field link</a>", 81 "<a href=\"../../pkg/relative-method-link.html\">relative method link</a>", 82 "<a href=\"../../pkg/relative-package-link.html\">relative package link</a>", 83 " <a href=\"../../pkg/relative-multi-line-link.html\">relative-multi-line-link</a>."); 84 85 // PACKAGE OVERVIEW 86 checkOutput("overview-summary.html", true, 87 "<a href=\"./pkg/relative-package-link.html\">relative package link</a>"); 88 } 89 }