use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketDisconnection in project ezyfox-server by youngmonkeys.
the class EzyDisconnectUserImplTest method test.
@Test
public void test() {
// given
String token = RandomUtil.randomShortAlphabetString();
EzySession session = newSession();
session.setToken(token);
String username = RandomUtil.randomShortAlphabetString();
EzySimpleUser user = newUser();
user.setName(username);
user.addSession(session);
// when
EzySimpleSocketDisconnection disconnection = new EzySimpleSocketDisconnection(session, EzyDisconnectReason.ADMIN_BAN);
// when
Asserts.assertEquals(user.getName(), username);
Asserts.assertEquals(user.getSession(), session);
Asserts.assertEquals(session.getToken(), token);
Asserts.assertEquals(disconnection.getSession(), session);
Asserts.assertEquals(disconnection.getDisconnectReason(), EzyDisconnectReason.ADMIN_BAN);
}
use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketDisconnection in project ezyfox-server by youngmonkeys.
the class EzySocketDisconnectionHandlerTest method processDisconnectionQueueExceptionCaseTest.
@Test
public void processDisconnectionQueueExceptionCaseTest() {
EzySocketDisconnectionHandler handler = new EzySocketDisconnectionHandler();
EzySocketDisconnectionQueue disconnectionQueue = new EzyBlockingSocketDisconnectionQueue();
EzySocketDataHandlerGroupRemover dataHandlerGroupRemover = mock(EzySocketDataHandlerGroupRemover.class);
when(dataHandlerGroupRemover.removeHandlerGroup(any(EzySession.class))).thenThrow(new IllegalArgumentException());
EzySession session = spy(EzyAbstractSession.class);
EzySocketDisconnection disconnection = new EzySimpleSocketDisconnection(session);
disconnectionQueue.add(disconnection);
handler.setDisconnectionQueue(disconnectionQueue);
handler.setDataHandlerGroupRemover(dataHandlerGroupRemover);
handler.handleEvent();
}
use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketDisconnection in project ezyfox-server by youngmonkeys.
the class EzySocketDisconnectionHandlerTest method test.
@Test
public void test() {
EzySocketDisconnectionHandler handler = new EzySocketDisconnectionHandler();
EzySocketDisconnectionQueue disconnectionQueue = new EzyBlockingSocketDisconnectionQueue();
EzySocketDataHandlerGroupRemover dataHandlerGroupRemover = mock(EzySocketDataHandlerGroupRemover.class);
EzySocketDataHandlerGroup handlerGroup = mock(EzySocketDataHandlerGroup.class);
when(dataHandlerGroupRemover.removeHandlerGroup(any(EzySession.class))).thenReturn(handlerGroup);
EzySession session = spy(EzyAbstractSession.class);
EzySocketDisconnection disconnection = new EzySimpleSocketDisconnection(session);
disconnectionQueue.add(disconnection);
handler.setDisconnectionQueue(disconnectionQueue);
handler.setDataHandlerGroupRemover(dataHandlerGroupRemover);
handler.handleEvent();
handler.destroy();
}
use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketDisconnection 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();
}
Aggregations