Search in sources :

Example 1 with SockJsFrameFormat

use of org.springframework.web.socket.sockjs.frame.SockJsFrameFormat in project spring-framework by spring-projects.

the class HttpSendingTransportHandlerTests method frameFormats.

@Test
public void frameFormats() throws Exception {
    this.servletRequest.setQueryString("c=callback");
    this.servletRequest.addParameter("c", "callback");
    SockJsFrame frame = SockJsFrame.openFrame();
    SockJsFrameFormat format = new XhrPollingTransportHandler().getFrameFormat(this.request);
    String formatted = format.format(frame);
    assertEquals(frame.getContent() + "\n", formatted);
    format = new XhrStreamingTransportHandler().getFrameFormat(this.request);
    formatted = format.format(frame);
    assertEquals(frame.getContent() + "\n", formatted);
    format = new HtmlFileTransportHandler().getFrameFormat(this.request);
    formatted = format.format(frame);
    assertEquals("<script>\np(\"" + frame.getContent() + "\");\n</script>\r\n", formatted);
    format = new EventSourceTransportHandler().getFrameFormat(this.request);
    formatted = format.format(frame);
    assertEquals("data: " + frame.getContent() + "\r\n\r\n", formatted);
    format = new JsonpPollingTransportHandler().getFrameFormat(this.request);
    formatted = format.format(frame);
    assertEquals("/**/callback(\"" + frame.getContent() + "\");\r\n", formatted);
}
Also used : SockJsFrameFormat(org.springframework.web.socket.sockjs.frame.SockJsFrameFormat) SockJsFrame(org.springframework.web.socket.sockjs.frame.SockJsFrame) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 SockJsFrame (org.springframework.web.socket.sockjs.frame.SockJsFrame)1 SockJsFrameFormat (org.springframework.web.socket.sockjs.frame.SockJsFrameFormat)1