Class WSProbe

java.lang.Object
akka.http.javadsl.testkit.WSProbe

public class WSProbe extends Object
A WSProbe is a probe that implements a Flow[Message, Message, Unit] for testing websocket code.

Requesting elements is handled automatically.

  • Constructor Summary

    Constructors
    Constructor
    Description
    WSProbe(WSProbe delegate)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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
    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.
    akka.stream.javadsl.Flow<Message,Message,akka.NotUsed>
     
    void
    Complete the output side of the flow.
    void
    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
    Send a text message containing the given string out of the flow.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WSProbe

      public WSProbe(WSProbe delegate)
  • Method Details

    • create

      public static WSProbe create(akka.actor.ActorSystem system, akka.stream.Materializer materializer)
    • 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

      public akka.stream.javadsl.Flow<Message,Message,akka.NotUsed> flow()
    • sendMessage

      public void sendMessage(Message message)
      Send the given messages out of the flow.
      Parameters:
      message - (undocumented)
    • sendMessage

      public void sendMessage(String text)
      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

      public Message expectMessage()
      Expect a message on the input side of the flow.
      Returns:
      (undocumented)
    • expectMessage

      public void expectMessage(String text)
      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.