test/langtools/jdk/javadoc/doclet/testRelativeLinks/TestRelativeLinks.java
changeset 53391 a99bd2570660
parent 53097 2e82ca64b25d
child 53562 0d9dee001667
--- a/test/langtools/jdk/javadoc/doclet/testRelativeLinks/TestRelativeLinks.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testRelativeLinks/TestRelativeLinks.java	Fri Jan 18 11:26:30 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,10 @@
  * @run main TestRelativeLinks
  */
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
 import javadoc.tester.JavadocTester;
 
 public class TestRelativeLinks extends JavadocTester {
@@ -106,5 +110,27 @@
                 "-sourcepath", testSrc,
                 "pkg", "pkg2");
         checkExit(Exit.OK);
+    }
+
+    @Override
+    public void checkLinks() {
+        // since the test uses explicit links to non-existent files,
+        // we create those files to avoid false positive errors from checkLinks
+        touch("pkg/relative-class-link.html");
+        touch("pkg/relative-field-link.html");
+        touch("pkg/relative-method-link.html");
+        touch("pkg/relative-package-link.html");
+        touch("pkg/relative-multi-line-link.html");
+        super.checkLinks();
+    }
+
+    private void touch(String file) {
+        File f = new File(outputDir, file);
+        out.println("touch " + f);
+        try (FileOutputStream fos = new FileOutputStream(f)) {
+        } catch (IOException e) {
+            checking("Touch file");
+            failed("Error creating file: " + e);
+        }
+    }
 }
-}