private void runTestAndExpect(String expected) {
		SingleNodeApplication application = new TestApplicationBootstrap().getSingleNodeApplication().run(
				"--transport", "local");

		// Set activate profiles AFTER the container has started, so we don't
		// interfere with container profiles themselves
		if (activeProfiles != null) {
			System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, activeProfiles);
		}
		SingleNodeIntegrationTestSupport integrationSupport = new SingleNodeIntegrationTestSupport(application);

		String streamDefinition = String.format("queue:producer > %s > queue:consumer", dslDefinition);
		String streamName = "test";

		StreamDefinition testStream = new StreamDefinition(streamName, streamDefinition);
		integrationSupport.createAndDeployStream(testStream);

		MessageBus messageBus = integrationSupport.messageBus();

		NamedChannelSource source = new SingleNodeNamedChannelSourceFactory(messageBus).createNamedChannelSource("queue:producer");
		NamedChannelSink sink = new SingleNodeNamedChannelSinkFactory(messageBus).createNamedChannelSink("queue:consumer");

		source.sendPayload("ping");
		String result = (String) sink.receivePayload(5000);
		assertEquals(expected, result);

		source.unbind();
		sink.unbind();

		assertTrue("stream " + testStream.getName() + "not undeployed",
				integrationSupport.undeployAndDestroyStream(testStream));
		application.close();
	}
Make sure to cleanup after ourselves as some of the stuff is per-JVM.
spring-xd-dirt/src/test/java/org/springframework/xd/dirt/stream/ModuleOptionsDefaultsOrderingTests.java