Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,23 @@ public Executor getAsyncExecutor() {
});
}

@Test
void enableAsyncUsesAutoConfiguredExecutorWhenModeIsForceAndHasPrimaryCustomTaskExecutor() {
this.contextRunner
.withPropertyValues("spring.task.execution.thread-name-prefix=auto-task-",
"spring.task.execution.mode=force")
.withBean("taskExecutor", Executor.class, () -> createCustomAsyncExecutor("custom-task-"),
(bd) -> bd.setPrimary(true))
.withUserConfiguration(AsyncConfiguration.class, TestBean.class)
.run((context) -> {
assertThat(context).hasSingleBean(AsyncConfigurer.class);
assertThat(context.getBeansOfType(Executor.class)).hasSize(2);
TestBean bean = context.getBean(TestBean.class);
String text = bean.echo("something").get();
assertThat(text).contains("auto-task-").contains("something");
});
}

private Executor createCustomAsyncExecutor(String threadNamePrefix) {
SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
executor.setThreadNamePrefix(threadNamePrefix);
Expand Down