use of com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting 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.setting.EzySimpleZoneSetting 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.setting.EzySimpleZoneSetting in project ezyfox-server by youngmonkeys.
the class EzySimpleZoneTest method test.
@Test
public void test() {
EzySimpleZone zone = new EzySimpleZone();
EzySimpleZoneSetting setting = new EzySimpleZoneSetting();
zone.setSetting(setting);
// noinspection EqualsWithItself
assert zone.equals(zone);
assert !zone.equals(new EzySimpleZone());
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting in project ezyfox-server by youngmonkeys.
the class EzyZoneContextsTest method newDefaultZoneContext.
public static EzySimpleZoneContext newDefaultZoneContext() {
EzySimpleZoneContext context = new EzySimpleZoneContext();
EzySimpleZone zone = new EzySimpleZone();
zone.setSetting(new EzySimpleZoneSetting());
context.setZone(zone);
return context;
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting in project ezyfox-server by youngmonkeys.
the class EzyZonesStarterTest method normalCaseTest.
@Test
public void normalCaseTest() {
EzySimpleSettings settings = new EzySimpleSettings();
EzySimpleZonesSetting zonesSetting = settings.getZones();
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
zoneSetting.setName("test");
zonesSetting.setItem(zoneSetting);
EzySimpleAppsSetting appsSetting = new EzySimpleAppsSetting();
EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
appSetting.setName("apps");
appSetting.setFolder("apps");
appSetting.setEntryLoader(ExEntryLoader.class.getName());
appsSetting.setItem(appSetting);
zoneSetting.setApplications(appsSetting);
EzySimplePluginsSetting pluginsSetting = new EzySimplePluginsSetting();
EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
pluginSetting.setName("plugins");
pluginSetting.setFolder("plugins");
pluginSetting.setEntryLoader(ExPluginEntryLoader.class.getName());
pluginsSetting.setItem(pluginSetting);
zoneSetting.setPlugins(pluginsSetting);
EzySimpleServer server = new EzySimpleServer();
server.setSettings(settings);
server.setConfig(new EzySimpleConfig());
EzyServerContext serverContext = mock(EzyServerContext.class);
when(serverContext.getServer()).thenReturn(server);
EzySimpleZone zone = new EzySimpleZone();
zone.setSetting(zoneSetting);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
when(zoneContext.getZone()).thenReturn(zone);
when(serverContext.getZoneContext("test")).thenReturn(zoneContext);
EzySimpleApplication app = new EzySimpleApplication();
app.setSetting(appSetting);
EzyAppContext appContext = mock(EzyAppContext.class);
when(appContext.getApp()).thenReturn(app);
when(zoneContext.getAppContext("apps")).thenReturn(appContext);
EzySimplePlugin plugin = new EzySimplePlugin();
plugin.setSetting(pluginSetting);
EzyPluginContext pluginContext = mock(EzyPluginContext.class);
when(pluginContext.getPlugin()).thenReturn(plugin);
when(zoneContext.getPluginContext("plugins")).thenReturn(pluginContext);
Map<String, ClassLoader> appClassLoaders = new HashMap<>();
appClassLoaders.put("apps", new EzyAppClassLoader(new File("test-data"), getClass().getClassLoader()));
server.setAppClassLoaders(appClassLoaders);
EzyZonesStarter starter = EzyZonesStarter.builder().serverContext(serverContext).build();
starter.start();
}
Aggregations