Search in sources :

Example 6 with EzyEventController

use of com.tvd12.ezyfoxserver.controller.EzyEventController in project ezyfox-server by youngmonkeys.

the class EzySimpleAppEntryTest method test.

@SuppressWarnings({ "rawtypes" })
@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");
    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);
    List<EzyEventController> serverReadyHandlers = appContext.getApp().getEventControllers().getControllers(EzyEventType.SERVER_READY);
    Assert.assertEquals(serverReadyHandlers.size(), 2);
    Assert.assertEquals(serverReadyHandlers.get(0).getClass(), ServerReadyEventHandler2.class);
    Assert.assertEquals(serverReadyHandlers.get(1).getClass(), ServerReadyEventHandler.class);
    List<EzyEventController> loginEventHandlers = appContext.getApp().getEventControllers().getControllers(EzyEventType.USER_LOGIN);
    Assert.assertEquals(loginEventHandlers.size(), 1);
    Assert.assertEquals(loginEventHandlers.get(0).getClass(), AppUserLoginRequestController.class);
    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) EzySimpleZone(com.tvd12.ezyfoxserver.EzySimpleZone) EzySimpleApplication(com.tvd12.ezyfoxserver.EzySimpleApplication) EzyEventControllers(com.tvd12.ezyfoxserver.wrapper.EzyEventControllers) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) EzySimpleAppContext(com.tvd12.ezyfoxserver.context.EzySimpleAppContext) EzyEventController(com.tvd12.ezyfoxserver.controller.EzyEventController) EzySimpleAppEntry(com.tvd12.ezyfoxserver.support.entry.EzySimpleAppEntry) Test(org.testng.annotations.Test)

Example 7 with EzyEventController

use of com.tvd12.ezyfoxserver.controller.EzyEventController in project ezyfox-server by youngmonkeys.

the class EzySimplePluginEntryTest method test.

@SuppressWarnings("rawtypes")
@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");
    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);
    List<EzyEventController> loginEventHandlers = pluginContext.getPlugin().getEventControllers().getControllers(EzyEventType.USER_LOGIN);
    Assert.assertEquals(loginEventHandlers.size(), 1);
    Assert.assertEquals(loginEventHandlers.get(0).getClass(), PluginUserLoginRequestController.class);
    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) EzyEventController(com.tvd12.ezyfoxserver.controller.EzyEventController) EzySimplePluginEntry(com.tvd12.ezyfoxserver.support.entry.EzySimplePluginEntry) Test(org.testng.annotations.Test)

Aggregations

EzyEventController (com.tvd12.ezyfoxserver.controller.EzyEventController)5 Test (org.testng.annotations.Test)5 EzyEventControllers (com.tvd12.ezyfoxserver.wrapper.EzyEventControllers)3 BaseTest (com.tvd12.test.base.BaseTest)3 EzyErrorScheduledExecutorService (com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService)2 EzyEventHandler (com.tvd12.ezyfox.core.annotation.EzyEventHandler)2 EzySimplePlugin (com.tvd12.ezyfoxserver.EzySimplePlugin)2 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)2 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)2 EzySetup (com.tvd12.ezyfoxserver.command.EzySetup)2 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)2 EzySimpleZoneContext (com.tvd12.ezyfoxserver.context.EzySimpleZoneContext)2 EzyEventControllersImpl (com.tvd12.ezyfoxserver.wrapper.impl.EzyEventControllersImpl)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 EzySimpleApplication (com.tvd12.ezyfoxserver.EzySimpleApplication)1 EzyPluginSetupImpl (com.tvd12.ezyfoxserver.command.impl.EzyPluginSetupImpl)1 EzyEventType (com.tvd12.ezyfoxserver.constant.EzyEventType)1 EzySimpleAppContext (com.tvd12.ezyfoxserver.context.EzySimpleAppContext)1 EzySimplePluginContext (com.tvd12.ezyfoxserver.context.EzySimplePluginContext)1 EzySimpleAppEntry (com.tvd12.ezyfoxserver.support.entry.EzySimpleAppEntry)1