|
|
@ -380,16 +380,15 @@ class WebMvcAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void defaultAsyncRequestTimeout() {
|
|
|
|
void defaultAsyncRequestTimeout() {
|
|
|
|
this.contextRunner.run((context) -> assertThat(ReflectionTestUtils
|
|
|
|
this.contextRunner.run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class))
|
|
|
|
.getField(context.getBean(RequestMappingHandlerAdapter.class), "asyncRequestTimeout")).isNull());
|
|
|
|
.extracting("asyncRequestTimeout").isNull());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void customAsyncRequestTimeout() {
|
|
|
|
void customAsyncRequestTimeout() {
|
|
|
|
this.contextRunner.withPropertyValues("spring.mvc.async.request-timeout:12345")
|
|
|
|
this.contextRunner.withPropertyValues("spring.mvc.async.request-timeout:12345")
|
|
|
|
.run((context) -> assertThat(ReflectionTestUtils
|
|
|
|
.run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class))
|
|
|
|
.getField(context.getBean(RequestMappingHandlerAdapter.class), "asyncRequestTimeout"))
|
|
|
|
.extracting("asyncRequestTimeout").isEqualTo(12345L));
|
|
|
|
.isEqualTo(12345L));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -397,8 +396,8 @@ class WebMvcAutoConfigurationTests {
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class))
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class))
|
|
|
|
.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
assertThat(context).hasSingleBean(AsyncTaskExecutor.class);
|
|
|
|
assertThat(context).hasSingleBean(AsyncTaskExecutor.class);
|
|
|
|
assertThat(ReflectionTestUtils.getField(context.getBean(RequestMappingHandlerAdapter.class),
|
|
|
|
assertThat(context.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor")
|
|
|
|
"taskExecutor")).isSameAs(context.getBean("applicationTaskExecutor"));
|
|
|
|
.isSameAs(context.getBean("applicationTaskExecutor"));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -407,8 +406,8 @@ class WebMvcAutoConfigurationTests {
|
|
|
|
this.contextRunner.withUserConfiguration(CustomApplicationTaskExecutorConfig.class)
|
|
|
|
this.contextRunner.withUserConfiguration(CustomApplicationTaskExecutorConfig.class)
|
|
|
|
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> {
|
|
|
|
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> {
|
|
|
|
assertThat(context).doesNotHaveBean(AsyncTaskExecutor.class);
|
|
|
|
assertThat(context).doesNotHaveBean(AsyncTaskExecutor.class);
|
|
|
|
assertThat(ReflectionTestUtils.getField(context.getBean(RequestMappingHandlerAdapter.class),
|
|
|
|
assertThat(context.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor")
|
|
|
|
"taskExecutor")).isNotSameAs(context.getBean("applicationTaskExecutor"));
|
|
|
|
.isNotSameAs(context.getBean("applicationTaskExecutor"));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -416,8 +415,8 @@ class WebMvcAutoConfigurationTests {
|
|
|
|
void asyncTaskExecutorWithMvcConfigurerCanOverrideExecutor() {
|
|
|
|
void asyncTaskExecutorWithMvcConfigurerCanOverrideExecutor() {
|
|
|
|
this.contextRunner.withUserConfiguration(CustomAsyncTaskExecutorConfigurer.class)
|
|
|
|
this.contextRunner.withUserConfiguration(CustomAsyncTaskExecutorConfigurer.class)
|
|
|
|
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class))
|
|
|
|
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class))
|
|
|
|
.run((context) -> assertThat(ReflectionTestUtils
|
|
|
|
.run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class))
|
|
|
|
.getField(context.getBean(RequestMappingHandlerAdapter.class), "taskExecutor"))
|
|
|
|
.extracting("taskExecutor")
|
|
|
|
.isSameAs(context.getBean(CustomAsyncTaskExecutorConfigurer.class).taskExecutor));
|
|
|
|
.isSameAs(context.getBean(CustomAsyncTaskExecutorConfigurer.class).taskExecutor));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -426,8 +425,8 @@ class WebMvcAutoConfigurationTests {
|
|
|
|
this.contextRunner.withUserConfiguration(CustomAsyncTaskExecutorConfig.class)
|
|
|
|
this.contextRunner.withUserConfiguration(CustomAsyncTaskExecutorConfig.class)
|
|
|
|
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> {
|
|
|
|
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> {
|
|
|
|
assertThat(context).hasSingleBean(AsyncTaskExecutor.class);
|
|
|
|
assertThat(context).hasSingleBean(AsyncTaskExecutor.class);
|
|
|
|
assertThat(ReflectionTestUtils.getField(context.getBean(RequestMappingHandlerAdapter.class),
|
|
|
|
assertThat(context.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor")
|
|
|
|
"taskExecutor")).isNotSameAs(context.getBean("customTaskExecutor"));
|
|
|
|
.isNotSameAs(context.getBean("customTaskExecutor"));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -643,8 +642,7 @@ class WebMvcAutoConfigurationTests {
|
|
|
|
Validator validator = context.getBean(Validator.class);
|
|
|
|
Validator validator = context.getBean(Validator.class);
|
|
|
|
assertThat(validator).isInstanceOf(ValidatorAdapter.class);
|
|
|
|
assertThat(validator).isInstanceOf(ValidatorAdapter.class);
|
|
|
|
Validator target = ((ValidatorAdapter) validator).getTarget();
|
|
|
|
Validator target = ((ValidatorAdapter) validator).getTarget();
|
|
|
|
assertThat(ReflectionTestUtils.getField(target, "targetValidator"))
|
|
|
|
assertThat(target).extracting("targetValidator").isSameAs(context.getBean("customJsr303Validator"));
|
|
|
|
.isSameAs(context.getBean("customJsr303Validator"));
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|