Created
November 5, 2014 10:24
-
-
Save Marthym/688e060560e6ae7454cf to your computer and use it in GitHub Desktop.
Wait until database is correctly started
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Using a mysql inside docker for executing test, I need to wait for MySQL is completly started before running test */ | |
Awaitility.await().atMost(5, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(new Callable<Boolean>() { | |
@Override | |
public Boolean call() throws Exception { | |
try (Connection conn = ds.getConnection()) { | |
return true; | |
} catch (Exception e) { | |
System.out.println(e.getClass() + ": " + e.getLocalizedMessage()); | |
return false; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment