test/langtools/jdk/javadoc/doclet/testRelativeLinks/TestRelativeLinks.java
changeset 53391 a99bd2570660
parent 53097 2e82ca64b25d
child 53562 0d9dee001667
equal deleted inserted replaced
53390:46db9786cd67 53391:a99bd2570660
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    30  * @library  ../../lib
    30  * @library  ../../lib
    31  * @modules jdk.javadoc/jdk.javadoc.internal.tool
    31  * @modules jdk.javadoc/jdk.javadoc.internal.tool
    32  * @build    javadoc.tester.*
    32  * @build    javadoc.tester.*
    33  * @run main TestRelativeLinks
    33  * @run main TestRelativeLinks
    34  */
    34  */
       
    35 
       
    36 import java.io.File;
       
    37 import java.io.FileOutputStream;
       
    38 import java.io.IOException;
    35 
    39 
    36 import javadoc.tester.JavadocTester;
    40 import javadoc.tester.JavadocTester;
    37 
    41 
    38 public class TestRelativeLinks extends JavadocTester {
    42 public class TestRelativeLinks extends JavadocTester {
    39 
    43 
   104                 "-html4",
   108                 "-html4",
   105                 "-use",
   109                 "-use",
   106                 "-sourcepath", testSrc,
   110                 "-sourcepath", testSrc,
   107                 "pkg", "pkg2");
   111                 "pkg", "pkg2");
   108         checkExit(Exit.OK);
   112         checkExit(Exit.OK);
       
   113     }
       
   114 
       
   115     @Override
       
   116     public void checkLinks() {
       
   117         // since the test uses explicit links to non-existent files,
       
   118         // we create those files to avoid false positive errors from checkLinks
       
   119         touch("pkg/relative-class-link.html");
       
   120         touch("pkg/relative-field-link.html");
       
   121         touch("pkg/relative-method-link.html");
       
   122         touch("pkg/relative-package-link.html");
       
   123         touch("pkg/relative-multi-line-link.html");
       
   124         super.checkLinks();
       
   125     }
       
   126 
       
   127     private void touch(String file) {
       
   128         File f = new File(outputDir, file);
       
   129         out.println("touch " + f);
       
   130         try (FileOutputStream fos = new FileOutputStream(f)) {
       
   131         } catch (IOException e) {
       
   132             checking("Touch file");
       
   133             failed("Error creating file: " + e);
       
   134         }
       
   135     }
   109 }
   136 }
   110 }