### Question:
JettyWebSocketHandler extends EngineIoWebSocket implements WebSocketListener { @Override public void onWebSocketClose(int statusCode, String reason) { emit("close"); mSession = null; } @SuppressWarnings("WeakerAccess")  JettyWebSocketHandler(EngineIoServer server); @Override Map<String, String> getQuery(); @Override void write(String message); @Override void write(byte[] message); @Override void close(); @Override void onWebSocketConnect(Session session); @Override void onWebSocketClose(int statusCode, String reason); @Override void onWebSocketError(Throwable cause); @Override void onWebSocketBinary(byte[] payload, int offset, int len); @Override void onWebSocketText(String message);  }### Answer:
@Test public void testOnClose() { final EngineIoServer server = new EngineIoServer(); final JettyWebSocketHandler handler = Mockito.spy(new JettyWebSocketHandler(server)); handler.onWebSocketClose(0, "test"); Mockito.verify(handler, Mockito.times(1)) .emit(Mockito.eq("close")); }