@Test public void testTransportPacket_message() { final Transport transport = Mockito.spy(new StubTransport()); final EngineIoSocket socket = new EngineIoSocket(new Object(), ServerYeast.yeast(), new EngineIoServer(), mPingTimeoutHandler); socket.init(transport, null); final String packetData = "TestMessage"; final Packet<String> packet = new Packet<>(Packet.MESSAGE, packetData); final Emitter.Listener messageListener = Mockito.mock(Emitter.Listener.class); Mockito.doAnswer(invocation -> { final Object[] args = invocation.getArguments(); Assert.assertEquals(1, args.length); Assert.assertEquals(packetData, args[0]); return null; }).when(messageListener).call(Mockito.any()); socket.on("message", messageListener); socket.on("data", messageListener); transport.emit("packet", packet); Mockito.verify(messageListener, Mockito.times(2)) .call(Mockito.eq(packetData)); }
void init(Transport transport, @SuppressWarnings("unused") HttpServletRequest initialRequest) { setTransport(transport); onOpen(); }
EngineIoSocket extends Emitter { void init(Transport transport, @SuppressWarnings("unused") HttpServletRequest initialRequest) { setTransport(transport); onOpen(); } }
EngineIoSocket extends Emitter { void init(Transport transport, @SuppressWarnings("unused") HttpServletRequest initialRequest) { setTransport(transport); onOpen(); } EngineIoSocket(Object lockObject, String sid, EngineIoServer server, EngineIoSocketTimeoutHandler pingTimeoutHandler); }
EngineIoSocket extends Emitter { void init(Transport transport, @SuppressWarnings("unused") HttpServletRequest initialRequest) { setTransport(transport); onOpen(); } EngineIoSocket(Object lockObject, String sid, EngineIoServer server, EngineIoSocketTimeoutHandler pingTimeoutHandler); @SuppressWarnings("WeakerAccess") String getId(); @SuppressWarnings("WeakerAccess") ReadyState getReadyState(); void send(Packet<?> packet); void close(); }
EngineIoSocket extends Emitter { void init(Transport transport, @SuppressWarnings("unused") HttpServletRequest initialRequest) { setTransport(transport); onOpen(); } EngineIoSocket(Object lockObject, String sid, EngineIoServer server, EngineIoSocketTimeoutHandler pingTimeoutHandler); @SuppressWarnings("WeakerAccess") String getId(); @SuppressWarnings("WeakerAccess") ReadyState getReadyState(); void send(Packet<?> packet); void close();  }