use of com.tvd12.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class HelloController2 method greet.
@EzyDoHandle("Hello")
public void greet(GreetRequest request, EzyUser user, EzySession session) {
GreetResponse response = new GreetResponse("Hello " + request.getWho() + "!");
System.out.println("HelloController::Big/Hello response: " + response);
}
use of com.tvd12.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class EzyBlockingSessionTicketsQueueTest method takeInactiveSession.
@Test
public void takeInactiveSession() throws Exception {
// given
EzyBlockingSessionTicketsQueue sut = new EzyBlockingSessionTicketsQueue();
MySession session = new MySession();
session.setActivated(false);
sut.add(session);
Thread newThread = new Thread(() -> {
// when
EzySession takeSession;
try {
takeSession = sut.take();
} catch (InterruptedException e) {
return;
}
// then
Asserts.assertEquals(session, takeSession);
});
newThread.start();
Thread.sleep(300L);
newThread.interrupt();
}
use of com.tvd12.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class EzySessionTicketsRequestQueuesTest method addSystemRequest.
@Test
public void addSystemRequest() {
// given
EzySession session = mock(EzySession.class);
EzyArray data = EzyEntityArrays.newArray(EzyCommand.APP_ACCESS.getId(), EzyEmptyObject.getInstance());
EzySocketRequest socketRequest = new EzySimpleSocketRequest(session, data);
EzyRequestQueue queue = mock(EzyRequestQueue.class);
when(queue.isEmpty()).thenReturn(false);
when(queue.add(socketRequest)).thenReturn(false);
when(session.getSystemRequestQueue()).thenReturn(queue);
EzySessionTicketsRequestQueues sut = new EzySessionTicketsRequestQueues();
// when
boolean result = sut.addRequest(socketRequest);
// then
Asserts.assertFalse(result);
Asserts.assertTrue(sut.getSystemQueue().isEmpty());
}
use of com.tvd12.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class EzySessionTicketsRequestQueuesTest method addSystemRequestWithEmptyQueue.
@Test
public void addSystemRequestWithEmptyQueue() {
// given
EzySession session = mock(EzySession.class);
EzyArray data = EzyEntityArrays.newArray(EzyCommand.APP_ACCESS.getId(), EzyEmptyObject.getInstance());
EzySocketRequest socketRequest = new EzySimpleSocketRequest(session, data);
EzyRequestQueue queue = mock(EzyRequestQueue.class);
when(queue.isEmpty()).thenReturn(true);
when(session.getSystemRequestQueue()).thenReturn(queue);
EzySessionTicketsRequestQueues sut = new EzySessionTicketsRequestQueues();
// when
boolean result = sut.addRequest(socketRequest);
// then
Asserts.assertFalse(result);
Asserts.assertTrue(sut.getSystemQueue().isEmpty());
}
use of com.tvd12.ezyfoxserver.entity.EzySession 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();
}
Aggregations