use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-boot by spring-projects.
the class TaskExecutionAutoConfigurationTests method taskExecutorBuilderShouldApplyCustomizer.
@Test
void taskExecutorBuilderShouldApplyCustomizer() {
this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> {
TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class);
ThreadPoolTaskExecutor executor = context.getBean(TaskExecutorBuilder.class).build();
then(customizer).should().customize(executor);
});
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-boot by spring-projects.
the class TaskExecutorBuilderTests method threadNamePrefixShouldApply.
@Test
void threadNamePrefixShouldApply() {
ThreadPoolTaskExecutor executor = this.builder.threadNamePrefix("test-").build();
assertThat(executor.getThreadNamePrefix()).isEqualTo("test-");
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-boot by spring-projects.
the class TaskExecutorBuilderTests method customizersShouldBeAppliedLast.
@Test
void customizersShouldBeAppliedLast() {
TaskDecorator taskDecorator = mock(TaskDecorator.class);
ThreadPoolTaskExecutor executor = spy(new ThreadPoolTaskExecutor());
this.builder.queueCapacity(10).corePoolSize(4).maxPoolSize(8).allowCoreThreadTimeOut(true).keepAlive(Duration.ofMinutes(1)).awaitTermination(true).awaitTerminationPeriod(Duration.ofSeconds(30)).threadNamePrefix("test-").taskDecorator(taskDecorator).additionalCustomizers((taskExecutor) -> {
then(taskExecutor).should().setQueueCapacity(10);
then(taskExecutor).should().setCorePoolSize(4);
then(taskExecutor).should().setMaxPoolSize(8);
then(taskExecutor).should().setAllowCoreThreadTimeOut(true);
then(taskExecutor).should().setKeepAliveSeconds(60);
then(taskExecutor).should().setWaitForTasksToCompleteOnShutdown(true);
then(taskExecutor).should().setAwaitTerminationSeconds(30);
then(taskExecutor).should().setThreadNamePrefix("test-");
then(taskExecutor).should().setTaskDecorator(taskDecorator);
});
this.builder.configure(executor);
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-boot by spring-projects.
the class TaskExecutorBuilderTests method additionalCustomizersShouldAddToExisting.
@Test
void additionalCustomizersShouldAddToExisting() {
TaskExecutorCustomizer customizer1 = mock(TaskExecutorCustomizer.class);
TaskExecutorCustomizer customizer2 = mock(TaskExecutorCustomizer.class);
ThreadPoolTaskExecutor executor = this.builder.customizers(customizer1).additionalCustomizers(customizer2).build();
then(customizer1).should().customize(executor);
then(customizer2).should().customize(executor);
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-boot by spring-projects.
the class TaskExecutorBuilderTests method awaitTerminationPeriodShouldApplyWithMillisecondPrecision.
@Test
void awaitTerminationPeriodShouldApplyWithMillisecondPrecision() {
Duration period = Duration.ofMillis(50);
ThreadPoolTaskExecutor executor = this.builder.awaitTerminationPeriod(period).build();
assertThat(executor).hasFieldOrPropertyWithValue("awaitTerminationMillis", period.toMillis());
}
Aggregations