Java Reference
In-Depth Information
The test is run as described in this chapter's client mode and uses Tyrus: the WebSocket
client reference implementation under the hood. The perfect deployment for this test is
our whole application, so we are going to use MavenImporter [1] . In the test, we de-
clared a concurrent deque to gather a received messaged [2] and a latch [3] , which we
will use to wait in [7] . In order to handle WebSockets on the client side, we have to de-
clare a handler [4] , which specifies the behavior on receiving the message. Here, we just
add a message to our deque and perform a latch countdown. In [5] , we have to register
the handler so that it will be used for an open session. The REST call is executed using a
rest-assured library, which provides a fluent API to test REST APIs. Finally, in [8] , we
perform some basic assertions concerning the received messages.
The fully configured pom.xml file and a whole working project can be found under
ticket-agency-test-websockets .
Search WWH ::

Custom Search