@Test
	public void testJavaSerialization() {
		Foo foo = new Foo();
		CompositeMessageConverter converter = converterFactory.newInstance(MimeType.valueOf("application/x-java-serialized-object"));
		Message<Foo> msg = MessageBuilder.withPayload(foo).copyHeaders(
				Collections.singletonMap(MessageHeaders.CONTENT_TYPE, MimeType.valueOf("application/x-java-object"))).build();
		Message<?> result = (Message<?>) converter.fromMessage(msg, byte[].class);
		assertTrue(result.getPayload() instanceof byte[]);
		assertEquals(MimeType.valueOf("application/x-java-serialized-object"),
				result.getHeaders().get(MessageHeaders.CONTENT_TYPE));

		// Now convert back
		converter = converterFactory.newInstance(MimeType.valueOf("application/x-java-object"));
		result = (Message<?>) converter.fromMessage(result, Foo.class);
		assertNotNull(result);
		assertTrue(result.getPayload() instanceof Foo);
		assertEquals(MimeType.valueOf("application/x-java-object;type=" + Foo.class.getName()),
				result.getHeaders().get(MessageHeaders.CONTENT_TYPE));
	}
Tests for converting from a Message.

@author David Turanski
spring-xd-dirt/src/test/java/org/springframework/xd/dirt/integration/bus/converter/FromMessageConverterTests.java