use of com.tvd12.ezyfoxserver.setting.EzySimpleEventControllersSetting in project ezyfox-server by youngmonkeys.
the class EzySimpleAppEntryTest method test2.
@Test
public void test2() 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);
EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
appSetting.setName("test");
EzyAppUserManager appUserManager = EzyAppUserManagerImpl.builder().build();
EzyEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
EzyEventControllers eventControllers = EzyEventControllersImpl.create(eventControllersSetting);
EzySimpleApplication application = new EzySimpleApplication();
application.setSetting(appSetting);
application.setUserManager(appUserManager);
application.setEventControllers(eventControllers);
ScheduledExecutorService appScheduledExecutorService = new EzyErrorScheduledExecutorService("not implement");
EzySimpleAppContext appContext = new EzySimpleAppContext();
appContext.setApp(application);
appContext.setParent(zoneContext);
appContext.setExecutorService(appScheduledExecutorService);
appContext.init();
EzySimpleAppEntry entry = new EzyAppEntryEx2();
entry.config(appContext);
entry.start();
entry.destroy();
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleEventControllersSetting 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.EzySimpleEventControllersSetting in project ezyfox-server by youngmonkeys.
the class EzyEventControllersImplTest method test.
@Test
public void test() {
EzySimpleEventControllersSetting controllersSetting = new EzySimpleEventControllersSetting();
EzySimpleEventControllerSetting setting1 = new EzySimpleEventControllerSetting();
setting1.setEventType(EzyEventType.SERVER_READY.toString());
setting1.setController(EventController1.class.getName());
controllersSetting.setItem(setting1);
EzyEventControllers controllers = EzyEventControllersImpl.create(controllersSetting);
controllers.addController(EzyEventType.SERVER_INITIALIZING, new EventController2());
controllers.destroy();
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleEventControllersSetting in project ezyfox-server by youngmonkeys.
the class EzyUserRequestAppSingletonControllerTest method test.
@Test
public void test() throws Exception {
EzyRequestHandlerImplementer.setDebug(true);
EzyExceptionHandlerImplementer.setDebug(true);
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);
EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
appSetting.setName("test");
EzyAppUserManager appUserManager = EzyAppUserManagerImpl.builder().build();
EzyEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
EzyEventControllers eventControllers = EzyEventControllersImpl.create(eventControllersSetting);
EzySimpleApplication application = new EzySimpleApplication();
application.setSetting(appSetting);
application.setUserManager(appUserManager);
application.setEventControllers(eventControllers);
ScheduledExecutorService appScheduledExecutorService = new EzyErrorScheduledExecutorService("not implement");
EzySimpleAppContext appContext = new EzySimpleAppContext();
appContext.setApp(application);
appContext.setParent(zoneContext);
appContext.setExecutorService(appScheduledExecutorService);
appContext.init();
EzySimpleAppEntry entry = new EzyAppEntryEx();
entry.config(appContext);
entry.start();
handleClientRequest(appContext);
EzyBeanContext beanContext = appContext.get(EzyBeanContext.class);
EzyRequestCommandManager requestCommandManager = beanContext.getSingleton(EzyRequestCommandManager.class);
EzyFeatureCommandManager featureCommandManager = beanContext.getSingleton(EzyFeatureCommandManager.class);
Asserts.assertTrue(requestCommandManager.containsCommand("v1.2.2/hello"));
Asserts.assertTrue(requestCommandManager.containsCommand("v122/listener/hello"));
Asserts.assertTrue(requestCommandManager.isManagementCommand("v1.2.2/hello"));
Asserts.assertTrue(requestCommandManager.isPaymentCommand("v1.2.2/hello"));
Asserts.assertEquals(featureCommandManager.getFeatureByCommand("v1.2.2/hello"), "hello.world");
entry.destroy();
}
use of com.tvd12.ezyfoxserver.setting.EzySimpleEventControllersSetting in project ezyfox-server by youngmonkeys.
the class EzyDefaultAppEntryTest 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);
EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
appSetting.setName("test");
appSetting.setActiveProfiles("hello,world");
appSetting.setPackageName("x.z.y");
EzyAppUserManager appUserManager = EzyAppUserManagerImpl.builder().build();
EzyEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
EzyEventControllers eventControllers = EzyEventControllersImpl.create(eventControllersSetting);
EzySimpleApplication application = new EzySimpleApplication();
application.setSetting(appSetting);
application.setUserManager(appUserManager);
application.setEventControllers(eventControllers);
ScheduledExecutorService appScheduledExecutorService = new EzyErrorScheduledExecutorService("not implement");
EzySimpleAppContext appContext = new EzySimpleAppContext();
appContext.setApp(application);
appContext.setParent(zoneContext);
appContext.setExecutorService(appScheduledExecutorService);
appContext.init();
EzySimpleAppEntry entry = new EzyAppEntryEx();
entry.config(appContext);
entry.start();
handleClientRequest(appContext);
entry.destroy();
}
Aggregations