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);
}
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);
}
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();
}
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);
}
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;
}
Aggregations