File tree Expand file tree Collapse file tree 3 files changed +47
-4
lines changed
tests/src/test/java/io/jooby/i3479 Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ public class ServerSentMessage {
2828
2929 private static final byte [] RETRY = "retry:" .getBytes (UTF_8 );
3030
31- private static final byte [] DATA = "data:" .getBytes (UTF_8 );
31+ private static final byte [] DATA = "data: " .getBytes (UTF_8 );
3232
3333 private Object id ;
3434
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public void shouldFormatMessage() throws Exception {
3434 when (ctx .getRoute ()).thenReturn (route );
3535
3636 ServerSentMessage message = new ServerSentMessage (data );
37- assertEquals ("data:" + data + "\n \n " , message .encode (ctx ).toString (StandardCharsets .UTF_8 ));
37+ assertEquals ("data: " + data + "\n \n " , message .encode (ctx ).toString (StandardCharsets .UTF_8 ));
3838 }
3939
4040 @ Test
@@ -55,7 +55,7 @@ public void shouldFormatMultiLineMessage() throws Exception {
5555
5656 ServerSentMessage message = new ServerSentMessage (data );
5757 assertEquals (
58- "data:line 1\n data: line ,a .. 2\n data:line ...abc 3\n \n " ,
58+ "data: line 1\n data: line ,a .. 2\n data: line ...abc 3\n \n " ,
5959 message .encode (ctx ).toString (StandardCharsets .UTF_8 ));
6060 }
6161
@@ -76,6 +76,6 @@ public void shouldFormatMessageEndingWithNL() throws Exception {
7676 when (ctx .getRoute ()).thenReturn (route );
7777
7878 ServerSentMessage message = new ServerSentMessage (data );
79- assertEquals ("data:" + data + "\n \n " , message .encode (ctx ).toString (StandardCharsets .UTF_8 ));
79+ assertEquals ("data: " + data + "\n \n " , message .encode (ctx ).toString (StandardCharsets .UTF_8 ));
8080 }
8181}
Original file line number Diff line number Diff line change 1+ /*
2+ * Jooby https://jooby.io
3+ * Apache License Version 2.0 https://jooby.io/LICENSE.txt
4+ * Copyright 2014 Edgar Espina
5+ */
6+ package io .jooby .i3479 ;
7+
8+ import static org .junit .jupiter .api .Assertions .assertEquals ;
9+
10+ import io .jooby .jackson .JacksonModule ;
11+ import io .jooby .junit .ServerTest ;
12+ import io .jooby .junit .ServerTestRunner ;
13+
14+ public class Issue3479 {
15+ @ ServerTest
16+ public void shouldRespectLeadingWhiteSpace (ServerTestRunner runner ) {
17+ var data =
18+ "This is my event.\n "
19+ + " This second line starts with a leading space.\n "
20+ + "But not this third one." ;
21+ runner
22+ .define (
23+ app -> {
24+ app .install (new JacksonModule ());
25+
26+ app .sse (
27+ "/3479" ,
28+ sse -> {
29+ sse .send (data );
30+ });
31+ })
32+ .ready (
33+ client -> {
34+ client
35+ .sse ("/3479" )
36+ .next (
37+ message -> {
38+ assertEquals (data , message .getData ());
39+ })
40+ .verify ();
41+ });
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments