Skip to content

Commit 256a8e2

Browse files
committed
Test decoupling of module java.scripting dependency
1 parent fe141d0 commit 256a8e2

File tree

6 files changed

+142
-76
lines changed

6 files changed

+142
-76
lines changed

.travis.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ matrix:
1414
- jdk: oraclejdk9
1515
env: JDK_RELEASE='JDK 9' EXTRA_GRADLE_ARGS='-PenableJaCoCo'
1616
install: echo "Don't let Travis CI execute './gradlew assemble' by default"
17-
# Java 10
18-
- env: JDK_RELEASE='JDK 10 Early-Access' EXTRA_GRADLE_ARGS=''
19-
install: . ./src/install/install-jdk-10.sh
17+
# Java 10 "Oracle JDK"
18+
- env: JDK_RELEASE='Oracle JDK 10' EXTRA_GRADLE_ARGS=''
19+
install: . ./src/install/install-jdk.sh -F 10 -L BCL
20+
# Java 10 "OpenJDK"
21+
- env: JDK_RELEASE='OpenJDK 10' EXTRA_GRADLE_ARGS=''
22+
install: . ./src/install/install-jdk.sh -F 10 -L GPL
23+
allow_failures:
24+
- env: JDK_RELEASE='OpenJDK 10' EXTRA_GRADLE_ARGS=''
2025

