use of com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting in project ezyfox-server by youngmonkeys.
the class EzyAppFireEventImplTest method test.
@Test
public void test() {
EzySimpleAppSetting app = mock(EzySimpleAppSetting.class);
EzyAppContext context = mock(EzyAppContext.class);
EzySimpleApplication application = new EzySimpleApplication();
application.setEventControllers(new EzyEventControllersImpl());
application.setSetting(app);
when(context.getApp()).thenReturn(application);
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting 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();
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting in project ezyfox-server by youngmonkeys.
the class EzySimpleAppContextTest method test.
@Test
public void test() {
EzyServerContext serverContext = mock(EzyServerContext.class);
EzySimpleZone zone = new EzySimpleZone();
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
when(zoneContext.getZone()).thenReturn(zone);
when(zoneContext.getParent()).thenReturn(serverContext);
EzySimpleApplication app = new EzySimpleApplication();
EzySimpleAppSetting setting = new EzySimpleAppSetting();
app.setSetting(setting);
EzySimpleAppContext appContext = new EzySimpleAppContext();
appContext.setParent(zoneContext);
appContext.setApp(app);
appContext.init();
Asserts.assertNull(appContext.get(Void.class));
// noinspection EqualsWithItself
assert appContext.equals(appContext);
EzySimpleAppContext appContext2 = new EzySimpleAppContext();
assert !appContext.equals(appContext2);
assert appContext.cmd(EzyAppResponse.class) != null;
Asserts.assertNull(appContext.cmd(Void.class));
EzySimpleUser user = new EzySimpleUser();
user.setName("test");
EzyAbstractSession session = spy(EzyAbstractSession.class);
user.addSession(session);
EzyData data = EzyEntityFactory.newArrayBuilder().build();
appContext.send(data, session, false);
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
appContext.setExecutorService(executorService);
assert appContext.getExecutorService() != null;
appContext.handleException(Thread.currentThread(), new Exception());
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting 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.setting.EzySimpleAppSetting 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());
}
Aggregations