Class MockWebSocket

  • All Implemented Interfaces:
    java.net.http.WebSocket

    public class MockWebSocket
    extends java.lang.Object
    implements java.net.http.WebSocket
    A Mock of a websocket that sends messages directly to a single listener on the other side
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.net.http.WebSocket

        java.net.http.WebSocket.Builder, java.net.http.WebSocket.Listener
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private SocketSet remoteSocketSet  
      • Fields inherited from interface java.net.http.WebSocket

        NORMAL_CLOSURE
    • Constructor Summary

      Constructors 
      Constructor Description
      MockWebSocket()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort()  
      java.lang.String getSubprotocol()  
      void init​(SocketSet otherSide)  
      boolean isInputClosed()  
      boolean isOutputClosed()  
      void request​(long n)  
      java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendBinary​(java.nio.ByteBuffer data, boolean last)  
      java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendClose​(int statusCode, java.lang.String reason)  
      java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendPing​(java.nio.ByteBuffer message)  
      java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendPong​(java.nio.ByteBuffer message)  
      java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendText​(java.lang.CharSequence data, boolean last)  
      private java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendToOtherSide​(java.util.function.BiConsumer<java.net.http.WebSocket,​java.net.http.WebSocket.Listener> consumer)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • remoteSocketSet

        private SocketSet remoteSocketSet
    • Constructor Detail

      • MockWebSocket

        public MockWebSocket()
    • Method Detail

      • sendToOtherSide

        private java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendToOtherSide​(java.util.function.BiConsumer<java.net.http.WebSocket,​java.net.http.WebSocket.Listener> consumer)
      • sendText

        public java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendText​(java.lang.CharSequence data,
                                                                                        boolean last)
        Specified by:
        sendText in interface java.net.http.WebSocket
      • sendBinary

        public java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendBinary​(java.nio.ByteBuffer data,
                                                                                          boolean last)
        Specified by:
        sendBinary in interface java.net.http.WebSocket
      • sendPing

        public java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendPing​(java.nio.ByteBuffer message)
        Specified by:
        sendPing in interface java.net.http.WebSocket
      • sendPong

        public java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendPong​(java.nio.ByteBuffer message)
        Specified by:
        sendPong in interface java.net.http.WebSocket
      • sendClose

        public java.util.concurrent.CompletableFuture<java.net.http.WebSocket> sendClose​(int statusCode,
                                                                                         java.lang.String reason)
        Specified by:
        sendClose in interface java.net.http.WebSocket
      • request

        public void request​(long n)
        Specified by:
        request in interface java.net.http.WebSocket
      • getSubprotocol

        public java.lang.String getSubprotocol()
        Specified by:
        getSubprotocol in interface java.net.http.WebSocket
      • isOutputClosed

        public boolean isOutputClosed()
        Specified by:
        isOutputClosed in interface java.net.http.WebSocket
      • isInputClosed

        public boolean isInputClosed()
        Specified by:
        isInputClosed in interface java.net.http.WebSocket
      • abort

        public void abort()
        Specified by:
        abort in interface java.net.http.WebSocket
      • init

        public void init​(SocketSet otherSide)