### Question:
WebSocketEndpoint { @OnError public void onError(Session session, @PathParam("username") String username, Throwable throwable) { sessions.remove(username); broadcaster.removeSession(session); broadcaster.broadcast("#User: " + username + " left on error: " + throwable); LOGGER.info("Some error happens, " + username + " is offline!", throwable); }  @OnOpen void onOpen(Session session, @PathParam("username") String username); @OnClose void onClose(Session session, @PathParam("username") String username); @OnError void onError(Session session, @PathParam("username") String username, Throwable throwable); @OnMessage void onMessage(String message, @PathParam("username") String username);  }### Answer:
@Test void onError() { webSocketEndpoint.onError(session, "user3", new RuntimeException("Error!")); Mockito.verify(broadcaster).removeSession(session); Mockito.verify(broadcaster).broadcast("#User: user3 left on error: java.lang.RuntimeException: Error!"); }