use of com.tvd12.ezyfoxserver.EzySimpleZone in project ezyfox-server by youngmonkeys.
the class EzyZoneContextsTest method test.
@Test
public void test() {
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
EzySimpleZone zone = new EzySimpleZone();
when(zoneContext.getZone()).thenReturn(zone);
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
zone.setSetting(zoneSetting);
assert EzyZoneContexts.getUserManagementSetting(zoneContext) == zoneSetting.getUserManagement();
}
use of com.tvd12.ezyfoxserver.EzySimpleZone in project ezyfox-server by youngmonkeys.
the class EzyAppsStarterTest method newAppEntryLoaderClassLoaderIsNull.
@Test
public void newAppEntryLoaderClassLoaderIsNull() {
// given
Map<String, ClassLoader> loaders = new ConcurrentHashMap<>();
EzySimpleZoneContext zoneContext = EzyZoneContextsTest.newDefaultZoneContext();
EzySimpleApplication app = new EzySimpleApplication();
EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
appSetting.setName("abc");
app.setSetting(appSetting);
EzySimpleAppContext appContext = new EzySimpleAppContext();
appContext.setApp(app);
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
EzySimpleAppsSetting appsSetting = new EzySimpleAppsSetting();
appsSetting.setItem(appSetting);
zoneSetting.setApplications(appsSetting);
zoneContext.addAppContext(appSetting, appContext);
EzySimpleZone zone = new EzySimpleZone();
zone.setSetting(zoneSetting);
zoneContext.setZone(zone);
EzyAppsStarter starter = new EzyAppsStarter.Builder().zoneContext(zoneContext).appClassLoaders(loaders).enableAppClassLoader(true).build();
// when
starter.start();
// then
Asserts.assertNull(app.getEntry());
}
use of com.tvd12.ezyfoxserver.EzySimpleZone in project ezyfox-server by youngmonkeys.
the class EzyAppsStarterTest method newAppEntryLoaderArgsNotNullTest.
@Test
public void newAppEntryLoaderArgsNotNullTest() {
// given
Map<String, ClassLoader> loaders = new ConcurrentHashMap<>();
EzySimpleZoneContext zoneContext = EzyZoneContextsTest.newDefaultZoneContext();
EzySimpleApplication app = new EzySimpleApplication();
EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
appSetting.setName("abc");
appSetting.setEntryLoader(InternalAppEntryLoader.class);
appSetting.setEntryLoaderArgs(new String[] { "Hello" });
app.setSetting(appSetting);
EzySimpleAppContext appContext = new EzySimpleAppContext();
appContext.setApp(app);
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
EzySimpleAppsSetting appsSetting = new EzySimpleAppsSetting();
appsSetting.setItem(appSetting);
zoneSetting.setApplications(appsSetting);
zoneContext.addAppContext(appSetting, appContext);
EzySimpleZone zone = new EzySimpleZone();
zone.setSetting(zoneSetting);
zoneContext.setZone(zone);
EzyAppsStarter starter = new EzyAppsStarter.Builder().zoneContext(zoneContext).appClassLoaders(loaders).enableAppClassLoader(false).classLoader(Thread.currentThread().getContextClassLoader()).build();
// when
starter.start();
// then
Asserts.assertNotNull(app.getEntry());
}
use of com.tvd12.ezyfoxserver.EzySimpleZone in project ezyfox-server by youngmonkeys.
the class EzyPluginsStarterTest method newAppEntryLoaderArgsNotNullTest.
@Test
public void newAppEntryLoaderArgsNotNullTest() {
// given
EzySimpleZoneContext zoneContext = EzyZoneContextsTest.newDefaultZoneContext();
EzySimplePlugin plugin = new EzySimplePlugin();
EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
pluginSetting.setName("abc");
pluginSetting.setEntryLoader(InternalPluginEntryLoader.class);
pluginSetting.setEntryLoaderArgs(new String[] { "Hello" });
plugin.setSetting(pluginSetting);
EzySimplePluginContext pluginContext = new EzySimplePluginContext();
pluginContext.setPlugin(plugin);
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
EzySimplePluginsSetting pluginsSetting = new EzySimplePluginsSetting();
pluginsSetting.setItem(pluginSetting);
zoneSetting.setPlugins(pluginsSetting);
zoneContext.addPluginContext(pluginSetting, pluginContext);
EzySimpleZone zone = new EzySimpleZone();
zone.setSetting(zoneSetting);
zoneContext.setZone(zone);
EzyPluginsStarter starter = new EzyPluginsStarter.Builder().zoneContext(zoneContext).build();
// when
starter.start();
// then
Asserts.assertNotNull(plugin.getEntry());
}
use of com.tvd12.ezyfoxserver.EzySimpleZone in project ezyfox-server by youngmonkeys.
the class EzyDefaultPluginEntryTest method test.
@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);
EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
pluginSetting.setName("test");
pluginSetting.setActiveProfiles("hello,world");
pluginSetting.setPackageName("x.z.y");
EzyEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
EzyEventControllers eventControllers = EzyEventControllersImpl.create(eventControllersSetting);
EzySimplePlugin plugin = new EzySimplePlugin();
plugin.setSetting(pluginSetting);
plugin.setEventControllers(eventControllers);
ScheduledExecutorService pluginScheduledExecutorService = new EzyErrorScheduledExecutorService("not implement");
EzySimplePluginContext pluginContext = new EzySimplePluginContext();
pluginContext.setPlugin(plugin);
pluginContext.setParent(zoneContext);
pluginContext.setExecutorService(pluginScheduledExecutorService);
pluginContext.init();
EzySimplePluginEntry entry = new EzyPluginEntryEx();
entry.config(pluginContext);
entry.start();
handleClientRequest(pluginContext);
entry.destroy();
}
Aggregations