Search in sources :

Example 41 with EzyZoneContext

use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.

the class EzySocketUserRemovalHandlerTest method processUserRemovalQueueThrowableCaseTest.

@Test
public void processUserRemovalQueueThrowableCaseTest() {
    TestBlockingSocketUserRemovalQueue queue = new TestBlockingSocketUserRemovalQueue();
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzySimpleUser user = new EzySimpleUser();
    user.setName("test");
    EzySocketUserRemoval item = new EzySimpleSocketUserRemoval(zoneContext, user, EzyUserRemoveReason.EXIT_APP) {

        @Override
        public void release() {
            throw new RuntimeException();
        }
    };
    queue.add(item);
    EzySocketUserRemovalHandler handler = new EzySocketUserRemovalHandler(queue);
    handler.handleEvent();
}
Also used : EzySimpleUser(com.tvd12.ezyfoxserver.entity.EzySimpleUser) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) Test(org.testng.annotations.Test)

Example 42 with EzyZoneContext

use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.

the class EzySocketUserRemovalHandlerTest method removeUserFromAppExceptionCaseTest.

@Test
public void removeUserFromAppExceptionCaseTest() {
    TestBlockingSocketUserRemovalQueue queue = new TestBlockingSocketUserRemovalQueue();
    EzyAppContext appContext1 = mock(EzyAppContext.class);
    EzyAppUserManager userManager1 = mock(EzyAppUserManager.class);
    when(userManager1.containsUser(any(EzyUser.class))).thenReturn(true);
    EzyApplication app1 = mock(EzyApplication.class);
    when(app1.getUserManager()).thenReturn(userManager1);
    when(appContext1.getApp()).thenReturn(app1);
    doThrow(new IllegalArgumentException()).when(userManager1).removeUser(any(), any());
    EzySimpleAppSetting appSetting1 = new EzySimpleAppSetting();
    appSetting1.setName("app1");
    when(app1.getSetting()).thenReturn(appSetting1);
    EzyAppContext appContext2 = mock(EzyAppContext.class);
    EzyAppUserManager userManager2 = mock(EzyAppUserManager.class);
    when(userManager2.containsUser(any(EzyUser.class))).thenReturn(false);
    EzyApplication app2 = mock(EzyApplication.class);
    when(app2.getUserManager()).thenReturn(userManager2);
    when(appContext2.getApp()).thenReturn(app2);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    when(zoneContext.getAppContexts()).thenReturn(Lists.newArrayList(appContext1, appContext2));
    EzySimpleUser user = new EzySimpleUser();
    user.setName("test");
    EzySocketUserRemoval item = new EzySimpleSocketUserRemoval(zoneContext, user, EzyUserRemoveReason.EXIT_APP);
    queue.add(item);
    EzySocketUserRemovalQueue userRemovalQueue = new EzyBlockingSocketUserRemovalQueue();
    new EzySocketUserRemovalHandler(userRemovalQueue);
    EzySocketUserRemovalHandler handler = new EzySocketUserRemovalHandler(queue);
    handler.handleEvent();
    handler.destroy();
}
Also used : EzySimpleAppSetting(com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting) EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzyApplication(com.tvd12.ezyfoxserver.EzyApplication) EzySimpleUser(com.tvd12.ezyfoxserver.entity.EzySimpleUser) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) Test(org.testng.annotations.Test)

Example 43 with EzyZoneContext

use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.

the class EzyRequestPluginControllerTest method test.

@Test
public void test() {
    EzyRequestPluginController controller = new EzyRequestPluginController();
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    when(serverContext.getZoneContext(1)).thenReturn(zoneContext);
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    when(zoneContext.getPluginContext(1)).thenReturn(pluginContext);
    EzyPlugin plugin = mock(EzyPlugin.class);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    EzyPluginRequestController requestController = mock(EzyPluginRequestController.class);
    when(plugin.getRequestController()).thenReturn(requestController);
    EzySimpleRequestPluginRequest request = new EzySimpleRequestPluginRequest();
    EzyAbstractSession session = spy(EzyAbstractSession.class);
    EzySimpleUser user = new EzySimpleUser();
    user.setZoneId(1);
    user.setId(1);
    user.setName("test");
    request.setSession(session);
    request.setUser(user);
    EzyArray array = EzyEntityFactory.newArrayBuilder().append(1).append(EzyEntityFactory.newArrayBuilder()).build();
    request.deserializeParams(array);
    controller.handle(serverContext, request);
}
Also used : EzySimpleUser(com.tvd12.ezyfoxserver.entity.EzySimpleUser) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzySimpleRequestPluginRequest(com.tvd12.ezyfoxserver.request.EzySimpleRequestPluginRequest) EzyAbstractSession(com.tvd12.ezyfoxserver.entity.EzyAbstractSession) EzyRequestPluginController(com.tvd12.ezyfoxserver.controller.EzyRequestPluginController) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyPluginRequestController(com.tvd12.ezyfoxserver.plugin.EzyPluginRequestController) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzyArray(com.tvd12.ezyfox.entity.EzyArray) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 44 with EzyZoneContext

use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.

the class EzySimpleStreamingControllerTest method test.

@Test
public void test() {
    EzySimpleStreamingController controller = new EzySimpleStreamingController();
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzySimpleStreamingRequest request = new EzySimpleStreamingRequest();
    controller.handle(zoneContext, request);
}
Also used : EzySimpleStreamingRequest(com.tvd12.ezyfoxserver.request.EzySimpleStreamingRequest) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzySimpleStreamingController(com.tvd12.ezyfoxserver.controller.EzySimpleStreamingController) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 45 with EzyZoneContext

use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.

the class EzySimpleAppUserDelegateTest method testExceptionCase.

@Test
public void testExceptionCase() {
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyAppContext appContext = mock(EzyAppContext.class);
    EzyApplication app = mock(EzyApplication.class);
    when(appContext.getApp()).thenReturn(app);
    EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
    when(app.getSetting()).thenReturn(appSetting);
    when(appContext.getParent()).thenReturn(zoneContext);
    doThrow(new IllegalStateException()).when(appContext).handleEvent(any(), any());
    EzySimpleAppUserDelegate delegate = new EzySimpleAppUserDelegate();
    delegate.setAppContext(appContext);
    EzySimpleUser user = new EzySimpleUser();
    user.setName("test");
    delegate.onUserRemoved(user, EzyUserRemoveReason.EXIT_APP);
}
Also used : EzySimpleAppSetting(com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting) EzyApplication(com.tvd12.ezyfoxserver.EzyApplication) EzySimpleUser(com.tvd12.ezyfoxserver.entity.EzySimpleUser) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzySimpleAppUserDelegate(com.tvd12.ezyfoxserver.delegate.EzySimpleAppUserDelegate) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Aggregations

EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)77 Test (org.testng.annotations.Test)65 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)42 BaseTest (com.tvd12.test.base.BaseTest)26 EzyZoneUserManager (com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager)24 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)23 EzyZone (com.tvd12.ezyfoxserver.EzyZone)21 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)21 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)20 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)20 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)18 EzySimpleZoneSetting (com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting)18 EzyArray (com.tvd12.ezyfox.entity.EzyArray)17 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)17 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)15 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)13 EzyPluginContext (com.tvd12.ezyfoxserver.context.EzyPluginContext)13 EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)12 EzyResponseApi (com.tvd12.ezyfoxserver.api.EzyResponseApi)12 EzyServer (com.tvd12.ezyfoxserver.EzyServer)11