use of com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting.EzySimpleListenEvents 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");
}
use of com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting.EzySimpleListenEvents in project ezyfox-server by youngmonkeys.
the class EzySimplePluginSettingTest method test.
@Test
public void test() {
EzySimplePluginSetting setting = new EzySimplePluginSetting();
setting.setZoneId(1);
assert setting.getZoneId() == 1;
setting.setHomePath("home");
assert setting.getHomePath().equals("home");
setting.setName("name");
setting.setFolder("folder");
assert setting.getFolder().equals("folder");
setting.setFolder("");
assert setting.getFolder().equals("name");
System.out.println(setting.getLocation());
System.out.println(setting.getConfigFile());
// noinspection EqualsWithItself
assert setting.equals(setting);
setting.setPriority(1);
setting.setListenEvents(new EzySimpleListenEvents());
}
use of com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting.EzySimpleListenEvents in project ezyfox-server by youngmonkeys.
the class EzyBroadcastPluginsEventImplTest method firePluginEventExceptionCase.
@Test
public void firePluginEventExceptionCase() {
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);
EzyPlugin plugin = mock(EzyPlugin.class);
when(pluginContext.getPlugin()).thenReturn(plugin);
EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
when(plugin.getSetting()).thenReturn(pluginSetting);
EzySimpleListenEvents listenEvents = pluginSetting.getListenEvents();
listenEvents.setEvent("SERVER_READY");
doThrow(new IllegalStateException("server maintain")).when(pluginContext).handleEvent(any(), any());
when(zoneContext.getPluginContexts()).thenReturn(Lists.newArrayList(pluginContext));
EzyBroadcastPluginsEventImpl cmd = new EzyBroadcastPluginsEventImpl(zoneContext);
EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
cmd.fire(EzyEventType.SERVER_READY, event, true);
}
Aggregations