use of com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting in project ezyfox-server by youngmonkeys.
the class EzySimpleAppEntryTest method test.
@SuppressWarnings({ "rawtypes" })
@Test
public void test() throws Exception {
EzySimpleSettings settings = new EzySimpleSettings();
EzySimpleServer server = new EzySimpleServer();
server.setSettings(settings);
EzySimpleServerContext serverContext = new EzySimpleServerContext();
serverContext.setServer(server);
serverContext.init();
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
EzySimpleZone zone = new EzySimpleZone();
zone.setSetting(zoneSetting);
EzySimpleZoneContext zoneContext = new EzySimpleZoneContext();
zoneContext.setZone(zone);
zoneContext.init();
zoneContext.setParent(serverContext);
EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
appSetting.setName("test");
EzyAppUserManager appUserManager = EzyAppUserManagerImpl.builder().build();
EzyEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
EzyEventControllers eventControllers = EzyEventControllersImpl.create(eventControllersSetting);
EzySimpleApplication application = new EzySimpleApplication();
application.setSetting(appSetting);
application.setUserManager(appUserManager);
application.setEventControllers(eventControllers);
ScheduledExecutorService appScheduledExecutorService = new EzyErrorScheduledExecutorService("not implement");
EzySimpleAppContext appContext = new EzySimpleAppContext();
appContext.setApp(application);
appContext.setParent(zoneContext);
appContext.setExecutorService(appScheduledExecutorService);
appContext.init();
EzySimpleAppEntry entry = new EzyAppEntryEx();
entry.config(appContext);
entry.start();
handleClientRequest(appContext);
List<EzyEventController> serverReadyHandlers = appContext.getApp().getEventControllers().getControllers(EzyEventType.SERVER_READY);
Assert.assertEquals(serverReadyHandlers.size(), 2);
Assert.assertEquals(serverReadyHandlers.get(0).getClass(), ServerReadyEventHandler2.class);
Assert.assertEquals(serverReadyHandlers.get(1).getClass(), ServerReadyEventHandler.class);
List<EzyEventController> loginEventHandlers = appContext.getApp().getEventControllers().getControllers(EzyEventType.USER_LOGIN);
Assert.assertEquals(loginEventHandlers.size(), 1);
Assert.assertEquals(loginEventHandlers.get(0).getClass(), AppUserLoginRequestController.class);
entry.destroy();
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting in project ezyfox-server by youngmonkeys.
the class EzyBroadcastPluginsEventImplTest method firePluginEventExceptionCase.
@Test
public void firePluginEventExceptionCase() {
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);
EzyPlugin plugin = mock(EzyPlugin.class);
when(pluginContext.getPlugin()).thenReturn(plugin);
EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
when(plugin.getSetting()).thenReturn(pluginSetting);
EzySimpleListenEvents listenEvents = pluginSetting.getListenEvents();
listenEvents.setEvent("SERVER_READY");
doThrow(new IllegalStateException("server maintain")).when(pluginContext).handleEvent(any(), any());
when(zoneContext.getPluginContexts()).thenReturn(Lists.newArrayList(pluginContext));
EzyBroadcastPluginsEventImpl cmd = new EzyBroadcastPluginsEventImpl(zoneContext);
EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
cmd.fire(EzyEventType.SERVER_READY, event, true);
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting in project ezyfox-server by youngmonkeys.
the class EzyBroadcastPluginsEventImplTest method pluginContextsNullCaseTest.
@Test
public void pluginContextsNullCaseTest() {
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);
EzyBroadcastPluginsEventImpl cmd = new EzyBroadcastPluginsEventImpl(zoneContext);
EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
cmd.fire(EzyEventType.SERVER_READY, event, true);
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting in project ezyfox-server by youngmonkeys.
the class EzyZoneBroadcastEventImplTest method firePluginEventNoCatchExceptionCaseTest.
@Test
public void firePluginEventNoCatchExceptionCaseTest() {
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));
EzyZoneBroadcastEventImpl cmd = new EzyZoneBroadcastEventImpl(zoneContext);
EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
cmd.fire(EzyEventType.SERVER_READY, event, false);
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting in project ezyfox-server by youngmonkeys.
the class EzyZoneBroadcastEventImplTest method fireAppEventCatchExceptionCaseTest.
@Test
public void fireAppEventCatchExceptionCaseTest() {
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));
doThrow(new IllegalStateException("server maintain")).when(appContext).handleEvent(any(), any());
EzyZoneBroadcastEventImpl cmd = new EzyZoneBroadcastEventImpl(zoneContext);
EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
cmd.fire(EzyEventType.SERVER_READY, event, true);
}
Aggregations