Append "data:" after line breaks for SSE JSON data fields

Issue: SPR-14899
This commit is contained in:
Sebastien Deleuze
2016-11-30 19:44:38 +01:00
parent e707c40e0b
commit 5700d65a53
2 changed files with 37 additions and 5 deletions

View File

@@ -225,6 +225,20 @@ public class MappingJackson2HttpMessageConverterTests {
assertEquals("{" + NEWLINE_SYSTEM_PROPERTY + " \"name\" : \"Jason\"" + NEWLINE_SYSTEM_PROPERTY + "}", result);
}
@Test
public void prettyPrintWithSse() throws Exception {
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
outputMessage.getHeaders().setContentType(new MediaType("text", "event-stream"));
PrettyPrintBean bean = new PrettyPrintBean();
bean.setName("Jason");
this.converter.setPrettyPrint(true);
this.converter.writeInternal(bean, null, outputMessage);
String result = outputMessage.getBodyAsString(Charset.forName("UTF-8"));
assertEquals("{\ndata: \"name\" : \"Jason\"\ndata:}", result);
}
@Test
public void prefixJson() throws Exception {
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();