Search in sources :

Example 6 with EzySocketDisconnection

use of com.tvd12.ezyfoxserver.socket.EzySocketDisconnection in project ezyfox-server by youngmonkeys.

the class EzySocketDisconnectionHandlerTest method hasNoHandlerGroupCaseTest.

@Test
public void hasNoHandlerGroupCaseTest() {
    EzySocketDisconnectionHandler handler = new EzySocketDisconnectionHandler();
    EzySocketDisconnectionQueue disconnectionQueue = new EzyBlockingSocketDisconnectionQueue();
    EzySocketDataHandlerGroupRemover dataHandlerGroupRemover = mock(EzySocketDataHandlerGroupRemover.class);
    when(dataHandlerGroupRemover.removeHandlerGroup(any(EzySession.class))).thenReturn(null);
    EzySession session = spy(EzyAbstractSession.class);
    EzySocketDisconnection disconnection = new EzySimpleSocketDisconnection(session);
    disconnectionQueue.add(disconnection);
    handler.setDisconnectionQueue(disconnectionQueue);
    handler.setDataHandlerGroupRemover(dataHandlerGroupRemover);
    handler.handleEvent();
}
Also used : EzySession(com.tvd12.ezyfoxserver.entity.EzySession) Test(org.testng.annotations.Test)

Example 7 with EzySocketDisconnection

use of com.tvd12.ezyfoxserver.socket.EzySocketDisconnection in project ezyfox-server by youngmonkeys.

the class EzyBlockingSocketDisconnectionQueueTest method test.

@Test
public void test() {
    EzyBlockingSocketDisconnectionQueue queue = new EzyBlockingSocketDisconnectionQueue();
    assert queue.isEmpty();
    assert queue.size() == 0;
    EzySocketDisconnection disconnection = mock(EzySocketDisconnection.class);
    queue.add(disconnection);
    assert queue.size() == 1;
    queue.remove(disconnection);
    assert queue.size() == 0;
}
Also used : EzyBlockingSocketDisconnectionQueue(com.tvd12.ezyfoxserver.socket.EzyBlockingSocketDisconnectionQueue) EzySocketDisconnection(com.tvd12.ezyfoxserver.socket.EzySocketDisconnection) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)6 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)4 EzyBlockingSocketDisconnectionQueue (com.tvd12.ezyfoxserver.socket.EzyBlockingSocketDisconnectionQueue)2 EzySocketDisconnection (com.tvd12.ezyfoxserver.socket.EzySocketDisconnection)2 EzyConstant (com.tvd12.ezyfox.constant.EzyConstant)1 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)1 EzyResponseApi (com.tvd12.ezyfoxserver.api.EzyResponseApi)1 EzyStreamingApi (com.tvd12.ezyfoxserver.api.EzyStreamingApi)1 EzySimpleConfig (com.tvd12.ezyfoxserver.config.EzySimpleConfig)1 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)1 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)1 EzyNioServerBootstrap (com.tvd12.ezyfoxserver.nio.EzyNioServerBootstrap)1 EzyHandlerGroupManager (com.tvd12.ezyfoxserver.nio.wrapper.EzyHandlerGroupManager)1 EzySimpleSessionTokenGenerator (com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator)1 EzyEventControllersSetting (com.tvd12.ezyfoxserver.setting.EzyEventControllersSetting)1 EzySimpleEventControllersSetting (com.tvd12.ezyfoxserver.setting.EzySimpleEventControllersSetting)1 EzySimpleSettings (com.tvd12.ezyfoxserver.setting.EzySimpleSettings)1 EzySimpleStreamingSetting (com.tvd12.ezyfoxserver.setting.EzySimpleStreamingSetting)1 EzyChannel (com.tvd12.ezyfoxserver.socket.EzyChannel)1 EzySocketDisconnectionQueue (com.tvd12.ezyfoxserver.socket.EzySocketDisconnectionQueue)1