mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-09 00:29:04 +00:00
Fix ignored target assertions in ConcurrencyLimitTests
The rejection tests verified the exception target with `satisfies(ex -> assertThat(ex.getTarget() == target))`, which never asserts anything as the boolean `assertThat` is not followed by a check. Assert the target via `extracting(...).isSameAs(...)` instead, against the proxy, since the concurrency throttle is applied at the AOP proxy level and the proxy is what gets passed as the exception target. Closes gh-37411 Signed-off-by: Tim te Beek <tim@moderne.io>
This commit is contained in:
+3
-3
@@ -137,7 +137,7 @@ class ConcurrencyLimitTests {
|
||||
futures.add(CompletableFuture.runAsync(() ->
|
||||
assertThatExceptionOfType(InvocationRejectedException.class).isThrownBy(proxy::rejectingOperation)
|
||||
.withMessageContaining(AnnotatedMethodBean.class.getName() + ".rejectingOperation")
|
||||
.satisfies(ex -> assertThat(ex.getTarget() == target))));
|
||||
.extracting(InvocationRejectedException::getTarget).isSameAs(proxy)));
|
||||
}
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
||||
assertThat(target.current).hasValue(2);
|
||||
@@ -178,11 +178,11 @@ class ConcurrencyLimitTests {
|
||||
futures.add(CompletableFuture.runAsync(() ->
|
||||
assertThatExceptionOfType(InvocationRejectedException.class).isThrownBy(proxy::concurrentOperation)
|
||||
.withMessageContaining(AnnotatedClassBeanWithRejection.class.getName())
|
||||
.satisfies(ex -> assertThat(ex.getTarget() == target))));
|
||||
.extracting(InvocationRejectedException::getTarget).isSameAs(proxy)));
|
||||
futures.add(CompletableFuture.runAsync(() ->
|
||||
assertThatExceptionOfType(InvocationRejectedException.class).isThrownBy(proxy::otherOperation)
|
||||
.withMessageContaining(AnnotatedClassBeanWithRejection.class.getName())
|
||||
.satisfies(ex -> assertThat(ex.getTarget() == target))));
|
||||
.extracting(InvocationRejectedException::getTarget).isSameAs(proxy)));
|
||||
for (int i = 0; i < 4; i++) {
|
||||
futures.add(CompletableFuture.runAsync(proxy::overrideOperation));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user