|
|
@ -20,6 +20,7 @@ import java.util.concurrent.Executor;
|
|
|
|
import java.util.concurrent.Future;
|
|
|
|
import java.util.concurrent.Future;
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Rule;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.DirectFieldAccessor;
|
|
|
|
import org.springframework.beans.DirectFieldAccessor;
|
|
|
@ -29,6 +30,7 @@ import org.springframework.boot.task.TaskExecutorCustomizer;
|
|
|
|
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
|
|
|
|
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.boot.test.context.runner.ContextConsumer;
|
|
|
|
import org.springframework.boot.test.context.runner.ContextConsumer;
|
|
|
|
|
|
|
|
import org.springframework.boot.test.rule.OutputCapture;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.core.task.SyncTaskExecutor;
|
|
|
|
import org.springframework.core.task.SyncTaskExecutor;
|
|
|
@ -55,6 +57,9 @@ public class TaskExecutionAutoConfigurationTests {
|
|
|
|
.withConfiguration(
|
|
|
|
.withConfiguration(
|
|
|
|
AutoConfigurations.of(TaskExecutionAutoConfiguration.class));
|
|
|
|
AutoConfigurations.of(TaskExecutionAutoConfiguration.class));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Rule
|
|
|
|
|
|
|
|
public final OutputCapture output = new OutputCapture();
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void taskExecutorBuilderShouldApplyCustomSettings() {
|
|
|
|
public void taskExecutorBuilderShouldApplyCustomSettings() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
@ -101,11 +106,15 @@ public class TaskExecutionAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void taskExecutorAutoConfigured() {
|
|
|
|
public void taskExecutorAutoConfigured() {
|
|
|
|
|
|
|
|
this.output.reset();
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
|
|
|
|
assertThat(this.output.toString())
|
|
|
|
|
|
|
|
.doesNotContain("Initializing ExecutorService");
|
|
|
|
assertThat(context).hasSingleBean(Executor.class);
|
|
|
|
assertThat(context).hasSingleBean(Executor.class);
|
|
|
|
assertThat(context).hasBean("applicationTaskExecutor");
|
|
|
|
assertThat(context).hasBean("applicationTaskExecutor");
|
|
|
|
assertThat(context).getBean("applicationTaskExecutor")
|
|
|
|
assertThat(context).getBean("applicationTaskExecutor")
|
|
|
|
.isInstanceOf(ThreadPoolTaskExecutor.class);
|
|
|
|
.isInstanceOf(ThreadPoolTaskExecutor.class);
|
|
|
|
|
|
|
|
assertThat(this.output.toString()).contains("Initializing ExecutorService");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|