Use Awaitility in our own tests

Closes gh-18227
This commit is contained in:
Andy Wilkinson
2019-09-12 15:50:53 +01:00
parent 568caa1206
commit 1b237de5f5
28 changed files with 403 additions and 348 deletions

View File

@@ -18,8 +18,10 @@ package org.springframework.boot.actuate.management;
import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest;
@@ -31,7 +33,7 @@ import org.springframework.http.MediaType;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.util.FileCopyUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
/**
* Integration tests for {@link HeapDumpWebEndpoint} exposed by Jersey, Spring MVC, and
@@ -64,11 +66,7 @@ class HeapDumpWebEndpointWebIntegrationTests {
}
private void assertHeapDumpFileIsDeleted() throws InterruptedException {
long end = System.currentTimeMillis() + 5000;
while (System.currentTimeMillis() < end && this.endpoint.file.exists()) {
Thread.sleep(100);
}
assertThat(this.endpoint.file.exists()).isFalse();
Awaitility.waitAtMost(Duration.ofSeconds(5)).until(this.endpoint.file::exists, is(false));
}
@Configuration(proxyBeanMethods = false)