@Test
public void testOnMessage() {

    // open the compute connection
    Session computeSession = mock(Session.class);
    URI computeURI = URI.create("http://fake" + RT_COMPUTE_ENDPOINT);
    when(computeSession.getRequestURI()).thenReturn(computeURI);
    underTest.onOpen(computeSession);
    assertEquals(0, underTest.getSessions().size());
    verify(computeSession).getRequestURI();
    verify(computeSession).setMaxIdleTimeout(0);
    verifyNoMoreInteractions(computeSession);
    assertTrue(underTest.isConnectedToCompute());
    // add two sessions, one closed and one open
    Async asyncRemote = mock(Async.class);
    // open first client session
    Session firstClientSession = mock(Session.class);
    URI resourceURI = URI.create("http://fake" + RT_EVENT_ENDPOINT);
    when(firstClientSession.getRequestURI()).thenReturn(resourceURI);
    when(firstClientSession.isOpen()).thenReturn(true);
    when(firstClientSession.getAsyncRemote()).thenReturn(asyncRemote);
    underTest.onOpen(firstClientSession);
    verify(firstClientSession).getRequestURI();
    verify(firstClientSession).getId();
    verify(firstClientSession).setMaxIdleTimeout(0);
    verifyNoMoreInteractions(firstClientSession);
    assertEquals(1, underTest.getSessions().size());
    // open second client session
    Session secondClientSession = mock(Session.class);
    when(secondClientSession.getRequestURI()).thenReturn(resourceURI);
    when(secondClientSession.isOpen()).thenReturn(true);
    when(secondClientSession.getAsyncRemote()).thenReturn(asyncRemote);
    underTest.onOpen(secondClientSession);
    verify(secondClientSession).getRequestURI();
    verify(secondClientSession).getId();
    verify(secondClientSession).setMaxIdleTimeout(0);
    verifyNoMoreInteractions(secondClientSession);
    assertEquals(2, underTest.getSessions().size());
    // close the first session
    when(firstClientSession.isOpen()).thenReturn(false);
    ChatAlyticsEvent event = mock(ChatAlyticsEvent.class);
    underTest.onMessage(event);
    verify(event).setClazz(null);
    verify(firstClientSession, never()).getAsyncRemote();
    verify(secondClientSession).getAsyncRemote();
    verify(asyncRemote).sendObject(event);
    assertEquals(1, underTest.getSessions().size());
}