8257617: TestLinkPlatform fails with new Java source version

Reviewed-by: darcy
This commit is contained in:
Hannes Wallnöfer 2020-12-03 07:12:25 +00:00
parent d80ae05f61
commit a5a034b72f
2 changed files with 18 additions and 15 deletions

View File

@ -30,7 +30,7 @@
* jdk.javadoc/jdk.javadoc.internal.tool
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* @build javadoc.tester.*
* @build toolbox.ToolBox javadoc.tester.*
* @run main TestLinkPlatform
*/
@ -55,8 +55,8 @@ public class TestLinkPlatform extends JavadocTester {
final static String NEW_PLATFORM_URL = "https://docs.oracle.com/en/java/javase/%d/docs/api/java.base/java/lang/Object.html";
final static String PRE_PLATFORM_URL = "https://download.java.net/java/early_access/jdk%d/docs/api/java.base/java/lang/Object.html";
final static String NON_MODULAR_CUSTOM_PLATFORM_URL = "https://some.domain/docs/%d/api/java/lang/Object.html";
final static String MODULAR_CUSTOM_PLATFORM_URL = "https://some.domain/docs/%d/api/java.base/java/lang/Object.html";
final static String NON_MODULAR_CUSTOM_PLATFORM_URL = "https://example.com/%d/api/java/lang/Object.html";
final static String MODULAR_CUSTOM_PLATFORM_URL = "https://example.com/%d/api/java.base/java/lang/Object.html";
final static int EARLIEST_VERSION = 7;
final static int LATEST_VERSION = Integer.parseInt(SourceVersion.latest().name().substring(8));
@ -113,13 +113,14 @@ public class TestLinkPlatform extends JavadocTester {
@Test
public void testPlatformLinkWithCustomPropertyURL(Path base) throws Exception {
Path customProps = writeCustomProperties(base);
for (int version = EARLIEST_VERSION; version <= LATEST_VERSION; version++) {
Path out = base.resolve("out_" + version);
javadoc("-d", out.toString(),
"-sourcepath", packageSrc.toString(),
"--release", Integer.toString(version),
"--link-platform-properties", "file:" + testSrc("linkplatform.properties"),
"--link-platform-properties", customProps.toUri().toString(),
"p.q");
checkExit(Exit.OK);
@ -134,13 +135,14 @@ public class TestLinkPlatform extends JavadocTester {
@Test
public void testPlatformLinkWithCustomPropertyFile(Path base) throws Exception {
Path customProps = writeCustomProperties(base);
for (int version = EARLIEST_VERSION; version <= LATEST_VERSION; version++) {
Path out = base.resolve("out_" + version);
javadoc("-d", out.toString(),
"-sourcepath", packageSrc.toString(),
"--release", Integer.toString(version),
"--link-platform-properties", testSrc("linkplatform.properties"),
"--link-platform-properties", customProps.toString(),
"p.q");
checkExit(Exit.OK);
@ -153,6 +155,17 @@ public class TestLinkPlatform extends JavadocTester {
}
}
private Path writeCustomProperties(Path base) throws IOException {
ToolBox tb = new ToolBox();
StringBuilder sb = new StringBuilder();
for (int version = EARLIEST_VERSION; version <= LATEST_VERSION; version++) {
sb.append(String.format("doclet.platform.docs.%1$d= https://example.com/%1$d/api/\n", version));
}
Path path = base.resolve("linkplatform.properties");
tb.writeFile(path, sb.toString());
return path;
}
@Test
public void testPlatformLinkWithInvalidPropertyFile(Path base) throws Exception {
for (int version = EARLIEST_VERSION; version <= LATEST_VERSION; version++) {

View File

@ -1,10 +0,0 @@
doclet.platform.docs.7= https://some.domain/docs/7/api/
doclet.platform.docs.8= https://some.domain/docs/8/api/
doclet.platform.docs.9= https://some.domain/docs/9/api/
doclet.platform.docs.10=https://some.domain/docs/10/api/
doclet.platform.docs.11=https://some.domain/docs/11/api/
doclet.platform.docs.12=https://some.domain/docs/12/api/
doclet.platform.docs.13=https://some.domain/docs/13/api/
doclet.platform.docs.14=https://some.domain/docs/14/api/
doclet.platform.docs.15=https://some.domain/docs/15/api/
doclet.platform.docs.16=https://some.domain/docs/16/api/