From 7c5ec73724ead59534dd9f17ebd1ed70a22caac1 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Wed, 2 Aug 2023 10:11:12 +0200 Subject: [PATCH] Polish SimpleAsyncTaskExecutorBuilderTests --- .../boot/task/SimpleAsyncTaskExecutorBuilderTests.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/SimpleAsyncTaskExecutorBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/SimpleAsyncTaskExecutorBuilderTests.java index fe856cd9cb..bd6f3607eb 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/SimpleAsyncTaskExecutorBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/SimpleAsyncTaskExecutorBuilderTests.java @@ -16,7 +16,6 @@ package org.springframework.boot.task; -import java.lang.reflect.Field; import java.util.Collections; import java.util.Set; @@ -24,9 +23,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledForJreRange; import org.junit.jupiter.api.condition.JRE; +import org.springframework.boot.testsupport.assertj.SimpleAsyncTaskExecutorAssert; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.core.task.TaskDecorator; -import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -55,11 +54,7 @@ class SimpleAsyncTaskExecutorBuilderTests { @EnabledForJreRange(min = JRE.JAVA_21) void virtualThreadsShouldApply() { SimpleAsyncTaskExecutor executor = this.builder.virtualThreads(true).build(); - Field field = ReflectionUtils.findField(SimpleAsyncTaskExecutor.class, "virtualThreadDelegate"); - assertThat(field).as("executor.virtualThreadDelegate").isNotNull(); - field.setAccessible(true); - Object virtualThreadDelegate = ReflectionUtils.getField(field, executor); - assertThat(virtualThreadDelegate).as("executor.virtualThreadDelegate").isNotNull(); + SimpleAsyncTaskExecutorAssert.assertThat(executor).usesVirtualThreads(); } @Test