Class WebSocketTester


  • public class WebSocketTester
    extends java.lang.Object
    A helper class to test WebSocket related operations.
    Since:
    6.0
    • Constructor Summary

      Constructors 
      Constructor Description
      WebSocketTester​(org.apache.wicket.util.tester.WicketTester wicketTester, java.lang.String resourceName)
      Constructor.
      WebSocketTester​(org.apache.wicket.util.tester.WicketTester wicketTester, org.apache.wicket.Page page)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void broadcast​(org.apache.wicket.Application application, java.lang.String sessionId, IKey key, IWebSocketPushMessage message)
      Broadcasts/pushes a message to specific web socket connection
      void broadcastAll​(org.apache.wicket.Application application, IWebSocketPushMessage message)
      Broadcasts/pushes a message to all active web socket connections
      void destroy()  
      protected void onOutMessage​(byte[] message, int offset, int length)
      A callback method which may be overritten to receive messages pushed by the server
      protected void onOutMessage​(java.lang.String message)
      A callback method which may be overritten to receive messages pushed by the server
      void sendMessage​(byte[] message, int offset, int length)
      Sends a binary message from the client (a test case) to the server
      void sendMessage​(java.lang.String message)
      Sends a text message from the client (a test case) to the server
      • Methods inherited from class java.lang.Object

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

      • WebSocketTester

        public WebSocketTester​(org.apache.wicket.util.tester.WicketTester wicketTester,
                               org.apache.wicket.Page page)
        Constructor. Prepares a WebSocketConnection that will be used to send messages from the client (the test case) to the server.
        Parameters:
        page - the page that may have registered WebSocketBehavior
      • WebSocketTester

        public WebSocketTester​(org.apache.wicket.util.tester.WicketTester wicketTester,
                               java.lang.String resourceName)
        Constructor. Prepares a WebSockConnection that will be used to send messages from the client (the test case) to the server.
        Parameters:
        resourceName - the name of the shared WebSocketResource that will handle the web socket messages
    • Method Detail

      • sendMessage

        public void sendMessage​(java.lang.String message)
        Sends a text message from the client (a test case) to the server
        Parameters:
        message - the text message to send to the server
      • sendMessage

        public void sendMessage​(byte[] message,
                                int offset,
                                int length)
        Sends a binary message from the client (a test case) to the server
        Parameters:
        message - the binary message to send to the server
        offset - the offset of the binary message to start to read from
        length - the length of bytes to read from the binary message
      • broadcast

        public void broadcast​(org.apache.wicket.Application application,
                              java.lang.String sessionId,
                              IKey key,
                              IWebSocketPushMessage message)
        Broadcasts/pushes a message to specific web socket connection
        Parameters:
        application - The application where the web socket connection is registered
        sessionId - The id of the http session with which the web socket connection is registered
        key - The key with which the web socket connection is registered
        message - The message to broadcast/push
      • broadcastAll

        public void broadcastAll​(org.apache.wicket.Application application,
                                 IWebSocketPushMessage message)
        Broadcasts/pushes a message to all active web socket connections
        Parameters:
        application - The application where the web socket connection is registered
        message - The message to broadcast/push
      • destroy

        public void destroy()
      • onOutMessage

        protected void onOutMessage​(java.lang.String message)
        A callback method which may be overritten to receive messages pushed by the server
        Parameters:
        message - the pushed text message from the server
      • onOutMessage

        protected void onOutMessage​(byte[] message,
                                    int offset,
                                    int length)
        A callback method which may be overritten to receive messages pushed by the server
        Parameters:
        message - the pushed binary message from the server
        offset - the offset of the binary message to start to read from
        length - the length of bytes to read from the binary message