}
@Test
public void testByteArrayToStringWithCharset() throws UnsupportedEncodingException {
String text = "Hello \u3044\u3002";
CompositeMessageConverter converter = converterFactory.newInstance(MimeType.valueOf("application/x-xd-string"));
Message<?> msg = MessageBuilder.withPayload(text.getBytes("UTF-8")).copyHeaders(
Collections.singletonMap(MessageHeaders.CONTENT_TYPE, MimeType.valueOf("text/plain;Charset=UTF-8")))
.build();
Object result = converter.fromMessage(msg, String.class);
assertEquals(text, result);
msg = MessageBuilder.withPayload(text.getBytes("ISO-8859-1")).copyHeaders(
Collections.singletonMap(MessageHeaders.CONTENT_TYPE, MimeType.valueOf("text/plain;Charset=ISO-8859-1")))
.build();
result = converter.fromMessage(msg, String.class);
assertEquals("Hello ??", result);
}