@Test
	public void test() throws Exception {
		final List<Message<?>> messages = new ArrayList<Message<?>>();
		final CountDownLatch latch = new CountDownLatch(2);
		DirectChannel channel = new DirectChannel();
		channel.subscribe(new MessageHandler() {

			@Override
			public void handleMessage(Message<?> message) throws MessagingException {
				messages.add(message);
				latch.countDown();
			}
		});
		int port = SocketUtils.findAvailableServerSocket();
		NettyHttpInboundChannelAdapter adapter = new NettyHttpInboundChannelAdapter(port);
		adapter.setOutputChannel(channel);
		adapter.start();
		RestTemplate template = new RestTemplate();
		URI uri1 = new URI("http://localhost:" + port + "/test1");
		URI uri2 = new URI("http://localhost:" + port + "/test2");
		ResponseEntity<?> response1 = template.postForEntity(uri1, "foo", Object.class);
		ResponseEntity<?> response2 = template.postForEntity(uri2, "bar", Object.class);
		assertEquals(HttpStatus.OK, response1.getStatusCode());
		assertEquals(HttpStatus.OK, response2.getStatusCode());
		assertTrue(latch.await(1, TimeUnit.SECONDS));
		assertEquals(2, messages.size());
		Message<?> message1 = messages.get(0);
		Message<?> message2 = messages.get(1);
		assertEquals("foo", message1.getPayload());
		assertEquals("bar", message2.getPayload());
		assertEquals("/test1", message1.getHeaders().get("requestPath"));
		assertEquals("/test2", message2.getHeaders().get("requestPath"));

		adapter.stop();
	}
@author Mark Fisher
@author David Turanski
@author Jennifer Hickey
@author Gary Russell
@author Peter Rietzler
extensions/spring-xd-extension-http/src/test/java/org/springframework/integration/x/http/NettyHttpInboundChannelAdapterTests.java