Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Bump AssertJ to 3.19.0, polish tests and isolate tckTest #2706

Merged
merged 5 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ext {

// Testing
jUnitPlatformVersion = '5.6.0'
assertJVersion = '3.11.1'
assertJVersion = '3.19.0' //needs to be manually synchronized in buildSrc
mockitoVersion = '2.23.0'
awaitilityVersion = '3.1.2'
throwingFunctionVersion = '1.5.0'
Expand Down Expand Up @@ -139,7 +139,6 @@ configure(subprojects) { p ->
test {
include '**/*Tests.*'
include '**/*Test.*'
include '**/*Spec.*'
}

//all test tasks will show FAILED for each test method,
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
}

dependencies {
testImplementation("org.assertj:assertj-core:3.11.1")
testImplementation("org.assertj:assertj-core:3.19.0")
testImplementation platform("org.junit:junit-bom:5.6.0")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
Expand Down
47 changes: 26 additions & 21 deletions reactor-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ext {
testSets {
blockHoundTest
withMicrometerTest
tckTest
}

configurations {
Expand All @@ -55,7 +56,7 @@ configurations {
dependencies {
// Reactive Streams
api "org.reactivestreams:reactive-streams:${reactiveStreamsVersion}"
testImplementation ("org.reactivestreams:reactive-streams-tck:${reactiveStreamsVersion}") {
tckTestImplementation ("org.reactivestreams:reactive-streams-tck:${reactiveStreamsVersion}") {
// without this exclusion, testng brings an old version of junit which *embeds* an old version of hamcrest
// which gets picked up first and that we don't want. TCK runs fine w/o (old) junit 4.
exclude group: 'junit', module: 'junit'
Expand Down Expand Up @@ -179,17 +180,9 @@ task loops(type: Test, group: 'verification') {
}
}

task reactivestreamsTCK(type: Test, group: 'verification') {
include '**/*Verification.*'
doFirst {
println "Additional tests from `${name}` (${includes})"
}
}

tasks.withType(Test).all {
if (it.name == "reactivestreamsTCK") {
useTestNG()
} else {
if (it.name == "test") {
//configure tag support for the core test task
def tags = rootProject.findProperty("junit-tags")
if (tags != null) {
println "junit5 tags for core: $tags"
Expand All @@ -201,6 +194,18 @@ tasks.withType(Test).all {
useJUnitPlatform()
}
}
else if (it.name != "tckTest") {
//default to JunitPlatform
useJUnitPlatform()
}
}

tckTest {
useTestNG()
include '**/*Verification.*'
doFirst {
println "Additional tests from `${name}` (${includes})"
}
}


Expand All @@ -210,17 +215,21 @@ blockHoundTest {
maxParallelForks = 1
}

//inherit basic test task + common configuration in root
//always depend on testNoMicrometer, skip reactivestreamsTCK on Travis, skip loops when not releasing
//note that this way the tasks can be run individually
jcstress {
mode = 'quick' //quick, default, tough
}

// inherit basic test task + common configuration in root
// always depend on withMicrometerTest, blockHoundTest and tckTest, skip loops when not releasing
// note that this way the tasks can be run individually
check {
dependsOn withMicrometerTest
if (!detectedCiServers.contains("TRAVIS")) {
dependsOn reactivestreamsTCK
}
dependsOn blockHoundTest
dependsOn tckTest
if (!version.endsWith('BUILD-SNAPSHOT')) {
dependsOn loops
}
dependsOn tasks.jcstress
}

//TODO all java9 / stubs / java-specific stuff should go in a convention plugin ?
Expand All @@ -243,10 +252,6 @@ jacocoTestReport.dependsOn test
check.dependsOn jacocoTestReport
check.dependsOn japicmp

jcstress {
mode = 'quick' //quick, default, tough
}
tasks.check.dependsOn(tasks.jcstress)

if (JavaVersion.current().java9Compatible) {
// SharedSecretsCallSiteSupplierFactory is a Java 8 specific optimization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public String toString() {
.isThrownBy(() -> {
assertThat(queueSubscription).isNull();
})
.withMessage("\n" + "Expecting:\n" + " <ThisIsNotAQueue>\n" + "to be equal to:\n" + " <null>\n" + "but was not.");
.withMessage("\n" + "expected: null\n" + "but was : ThisIsNotAQueue");
}

}
30 changes: 15 additions & 15 deletions reactor-core/src/test/java/reactor/core/ScannableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ public void taggedFluxTest() {
.hide();

final Stream<Tuple2<String, String>> scannedTags1 = Scannable.from(tagged1).tags();
assertThat(scannedTags1.iterator())
assertThat(scannedTags1)
.containsExactlyInAnyOrder(Tuples.of("1", "One"));

final Stream<Tuple2<String, String>> scannedTags2 = Scannable.from(tagged2).tags();
assertThat(scannedTags2.iterator())
assertThat(scannedTags2)
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -235,11 +235,11 @@ public void taggedHideFluxTest() {
.hide();

final Stream<Tuple2<String, String>> scannedTags1 = Scannable.from(tagged1).tags();
assertThat(scannedTags1.iterator())
assertThat(scannedTags1)
.containsExactlyInAnyOrder(Tuples.of("1", "One"));

final Stream<Tuple2<String, String>> scannedTags2 = Scannable.from(tagged2).tags();
assertThat(scannedTags2.iterator())
assertThat(scannedTags2)
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -251,7 +251,7 @@ public void taggedAppendedFluxTest() {
.tag("2", "Two");

final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
assertThat(scannedTags)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering why there we use stream without .iterator()).toIterable() but in the above changes we do with

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like there's no particular reason not to directly assert the Stream itself since AssertJ now supports all the necessary containsXxx assertions on these, will change.

.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -264,7 +264,7 @@ public void taggedAppendedHideFluxTest() {
.tag("2", "Two");

final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
assertThat(scannedTags)
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand Down Expand Up @@ -351,11 +351,11 @@ public void taggedMonoTest() {
.hide();

final Stream<Tuple2<String, String>> scannedTags1 = Scannable.from(tagged1).tags();
assertThat(scannedTags1.iterator())
assertThat(scannedTags1)
.containsExactlyInAnyOrder(Tuples.of("1", "One"));

final Stream<Tuple2<String, String>> scannedTags2 = Scannable.from(tagged2).tags();
assertThat(scannedTags2.iterator())
assertThat(scannedTags2)
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -372,11 +372,11 @@ public void taggedHideMonoTest() {
.hide();

final Stream<Tuple2<String, String>> scannedTags1 = Scannable.from(tagged1).tags();
assertThat(scannedTags1.iterator())
assertThat(scannedTags1)
.containsExactlyInAnyOrder(Tuples.of("1", "One"));

final Stream<Tuple2<String, String>> scannedTags2 = Scannable.from(tagged2).tags();
assertThat(scannedTags2.iterator())
assertThat(scannedTags2)
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -388,7 +388,7 @@ public void taggedAppendedMonoTest() {
.tag("2", "Two");

final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
assertThat(scannedTags)
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -401,7 +401,7 @@ public void taggedAppendedHideMonoTest() {
.tag("2", "Two");

final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
assertThat(scannedTags)
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand Down Expand Up @@ -456,10 +456,10 @@ public void taggedParallelFluxTest() {
.hide();

Stream<Tuple2<String, String>> scannedTags1 = Scannable.from(tagged1).tags();
assertThat(scannedTags1.iterator()).containsExactlyInAnyOrder(Tuples.of("1", "One"));
assertThat(scannedTags1).containsExactlyInAnyOrder(Tuples.of("1", "One"));

Stream<Tuple2<String, String>> scannedTags2 = Scannable.from(tagged2).tags();
assertThat(scannedTags2.iterator())
assertThat(scannedTags2)
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -471,7 +471,7 @@ public void taggedAppendedParallelFluxTest() {
.tag("2", "Two");

final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
assertThat(scannedTags)
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,7 @@ public void errorModeContinueDelayErrorsWithCallable() {
public void errorModeContinueInternalErrorStopStrategy() {
for (int iterations = 0; iterations < 1000; iterations++) {
AtomicInteger i = new AtomicInteger();
@SuppressWarnings("unchecked")
TestPublisher<Integer>[] inners = new TestPublisher[]{
TestPublisher.createNoncompliant(TestPublisher.Violation.CLEANUP_ON_TERMINATE),
TestPublisher.createNoncompliant(TestPublisher.Violation.CLEANUP_ON_TERMINATE)
Expand Down Expand Up @@ -1709,6 +1710,7 @@ public void errorModeContinueInternalErrorStopStrategy() {
public void errorModeContinueInternalErrorStopStrategyAsync() {
for (int iterations = 0; iterations < 1000; iterations++) {
AtomicInteger i = new AtomicInteger();
@SuppressWarnings("unchecked")
TestPublisher<Integer>[] inners = new TestPublisher[]{
TestPublisher.createNoncompliant(TestPublisher.Violation.CLEANUP_ON_TERMINATE),
TestPublisher.createNoncompliant(TestPublisher.Violation.CLEANUP_ON_TERMINATE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package reactor.core.publisher;

import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;

import java.time.Duration;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void scanOperator() throws Exception {
//noinspection unchecked
final Stream<Tuple2<String, String>> scannedTags = test.scan(Scannable.Attr.TAGS);
assertThat(scannedTags).isNotNull();
assertThat(scannedTags.iterator()).containsExactlyInAnyOrder(tag1, tag2);
assertThat(scannedTags).containsExactlyInAnyOrder(tag1, tag2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void scanOperator() throws Exception {

final Stream<Tuple2<String, String>> scannedTags = test.scan(Scannable.Attr.TAGS);
assertThat(scannedTags).isNotNull();
assertThat(scannedTags.iterator()).containsExactlyInAnyOrder(tag1, tag2);
assertThat(scannedTags).containsExactlyInAnyOrder(tag1, tag2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public void parallelFluxCheckpointDescriptionAndForceStack() {
Iterator<String> lines = seekToBacktrace(debugStack);

assertThat(lines)
.toIterable()
.startsWith(
"|_ ParallelFlux.checkpoint ⇢ at reactor.core.publisher.FluxOnAssemblyTest.parallelFluxCheckpointDescriptionAndForceStack(FluxOnAssemblyTest.java:" + (baseline + 4) + ")",
"Stack trace:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import static org.assertj.core.api.Assertions.assertThat;

@SuppressWarnings("deprecation")
public class FluxSwitchMapTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -944,11 +944,12 @@ public void shouldReturnNormallyIfExceptionIsThrownOnNextDuringSwitching() {
.expectError(NullPointerException.class)
.verifyThenAssertThat(Duration.ofSeconds(5))
.hasOperatorErrorsSatisfying(c ->
assertThat(c)
.hasOnlyOneElementSatisfying(t -> {
assertThat(t.getT1()).containsInstanceOf(NullPointerException.class);
assertThat(t.getT2()).isEqualTo(expectedCause);
})
assertThat(c)
.singleElement()
.satisfies(t -> {
assertThat(t.getT1()).containsInstanceOf(NullPointerException.class);
assertThat(t.getT2()).isEqualTo(expectedCause);
})
);


Expand Down Expand Up @@ -1018,7 +1019,8 @@ public void shouldReturnNormallyIfExceptionIsThrownOnNextDuringSwitchingConditio
.verifyThenAssertThat()
.hasOperatorErrorsSatisfying(c ->
assertThat(c)
.hasOnlyOneElementSatisfying(t -> {
.singleElement()
.satisfies(t -> {
assertThat(t.getT1()).containsInstanceOf(NullPointerException.class);
assertThat(t.getT2()).isEqualTo(expectedCause);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.*;
import static org.testng.Assert.assertTrue;

public class LambdaMonoSubscriberTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ public void ensuresElementsIsDiscarded() {
Hooks.onNextDropped(collector::add);
AssertSubscriber<Object> assertSubscriber = new AssertSubscriber<>(Operators.enableOnDiscard(null, collector::add), 1);

@SuppressWarnings("unchecked")
MonoSink<Object>[] sinks = new MonoSink[1];

Mono.create(sink -> sinks[0] = sink)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package reactor.core.publisher;

import org.junit.jupiter.api.Test;
import org.testng.Assert;

import reactor.core.Exceptions;
import reactor.test.StepVerifier;
import reactor.test.subscriber.AssertSubscriber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void scanOperator() throws Exception {

final Stream<Tuple2<String, String>> scannedTags = test.scan(Scannable.Attr.TAGS);
assertThat(scannedTags).isNotNull();
assertThat(scannedTags.iterator()).containsExactlyInAnyOrder(tag1, tag2);
assertThat(scannedTags).containsExactlyInAnyOrder(tag1, tag2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void scanOperator() throws Exception {

final Stream<Tuple2<String, String>> scannedTags = test.scan(Scannable.Attr.TAGS);
assertThat(scannedTags).isNotNull();
assertThat(scannedTags.iterator()).containsExactlyInAnyOrder(tag1, tag2);
assertThat(scannedTags).containsExactlyInAnyOrder(tag1, tag2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class MonoProcessorTest {

Expand Down
Loading