langtools/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java
changeset 24399 af1a0220d0fa
parent 24072 e7549dcbc4af
child 24603 43e7e44d63da
equal deleted inserted replaced
24398:601a611d0aee 24399:af1a0220d0fa
    25  * @test
    25  * @test
    26  * @bug      4460354 8014636
    26  * @bug      4460354 8014636
    27  * @summary  Test to make sure that relative paths are redirected in the
    27  * @summary  Test to make sure that relative paths are redirected in the
    28  *           output so that they are not broken.
    28  *           output so that they are not broken.
    29  * @author   jamieh
    29  * @author   jamieh
    30  * @library  ../lib/
    30  * @library  ../lib
    31  * @build    JavadocTester
    31  * @build    JavadocTester
    32  * @build    TestRelativeLinks
       
    33  * @run main TestRelativeLinks
    32  * @run main TestRelativeLinks
    34  */
    33  */
    35 
    34 
    36 public class TestRelativeLinks extends JavadocTester {
    35 public class TestRelativeLinks extends JavadocTester {
    37 
    36 
    38     //Javadoc arguments.
    37     public static void main(String... args) throws Exception {
    39     private static final String[] ARGS = new String[] {
    38         TestRelativeLinks tester = new TestRelativeLinks();
    40         "-d", OUTPUT_DIR, "-use", "-sourcepath", SRC_DIR, "pkg", "pkg2"
    39         tester.runTests();
    41     };
    40     }
    42 
    41 
    43     //Input for string search tests.
    42     @Test
    44     private static final String[][] TEST = {
    43     void test() {
    45         //These relative paths should stay relative because they appear
    44         javadoc("-d", "out",
    46         //in the right places.
    45                 "-use",
    47         { "pkg/C.html",
    46                 "-sourcepath", testSrc,
    48             "<a href=\"relative-class-link.html\">relative class link</a>"},
    47                 "pkg", "pkg2");
    49         { "pkg/C.html",
    48         checkExit(Exit.OK);
    50             "<a href=\"relative-field-link.html\">relative field link</a>"},
    49 
    51         { "pkg/C.html",
    50         // These relative paths should stay relative because they appear
    52             "<a href=\"relative-method-link.html\">relative method link</a>"},
    51         // in the right places.
    53         { "pkg/package-summary.html",
    52         checkOutput("pkg/C.html", true,
    54             "<a href=\"relative-package-link.html\">relative package link</a>"},
    53             "<a href=\"relative-class-link.html\">relative class link</a>",
    55         { "pkg/C.html",
    54             "<a href=\"relative-field-link.html\">relative field link</a>",
       
    55             "<a href=\"relative-method-link.html\">relative method link</a>",
    56             " <a\n" +
    56             " <a\n" +
    57             " href=\"relative-multi-line-link.html\">relative-multi-line-link</a>."},
    57             " 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>");
    58 
    60 
    59         //These relative paths should be redirected because they are in different
    61         // These relative paths should be redirected because they are in different
    60         //places.
    62         // places.
    61 
    63 
    62         //INDEX PAGE
    64         // INDEX PAGE
    63         { "index-all.html",
    65         checkOutput("index-all.html", true,
    64             "<a href=\"./pkg/relative-class-link.html\">relative class link</a>"},
    66             "<a href=\"./pkg/relative-class-link.html\">relative class link</a>",
    65         { "index-all.html",
    67             "<a href=\"./pkg/relative-field-link.html\">relative field link</a>",
    66             "<a href=\"./pkg/relative-field-link.html\">relative field link</a>"},
    68             "<a href=\"./pkg/relative-method-link.html\">relative method link</a>",
    67         { "index-all.html",
    69             "<a href=\"./pkg/relative-package-link.html\">relative package link</a>",
    68             "<a href=\"./pkg/relative-method-link.html\">relative method link</a>"},
       
    69         { "index-all.html",
       
    70             "<a href=\"./pkg/relative-package-link.html\">relative package link</a>"},
       
    71         { "index-all.html",
       
    72             " <a\n" +
    70             " <a\n" +
    73             " href=\"./pkg/relative-multi-line-link.html\">relative-multi-line-link</a>."},
    71             " href=\"./pkg/relative-multi-line-link.html\">relative-multi-line-link</a>.");
    74 
    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>");
    75 
    77 
    76         //PACKAGE USE
    78         // CLASS_USE
    77         { "pkg/package-use.html",
    79         checkOutput("pkg/class-use/C.html", true,
    78             "<a href=\"../pkg/relative-package-link.html\">relative package link</a>."},
    80             "<a href=\"../../pkg/relative-field-link.html\">relative field link</a>",
    79         { "pkg/package-use.html",
    81             "<a href=\"../../pkg/relative-method-link.html\">relative method link</a>",
    80             "<a href=\"../pkg/relative-class-link.html\">relative class link</a>"},
    82             "<a href=\"../../pkg/relative-package-link.html\">relative package link</a>",
       
    83             " <a\n" +
       
    84             " href=\"../../pkg/relative-multi-line-link.html\">relative-multi-line-link</a>.");
    81 
    85 
    82         //CLASS_USE
    86         // PACKAGE OVERVIEW
    83         { "pkg/class-use/C.html",
    87         checkOutput("overview-summary.html", true,
    84             "<a href=\"../../pkg/relative-field-link.html\">relative field link</a>"},
    88             "<a href=\"./pkg/relative-package-link.html\">relative package link</a>");
    85         { "pkg/class-use/C.html",
       
    86             "<a href=\"../../pkg/relative-method-link.html\">relative method link</a>"},
       
    87         { "pkg/class-use/C.html",
       
    88             "<a href=\"../../pkg/relative-package-link.html\">relative package link</a>"},
       
    89         { "pkg/class-use/C.html",
       
    90             " <a\n" +
       
    91             " href=\"../../pkg/relative-multi-line-link.html\">relative-multi-line-link</a>."},
       
    92 
       
    93         //PACKAGE OVERVIEW
       
    94         { "overview-summary.html",
       
    95             "<a href=\"./pkg/relative-package-link.html\">relative package link</a>"},
       
    96     };
       
    97 
       
    98     /**
       
    99      * The entry point of the test.
       
   100      * @param args the array of command line arguments.
       
   101      */
       
   102     public static void main(String[] args) {
       
   103         TestRelativeLinks tester = new TestRelativeLinks();
       
   104         tester.run(ARGS, TEST, NO_TEST);
       
   105         tester.printSummary();
       
   106     }
    89     }
   107 }
    90 }