Search in sources :

Example 1 with PartialTrackingSocket

use of org.eclipse.jetty.websocket.jsr356.server.samples.partial.PartialTrackingSocket in project jetty.project by eclipse.

the class OnPartialTest method testOnTextPartial.

@Test
public void testOnTextPartial() throws Throwable {
    List<WebSocketFrame> frames = new ArrayList<>();
    frames.add(new TextFrame().setPayload("Saved").setFin(false));
    frames.add(new ContinuationFrame().setPayload(" by ").setFin(false));
    frames.add(new ContinuationFrame().setPayload("zero").setFin(true));
    PartialTrackingSocket socket = new PartialTrackingSocket();
    EventDriver driver = toEventDriver(socket);
    driver.onConnect();
    for (WebSocketFrame frame : frames) {
        driver.incomingFrame(frame);
    }
    Assert.assertThat("Captured Event Queue size", socket.eventQueue.size(), is(3));
    Assert.assertThat("Event[0]", socket.eventQueue.poll(), is("onPartial(\"Saved\",false)"));
    Assert.assertThat("Event[1]", socket.eventQueue.poll(), is("onPartial(\" by \",false)"));
    Assert.assertThat("Event[2]", socket.eventQueue.poll(), is("onPartial(\"zero\",true)"));
}
Also used : EventDriver(org.eclipse.jetty.websocket.common.events.EventDriver) PartialTrackingSocket(org.eclipse.jetty.websocket.jsr356.server.samples.partial.PartialTrackingSocket) ArrayList(java.util.ArrayList) TextFrame(org.eclipse.jetty.websocket.common.frames.TextFrame) WebSocketFrame(org.eclipse.jetty.websocket.common.WebSocketFrame) ContinuationFrame(org.eclipse.jetty.websocket.common.frames.ContinuationFrame) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 WebSocketFrame (org.eclipse.jetty.websocket.common.WebSocketFrame)1 EventDriver (org.eclipse.jetty.websocket.common.events.EventDriver)1 ContinuationFrame (org.eclipse.jetty.websocket.common.frames.ContinuationFrame)1 TextFrame (org.eclipse.jetty.websocket.common.frames.TextFrame)1 PartialTrackingSocket (org.eclipse.jetty.websocket.jsr356.server.samples.partial.PartialTrackingSocket)1 Test (org.junit.Test)1