WSController implements IWSController { @Override public void onError(Session session, Throwable t) { logger.error("Unknow error for session " + session.getId()+" : "+t.getMessage()); if (!session.isOpen()) { userContextFactory.destroyUserContext(session.getId()); topicManager.removeSessionToTopics(session); } }  @Override void handleOpenConnexion(Session session, EndpointConfig config); @Override void onError(Session session, Throwable t); @Override void handleClosedConnexion(Session session, CloseReason closeReason); @Override void receiveCommandMessage(Session client, String json);  }
@Test public void testOnError() { System.out.println("onError"); Session session = mock(Session.class); when(session.getId()).thenReturn(UUID.randomUUID().toString()); Throwable t = new Exception(); instance.onError(session, t); }