public void waitForTablePopulation(String query, JdbcTemplate jdbcTemplate, int size) {
		boolean ready = false;
		long timeout = System.currentTimeMillis() + WAIT_TIME;
		while (!ready && System.currentTimeMillis() < timeout) {
			try {
				Thread.sleep(1000);
			}
			catch (InterruptedException e) {
				Thread.currentThread().interrupt();
				throw new IllegalStateException(e.getMessage(), e);
			}
			try {
				List<String> results = jdbcTemplate.queryForList(query, String.class);
				if (results.size() == size) {
					ready = true;
				}
			}
			catch (DataAccessException dae) {
				ready = false;
			}
		}
	}
Wait for the number of rows returned from the query  == size param or until WAIT_TIME is reached.
@param query the test query to execute
@param jdbcTemplate The jdbc template that has connectivity to the DB
@param size The number of rows to reach before exiting the method.
spring-xd-integration-test/src/test/java/org/springframework/xd/integration/test/AbstractIntegrationTest.java