@Test
public void jsonEncodingTestXhrServerDecodes() throws Exception {
final SockJsServiceFactory echoFactory = echoService();
final String sessionUrl = echoFactory.config().prefix() + "/abc/" + UUID.randomUUID().toString();
final FullHttpResponse response = xhrRequest(sessionUrl, echoFactory);
assertThat(response.getStatus(), is(HttpResponseStatus.OK));
assertThat(response.content().toString(UTF_8), equalTo("o\n"));
final String content = "[\"" + clientKillerStringEsc() + "\"]";
final FullHttpResponse xhrSendResponse = xhrSendRequest(sessionUrl, content, echoFactory);
assertThat(xhrSendResponse.getStatus(), is(HttpResponseStatus.NO_CONTENT));
final FullHttpResponse pollResponse = xhrRequest(sessionUrl, echoFactory);
assertThat(pollResponse.getStatus(), is(HttpResponseStatus.OK));
// Let the content go through the MessageFrame to match what the response will go through.
final MessageFrame messageFrame = new MessageFrame(JsonUtil.decode(content)[0]);
String expectedContent = JsonUtil.encode(messageFrame.content().toString(UTF_8) + '\n');
String responseContent = JsonUtil.encode(pollResponse.content().toString(UTF_8));
assertThat(responseContent, equalTo(expectedContent));
}