java.lang.Object
io.jooby.test.MockWebSocket
- All Implemented Interfaces:
io.jooby.WebSocket
Mock implementation of
WebSocket
for unit testing purpose.
App:
ws("/path", (ctx, initializer) -> {
initializer.onConnect(ws -> {
ws.send("OnConnect");
});
});
Test:
MockRouter router = new MockRouter(new App());
router.ws("/path", ws -> {
ws.onMessage(message -> {
System.out.println("Got: " + message);
});
ws.send("Another message");
})
- Since:
- 2.2.0
- Author:
- edgar
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jooby.WebSocket
io.jooby.WebSocket.Initializer, io.jooby.WebSocket.OnClose, io.jooby.WebSocket.OnConnect, io.jooby.WebSocket.OnError, io.jooby.WebSocket.OnMessage
-
Field Summary
Fields inherited from interface io.jooby.WebSocket
MAX_BUFFER_SIZE
-
Method Summary
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jooby.WebSocket
attribute, attribute, close, getAttributes, render, send, send
-
Method Details
-
getContext
@NonNull public io.jooby.Context getContext()- Specified by:
getContext
in interfaceio.jooby.WebSocket
-
getSessions
- Specified by:
getSessions
in interfaceio.jooby.WebSocket
-
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfaceio.jooby.WebSocket
-
send
- Specified by:
send
in interfaceio.jooby.WebSocket
-
send
@NonNull public io.jooby.WebSocket send(@NonNull byte[] message, boolean broadcast) - Specified by:
send
in interfaceio.jooby.WebSocket
-
render
- Specified by:
render
in interfaceio.jooby.WebSocket
-
close
@NonNull public io.jooby.WebSocket close(@NonNull io.jooby.WebSocketCloseStatus closeStatus) - Specified by:
close
in interfaceio.jooby.WebSocket
-