Search in sources :

Example 1 with EzySimplePluginsSetting

use of com.tvd12.ezyfoxserver.setting.EzySimplePluginsSetting in project ezyfox-server by youngmonkeys.

the class EzyPluginsTest method test.

@Test(expectedExceptions = { IllegalArgumentException.class })
public void test() {
    EzySimplePluginsSetting plugins = new EzySimplePluginsSetting();
    plugins.getPluginById(-1);
}
Also used : EzySimplePluginsSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginsSetting) BaseCoreTest(com.tvd12.ezyfoxserver.testing.BaseCoreTest) Test(org.testng.annotations.Test)

Example 2 with EzySimplePluginsSetting

use of com.tvd12.ezyfoxserver.setting.EzySimplePluginsSetting in project ezyfox-server by youngmonkeys.

the class EzyPluginsTest method test.

@Test(expectedExceptions = { IllegalArgumentException.class })
public void test() {
    EzySimplePluginsSetting plugins = new EzySimplePluginsSetting();
    plugins.getPluginByName("zzz");
}
Also used : EzySimplePluginsSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginsSetting) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 3 with EzySimplePluginsSetting

use of com.tvd12.ezyfoxserver.setting.EzySimplePluginsSetting in project ezyfox-server by youngmonkeys.

the class EzyZoneSettingBuilderTest method test.

@Test
public void test() {
    EzySimpleAppSetting appSetting = new EzyAppSettingBuilder().configFile("config.properties").entryLoader(TestAppEntryLoader.class).entryLoaderArgs(new String[] { "hello" }).maxUsers(100).name("test").threadPoolSize(3).build();
    EzySimpleAppsSetting appsSetting = new EzySimpleAppsSetting();
    EzySimpleListenEvents listenEvents = new EzySimpleListenEvents();
    EzySimplePluginSetting pluginSetting = new EzyPluginSettingBuilder().configFile("config.properties").entryLoader(TestPluginEntryLoader.class).name("test").threadPoolSize(3).priority(1).listenEvents(listenEvents).addListenEvent(EzyEventType.USER_LOGIN).addListenEvent(EzyEventType.USER_LOGIN.toString()).build();
    EzySimplePluginsSetting pluginsSetting = new EzySimplePluginsSetting();
    EzySimpleStreamingSetting streamingSetting = new EzySimpleStreamingSetting();
    EzySimpleEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
    EzySimpleUserManagementSetting userManagementSetting = new EzyUserManagementSettingBuilder().allowChangeSession(true).allowGuestLogin(true).guestNamePrefix("Guest#").maxSessionPerUser(3).userMaxIdleTimeInSecond(100).userNamePattern("user#name").build();
    EzySimpleZoneSetting setting = new EzyZoneSettingBuilder().configFile("config.properties").maxUsers(1000).name("test").applications(appsSetting).application(appSetting).plugins(pluginsSetting).plugin(pluginSetting).streaming(streamingSetting).eventControllers(eventControllersSetting).userManagement(userManagementSetting).addEventController(EzyEventType.SERVER_READY, HelloZoneServerReadyController.class).build();
    assertEquals(setting.getConfigFile(), "config.properties");
    assertEquals(setting.getMaxUsers(), 1000);
    assertEquals(setting.getName(), "test");
    assertEquals(setting.getApplications(), appsSetting);
    assertEquals(setting.getPlugins(), pluginsSetting);
    assertEquals(setting.getStreaming(), streamingSetting);
    assertEquals(setting.getEventControllers(), eventControllersSetting);
    assertEquals(setting.getUserManagement(), userManagementSetting);
    appSetting = appsSetting.getAppByName("test");
    assertEquals(appSetting.getConfigFile(true), "config.properties");
    assertEquals(appSetting.getEntryLoader(), TestAppEntryLoader.class.getName());
    assertEquals(appSetting.getFolder(), "test");
    assertEquals(appSetting.getMaxUsers(), 100);
    assertEquals(appSetting.getName(), "test");
    assertEquals(appSetting.getThreadPoolSize(), 3);
    assertEquals(appSetting.getConfigFileInput(), "config.properties");
    pluginSetting = pluginsSetting.getPluginByName("test");
    assertEquals(pluginSetting.getConfigFile(true), "config.properties");
    assertEquals(pluginSetting.getEntryLoader(), TestPluginEntryLoader.class.getName());
    assertEquals(pluginSetting.getFolder(), "test");
    assertEquals(pluginSetting.getName(), "test");
    assertEquals(pluginSetting.getThreadPoolSize(), 3);
    assertEquals(pluginSetting.getPriority(), 1);
    assertEquals(pluginSetting.getListenEvents().getEvents().size(), 1);
    userManagementSetting = setting.getUserManagement();
    assertTrue(userManagementSetting.isAllowChangeSession());
    assertTrue(userManagementSetting.isAllowGuestLogin());
    assertEquals(userManagementSetting.getGuestNamePrefix(), "Guest#");
    assertEquals(userManagementSetting.getMaxSessionPerUser(), 3);
    assertEquals(userManagementSetting.getUserMaxIdleTimeInSecond(), 100);
    assertEquals(userManagementSetting.getUserNamePattern(), "user#name");
}
Also used : EzySimpleListenEvents(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting.EzySimpleListenEvents) Test(org.testng.annotations.Test)

Example 4 with EzySimplePluginsSetting

use of com.tvd12.ezyfoxserver.setting.EzySimplePluginsSetting 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();
}
Also used : EzyAppClassLoader(com.tvd12.ezyfoxserver.ccl.EzyAppClassLoader) HashMap(java.util.HashMap) EzyAppClassLoader(com.tvd12.ezyfoxserver.ccl.EzyAppClassLoader) EzySimpleConfig(com.tvd12.ezyfoxserver.config.EzySimpleConfig) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) File(java.io.File) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 5 with EzySimplePluginsSetting

use of com.tvd12.ezyfoxserver.setting.EzySimplePluginsSetting 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)

Aggregations

Test (org.testng.annotations.Test)5 EzySimplePluginsSetting (com.tvd12.ezyfoxserver.setting.EzySimplePluginsSetting)3 BaseTest (com.tvd12.test.base.BaseTest)3 EzyPluginsStarter (com.tvd12.ezyfoxserver.EzyPluginsStarter)1 EzySimplePlugin (com.tvd12.ezyfoxserver.EzySimplePlugin)1 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)1 EzyAppClassLoader (com.tvd12.ezyfoxserver.ccl.EzyAppClassLoader)1 EzySimpleConfig (com.tvd12.ezyfoxserver.config.EzySimpleConfig)1 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)1 EzyPluginContext (com.tvd12.ezyfoxserver.context.EzyPluginContext)1 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)1 EzySimplePluginContext (com.tvd12.ezyfoxserver.context.EzySimplePluginContext)1 EzySimpleZoneContext (com.tvd12.ezyfoxserver.context.EzySimpleZoneContext)1 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)1 EzySimplePluginSetting (com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting)1 EzySimpleListenEvents (com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting.EzySimpleListenEvents)1 EzySimpleZoneSetting (com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting)1 BaseCoreTest (com.tvd12.ezyfoxserver.testing.BaseCoreTest)1 File (java.io.File)1 HashMap (java.util.HashMap)1