Skip to content

Commit 76a571c

Browse files
committed
Use AssertJ CompletableFuture assertions for exception verification
1 parent 91f9980 commit 76a571c

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/AsyncRabbitTemplateTests.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,9 @@ public Object fromMessage(Message message) throws MessageConversionException {
408408

409409
RabbitConverterFuture<String> replyFuture = this.asyncTemplate.convertSendAndReceive("conversionException");
410410

411-
final CountDownLatch cdl = new CountDownLatch(1);
412-
final AtomicReference<Object> resultRef = new AtomicReference<>();
413-
replyFuture.whenComplete((result, ex) -> {
414-
resultRef.set(result);
415-
cdl.countDown();
416-
});
417-
assertThat(cdl.await(10, TimeUnit.SECONDS)).isTrue();
418-
assertThat(replyFuture).isCompletedExceptionally();
419-
assertThat(resultRef.get()).isNull();
411+
assertThat(replyFuture).failsWithin(Duration.ofSeconds(10))
412+
.withThrowableThat()
413+
.withCauseInstanceOf(MessageConversionException.class);
420414
}
421415

422416
@Test

0 commit comments

Comments
 (0)