mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Fix race condition in SampleQuartzApplicationTests
This commit is contained in:
parent
87182a3a2b
commit
6fb629227c
@ -36,11 +36,15 @@ public class SampleQuartzApplicationTests {
|
||||
public OutputCapture outputCapture = new OutputCapture();
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
try (ConfigurableApplicationContext context = SpringApplication.run(
|
||||
SampleQuartzApplication.class)) {
|
||||
String output = this.outputCapture.toString();
|
||||
assertThat(output).contains("Hello World!");
|
||||
public void quartzJobIsTriggered() throws InterruptedException {
|
||||
try (ConfigurableApplicationContext context = SpringApplication
|
||||
.run(SampleQuartzApplication.class)) {
|
||||
long end = System.currentTimeMillis() + 5000;
|
||||
while ((!this.outputCapture.toString().contains("Hello World!"))
|
||||
&& System.currentTimeMillis() < end) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
assertThat(this.outputCapture.toString()).contains("Hello World!");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user