Search in sources :

Example 21 with EzyZone

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

the class EzyZoneBroadcastEventImplTest method fireAppEventNoCatchExceptionCaseTest.

@Test
public void fireAppEventNoCatchExceptionCaseTest() {
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyZone zone = mock(EzyZone.class);
    when(zoneContext.getZone()).thenReturn(zone);
    EzySimpleZoneSetting setting = new EzySimpleZoneSetting();
    setting.setName("test");
    when(zone.getSetting()).thenReturn(setting);
    EzyAppContext appContext = mock(EzyAppContext.class);
    when(zoneContext.getAppContexts()).thenReturn(Lists.newArrayList(appContext));
    EzyZoneBroadcastEventImpl cmd = new EzyZoneBroadcastEventImpl(zoneContext);
    EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
    cmd.fire(EzyEventType.SERVER_READY, event, false);
}
Also used : EzyZone(com.tvd12.ezyfoxserver.EzyZone) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyZoneBroadcastEventImpl(com.tvd12.ezyfoxserver.command.impl.EzyZoneBroadcastEventImpl) EzySimpleServerReadyEvent(com.tvd12.ezyfoxserver.event.EzySimpleServerReadyEvent) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) EzyServerReadyEvent(com.tvd12.ezyfoxserver.event.EzyServerReadyEvent) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 22 with EzyZone

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

the class EzyZoneBroadcastEventImplTest method firePluginEventCatchExceptionCaseTest.

@Test
public void firePluginEventCatchExceptionCaseTest() {
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyZone zone = mock(EzyZone.class);
    when(zoneContext.getZone()).thenReturn(zone);
    EzySimpleZoneSetting setting = new EzySimpleZoneSetting();
    setting.setName("test");
    when(zone.getSetting()).thenReturn(setting);
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    when(zoneContext.getPluginContexts()).thenReturn(Lists.newArrayList(pluginContext));
    doThrow(new IllegalStateException("server maintain")).when(pluginContext).handleEvent(any(), any());
    EzyZoneBroadcastEventImpl cmd = new EzyZoneBroadcastEventImpl(zoneContext);
    EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
    cmd.fire(EzyEventType.SERVER_READY, event, true);
}
Also used : EzyZone(com.tvd12.ezyfoxserver.EzyZone) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyZoneBroadcastEventImpl(com.tvd12.ezyfoxserver.command.impl.EzyZoneBroadcastEventImpl) EzySimpleServerReadyEvent(com.tvd12.ezyfoxserver.event.EzySimpleServerReadyEvent) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) EzyServerReadyEvent(com.tvd12.ezyfoxserver.event.EzyServerReadyEvent) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 23 with EzyZone

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

the class EzySocketUserRemovalHandlerTest method notifyUserRemovedToPluginsExceptionCaseTest.

@Test
public void notifyUserRemovedToPluginsExceptionCaseTest() {
    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 RuntimeException()).when(appContext1).handleEvent(any(EzyConstant.class), any(EzyUserEvent.class));
    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));
    EzyZone zone = mock(EzyZone.class);
    when(zoneContext.getZone()).thenReturn(zone);
    EzyZoneSetting zoneSetting = mock(EzyZoneSetting.class);
    when(zoneSetting.getName()).thenReturn("test");
    when(zone.getSetting()).thenReturn(zoneSetting);
    doThrow(new RuntimeException()).when(zoneContext).broadcastPlugins(any(EzyConstant.class), any(EzyUserEvent.class), anyBoolean());
    EzySimpleUser user = new EzySimpleUser();
    user.setName("test");
    EzySocketUserRemoval item = new EzySimpleSocketUserRemoval(zoneContext, user, EzyUserRemoveReason.EXIT_APP);
    queue.add(item);
    EzySocketUserRemovalHandler handler = new EzySocketUserRemovalHandler(queue);
    handler.handleEvent();
    handler.destroy();
}
Also used : EzyZone(com.tvd12.ezyfoxserver.EzyZone) EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyZoneSetting(com.tvd12.ezyfoxserver.setting.EzyZoneSetting) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzyApplication(com.tvd12.ezyfoxserver.EzyApplication) EzySimpleUser(com.tvd12.ezyfoxserver.entity.EzySimpleUser) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) EzyConstant(com.tvd12.ezyfox.constant.EzyConstant) EzyUserEvent(com.tvd12.ezyfoxserver.event.EzyUserEvent) Test(org.testng.annotations.Test)

Example 24 with EzyZone

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

the class EzyAppAccessHandler method handle.

@Override
public void handle(EzyArray data) {
    EzyZone zone = client.getZone();
    EzyAppManager appManager = zone.getAppManager();
    EzyApp app = newApp(zone, data);
    appManager.addApp(app);
    postHandle(app, data);
}
Also used : EzyZone(com.tvd12.ezyfoxserver.client.entity.EzyZone) EzyApp(com.tvd12.ezyfoxserver.client.entity.EzyApp) EzyAppManager(com.tvd12.ezyfoxserver.client.manager.EzyAppManager)

Example 25 with EzyZone

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

the class EzyAppAccessHandler method newApp.

protected EzyApp newApp(EzyZone zone, EzyArray data) {
    int appId = data.get(0, int.class);
    String appName = data.get(1, String.class);
    EzySimpleApp app = new EzySimpleApp(zone, appId, appName);
    return app;
}
Also used : EzySimpleApp(com.tvd12.ezyfoxserver.client.entity.EzySimpleApp)

Aggregations

EzyZone (com.tvd12.ezyfoxserver.EzyZone)21 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)20 Test (org.testng.annotations.Test)18 EzyZoneUserManager (com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager)13 EzyServer (com.tvd12.ezyfoxserver.EzyServer)11 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)11 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)11 EzyCloseSession (com.tvd12.ezyfoxserver.command.EzyCloseSession)10 EzyController (com.tvd12.ezyfoxserver.controller.EzyController)10 EzyStreamingController (com.tvd12.ezyfoxserver.controller.EzyStreamingController)10 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)10 EzyInterceptor (com.tvd12.ezyfoxserver.interceptor.EzyInterceptor)10 EzyLoggerSetting (com.tvd12.ezyfoxserver.setting.EzyLoggerSetting)10 EzySessionManagementSetting (com.tvd12.ezyfoxserver.setting.EzySessionManagementSetting)10 EzySettings (com.tvd12.ezyfoxserver.setting.EzySettings)10 EzyChannel (com.tvd12.ezyfoxserver.socket.EzyChannel)10 EzyServerControllers (com.tvd12.ezyfoxserver.wrapper.EzyServerControllers)10 BaseTest (com.tvd12.test.base.BaseTest)9 BaseCoreTest (com.tvd12.ezyfoxserver.testing.BaseCoreTest)8 EzyServerReadyEvent (com.tvd12.ezyfoxserver.event.EzyServerReadyEvent)6