Polish SimpleAsyncTaskExecutorBuilderTests

This commit is contained in:
Moritz Halbritter 2023-08-02 10:11:12 +02:00
parent 5d9d0f43b6
commit 7c5ec73724
1 changed files with 2 additions and 7 deletions

View File

@ -16,7 +16,6 @@
package org.springframework.boot.task; package org.springframework.boot.task;
import java.lang.reflect.Field;
import java.util.Collections; import java.util.Collections;
import java.util.Set; 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.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE; 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.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskDecorator; 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.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@ -55,11 +54,7 @@ class SimpleAsyncTaskExecutorBuilderTests {
@EnabledForJreRange(min = JRE.JAVA_21) @EnabledForJreRange(min = JRE.JAVA_21)
void virtualThreadsShouldApply() { void virtualThreadsShouldApply() {
SimpleAsyncTaskExecutor executor = this.builder.virtualThreads(true).build(); SimpleAsyncTaskExecutor executor = this.builder.virtualThreads(true).build();
Field field = ReflectionUtils.findField(SimpleAsyncTaskExecutor.class, "virtualThreadDelegate"); SimpleAsyncTaskExecutorAssert.assertThat(executor).usesVirtualThreads();
assertThat(field).as("executor.virtualThreadDelegate").isNotNull();
field.setAccessible(true);
Object virtualThreadDelegate = ReflectionUtils.getField(field, executor);
assertThat(virtualThreadDelegate).as("executor.virtualThreadDelegate").isNotNull();
} }
@Test @Test