@Test public void test_onError() { final EngineIoServer engineIoServer = new EngineIoServer(); final SocketIoServer server = Mockito.spy(new SocketIoServer(engineIoServer)); final SocketIoNamespace namespace = server.namespace("/"); final Emitter.Listener connectionListener = Mockito.mock(Emitter.Listener.class); Mockito.doAnswer(invocation -> { final Object[] args = invocation.getArguments(); final SocketIoSocket socket = (SocketIoSocket) args[0]; final Emitter.Listener errorListener = Mockito.mock(Emitter.Listener.class); socket.on("error", errorListener); Mockito.reset(errorListener); socket.onError("reason"); Mockito.verify(errorListener, Mockito.times(1)) .call(Mockito.eq("reason")); return null; }).when(connectionListener).call(Mockito.any()); namespace.on("connection", connectionListener); final EngineIoWebSocketImpl webSocket = new EngineIoWebSocketImpl(); engineIoServer.handleWebSocket(webSocket); Mockito.verify(connectionListener, Mockito.times(1)) .call(Mockito.any(SocketIoSocket.class)); }
void onError(String error) { if (listeners("error").size() > 0) { emit("error", error); } }
SocketIoSocket extends Emitter { void onError(String error) { if (listeners("error").size() > 0) { emit("error", error); } } }
SocketIoSocket extends Emitter { void onError(String error) { if (listeners("error").size() > 0) { emit("error", error); } } SocketIoSocket(SocketIoNamespaceImpl namespace, SocketIoClient client); }
SocketIoSocket extends Emitter { void onError(String error) { if (listeners("error").size() > 0) { emit("error", error); } } SocketIoSocket(SocketIoNamespaceImpl namespace, SocketIoClient client); @Override int hashCode(); @Override boolean equals(Object obj); String getId(); SocketIoNamespace getNamespace(); void disconnect(boolean close); void broadcast(String room, String event, Object... args); void broadcast(String[] rooms, String event, Object[] args); void send(String event, Object... args); void send(String event, Object[] args, ReceivedByRemoteAcknowledgementCallback acknowledgementCallback); synchronized void joinRoom(String... rooms); synchronized void leaveRoom(String... rooms); synchronized void leaveAllRooms(); void registerAllEventListener(AllEventListener listener); void unregisterAllEventListener(AllEventListener listener); }
SocketIoSocket extends Emitter { void onError(String error) { if (listeners("error").size() > 0) { emit("error", error); } } SocketIoSocket(SocketIoNamespaceImpl namespace, SocketIoClient client); @Override int hashCode(); @Override boolean equals(Object obj); String getId(); SocketIoNamespace getNamespace(); void disconnect(boolean close); void broadcast(String room, String event, Object... args); void broadcast(String[] rooms, String event, Object[] args); void send(String event, Object... args); void send(String event, Object[] args, ReceivedByRemoteAcknowledgementCallback acknowledgementCallback); synchronized void joinRoom(String... rooms); synchronized void leaveRoom(String... rooms); synchronized void leaveAllRooms(); void registerAllEventListener(AllEventListener listener); void unregisterAllEventListener(AllEventListener listener);  }