@Test
	public void doStopJobExecution() throws Exception {
		String jobName = generateJobName();
		executeJobCreate(jobName, JOB_WITH_STEP_EXECUTIONS);
		checkForJobInList(jobName, JOB_WITH_STEP_EXECUTIONS, true);
		triggerJobWithDelay(jobName, "5");
		Thread.sleep(5000);
		String executionId = getJobExecutionId(jobName);
		String executionStatus = getJobExecutionStatus(jobName);
		long timeout = System.currentTimeMillis() + 20000;
		while ((executionStatus.equals("STARTING") || executionStatus.equals("STARTED"))
				&& System.currentTimeMillis() < timeout) {
			executionStatus = getJobExecutionStatus(jobName);
			executionId = getJobExecutionId(jobName);
		}
		// Stop the execution by the given executionId.
		executeCommand("job execution stop " + executionId);
		// sleep for stop() until the step2 is invoked.
		Thread.sleep(3000);
		Table table;
		int n = 0;
		do {
			table = (Table) executeCommand("job execution list").getResult();
			for (TableRow tr : table.getRows()) {
				// Match by above executionId
				if (tr.getValue(1).equals(executionId)) {
					executionStatus = tr.getValue(5);
					break;
				}
			}
			if (!"STOPPED".equals(executionStatus)) {
				Thread.sleep(100);
			}
		}
		while (!"STOPPED".equals(executionStatus) && n++ < 100);
		assertEquals("STOPPED", executionStatus);
	}
Test {@link JobCommands}.

@author Glenn Renfro
@author Gunnar Hillert
@author Ilayaperumal Gopinathan
@author Michael Minella
@since 1.0
spring-xd-shell/src/test/java/org/springframework/xd/shell/command/AbstractJobCommandsTests.java