@Test public void testTextToURLEncodedConversion() throws UnsupportedEncodingException { String source = "They're either a benefit or a hazard. If they're a benefit, it's not my problem."; String result = StandardConversions.convertTextToUrlEncoded(source, TEXT_PLAIN.withCharset(UTF_16)); assertEquals(URLEncoder.encode(source, "UTF-16"), result); }
private Object convertToUrlEncoded(Object content, MediaType contentType) { if (contentType.match(APPLICATION_OCTET_STREAM)) { return StandardConversions.convertOctetStreamToUrlEncoded(content, contentType); } if (contentType.match(APPLICATION_OBJECT)) { return StandardConversions.convertUrlEncodedToObject(content); } if (contentType.match(TEXT_PLAIN)) { return StandardConversions.convertTextToUrlEncoded(content, contentType); } if (contentType.match(APPLICATION_WWW_FORM_URLENCODED)) { return content; } throw log.unsupportedContent(content); }