Search in sources :

Example 26 with EzyArray

use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.

the class EzyPluginInfoControllerTest method test.

@Test
public void test() {
    EzyPluginInfoController controller = new EzyPluginInfoController();
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    when(serverContext.getZoneContext(1)).thenReturn(zoneContext);
    EzySimplePluginInfoRequest request = new EzySimplePluginInfoRequest();
    EzyAbstractSession session = spy(EzyAbstractSession.class);
    EzySimpleUser user = new EzySimpleUser();
    user.setZoneId(1);
    request.setSession(session);
    request.setUser(user);
    EzyArray data = EzyEntityFactory.newArrayBuilder().append("test").build();
    request.deserializeParams(data);
    controller.handle(serverContext, request);
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    EzySimplePlugin plugin = new EzySimplePlugin();
    EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
    plugin.setSetting(pluginSetting);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    when(zoneContext.getPluginContext("test")).thenReturn(pluginContext);
    controller.handle(serverContext, request);
}
Also used : EzySimplePluginInfoRequest(com.tvd12.ezyfoxserver.request.EzySimplePluginInfoRequest) EzySimpleUser(com.tvd12.ezyfoxserver.entity.EzySimpleUser) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyAbstractSession(com.tvd12.ezyfoxserver.entity.EzyAbstractSession) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyPluginInfoController(com.tvd12.ezyfoxserver.controller.EzyPluginInfoController) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimplePlugin(com.tvd12.ezyfoxserver.EzySimplePlugin) EzySimplePluginSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 27 with EzyArray

use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.

the class EzyRequestAppControllerTest method testHasNotAccessed.

@Test
public void testHasNotAccessed() {
    EzyArray data = EzyEntityArrays.newArray(1, EzyEntityArrays.newArray());
    EzyRequestAppController controller = new EzyRequestAppController();
    MyTestUser user = new MyTestUser();
    user.setName("dungtv1");
    user.addSession(session);
    EzySimpleRequestAppRequest request = new EzySimpleRequestAppRequest();
    request.deserializeParams(data);
    request.setUser(user);
    request.setSession(session);
    EzyServerContext ctx = newServerContext();
    controller.handle(ctx, request);
}
Also used : EzyRequestAppController(com.tvd12.ezyfoxserver.controller.EzyRequestAppController) MyTestUser(com.tvd12.ezyfoxserver.testing.MyTestUser) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleRequestAppRequest(com.tvd12.ezyfoxserver.request.EzySimpleRequestAppRequest) Test(org.testng.annotations.Test) BaseCoreContextTest(com.tvd12.ezyfoxserver.testing.BaseCoreContextTest)

Example 28 with EzyArray

use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.

the class EzyRequestAppControllerTest method test.

@Test
public void test() {
    EzyArray data = EzyEntityArrays.newArray(1, EzyEntityArrays.newArray());
    EzyRequestAppController controller = new EzyRequestAppController();
    EzySimpleRequestAppRequest request = new EzySimpleRequestAppRequest();
    request.deserializeParams(data);
    request.setUser(user);
    request.setSession(session);
    EzyServerContext ctx = newServerContext();
    controller.handle(ctx, request);
}
Also used : EzyRequestAppController(com.tvd12.ezyfoxserver.controller.EzyRequestAppController) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleRequestAppRequest(com.tvd12.ezyfoxserver.request.EzySimpleRequestAppRequest) Test(org.testng.annotations.Test) BaseCoreContextTest(com.tvd12.ezyfoxserver.testing.BaseCoreContextTest)

Example 29 with EzyArray

use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.

the class EzyAbstractHandlerGroupTest method handleReceivedDataNotSuccess.

@Test
public void handleReceivedDataNotSuccess() throws Exception {
    // given
    ExHandlerGroup sut = newHandlerGroup();
    EzySession session = FieldUtil.getFieldValue(sut, "session");
    when(session.addReceivedRequests(1)).thenReturn(false);
    when(session.isActivated()).thenReturn(true);
    EzySessionTicketsRequestQueues sessionTicketsRequestQueues = FieldUtil.getFieldValue(sut, "sessionTicketsRequestQueues");
    EzyArray data = EzyEntityFactory.newArrayBuilder().append(EzyCommand.APP_ACCESS.getId()).append(EzyEntityFactory.newArray()).build();
    // when
    MethodInvoker.create().object(sut).method("handleReceivedData").param(Object.class, data).param(int.class, 100).call();
    // then
    verify(sessionTicketsRequestQueues, times(1)).addRequest(any());
}
Also used : EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 30 with EzyArray

use of com.tvd12.ezyfoxserver.client.entity.EzyArray in project ezyfox-server by youngmonkeys.

the class EzySocketRequestHandlerTest method test.

@Test
public void test() {
    ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
    EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
    EzySocketDataHandlerGroup handlerGroup = mock(EzySocketDataHandlerGroup.class);
    when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(handlerGroup);
    EzySession session = spy(EzyAbstractSession.class);
    session.setActivated(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();
    handler.destroy();
}
Also used : EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) Test(org.testng.annotations.Test)

Aggregations

EzyArray (com.tvd12.ezyfox.entity.EzyArray)80 Test (org.testng.annotations.Test)45 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)30 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)17 EzyResponseApi (com.tvd12.ezyfoxserver.api.EzyResponseApi)15 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)14 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)13 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)13 EzySimpleLoginRequest (com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest)13 FieldSetting (com.tvd12.dahlia.core.setting.FieldSetting)12 EzyObject (com.tvd12.ezyfox.entity.EzyObject)12 EzyLoginController (com.tvd12.ezyfoxserver.controller.EzyLoginController)12 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)11 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)9 CollectionSetting (com.tvd12.dahlia.core.setting.CollectionSetting)8 BaseCoreTest (com.tvd12.ezyfoxserver.testing.BaseCoreTest)8 Collection (com.tvd12.dahlia.core.entity.Collection)7 EzyArray (com.tvd12.ezyfoxserver.client.entity.EzyArray)7 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)7 Record (com.tvd12.dahlia.core.entity.Record)5