Tolerate illegal reflective access warnings when testing with Java 9
See gh-7226
This commit is contained in:
parent
ebf3b47305
commit
46155ca5da
|
@ -40,6 +40,22 @@ import static org.junit.Assert.assertTrue;
|
||||||
*/
|
*/
|
||||||
public class JarCommandIT {
|
public class JarCommandIT {
|
||||||
|
|
||||||
|
private static final boolean java9OrLater;
|
||||||
|
|
||||||
|
static {
|
||||||
|
boolean loaded = false;
|
||||||
|
try {
|
||||||
|
Class.forName("java.security.cert.URICertStoreParameters");
|
||||||
|
loaded = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
// Continue
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
java9OrLater = loaded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final CommandLineInvoker cli = new CommandLineInvoker(
|
private final CommandLineInvoker cli = new CommandLineInvoker(
|
||||||
new File("src/it/resources/jar-command"));
|
new File("src/it/resources/jar-command"));
|
||||||
|
|
||||||
|
@ -67,11 +83,15 @@ public class JarCommandIT {
|
||||||
Invocation invocation = this.cli.invoke("run", jar.getAbsolutePath(),
|
Invocation invocation = this.cli.invoke("run", jar.getAbsolutePath(),
|
||||||
"bad.groovy");
|
"bad.groovy");
|
||||||
invocation.await();
|
invocation.await();
|
||||||
assertThat(invocation.getErrorOutput(), equalTo(""));
|
if (!java9OrLater) {
|
||||||
|
assertThat(invocation.getErrorOutput(), equalTo(""));
|
||||||
|
}
|
||||||
invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "bad.groovy");
|
invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "bad.groovy");
|
||||||
invocation.await();
|
invocation.await();
|
||||||
assertEquals(invocation.getErrorOutput(), 0,
|
if (!java9OrLater) {
|
||||||
invocation.getErrorOutput().length());
|
assertEquals(invocation.getErrorOutput(), 0,
|
||||||
|
invocation.getErrorOutput().length());
|
||||||
|
}
|
||||||
assertTrue(jar.exists());
|
assertTrue(jar.exists());
|
||||||
|
|
||||||
Process process = new JavaExecutable()
|
Process process = new JavaExecutable()
|
||||||
|
@ -79,7 +99,9 @@ public class JarCommandIT {
|
||||||
invocation = new Invocation(process);
|
invocation = new Invocation(process);
|
||||||
invocation.await();
|
invocation.await();
|
||||||
|
|
||||||
assertThat(invocation.getErrorOutput(), equalTo(""));
|
if (!java9OrLater) {
|
||||||
|
assertThat(invocation.getErrorOutput(), equalTo(""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -88,8 +110,10 @@ public class JarCommandIT {
|
||||||
Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(),
|
Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(),
|
||||||
"jar.groovy");
|
"jar.groovy");
|
||||||
invocation.await();
|
invocation.await();
|
||||||
assertEquals(invocation.getErrorOutput(), 0,
|
if (!java9OrLater) {
|
||||||
invocation.getErrorOutput().length());
|
assertEquals(invocation.getErrorOutput(), 0,
|
||||||
|
invocation.getErrorOutput().length());
|
||||||
|
}
|
||||||
assertTrue(jar.exists());
|
assertTrue(jar.exists());
|
||||||
|
|
||||||
Process process = new JavaExecutable()
|
Process process = new JavaExecutable()
|
||||||
|
@ -97,7 +121,9 @@ public class JarCommandIT {
|
||||||
invocation = new Invocation(process);
|
invocation = new Invocation(process);
|
||||||
invocation.await();
|
invocation.await();
|
||||||
|
|
||||||
assertThat(invocation.getErrorOutput(), equalTo(""));
|
if (!java9OrLater) {
|
||||||
|
assertThat(invocation.getErrorOutput(), equalTo(""));
|
||||||
|
}
|
||||||
assertThat(invocation.getStandardOutput(), containsString("Hello World!"));
|
assertThat(invocation.getStandardOutput(), containsString("Hello World!"));
|
||||||
assertThat(invocation.getStandardOutput(),
|
assertThat(invocation.getStandardOutput(),
|
||||||
containsString("/BOOT-INF/classes!/public/public.txt"));
|
containsString("/BOOT-INF/classes!/public/public.txt"));
|
||||||
|
@ -118,8 +144,10 @@ public class JarCommandIT {
|
||||||
Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "--include",
|
Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "--include",
|
||||||
"-public/**,-resources/**", "jar.groovy");
|
"-public/**,-resources/**", "jar.groovy");
|
||||||
invocation.await();
|
invocation.await();
|
||||||
assertEquals(invocation.getErrorOutput(), 0,
|
if (!java9OrLater) {
|
||||||
invocation.getErrorOutput().length());
|
assertEquals(invocation.getErrorOutput(), 0,
|
||||||
|
invocation.getErrorOutput().length());
|
||||||
|
}
|
||||||
assertTrue(jar.exists());
|
assertTrue(jar.exists());
|
||||||
|
|
||||||
Process process = new JavaExecutable()
|
Process process = new JavaExecutable()
|
||||||
|
@ -127,7 +155,9 @@ public class JarCommandIT {
|
||||||
invocation = new Invocation(process);
|
invocation = new Invocation(process);
|
||||||
invocation.await();
|
invocation.await();
|
||||||
|
|
||||||
assertThat(invocation.getErrorOutput(), equalTo(""));
|
if (!java9OrLater) {
|
||||||
|
assertThat(invocation.getErrorOutput(), equalTo(""));
|
||||||
|
}
|
||||||
assertThat(invocation.getStandardOutput(), containsString("Hello World!"));
|
assertThat(invocation.getStandardOutput(), containsString("Hello World!"));
|
||||||
assertThat(invocation.getStandardOutput(),
|
assertThat(invocation.getStandardOutput(),
|
||||||
not(containsString("/public/public.txt")));
|
not(containsString("/public/public.txt")));
|
||||||
|
|
Loading…
Reference in New Issue