Merge branch '6.1.x'

This commit is contained in:
Stéphane Nicoll 2024-03-26 17:45:25 +01:00
commit bf5b22d64f
9 changed files with 48 additions and 47 deletions

View File

@ -57,7 +57,7 @@ class SimpleThreadScopeTests {
thread2.start();
// Assert
Awaitility.await()
.atMost(500, TimeUnit.MILLISECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> (beans[0] != null) && (beans[1] != null));
assertThat(beans[1]).isNotSameAs(beans[0]);

View File

@ -339,7 +339,7 @@ class AsyncExecutionTests {
context.refresh();
// Assert
Awaitility.await()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> listenerCalled == 1);
context.close();
@ -357,7 +357,7 @@ class AsyncExecutionTests {
context.close();
// Assert
Awaitility.await()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> listenerCalled == 2);
assertThat(listenerConstructed).isEqualTo(1);
@ -377,7 +377,7 @@ class AsyncExecutionTests {
context.close();
// Assert
Awaitility.await()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> listenerCalled == 2);
assertThat(listenerConstructed).isEqualTo(2);

View File

@ -226,7 +226,7 @@ class EnableAsyncTests {
asyncBean.work();
// Assert
Awaitility.await()
.atMost(500, TimeUnit.MILLISECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> asyncBean.getThreadOfExecution() != null);
assertThat(asyncBean.getThreadOfExecution().getName()).startsWith("Custom-");
@ -244,7 +244,7 @@ class EnableAsyncTests {
asyncBean.work();
// Assert
Awaitility.await()
.atMost(500, TimeUnit.MILLISECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> asyncBean.getThreadOfExecution() != null);
assertThat(asyncBean.getThreadOfExecution().getName()).startsWith("Custom-");
@ -266,7 +266,7 @@ class EnableAsyncTests {
asyncBean.fail();
// Assert
Awaitility.await()
.atMost(500, TimeUnit.MILLISECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.untilAsserted(() -> exceptionHandler.assertCalledWith(method, UnsupportedOperationException.class));
ctx.close();
@ -283,7 +283,7 @@ class EnableAsyncTests {
asyncBean.work();
// Assert
Awaitility.await()
.atMost(500, TimeUnit.MILLISECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> asyncBean.getThreadOfExecution() != null);
assertThat(asyncBean.getThreadOfExecution().getName()).startsWith("Post-");
@ -305,7 +305,7 @@ class EnableAsyncTests {
asyncBean.fail();
// Assert
Awaitility.await()
.atMost(500, TimeUnit.MILLISECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.untilAsserted(() -> exceptionHandler.assertCalledWith(method, UnsupportedOperationException.class));
ctx.close();
@ -320,7 +320,7 @@ class EnableAsyncTests {
asyncBean.work();
// Assert
Awaitility.await()
.atMost(500, TimeUnit.MILLISECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> asyncBean.getThreadOfExecution() != null);
assertThat(asyncBean.getThreadOfExecution().getName()).startsWith("Custom-");
@ -336,7 +336,7 @@ class EnableAsyncTests {
asyncBean.work();
// Assert
Awaitility.await()
.atMost(500, TimeUnit.MILLISECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> asyncBean.getThreadOfExecution() != null);
assertThat(asyncBean.getThreadOfExecution().getName()).startsWith("Custom-");

View File

@ -89,7 +89,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
executor.execute(task);
Awaitility.await()
.dontCatchUncaughtExceptions()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> task.exception.get() != null && task.exception.get().getMessage().equals(
"TestTask failure for test 'executeFailingRunnable': expectedRunCount:<0>, actualRunCount:<1>"));
@ -133,7 +133,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
future.addCallback(result -> outcome = result, ex -> outcome = ex);
// Assert
Awaitility.await()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(future::isDone);
assertThat(outcome).isNull();
@ -148,7 +148,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
future.whenComplete(this::storeOutcome);
// Assert
Awaitility.await()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(future::isDone);
assertThat(outcome).isNull();
@ -164,7 +164,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
Awaitility.await()
.dontCatchUncaughtExceptions()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> future.isDone() && outcome != null);
assertThat(outcome.getClass()).isSameAs(RuntimeException.class);
@ -178,7 +178,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
Awaitility.await()
.dontCatchUncaughtExceptions()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> future.isDone() && outcome != null);
assertThat(outcome.getClass()).isSameAs(CompletionException.class);
@ -198,7 +198,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
// ignore
}
Awaitility.await()
.atMost(4, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.untilAsserted(() -> assertThatExceptionOfType(CancellationException.class)
.isThrownBy(() -> future2.get(1000, TimeUnit.MILLISECONDS)));
@ -217,7 +217,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
// ignore
}
Awaitility.await()
.atMost(4, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.untilAsserted(() -> assertThatExceptionOfType(TimeoutException.class)
.isThrownBy(() -> future2.get(1000, TimeUnit.MILLISECONDS)));
@ -253,7 +253,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
// ignore
}
Awaitility.await()
.atMost(4, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.untilAsserted(() -> assertThatExceptionOfType(CancellationException.class)
.isThrownBy(() -> future2.get(1000, TimeUnit.MILLISECONDS)));
@ -268,7 +268,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
future.addCallback(result -> outcome = result, ex -> outcome = ex);
// Assert
Awaitility.await()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> future.isDone() && outcome != null);
assertThat(outcome.toString().substring(0, this.threadNamePrefix.length())).isEqualTo(this.threadNamePrefix);
@ -284,7 +284,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
// Assert
Awaitility.await()
.dontCatchUncaughtExceptions()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> future.isDone() && outcome != null);
assertThat(outcome.getClass()).isSameAs(RuntimeException.class);
@ -310,7 +310,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
future.whenComplete(this::storeOutcome);
// Assert
Awaitility.await()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> future.isDone() && outcome != null);
assertThat(outcome.toString().substring(0, this.threadNamePrefix.length())).isEqualTo(this.threadNamePrefix);
@ -325,7 +325,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
// Assert
Awaitility.await()
.dontCatchUncaughtExceptions()
.atMost(1, TimeUnit.SECONDS)
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> future.isDone() && outcome != null);
assertThat(outcome.getClass()).isSameAs(CompletionException.class);

View File

@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@SuppressWarnings("unchecked")
class ReactiveAdapterRegistryTests {
private static final Duration ONE_SECOND = Duration.ofSeconds(1);
private static final Duration FIVE_SECONDS = Duration.ofSeconds(5);
private final ReactiveAdapterRegistry registry = ReactiveAdapterRegistry.getSharedInstance();
@ -134,7 +134,7 @@ class ReactiveAdapterRegistryTests {
Publisher<Integer> source = io.reactivex.rxjava3.core.Flowable.fromIterable(sequence);
Object target = getAdapter(Flux.class).fromPublisher(source);
assertThat(target).isInstanceOf(Flux.class);
assertThat(((Flux<Integer>) target).collectList().block(ONE_SECOND)).isEqualTo(sequence);
assertThat(((Flux<Integer>) target).collectList().block(FIVE_SECONDS)).isEqualTo(sequence);
}
@Test
@ -142,7 +142,7 @@ class ReactiveAdapterRegistryTests {
Publisher<Integer> source = io.reactivex.rxjava3.core.Flowable.fromArray(1, 2, 3);
Object target = getAdapter(Mono.class).fromPublisher(source);
assertThat(target).isInstanceOf(Mono.class);
assertThat(((Mono<Integer>) target).block(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
assertThat(((Mono<Integer>) target).block(FIVE_SECONDS)).isEqualTo(Integer.valueOf(1));
}
@Test
@ -152,7 +152,7 @@ class ReactiveAdapterRegistryTests {
Object target = getAdapter(Flow.Publisher.class).fromPublisher(source);
assertThat(target).isInstanceOf(Flow.Publisher.class);
assertThat(JdkFlowAdapter.flowPublisherToFlux((Flow.Publisher<Integer>) target)
.collectList().block(ONE_SECOND)).isEqualTo(sequence);
.collectList().block(FIVE_SECONDS)).isEqualTo(sequence);
}
@Test
@ -169,7 +169,7 @@ class ReactiveAdapterRegistryTests {
future.complete(1);
Object target = getAdapter(CompletableFuture.class).toPublisher(future);
assertThat(target).as("Expected Mono Publisher: " + target.getClass().getName()).isInstanceOf(Mono.class);
assertThat(((Mono<Integer>) target).block(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
assertThat(((Mono<Integer>) target).block(FIVE_SECONDS)).isEqualTo(Integer.valueOf(1));
}
}
@ -227,7 +227,7 @@ class ReactiveAdapterRegistryTests {
Object source = io.reactivex.rxjava3.core.Flowable.fromIterable(sequence);
Object target = getAdapter(io.reactivex.rxjava3.core.Flowable.class).toPublisher(source);
assertThat(target).as("Expected Flux Publisher: " + target.getClass().getName()).isInstanceOf(Flux.class);
assertThat(((Flux<Integer>) target).collectList().block(ONE_SECOND)).isEqualTo(sequence);
assertThat(((Flux<Integer>) target).collectList().block(FIVE_SECONDS)).isEqualTo(sequence);
}
@Test
@ -236,7 +236,7 @@ class ReactiveAdapterRegistryTests {
Object source = io.reactivex.rxjava3.core.Observable.fromIterable(sequence);
Object target = getAdapter(io.reactivex.rxjava3.core.Observable.class).toPublisher(source);
assertThat(target).as("Expected Flux Publisher: " + target.getClass().getName()).isInstanceOf(Flux.class);
assertThat(((Flux<Integer>) target).collectList().block(ONE_SECOND)).isEqualTo(sequence);
assertThat(((Flux<Integer>) target).collectList().block(FIVE_SECONDS)).isEqualTo(sequence);
}
@Test
@ -244,7 +244,7 @@ class ReactiveAdapterRegistryTests {
Object source = io.reactivex.rxjava3.core.Single.just(1);
Object target = getAdapter(io.reactivex.rxjava3.core.Single.class).toPublisher(source);
assertThat(target).as("Expected Mono Publisher: " + target.getClass().getName()).isInstanceOf(Mono.class);
assertThat(((Mono<Integer>) target).block(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
assertThat(((Mono<Integer>) target).block(FIVE_SECONDS)).isEqualTo(Integer.valueOf(1));
}
@Test
@ -252,7 +252,7 @@ class ReactiveAdapterRegistryTests {
Object source = io.reactivex.rxjava3.core.Completable.complete();
Object target = getAdapter(io.reactivex.rxjava3.core.Completable.class).toPublisher(source);
assertThat(target).as("Expected Mono Publisher: " + target.getClass().getName()).isInstanceOf(Mono.class);
((Mono<Void>) target).block(ONE_SECOND);
((Mono<Void>) target).block(FIVE_SECONDS);
}
}
@ -289,7 +289,7 @@ class ReactiveAdapterRegistryTests {
Publisher<Integer> source = Mono.just(1);
Object target = getAdapter(Uni.class).fromPublisher(source);
assertThat(target).isInstanceOf(Uni.class);
assertThat(((Uni<Integer>) target).await().atMost(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
assertThat(((Uni<Integer>) target).await().atMost(FIVE_SECONDS)).isEqualTo(Integer.valueOf(1));
}
@Test
@ -297,7 +297,7 @@ class ReactiveAdapterRegistryTests {
Uni<Integer> source = Uni.createFrom().item(1);
Object target = getAdapter(Uni.class).toPublisher(source);
assertThat(target).isInstanceOf(Mono.class);
assertThat(((Mono<Integer>) target).block(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
assertThat(((Mono<Integer>) target).block(FIVE_SECONDS)).isEqualTo(Integer.valueOf(1));
}
@Test
@ -306,7 +306,7 @@ class ReactiveAdapterRegistryTests {
Publisher<Integer> source = Flux.fromIterable(sequence);
Object target = getAdapter(Multi.class).fromPublisher(source);
assertThat(target).isInstanceOf(Multi.class);
assertThat(((Multi<Integer>) target).collect().asList().await().atMost(ONE_SECOND)).isEqualTo(sequence);
assertThat(((Multi<Integer>) target).collect().asList().await().atMost(FIVE_SECONDS)).isEqualTo(sequence);
}
@Test
@ -315,7 +315,7 @@ class ReactiveAdapterRegistryTests {
Multi<Integer> source = Multi.createFrom().iterable(sequence);
Object target = getAdapter(Multi.class).toPublisher(source);
assertThat(target).isInstanceOf(Flux.class);
assertThat(((Flux<Integer>) target).blockLast(ONE_SECOND)).isEqualTo(Integer.valueOf(3));
assertThat(((Flux<Integer>) target).blockLast(FIVE_SECONDS)).isEqualTo(Integer.valueOf(3));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,11 +16,11 @@
package org.springframework.test.context.junit.jupiter.event;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.awaitility.Awaitility;
import org.awaitility.Durations;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
@ -263,7 +263,7 @@ class JUnitJupiterApplicationEventsIntegrationTests {
void asyncConsumption() {
context.publishEvent(new CustomEvent("sync"));
Awaitility.await().atMost(Durations.ONE_SECOND)
Awaitility.await().atMost(5, TimeUnit.SECONDS)
.untilAsserted(() -> assertThat(this.applicationEvents.stream(CustomEvent.class))
.singleElement()
.extracting(CustomEvent::getMessage, InstanceOfAssertFactories.STRING)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,7 +26,6 @@ import java.util.stream.Stream;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.awaitility.Awaitility;
import org.awaitility.Durations;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
@ -221,7 +220,7 @@ class ParallelApplicationEventsIntegrationTests {
void asyncConsumption() {
this.context.publishEvent("asyncConsumption");
Awaitility.await().atMost(Durations.ONE_SECOND).untilAsserted(() ->//
Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() ->//
assertThat(ApplicationEventsHolder//
.getRequiredApplicationEvents()//
.stream()//

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,9 +16,10 @@
package org.springframework.test.context.junit4.event;
import java.util.concurrent.TimeUnit;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.awaitility.Awaitility;
import org.awaitility.Durations;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
@ -70,7 +71,7 @@ public class JUnit4ApplicationEventsAsyncIntegrationTests {
public void asyncConsumption() {
context.publishEvent(new CustomEvent("sync"));
Awaitility.await().atMost(Durations.ONE_SECOND)
Awaitility.await().atMost(5, TimeUnit.SECONDS)
.untilAsserted(() -> assertThat(this.applicationEvents.stream(CustomEvent.class))
.singleElement()
.extracting(CustomEvent::getMessage, InstanceOfAssertFactories.STRING)

View File

@ -16,9 +16,10 @@
package org.springframework.test.context.testng.event;
import java.util.concurrent.TimeUnit;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.awaitility.Awaitility;
import org.awaitility.Durations;
import org.testng.annotations.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -64,7 +65,7 @@ class TestNGApplicationEventsAsyncIntegrationTests extends AbstractTestNGSpringC
void asyncConsumption() {
context.publishEvent(new CustomEvent("asyncConsumption"));
Awaitility.await().atMost(Durations.ONE_SECOND)
Awaitility.await().atMost(5, TimeUnit.SECONDS)
.untilAsserted(() -> assertThat(this.applicationEvents.stream(CustomEvent.class))
.singleElement()
.extracting(CustomEvent::getMessage, InstanceOfAssertFactories.STRING)