@Test public void decodeUtf16EncodedResponse() { HttpResponse httpResponse = new HttpResponse(); httpResponse.setStatus(200); httpResponse.setHeader(CONTENT_TYPE, JSON_UTF_8.withCharset(UTF_16).toString()); httpResponse.setContent("{\"status\":0,\"value\":\"水\"}".getBytes(UTF_16)); Response response = codec.decode(httpResponse); assertEquals("水", response.getValue()); }
@Test public void decodeRequestWithUtf16Encoding() { codec.defineCommand("num", POST, "/one"); byte[] data = "{\"char\":\"水\"}".getBytes(UTF_16); HttpRequest request = new HttpRequest(POST, "/one"); request.setHeader(CONTENT_TYPE, JSON_UTF_8.withCharset(UTF_16).toString()); request.setHeader(CONTENT_LENGTH, String.valueOf(data.length)); request.setContent(data); Command command = codec.decode(request); assertThat((String) command.getParameters().get("char"), is("水")); }