[bluetooth] Try to make tests more stable No.2 (#9309)
* [bluetooth] Try to make tests more stable No.2 Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
This commit is contained in:
parent
3bd17f4788
commit
941189ad55
|
@ -115,7 +115,7 @@ class RetryFutureTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void composeWithRetry1() throws InterruptedException {
|
void composeWithRetry1() {
|
||||||
AtomicInteger visitCount = new AtomicInteger();
|
AtomicInteger visitCount = new AtomicInteger();
|
||||||
CompletableFuture<String> composedFuture = new CompletableFuture<>();
|
CompletableFuture<String> composedFuture = new CompletableFuture<>();
|
||||||
Future<String> retryFuture = RetryFuture.composeWithRetry(() -> {
|
Future<String> retryFuture = RetryFuture.composeWithRetry(() -> {
|
||||||
|
@ -152,11 +152,12 @@ class RetryFutureTest {
|
||||||
if (!latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
|
if (!latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
|
||||||
fail("Timeout while waiting for latch");
|
fail("Timeout while waiting for latch");
|
||||||
}
|
}
|
||||||
Thread.sleep(1);
|
Future<Boolean> future = scheduler.submit(() -> {
|
||||||
retryFuture.cancel(false);
|
retryFuture.cancel(false);
|
||||||
|
return composedFuture.isCancelled();
|
||||||
assertTrue(composedFuture.isCancelled());
|
});
|
||||||
} catch (InterruptedException e) {
|
assertTrue(future.get(TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
||||||
|
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||||
fail(e);
|
fail(e);
|
||||||
}
|
}
|
||||||
assertEquals(2, visitCount.get());
|
assertEquals(2, visitCount.get());
|
||||||
|
|
Loading…
Reference in New Issue