@Test public void testInit() { final Transport transport = Mockito.spy(new StubTransport()); final EngineIoSocket socket = Mockito.spy(new EngineIoSocket(new Object(), ServerYeast.yeast(), new EngineIoServer(), mPingTimeoutHandler)); Mockito.doAnswer(invocationOnMock -> { final List<Packet<?>> packetList = invocationOnMock.getArgument(0); for (Packet<?> packet : packetList) { if (packet.type.equals(Packet.OPEN)) { final JSONObject jsonObject = new JSONObject((String) packet.data); Assert.assertTrue(jsonObject.has("sid")); Assert.assertEquals(socket.getId(), jsonObject.getString("sid")); } } return null; }).when(transport).send(Mockito.anyList()); socket.init(transport, null); Assert.assertEquals(SUB_TRANSPORT_NAME, socket.getCurrentTransportName()); Mockito.verify(socket, Mockito.times(1)) .emit(Mockito.eq("open")); Mockito.verify(socket, Mockito.times(1)) .emit(Mockito.eq("flush"), Mockito.any()); Mockito.verify(socket, Mockito.times(1)) .emit(Mockito.eq("drain")); Mockito.verify(transport, Mockito.times(1)) .send(Mockito.anyList()); }
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();  }