use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzySocketRequestHandlerTest method processRequestQueue0RemainTest.
@Test
public void processRequestQueue0RemainTest() {
// given
ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
EzySocketDataHandlerGroup handlerGroup = mock(EzySocketDataHandlerGroup.class);
EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(handlerGroup);
EzySession session = spy(EzyAbstractSession.class);
when(session.isActivated()).thenReturn(Boolean.TRUE);
EzyRequestQueue requestQueue = new EzyNonBlockingRequestQueue();
when(session.getExtensionRequestQueue()).thenReturn(requestQueue);
EzyArray array = EzyEntityFactory.newArrayBuilder().append(10).build();
EzySocketRequest request = new EzySimpleSocketRequest(session, array);
EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
handler.setSessionTicketsQueue(sessionTicketsRequestQueues.getExtensionQueue());
sessionTicketsRequestQueues.addRequest(request);
sessionTicketsRequestQueues.addRequest(request);
handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
// when
handler.handleEvent();
// then
Asserts.assertEquals(sessionTicketsRequestQueues.getExtensionQueue().size(), 1);
}
use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzySocketRequestHandlerTest method handleGroupNullCaseTest.
@Test
public void handleGroupNullCaseTest() {
ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(null);
EzySession session = spy(EzyAbstractSession.class);
when(session.isActivated()).thenReturn(Boolean.TRUE);
EzyRequestQueue requestQueue = new EzyNonBlockingRequestQueue();
when(session.getExtensionRequestQueue()).thenReturn(requestQueue);
EzyArray array = EzyEntityFactory.newArrayBuilder().append(10).build();
EzySocketRequest request = new EzySimpleSocketRequest(session, array);
EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
handler.setSessionTicketsQueue(sessionTicketsRequestQueues.getExtensionQueue());
sessionTicketsRequestQueues.addRequest(request);
handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
handler.handleEvent();
}
use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzySocketRequestHandlerTest method processRequestQueue0ExceptionCaseTest.
@Test
public void processRequestQueue0ExceptionCaseTest() {
ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenThrow(new IllegalArgumentException());
EzySession session = spy(EzyAbstractSession.class);
when(session.isActivated()).thenReturn(Boolean.TRUE);
EzyRequestQueue requestQueue = new EzyNonBlockingRequestQueue();
when(session.getExtensionRequestQueue()).thenReturn(requestQueue);
EzyArray array = EzyEntityFactory.newArrayBuilder().append(10).build();
EzySocketRequest request = new EzySimpleSocketRequest(session, array);
EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
handler.setSessionTicketsQueue(sessionTicketsRequestQueues.getExtensionQueue());
sessionTicketsRequestQueues.addRequest(request);
handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
handler.handleEvent();
}
use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzyUserRequestAppSingletonControllerTest method handleClientRequest.
private void handleClientRequest(EzyAppContext context) {
EzySimpleApplication app = (EzySimpleApplication) context.getApp();
EzyAppRequestController requestController = app.getRequestController();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
EzyArray data = EzyEntityFactory.newArrayBuilder().append("hello").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
EzyUserRequestAppEvent event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("responseFactoryTest").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("no command").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("hello2").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("hello6").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("c_hello").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestSend").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestNotSend").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("requestException").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
try {
data = EzyEntityFactory.newArrayBuilder().append("requestException2").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
} catch (Exception e) {
assert e.getCause().getClass() == Exception.class;
}
data = EzyEntityFactory.newArrayBuilder().append("requestException3").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
try {
data = EzyEntityFactory.newArrayBuilder().append("exception").build();
event = new EzySimpleUserRequestAppEvent(user, session, data);
requestController.handle(context, event);
} catch (Exception e) {
assert e instanceof IllegalStateException;
}
}
use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.
the class EzyUserRequestPluginSingletonControllerTest method handleClientRequest.
private void handleClientRequest(EzyPluginContext context) {
EzySimplePlugin plugin = (EzySimplePlugin) context.getPlugin();
EzyPluginRequestController requestController = plugin.getRequestController();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
EzyArray data = EzyEntityFactory.newArrayBuilder().append("hello").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
EzyUserRequestPluginEvent event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("responseFactoryTest").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("no command").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("hello2").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("plugin/c_hello").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestSend").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestNotSend").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("plugin/requestException4").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
try {
data = EzyEntityFactory.newArrayBuilder().append("exception").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
} catch (Exception e) {
assert e instanceof IllegalStateException;
}
}
Aggregations