@Test
	public final void deployAndUndeploy() throws InterruptedException {

		assertEquals(0, integrationSupport.streamRepository().count());
		final int iterations = 5;
		int i;
		for (i = 0; i < iterations; i++) {
			String streamName = "test" + i;
			StreamDefinition definition = new StreamDefinition(streamName,
					"http --port=" + SocketUtils.findAvailableServerSocket()
							+ "| transform --expression=payload | filter --expression=true | log");
			integrationSupport.streamDeployer().save(definition);
			assertTrue(String.format("stream %s (%s) not deployed", streamName, definition),
					integrationSupport.deployStream(definition));
			assertEquals(1, integrationSupport.streamRepository().count());
			assertTrue(integrationSupport.streamRepository().exists("test" + i));
			assertEquals(DeploymentUnitStatus.State.deployed, integrationSupport.streamRepository()
					.getDeploymentStatus("test" + i).getState());
			assertTrue("stream not undeployed", integrationSupport.undeployStream(definition));
			assertEquals(0, integrationSupport.streamRepository().count());
			assertFalse(integrationSupport.streamRepository().exists("test" + i));
			assertEquals(DeploymentUnitStatus.State.undeployed, integrationSupport.streamRepository()
					.getDeploymentStatus("test" + i).getState());
			// Deploys in reverse order
			assertModuleRequest(streamName, "log", false);
			assertModuleRequest(streamName, "filter", false);
			assertModuleRequest(streamName, "transform", false);
			assertModuleRequest(streamName, "http", false);
			// Undeploys in stream order
			assertModuleRequest(streamName, "http", true);
			assertModuleRequest(streamName, "transform", true);
			assertModuleRequest(streamName, "filter", true);
			assertModuleRequest(streamName, "log", true);
		}
		assertEquals(iterations, i);
	}
Get the stream 'http | log' with random available http port selected.

@return the stream
spring-xd-dirt/src/test/java/org/springframework/xd/dirt/stream/AbstractSingleNodeStreamDeploymentIntegrationTests.java