Class MockListener
java.lang.Object
kong.unirest.core.MockListener
- All Implemented Interfaces:
WebSocket.Listener
A Mock WebSocket.Lister that records messages and has custom asserts.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate intprivate List<MockListener.Message> private booleanprivate ByteBufferprivate ByteBuffer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassertIsClosed(int status, String message) voidvoidassertPing(ByteBuffer message) assert that a ping message was received.voidassertPong(ByteBuffer message) assert that a pong message was received.voidassertReceivedMessage(Object message, boolean last) onBinary(WebSocket webSocket, ByteBuffer data, boolean last) voidvoidonPing(WebSocket webSocket, ByteBuffer message) onPong(WebSocket webSocket, ByteBuffer message) onText(WebSocket webSocket, CharSequence data, boolean last)
-
Field Details
-
messagesReceived
-
ping
-
pong
-
open
private boolean open -
closedStatus
private int closedStatus -
closedMessage
-
-
Constructor Details
-
MockListener
public MockListener()
-
-
Method Details
-
onOpen
- Specified by:
onOpenin interfaceWebSocket.Listener
-
onText
- Specified by:
onTextin interfaceWebSocket.Listener
-
onBinary
- Specified by:
onBinaryin interfaceWebSocket.Listener
-
onPing
- Specified by:
onPingin interfaceWebSocket.Listener
-
onPong
- Specified by:
onPongin interfaceWebSocket.Listener
-
onClose
- Specified by:
onClosein interfaceWebSocket.Listener
-
onError
- Specified by:
onErrorin interfaceWebSocket.Listener
-
assertReceivedMessage
-
assertIsClosed
-
assertPing
assert that a ping message was received. Note that the onPing method will automatically send a pong to the WebSocket- Parameters:
message- the message
-
assertPong
assert that a pong message was received. Note that the onPing method will automatically send a pong to the WebSocket- Parameters:
message- the message
-
assertIsOpen
public void assertIsOpen()
-