Package akka.http.javadsl.testkit
Class WSProbe
java.lang.Object
akka.http.javadsl.testkit.WSProbe
A WSProbe is a probe that implements a
Flow[Message, Message, Unit]
for testing
websocket code.
Requesting elements is handled automatically.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic WSProbe
create
(akka.actor.ActorSystem system, akka.stream.Materializer materializer) static WSProbe
create
(akka.actor.ActorSystem system, akka.stream.Materializer materializer, int maxChunks, long maxChunkCollectionMills) Creates a WSProbe to use in tests against websocket handlers.void
Expect completion on the input side of the flow.Expect a message on the input side of the flow.void
expectMessage
(akka.util.ByteString bytes) Expect a binary message on the input side of the flow and compares its payload with the given one.void
expectMessage
(String text) Expect a text message on the input side of the flow and compares its payload with the given one.void
Expect no message on the input side of the flow.void
expectNoMessage
(scala.concurrent.duration.FiniteDuration max) Expect no message on the input side of the flow for the given maximum duration.flow()
void
Complete the output side of the flow.void
sendMessage
(Message message) Send the given messages out of the flow.void
sendMessage
(akka.util.ByteString bytes) Send a binary message containing the given bytes out of the flow.void
sendMessage
(String text) Send a text message containing the given string out of the flow.
-
Constructor Details
-
WSProbe
-
-
Method Details
-
create
-
create
public static WSProbe create(akka.actor.ActorSystem system, akka.stream.Materializer materializer, int maxChunks, long maxChunkCollectionMills) Creates a WSProbe to use in tests against websocket handlers.- Parameters:
maxChunks
- The maximum number of chunks to collect for streamed messages.maxChunkCollectionMills
- The maximum time in milliseconds to collect chunks for streamed messages.system
- (undocumented)materializer
- (undocumented)- Returns:
- (undocumented)
-
flow
-
sendMessage
Send the given messages out of the flow.- Parameters:
message
- (undocumented)
-
sendMessage
Send a text message containing the given string out of the flow.- Parameters:
text
- (undocumented)
-
sendMessage
public void sendMessage(akka.util.ByteString bytes) Send a binary message containing the given bytes out of the flow.- Parameters:
bytes
- (undocumented)
-
sendCompletion
public void sendCompletion()Complete the output side of the flow. -
expectMessage
Expect a message on the input side of the flow.- Returns:
- (undocumented)
-
expectMessage
Expect a text message on the input side of the flow and compares its payload with the given one. If the received message is streamed its contents are collected and then asserted against the given String.- Parameters:
text
- (undocumented)
-
expectMessage
public void expectMessage(akka.util.ByteString bytes) Expect a binary message on the input side of the flow and compares its payload with the given one. If the received message is streamed its contents are collected and then asserted against the given ByteString.- Parameters:
bytes
- (undocumented)
-
expectNoMessage
public void expectNoMessage()Expect no message on the input side of the flow. -
expectNoMessage
public void expectNoMessage(scala.concurrent.duration.FiniteDuration max) Expect no message on the input side of the flow for the given maximum duration.- Parameters:
max
- (undocumented)
-
expectCompletion
public void expectCompletion()Expect completion on the input side of the flow.
-