package org.sonar.process;
import java.util.concurrent.TimeUnit;
+import org.awaitility.core.ConditionTimeoutException;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
import static org.awaitility.Awaitility.await;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
verify(monitored, timeout(3_000)).hardStop();
stopper.stopIt();
- await().atMost(3, TimeUnit.SECONDS).until(() -> !stopper.isAlive());
- assertThat(stopper.isAlive()).isFalse();
+
+ int timeout = 10;
+ try {
+ await()
+ .atMost(timeout, TimeUnit.SECONDS)
+ .until(() -> !stopper.isAlive());
+ } catch (ConditionTimeoutException conditionTimeoutException) {
+ fail(String.format("Thread was still alive after %d seconds.", timeout));
+ }
+
}
}