2126
script:
2227
# Display Gradle, Groovy, JVM and other versions

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

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -62,46 +62,21 @@ task execScanModulepath(type: Exec, dependsOn: [generateDependenciesDirectory, g
6262
errorOutput = new ByteArrayOutputStream()
6363
}
6464

65-
/*
66-
| .
67-
| +-- JUnit Vintage [OK]
68-
| | '-- integration.VintageIntegrationTest [OK]
69-
| | '-- successfulTest [OK]
70-
| '-- JUnit Jupiter [OK]
71-
| '-- JupiterIntegrationTests [OK]
72-
| +-- version() [OK]
73-
| +-- moduleIsNamed() [OK]
74-
| +-- packageName() [OK]
75-
| '-- resolve() [OK]
76-
77-
Test run finished after 43 ms
78-
[ 4 containers found ]
79-
[ 0 containers skipped ]
80-
[ 4 containers started ]
81-
[ 0 containers aborted ]
82-
[ 4 containers successful ]
83-
[ 0 containers failed ]
84-
[ 5 tests found ]
85-
[ 0 tests skipped ]
86-
[ 5 tests started ]
87-
[ 0 tests aborted ]
88-
[ 5 tests successful ]
89-
[ 0 tests failed ]
65+
// Execute console launcher on the module-path w/o "java.scripting"
66+
task execNoJavaScripting(type: Exec, dependsOn: [generateDependenciesDirectory, generateIntegrationTestsJar]) {
67+
executable = 'java'
68+
args = [
69+
'--show-module-resolution',
70+
'--module-path', files(
71+
generateDependenciesDirectory.destinationDir,
72+
generateIntegrationTestsJar.archivePath
73+
).asPath,
74+
'--add-modules', 'junit.commons.integration.tests',
75+
'--module', 'org.junit.platform.console',
76+
'--scan-modules'
77+
]
78+
}
9079

91-
Test run finished after 54 ms
92-
[ 4 containers found ]
93-
[ 0 containers skipped ]
94-
[ 4 containers started ]
95-
[ 0 containers aborted ]
96-
[ 4 containers successful ]
97-
[ 0 containers failed ]
98-
[ 4 tests found ]
99-
[ 0 tests skipped ]
100-
[ 4 tests started ]
101-
[ 0 tests aborted ]
102-
[ 4 tests successful ]
103-
[ 0 tests failed ]
104-
*/
10580
task testScanModulepath(dependsOn: execScanModulepath) {
10681
doLast {
10782
String text = execScanModulepath.errorOutput.toString() + execScanModulepath.standardOutput.toString()
@@ -114,6 +89,7 @@ task testScanModulepath(dependsOn: execScanModulepath) {
11489
assert text.contains("version()")
11590
assert text.contains("moduleIsNamed()")
11691
assert text.contains("packageName()")
92+
assert text.contains("javaScriptingModuleIsAvailable()")
11793
// summary
11894
assert text.contains("Test run finished after")
11995
// container summary
@@ -124,11 +100,11 @@ task testScanModulepath(dependsOn: execScanModulepath) {
124100
assert text.contains("4 containers successful")
125101
assert text.contains("0 containers failed")
126102
// tests summary
127-
assert text.contains("5 tests found")
103+
assert text.contains("6 tests found")
128104
assert text.contains("0 tests skipped")
129-
assert text.contains("5 tests started")
105+
assert text.contains("6 tests started")
130106
assert text.contains("0 tests aborted")
131-
assert text.contains("5 tests successful")
107+
assert text.contains("6 tests successful")
132108
assert text.contains("0 tests failed")
133109
}
134110
}

junit-platform-commons-java-9/src/test/java/integration/JupiterIntegrationTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import static org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.request;
1818

1919
import org.junit.jupiter.api.Test;
20+
import org.junit.jupiter.api.condition.EnabledIf;
2021
import org.junit.jupiter.engine.JupiterTestEngine;
2122
import org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor;
2223
import org.junit.jupiter.engine.discovery.DiscoverySelectorResolver;
@@ -66,6 +67,13 @@ void resolve() {
6667
resolver.resolveSelectors(request().selectors(selector).build(), engine);
6768

6869
assertEquals(1, engine.getChildren().size()); // JupiterIntegrationTests.class
69-
assertEquals(4, getOnlyElement(engine.getChildren()).getChildren().size()); // 4 test methods
70+
assertEquals(5, getOnlyElement(engine.getChildren()).getChildren().size()); // 5 test methods
7071
}
72+
73+
@Test
74+
@EnabledIf("1 == 1")
75+
void javaScriptingModuleIsAvailable() {
76+
/* empty */
77+
}
78+
7179
}

src/install/install-jdk-10.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/install/install-jdk-9.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/install/install-jdk.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Install JDK for Linux
5+
#
6+
# This script determines the most recent early-access build number,
7+
# downloads the JDK archive to the user home directory and extracts
8+
# it there.
9+
#
10+
# Example usage
11+
#
12+
# install-jdk.sh | install most recent early-access JDK
13+
# install-jdk.sh -W /usr/opt | install most recent early-access JDK to /usr/opt
14+
# install-jdk.sh -F 9 | install most recent OpenJDK 9
15+
# install-jdk.sh -F 10 | install most recent OpenJDK 10
16+
# install-jdk.sh -F 10 -L BCL | install most recent OracleJDK 10
17+
#
18+
# Options
19+
#
20+
# -F f | Feature number of the JDK release, [9|10|...]
21+
# -B b | Build number of the JDK release [?|1|2...]
22+
# -L l | License of the JDK [GPL|BCL]
23+
# -W w | Working directory and install path [${HOME}]
24+
#
25+
# Exported environment variables
26+
#
27+
# JAVA_HOME is set to the extracted JDK directory
28+
# PATH is prepended with ${JAVA_HOME}/bin
29+
#
30+
# (C) 2018 Christian Stein
31+
#
32+
# https://github.com/sormuras/bach/blob/master/install-jdk.sh
33+
#
34+
set -e
35+
36+
JDK_FEATURE='10'
37+
JDK_BUILD='?'
38+
JDK_LICENSE='GPL'
39+
JDK_WORKSPACE=${HOME}
40+
41+
while getopts F:B:L:W: option
42+
do
43+
case "${option}" in
44+
F) JDK_FEATURE=${OPTARG};;
45+
B) JDK_BUILD=${OPTARG};;
46+
L) JDK_LICENSE=${OPTARG};;
47+
W) JDK_WORKSPACE=${OPTARG};;
48+
esac
49+
done
50+
51+
#
52+
# Other constants
53+
#
54+
JDK_DOWNLOAD='https://download.java.net/java'
55+
JDK_BASENAME='openjdk'
56+
if [ "${JDK_LICENSE}" != 'GPL' ]; then
57+
JDK_BASENAME='jdk'
58+
fi
59+
60+
#
61+
# 9
62+
#
63+
if [ "${JDK_FEATURE}" == '9' ]; then
64+
if [ "${JDK_BUILD}" == '?' ]; then
65+
TMP=$(curl -L jdk.java.net/${JDK_FEATURE})
66+
TMP="${TMP#*<h1>JDK}" # remove everything before the number
67+
TMP="${TMP%%General-Availability Release*}" # remove everything after the number
68+
JDK_BUILD="$(echo -e "${TMP}" | tr -d '[:space:]')" # remove all whitespace
69+
fi
70+
71+
JDK_ARCHIVE=${JDK_BASENAME}-${JDK_BUILD}_linux-x64_bin.tar.gz
72+
JDK_URL=${JDK_DOWNLOAD}/GA/jdk${JDK_FEATURE}/${JDK_BUILD}/binaries/${JDK_ARCHIVE}
73+
JDK_HOME=jdk-${JDK_BUILD}
74+
fi
75+
76+
#
77+
# 10
78+
#
79+
if [ "${JDK_FEATURE}" == '10' ]; then
80+
if [ "${JDK_BUILD}" == '?' ]; then
81+
TMP=$(curl -L jdk.java.net/${JDK_FEATURE})
82+
TMP="${TMP#*Most recent build: jdk-${JDK_FEATURE}-ea+}" # remove everything before the number
83+
TMP="${TMP%%<*}" # remove everything after the number
84+
JDK_BUILD="$(echo -e "${TMP}" | tr -d '[:space:]')" # remove all whitespace
85+
fi
86+
87+
JDK_ARCHIVE=${JDK_BASENAME}-${JDK_FEATURE}-ea+${JDK_BUILD}_linux-x64_bin.tar.gz
88+
JDK_URL=${JDK_DOWNLOAD}/jdk${JDK_FEATURE}/archive/${JDK_BUILD}/${JDK_LICENSE}/${JDK_ARCHIVE}
89+
JDK_HOME=jdk-${JDK_FEATURE}
90+
fi
91+
92+
#
93+
# Create any missing intermediate paths, switch to workspace, download, unpack, switch back.
94+
#
95+
mkdir -p ${JDK_WORKSPACE}
96+
cd ${JDK_WORKSPACE}
97+
wget ${JDK_URL}
98+
tar -xzf ${JDK_ARCHIVE}
99+
cd -
100+
101+
#
102+
# Update environment and test-drive.
103+
#
104+
export JAVA_HOME=${JDK_WORKSPACE}/${JDK_HOME}
105+
export PATH=${JAVA_HOME}/bin:$PATH
106+
107+
java --version

0 commit comments

Comments
 (0)