private void waitForJobCompletion(String jobName) {
		// could match on parameters if necessary (for disambiguation of concurrent executions)
		PollableChannel channel = jobTapChannels.get(jobName);
		Message<?> message = null;
		do {
			message = channel.receive(10000);
			if (message != null) {
				Object payload = message.getPayload();
				if (payload instanceof JobExecution) {
					// could add a waitForJobLaunch that returns as soon as it sees STARTED status
					if (BatchStatus.COMPLETED.equals(((JobExecution) payload).getStatus())) {
						return;
					}
				}
			}
		}
		while (message != null);
		throw new IllegalStateException(String.format("timed out while waiting for job: %s", jobName));
	}
Launch a job that is already deployed
spring-xd-shell/src/test/java/org/springframework/xd/shell/command/AbstractJobIntegrationTest.java