Skip to content

Commit 9caa31d

Browse files
committed
Assert script-based error message when ScriptEngine isn't loadable
1 parent 35b6e65 commit 9caa31d

File tree

2 files changed

+74
-24
lines changed

2 files changed

+74
-24
lines changed

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ branches:
1010

1111
matrix:
1212
include:
13-
# Java 9 (openjdk-9.0.1 fails with java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty)
13+
# Java 9 "Oracle JDK" (provided by Travis CI)
1414
- jdk: oraclejdk9
15-
env: JDK_RELEASE='JDK 9' EXTRA_GRADLE_ARGS='-PenableJaCoCo'
15+
env: JDK_RELEASE='Oracle JDK 9' EXTRA_GRADLE_ARGS='-PenableJaCoCo'
1616
install: echo "Don't let Travis CI execute './gradlew assemble' by default"
17+
# Java 9 "OpenJDK"
18+
- env: JDK_RELEASE='OpenJDK 9' EXTRA_GRADLE_ARGS=''
19+
install: . ./src/install/install-jdk.sh -F 9 -L GPL
1720
# Java 10 "Oracle JDK"
1821
- env: JDK_RELEASE='Oracle JDK 10' EXTRA_GRADLE_ARGS=''
1922
install: . ./src/install/install-jdk.sh -F 10 -L BCL
2023
# Java 10 "OpenJDK"
2124
- env: JDK_RELEASE='OpenJDK 10' EXTRA_GRADLE_ARGS=''
2225
install: . ./src/install/install-jdk.sh -F 10 -L GPL
23-
allow_failures:
24-
- env: JDK_RELEASE='OpenJDK 10' EXTRA_GRADLE_ARGS=''
2526

2627
script:
2728
# Display Gradle, Groovy, JVM and other versions
@@ -42,5 +43,5 @@ cache:
4243

