@ -1,5 +1,5 @@
/ *
* Copyright 2012 - 202 0 the original author or authors .
* Copyright 2012 - 202 1 the original author or authors .
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -23,13 +23,13 @@ import java.util.function.Consumer;
import org.junit.jupiter.api.Test ;
import org.junit.jupiter.api.extension.ExtendWith ;
import org.springframework.beans.factory.config.BeanDefinition ;
import org.springframework.boot.autoconfigure.AutoConfigurations ;
import org.springframework.boot.task.TaskExecutorBuilder ;
import org.springframework.boot.task.TaskExecutorCustomizer ;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext ;
import org.springframework.boot.test.context.runner.ApplicationContextRunner ;
import org.springframework.boot.test.context.runner.ContextConsumer ;
import org.springframework.boot.test.system.CapturedOutput ;
import org.springframework.boot.test.system.OutputCaptureExtension ;
import org.springframework.context.annotation.Bean ;
import org.springframework.context.annotation.Configuration ;
@ -96,13 +96,13 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
void taskExecutorAutoConfigured ( CapturedOutput output ) {
void taskExecutorAutoConfigured IsLazy ( ) {
this . contextRunner . run ( ( context ) - > {
assertThat ( output ) . doesNotContain ( "Initializing ExecutorService" ) ;
assertThat ( context ) . hasSingleBean ( Executor . class ) ;
assertThat ( context ) . hasBean ( "applicationTaskExecutor" ) ;
assertThat ( context ) . hasSingleBean ( Executor . class ) . hasBean ( "applicationTaskExecutor" ) ;
BeanDefinition beanDefinition = context . getSourceApplicationContext ( ) . getBeanFactory ( )
. getBeanDefinition ( "applicationTaskExecutor" ) ;
assertThat ( beanDefinition . isLazyInit ( ) ) . isTrue ( ) ;
assertThat ( context ) . getBean ( "applicationTaskExecutor" ) . isInstanceOf ( ThreadPoolTaskExecutor . class ) ;
assertThat ( output ) . contains ( "Initializing ExecutorService" ) ;
} ) ;
}