Make BootRunIntegrationTests compatible with Java 9
Closes gh-10019
This commit is contained in:
parent
3cf0f65179
commit
a07833fb51
|
@ -16,8 +16,8 @@
|
|||
|
||||
package com.example;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.io.File;
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
/**
|
||||
* Very basic application used for testing {@code BootRun}.
|
||||
|
@ -32,11 +32,10 @@ public class BootRunApplication {
|
|||
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
for (URL url : ((URLClassLoader) BootRunApplication.class.getClassLoader())
|
||||
.getURLs()) {
|
||||
System.out.println(i++ + ". " + url);
|
||||
for (String entry : ManagementFactory.getRuntimeMXBean().getClassPath()
|
||||
.split(File.pathSeparator)) {
|
||||
System.out.println(i++ + ". " + entry);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,9 +48,12 @@ public class BootRunIntegrationTests {
|
|||
new File(this.gradleBuild.getProjectDir(), "src/main/resources").mkdirs();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("1. " + urlOf("build/classes/java/main"));
|
||||
assertThat(result.getOutput()).contains("2. " + urlOf("build/resources/main"));
|
||||
assertThat(result.getOutput()).doesNotContain(urlOf("src/main/resources"));
|
||||
assertThat(result.getOutput())
|
||||
.contains("1. " + canonicalPathOf("build/classes/java/main"));
|
||||
assertThat(result.getOutput())
|
||||
.contains("2. " + canonicalPathOf("build/resources/main"));
|
||||
assertThat(result.getOutput())
|
||||
.doesNotContain(canonicalPathOf("src/main/resources"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -58,9 +61,12 @@ public class BootRunIntegrationTests {
|
|||
copyApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("1. " + urlOf("src/main/resources"));
|
||||
assertThat(result.getOutput()).contains("2. " + urlOf("build/classes/java/main"));
|
||||
assertThat(result.getOutput()).doesNotContain(urlOf("build/resources/main"));
|
||||
assertThat(result.getOutput())
|
||||
.contains("1. " + canonicalPathOf("src/main/resources"));
|
||||
assertThat(result.getOutput())
|
||||
.contains("2. " + canonicalPathOf("build/classes/java/main"));
|
||||
assertThat(result.getOutput())
|
||||
.doesNotContain(canonicalPathOf("build/resources/main"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -98,9 +104,8 @@ public class BootRunIntegrationTests {
|
|||
FileSystemUtils.copyRecursively(new File("src/test/java/com/example"), output);
|
||||
}
|
||||
|
||||
private String urlOf(String path) throws IOException {
|
||||
return new File(this.gradleBuild.getProjectDir().getCanonicalFile(), path).toURI()
|
||||
.toURL().toString();
|
||||
private String canonicalPathOf(String path) throws IOException {
|
||||
return new File(this.gradleBuild.getProjectDir(), path).getCanonicalPath();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue