8262899: TestRedirectLinks fails
Reviewed-by: prappo
This commit is contained in:
parent
963f1fc6de
commit
f17ea9e66b
@ -385,7 +385,7 @@ public class Extern {
|
|||||||
private static final long serialVersionUID = 0;
|
private static final long serialVersionUID = 0;
|
||||||
|
|
||||||
Fault(String msg, Exception cause) {
|
Fault(String msg, Exception cause) {
|
||||||
super(msg, cause);
|
super(msg + (cause == null ? "" : " (" + cause + ")"), cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,9 +43,12 @@ import java.net.InetAddress;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
import javax.net.ssl.HostnameVerifier;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
@ -84,9 +87,31 @@ public class TestRedirectLinks extends JavadocTester {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRedirects() throws Exception {
|
public void testRedirects() throws Exception {
|
||||||
// first, test to see if access to external URLs is available
|
// This test relies on access to an external resource, which may or may not be
|
||||||
|
// reliably available, depending on the host system configuration and other
|
||||||
|
// networking issues. Therefore, it is disabled by default, unless the system
|
||||||
|
// property "javadoc.dev" is set "true".
|
||||||
|
String property = "javadoc.dev";
|
||||||
|
if (!Boolean.getBoolean(property)) {
|
||||||
|
out.println("Test case disabled by default; "
|
||||||
|
+ "set system property \"" + property + "\" to true to enable it.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// test to see if access to external URLs is available, and that the URL uses a redirect
|
||||||
|
|
||||||
URL testURL = new URL("http://docs.oracle.com/en/java/javase/11/docs/api/element-list");
|
URL testURL = new URL("http://docs.oracle.com/en/java/javase/11/docs/api/element-list");
|
||||||
|
String testURLHost = testURL.getHost();
|
||||||
|
try {
|
||||||
|
InetAddress testAddr = InetAddress.getByName(testURLHost);
|
||||||
|
out.println("Found " + testURLHost + ": " + testAddr);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
out.println("Setup failed (" + testURLHost + " not found); this test skipped");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean haveRedirectURL = false;
|
boolean haveRedirectURL = false;
|
||||||
|
Instant start = Instant.now();
|
||||||
try {
|
try {
|
||||||
URLConnection conn = testURL.openConnection();
|
URLConnection conn = testURL.openConnection();
|
||||||
conn.connect();
|
conn.connect();
|
||||||
@ -107,10 +132,12 @@ public class TestRedirectLinks extends JavadocTester {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
out.println("Exception occurred: " + e);
|
out.println("Exception occurred: " + e);
|
||||||
|
Instant now = Instant.now();
|
||||||
|
out.println("Attempt took " + Duration.between(start, now).toSeconds() + " seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!haveRedirectURL) {
|
if (!haveRedirectURL) {
|
||||||
out.println("Setup failed; this test skipped");
|
out.println("Setup failed (no redirect URL); this test skipped");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +146,7 @@ public class TestRedirectLinks extends JavadocTester {
|
|||||||
javadoc("-d", outRedirect,
|
javadoc("-d", outRedirect,
|
||||||
"-sourcepath", testSrc,
|
"-sourcepath", testSrc,
|
||||||
"-link", apiURL,
|
"-link", apiURL,
|
||||||
|
"-Xdoclint:none",
|
||||||
"pkg");
|
"pkg");
|
||||||
checkExit(Exit.OK);
|
checkExit(Exit.OK);
|
||||||
checkOutput("pkg/B.html", true,
|
checkOutput("pkg/B.html", true,
|
||||||
@ -157,16 +185,19 @@ public class TestRedirectLinks extends JavadocTester {
|
|||||||
new JavacTask(tb)
|
new JavacTask(tb)
|
||||||
.outdir(libModules)
|
.outdir(libModules)
|
||||||
.options("--module-source-path", libSrc.toString(),
|
.options("--module-source-path", libSrc.toString(),
|
||||||
"--module", "mA,mB")
|
"--module", "mA,mB",
|
||||||
|
"-Xdoclint:none")
|
||||||
.run()
|
.run()
|
||||||
.writeAll();
|
.writeAll();
|
||||||
|
|
||||||
javadoc("-d", libApi.toString(),
|
javadoc("-d", libApi.toString(),
|
||||||
"--module-source-path", libSrc.toString(),
|
"--module-source-path", libSrc.toString(),
|
||||||
"--module", "mA,mB" );
|
"--module", "mA,mB",
|
||||||
|
"-Xdoclint:none" );
|
||||||
|
|
||||||
// start web servers
|
// start web servers
|
||||||
InetAddress localHost = InetAddress.getLocalHost();
|
// use loopback address to avoid any issues if proxy is in use
|
||||||
|
InetAddress localHost = InetAddress.getLoopbackAddress();
|
||||||
try {
|
try {
|
||||||
oldServer = HttpServer.create(new InetSocketAddress(localHost, 0), 0);
|
oldServer = HttpServer.create(new InetSocketAddress(localHost, 0), 0);
|
||||||
String oldURL = "http:/" + oldServer.getAddress();
|
String oldURL = "http:/" + oldServer.getAddress();
|
||||||
@ -201,7 +232,8 @@ public class TestRedirectLinks extends JavadocTester {
|
|||||||
"--module-source-path", src.toString(),
|
"--module-source-path", src.toString(),
|
||||||
"--module-path", libModules.toString(),
|
"--module-path", libModules.toString(),
|
||||||
"-link", "http:/" + oldServer.getAddress(),
|
"-link", "http:/" + oldServer.getAddress(),
|
||||||
"--module", "mC" );
|
"--module", "mC",
|
||||||
|
"-Xdoclint:none");
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
HttpsURLConnection.setDefaultHostnameVerifier(prevHostNameVerifier);
|
HttpsURLConnection.setDefaultHostnameVerifier(prevHostNameVerifier);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user