mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Handle timeout of latch await in tests
This commit is contained in:
parent
de57b5f4a4
commit
b5a48e926d
@ -51,7 +51,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
@ -366,9 +365,7 @@ class TaskExecutionAutoConfigurationTests {
|
||||
threadReference.set(currentThread);
|
||||
latch.countDown();
|
||||
});
|
||||
if (!latch.await(30, TimeUnit.SECONDS)) {
|
||||
fail("Timeout while waiting for latch");
|
||||
}
|
||||
assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();
|
||||
Thread thread = threadReference.get();
|
||||
assertThat(thread).extracting("virtual").as("%s is virtual", thread).isEqualTo(true);
|
||||
return thread.getName();
|
||||
|
@ -50,8 +50,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class SpringBootMockMvcBuilderCustomizerTests {
|
||||
|
||||
private SpringBootMockMvcBuilderCustomizer customizer;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void customizeShouldAddFilters() {
|
||||
@ -61,8 +59,8 @@ class SpringBootMockMvcBuilderCustomizerTests {
|
||||
context.register(ServletConfiguration.class, FilterConfiguration.class);
|
||||
context.refresh();
|
||||
DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(context);
|
||||
this.customizer = new SpringBootMockMvcBuilderCustomizer(context);
|
||||
this.customizer.customize(builder);
|
||||
SpringBootMockMvcBuilderCustomizer customizer = new SpringBootMockMvcBuilderCustomizer(context);
|
||||
customizer.customize(builder);
|
||||
FilterRegistrationBean<?> registrationBean = (FilterRegistrationBean<?>) context
|
||||
.getBean("filterRegistrationBean");
|
||||
Filter testFilter = (Filter) context.getBean("testFilter");
|
||||
@ -94,7 +92,7 @@ class SpringBootMockMvcBuilderCustomizerTests {
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
latch.await(60, TimeUnit.SECONDS);
|
||||
assertThat(latch.await(60, TimeUnit.SECONDS)).isTrue();
|
||||
|
||||
assertThat(delegate.allWritten).hasSize(10000);
|
||||
assertThat(delegate.allWritten)
|
||||
|
Loading…
Reference in New Issue
Block a user