@Test
	public void testNewContainerDeployment() throws Exception {
		String streamName = testName.getMethodName() + "-upper-case";

		SpringXDTemplate template = ensureTemplate();
		int httpPort = SocketUtils.findAvailableServerSocket();
		template.streamOperations().createStream(streamName,
				String.format("http --port=%d | transform --expression='payload.toUpperCase()' | log", httpPort),
				false);
		verifyStreamCreated(streamName);

		template.streamOperations().deploy(streamName, Collections.<String, String> emptyMap());
		verifyStreamState(streamName, DeploymentUnitStatus.State.failed);

		for (int i = 0; i < 3; i++) {
			startContainer();
		}

		Map<Long, String> mapPidUuid = waitForContainers();

		verifyStreamDeployed(streamName);
		ModuleRuntimeContainers moduleContainers = retrieveModuleRuntimeContainers(streamName);

		assertEquals("Expected one source container",
				1, moduleContainers.getSourceContainers().size());
		assertEquals("Expected one processor container",
				1, moduleContainers.getProcessorContainers().keySet().size());
		assertEquals("Expected one sink container",
				1, moduleContainers.getSinkContainers().size());

		Set<String> targetContainers = new HashSet<String>(mapPidUuid.values());
		targetContainers.removeAll(moduleContainers.getSourceContainers());
		targetContainers.removeAll(moduleContainers.getProcessorContainers().keySet());
		targetContainers.removeAll(moduleContainers.getSinkContainers());

		assertTrue(String.format("These containers did not receive any module deployments: %s", targetContainers),
				targetContainers.isEmpty());
	}
Assert correct deployment behavior when a stream is deployed
prior to the availability of any containers to deploy it. The
sequence is as follows:
<ul>
    <li>Deploy a 3 module stream</li>
    <li>Assert that the stream state is "failed"</li>
    <li>Start 3 containers</li>
    <li>Assert that each container deployed a module from the stream</li>
</ul>

@throws Exception
spring-xd-distributed-test/src/test/java/org/springframework/xd/distributed/test/ContainerRedeploymentTests.java