4344
# Run clover report and send report to codecov after build success for JDK 9 builds
4445
after_success:
45-
- test "$JDK_RELEASE" = "JDK 9" && ./gradlew -PenableJaCoCo jacocoRootReport || true
46-
- test "$JDK_RELEASE" = "JDK 9" && bash <(curl -s https://codecov.io/bash) || true
46+
- test "$JDK_RELEASE" = "Oracle JDK 9" && ./gradlew -PenableJaCoCo jacocoRootReport || true
47+
- test "$JDK_RELEASE" = "Oracle JDK 9" && bash <(curl -s https://codecov.io/bash) || true

junit-platform-commons-java-9/junit-platform-commons-java-9.gradle

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ junitPlatform {
3535
// Create "junit-commons-integration-tests.jar" archive which will be later
3636
// mounted as an automatic jar into the integration test module-path.
3737
task generateIntegrationTestsJar(type: Jar, dependsOn: compileTestJava) {
38-
archiveName 'junit-commons-integration-tests.jar'
38+
archiveName = 'junit-commons-integration-tests.jar'
3939
from compileTestJava.destinationDir
4040
include("integration/**/*")
4141
}
@@ -49,29 +49,14 @@ task generateDependenciesDirectory(type: Copy) {
4949
// Execute console launcher on the module-path.
5050
task execScanModulepath(type: Exec, dependsOn: [generateDependenciesDirectory, generateIntegrationTestsJar]) {
5151
executable = 'java'
52-
args = [
53-
'--module-path', files(
54-
generateDependenciesDirectory.destinationDir,
55-
generateIntegrationTestsJar.archivePath
56-
).asPath,
57-
'--add-modules', 'ALL-MODULE-PATH,ALL-DEFAULT',
58-
'--module', 'org.junit.platform.console',
59-
'--scan-modules'
60-
]
6152
standardOutput = new ByteArrayOutputStream()
6253
errorOutput = new ByteArrayOutputStream()
63-
}
64-
65-
// Execute console launcher on the module-path w/o "java.scripting"
66-
task execNoJavaScripting(type: Exec, dependsOn: [generateDependenciesDirectory, generateIntegrationTestsJar]) {
67-
executable = 'java'
6854
args = [
69-
'--show-module-resolution',
7055
'--module-path', files(
7156
generateDependenciesDirectory.destinationDir,
7257
generateIntegrationTestsJar.archivePath
7358
).asPath,
74-
'--add-modules', 'junit.commons.integration.tests',
59+
'--add-modules', 'ALL-MODULE-PATH,ALL-DEFAULT',
7560
'--module', 'org.junit.platform.console',
7661
'--scan-modules'
7762
]
@@ -109,5 +94,69 @@ task testScanModulepath(dependsOn: execScanModulepath) {
10994
}
11095
}
11196

112-
test.dependsOn execNoJavaScripting
97+
// Execute console launcher on the module-path w/o "java.scripting"
98+
task execNoJavaScripting(type: Exec, dependsOn: [generateDependenciesDirectory, generateIntegrationTestsJar]) {
99+
ignoreExitValue = true
100+
standardOutput = new ByteArrayOutputStream()
101+
errorOutput = new ByteArrayOutputStream()
102+
executable = 'java'
103+
args = [
104+
'--show-module-resolution',
105+
'--module-path', files(generateDependenciesDirectory.destinationDir, generateIntegrationTestsJar.archivePath).asPath,
106+
// only "java.base" and "java.logging" are visible
107+
'--limit-modules', 'java.base',
108+
'--limit-modules', 'java.logging',
109+
// system modules
110+
// '--add-modules', 'java.scripting',
111+
// '--add-modules', 'jdk.scripting.nashorn',
112+
// '--add-modules', 'jdk.dynalink',
113+
// "JUnit 5" modules
114+
'--add-modules', 'org.junit.platform.commons',
115+
'--add-modules', 'org.junit.platform.engine',
116+
'--add-modules', 'org.junit.platform.launcher',
117+
'--add-modules', 'org.junit.jupiter.api',
118+
'--add-modules', 'org.junit.jupiter.engine',
119+
'--add-modules', 'org.opentest4j',
120+
'--add-modules', 'org.apiguardian.api',
121+
// local module containing tests
122+
'--add-modules', 'junit.commons.integration.tests',
123+
// console launcher with arguments
124+
'--module', 'org.junit.platform.console',
125+
'--scan-modules'
126+
]
127+
}
128+
129+
task testNoJavaScripting(dependsOn: execNoJavaScripting) {
130+
doLast {
131+
String text = execNoJavaScripting.errorOutput.toString() + execNoJavaScripting.standardOutput.toString()
132+
// tree node names
133+
assert text.contains("JUnit Jupiter")
134+
assert text.contains("JupiterIntegrationTests")
135+
assert text.contains("version()")
136+
assert text.contains("moduleIsNamed()")
137+
assert text.contains("packageName()")
138+
assert text.contains("javaScriptingModuleIsAvailable()")
139+
assert text.contains("Failed to evaluate condition")
140+
assert text.contains("Class `javax.script.ScriptEngine` is not loadable")
141+
assert text.contains("script-based test execution is disabled")
142+
// summary
143+
assert text.contains("Test run finished after")
144+
// container summary
145+
assert text.contains("2 containers found")
146+
assert text.contains("0 containers skipped")
147+
assert text.contains("2 containers started")
148+
assert text.contains("0 containers aborted")
149+
assert text.contains("2 containers successful")
150+
assert text.contains("0 containers failed")
151+
// tests summary
152+
assert text.contains("5 tests found")
153+
assert text.contains("0 tests skipped")
154+
assert text.contains("5 tests started")
155+
assert text.contains("0 tests aborted")
156+
assert text.contains("4 tests successful")
157+
assert text.contains("1 tests failed")
158+
}
159+
}
160+
113161
test.dependsOn testScanModulepath
162+
test.dependsOn testNoJavaScripting

0 commit comments

Comments
 (0)