Search in sources :

Example 26 with EzySimpleZone

use of com.tvd12.ezyfoxserver.client.entity.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();
}
Also used : EzySimpleZone(com.tvd12.ezyfoxserver.EzySimpleZone) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 27 with EzySimpleZone

use of com.tvd12.ezyfoxserver.client.entity.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());
}
Also used : EzySimpleAppSetting(com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting) EzySimpleZoneContext(com.tvd12.ezyfoxserver.context.EzySimpleZoneContext) EzyAppsStarter(com.tvd12.ezyfoxserver.EzyAppsStarter) EzySimpleZone(com.tvd12.ezyfoxserver.EzySimpleZone) EzySimpleApplication(com.tvd12.ezyfoxserver.EzySimpleApplication) EzySimpleAppsSetting(com.tvd12.ezyfoxserver.setting.EzySimpleAppsSetting) EzySimpleAppContext(com.tvd12.ezyfoxserver.context.EzySimpleAppContext) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 28 with EzySimpleZone

use of com.tvd12.ezyfoxserver.client.entity.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());
}
Also used : EzySimpleAppSetting(com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting) EzySimpleZoneContext(com.tvd12.ezyfoxserver.context.EzySimpleZoneContext) EzyAppsStarter(com.tvd12.ezyfoxserver.EzyAppsStarter) EzySimpleZone(com.tvd12.ezyfoxserver.EzySimpleZone) EzySimpleApplication(com.tvd12.ezyfoxserver.EzySimpleApplication) EzySimpleAppsSetting(com.tvd12.ezyfoxserver.setting.EzySimpleAppsSetting) EzySimpleAppContext(com.tvd12.ezyfoxserver.context.EzySimpleAppContext) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 29 with EzySimpleZone

use of com.tvd12.ezyfoxserver.client.entity.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());
}
Also used : EzySimpleZone(com.tvd12.ezyfoxserver.EzySimpleZone) EzySimplePluginContext(com.tvd12.ezyfoxserver.context.EzySimplePluginContext) EzySimpleZoneContext(com.tvd12.ezyfoxserver.context.EzySimpleZoneContext) EzySimplePlugin(com.tvd12.ezyfoxserver.EzySimplePlugin) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) EzyPluginsStarter(com.tvd12.ezyfoxserver.EzyPluginsStarter) EzySimplePluginsSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginsSetting) EzySimplePluginSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 30 with EzySimpleZone

use of com.tvd12.ezyfoxserver.client.entity.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();
}
Also used : EzyErrorScheduledExecutorService(com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyErrorScheduledExecutorService(com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzySimpleZoneContext(com.tvd12.ezyfoxserver.context.EzySimpleZoneContext) EzySimplePlugin(com.tvd12.ezyfoxserver.EzySimplePlugin) EzySimpleZone(com.tvd12.ezyfoxserver.EzySimpleZone) EzyEventControllers(com.tvd12.ezyfoxserver.wrapper.EzyEventControllers) EzySimplePluginContext(com.tvd12.ezyfoxserver.context.EzySimplePluginContext) EzySimplePluginEntry(com.tvd12.ezyfoxserver.support.entry.EzySimplePluginEntry) Test(org.testng.annotations.Test)

Aggregations

EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)29 Test (org.testng.annotations.Test)29 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)19 EzySimpleZoneContext (com.tvd12.ezyfoxserver.context.EzySimpleZoneContext)16 EzySimpleZoneSetting (com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting)16 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)14 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)13 BaseTest (com.tvd12.test.base.BaseTest)12 EzyEventControllers (com.tvd12.ezyfoxserver.wrapper.EzyEventControllers)11 EzyZoneUserManager (com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager)11 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)11 EzyErrorScheduledExecutorService (com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService)10 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)10 EzyStatistics (com.tvd12.ezyfoxserver.statistics.EzyStatistics)9 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)9 EzySimpleApplication (com.tvd12.ezyfoxserver.EzySimpleApplication)8 EzySimpleAppContext (com.tvd12.ezyfoxserver.context.EzySimpleAppContext)8 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)8 EzySimplePlugin (com.tvd12.ezyfoxserver.EzySimplePlugin)7 EzySimplePluginContext (com.tvd12.ezyfoxserver.context.EzySimplePluginContext)7