Skip to content

Commit

Permalink
Get jdk-9 back to build JUnit 5 on Travis
Browse files Browse the repository at this point in the history
Upgrade to AssertJ 3.7.0-SNAPSHOT (using jitpack)
Use JDK_JAVA_OPTIONS to open java.base and other packages
ServiceLoader.load() loads providers multiple times - prune 'em

Addresses: #775
  • Loading branch information
sormuras committed Apr 14, 2017
1 parent 63cd1bd commit 550346e
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 16 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ language: java
sudo: false
dist: trusty

jdk:
- oraclejdk8

addons:
apt:
packages:
- oracle-java8-installer
matrix:
include:
- jdk: oraclejdk8
addons: {apt: {packages: [oracle-java8-installer]}}
- jdk: oraclejdk9
addons: {apt: {packages: [oracle-java9-installer]}}
# With jdk-9-b163(or higher) available on Travis, env: JDK_JAVA_OPTIONS='--permit-illegal-access'
env: JDK_JAVA_OPTIONS='--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED'

# Display Gradle version instead of letting Travis execute './gradlew assemble' by default
install:
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ allprojects { subproj ->
// mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url "https://jitpack.io" }
}

tasks.withType(Test) { task ->
Expand Down Expand Up @@ -127,7 +128,7 @@ allprojects { subproj ->
'-Xlint:unchecked',
'-Xlint:varargs',
'-Xlint:-options',
'-Werror'
// '-Werror' // allow warnings with jdk-9
]

// See: http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html#BHCJCABJ
Expand Down
2 changes: 1 addition & 1 deletion junit-jupiter-engine/junit-jupiter-engine.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
testImplementation(project(':junit-platform-launcher'))
testImplementation(project(':junit-platform-runner'))
testImplementation(project(path: ':junit-platform-engine', configuration: 'testArtifacts'))
testImplementation("org.assertj:assertj-core:${assertJVersion}")
testImplementation("com.github.joel-costigliola:assertj-core:master-SNAPSHOT")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")

// Include junit-platform-console so that the JUnit Gradle plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
testImplementation(project(':junit-platform-launcher'))
testImplementation(project(':junit-platform-runner'))
testImplementation(project(path: ':junit-platform-engine', configuration: 'testArtifacts'))
testImplementation("org.assertj:assertj-core:${assertJVersion}")
testImplementation("com.github.joel-costigliola:assertj-core:master-SNAPSHOT")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")

// Include junit-platform-console so that the JUnit Gradle plugin
Expand Down
2 changes: 1 addition & 1 deletion junit-jupiter-params/junit-jupiter-params.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {

shadow('com.univocity:univocity-parsers:2.4.1')

testImplementation("org.assertj:assertj-core:${assertJVersion}")
testImplementation("com.github.joel-costigliola:assertj-core:master-SNAPSHOT")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
testImplementation(project(path: ':junit-platform-engine', configuration: 'testArtifacts'))
testImplementation(project(':junit-jupiter-engine'))
Expand Down
2 changes: 1 addition & 1 deletion junit-platform-engine/junit-platform-engine.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ dependencies {
api(project(':junit-platform-commons'))
api("org.opentest4j:opentest4j:${ota4jVersion}")

testImplementation("org.assertj:assertj-core:${assertJVersion}")
testImplementation("com.github.joel-costigliola:assertj-core:master-SNAPSHOT")
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Logger;

import org.junit.platform.commons.util.ClassLoaderUtils;
Expand All @@ -29,7 +31,20 @@ public Iterable<TestEngine> loadTestEngines() {
Iterable<TestEngine> testEngines = ServiceLoader.load(TestEngine.class,
ClassLoaderUtils.getDefaultClassLoader());
LOG.config(() -> createDiscoveredTestEnginesMessage(testEngines));
return testEngines;

// filter duplicates, jdk-9 bug: https://bugs.openjdk.java.net/browse/JDK-8177139
List<TestEngine> pruned = new ArrayList<>();
Set<String> set = new TreeSet<>();
for (TestEngine engine : testEngines) {
String className = engine.getClass().getName();
if (set.contains(className)) {
LOG.warning("Test engine already loaded: " + engine);
continue;
}
set.add(className);
pruned.add(engine);
}
return pruned;
}

private String createDiscoveredTestEnginesMessage(Iterable<TestEngine> testEngines) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
testImplementation(project(':junit-platform-runner'))
testImplementation(project(':junit-jupiter-engine'))
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
testImplementation("org.assertj:assertj-core:${assertJVersion}")
testImplementation("com.github.joel-costigliola:assertj-core:master-SNAPSHOT")

// Include junit-platform-console so that the JUnit Gradle plugin
// uses the local version of the ConsoleLauncher.
Expand Down
2 changes: 1 addition & 1 deletion junit-vintage-engine/junit-vintage-engine.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
testImplementation(project(':junit-jupiter-api'))
testImplementation(project(':junit-platform-runner'))
testImplementation(project(path: ':junit-platform-engine', configuration: 'testArtifacts'))
testImplementation("org.assertj:assertj-core:${assertJVersion}")
testImplementation("com.github.joel-costigliola:assertj-core:master-SNAPSHOT")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")

// Include junit-platform-console so that the JUnit Gradle plugin
Expand Down
2 changes: 1 addition & 1 deletion platform-tests/platform-tests.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
testImplementation(project(':junit-jupiter-api'))
testImplementation(project(':junit-platform-runner'))
testImplementation(project(path: ':junit-platform-engine', configuration: 'testArtifacts'))
testImplementation("org.assertj:assertj-core:${assertJVersion}")
testImplementation("com.github.joel-costigliola:assertj-core:master-SNAPSHOT")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")

// --- Test run-time dependencies ---------------------------------------------
Expand Down

0 comments on commit 550346e

Please sign in to comment.