public HttpSource ensureReady(int timeout) {
		long giveUpAt = System.currentTimeMillis() + timeout;
		while (System.currentTimeMillis() < giveUpAt) {
			try {
				new RestTemplate().headForHeaders("http://" + host + ":" + port);
				return this;
			}
			catch (Exception e) {
				try {
					Thread.sleep(100);
				}
				catch (InterruptedException e1) {
					Thread.currentThread().interrupt();
					throw new IllegalStateException(e1);
				}
			}
		}
		throw new IllegalStateException(String.format(
				"Source [%s] does not seem to be listening after waiting for %dms", this, timeout));
	}
Attempts connections to the source until it is ready to accept data.
spring-xd-shell/src/test/java/org/springframework/xd/shell/command/fixtures/HttpSource.java