MailMessageConverter implements MessageConverter<MimeMailMessage, MimeMailMessage, MailEndpointConfiguration> { static String parseCharsetFromContentType(String contentType) { final String charsetPrefix = "charset="; if (org.apache.commons.lang.StringUtils.contains(contentType, charsetPrefix)) { String charsetName = org.apache.commons.lang.StringUtils.substringAfter(contentType, charsetPrefix); return org.apache.commons.lang.StringUtils.substringBefore(charsetName, ";"); } else { return CitrusSettings.CITRUS_FILE_ENCODING; } }  @Override MimeMailMessage convertOutbound(Message message, MailEndpointConfiguration endpointConfiguration, TestContext context); @Override void convertOutbound(MimeMailMessage mimeMailMessage, Message message, MailEndpointConfiguration endpointConfiguration, TestContext context); @Override MailMessage convertInbound(MimeMailMessage message, MailEndpointConfiguration endpointConfiguration, TestContext context);  }
@Test public void testParseCharsetFromContentType() throws Exception { assertEquals(parseCharsetFromContentType("text/plain; charset=UTF-8"), StandardCharsets.UTF_8.name()); assertEquals(parseCharsetFromContentType("text/plain;charset=UTF-8"), StandardCharsets.UTF_8.name()); assertEquals(parseCharsetFromContentType("text*; charset=ISO-8859-1"), StandardCharsets.ISO_8859_1.name()); assertEquals(parseCharsetFromContentType("text/plain"), CitrusSettings.CITRUS_FILE_ENCODING); assertEquals(parseCharsetFromContentType("text/plain ; "), CitrusSettings.CITRUS_FILE_ENCODING); }