Class WSProbe


  • public class WSProbe
    extends java.lang.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

      All Methods Static Methods Instance Methods Concrete Methods 
      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 expectCompletion()
      Expect completion on the input side of the flow.
      Message expectMessage()
      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​(java.lang.String text)
      Expect a text message on the input side of the flow and compares its payload with the given one.
      void expectNoMessage()
      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> flow()  
      void sendCompletion()
      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​(java.lang.String text)
      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 Detail

      • WSProbe

        public WSProbe​(WSProbe delegate)
    • Method Detail

      • 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​(java.lang.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​(java.lang.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.