Search in sources :

Example 16 with EzySimpleApplication

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

the class EzyAppHandleExceptionImplTest method handleExceptionWithEmptyHandlers.

@Test
public void handleExceptionWithEmptyHandlers() {
    // given
    EzySimpleApplication app = new EzySimpleApplication();
    EzySimpleAppSetting setting = new EzySimpleAppSetting();
    String appName = RandomUtil.randomShortAlphabetString();
    setting.setName(appName);
    app.setSetting(setting);
    EzyAppHandleExceptionImpl sut = new EzyAppHandleExceptionImpl(app);
    Logger logger = mock(Logger.class);
    FieldUtil.setFieldValue(sut, "logger", logger);
    // when
    Exception exception = new IllegalArgumentException("one");
    sut.handle(Thread.currentThread(), exception);
    // then
    verify(logger, times(1)).info("app: {} has no handler for exception:", appName, exception);
}
Also used : EzySimpleAppSetting(com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting) EzySimpleApplication(com.tvd12.ezyfoxserver.EzySimpleApplication) EzyAppHandleExceptionImpl(com.tvd12.ezyfoxserver.command.impl.EzyAppHandleExceptionImpl) EzyStrings.exceptionToSimpleString(com.tvd12.ezyfox.io.EzyStrings.exceptionToSimpleString) Logger(org.slf4j.Logger) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 17 with EzySimpleApplication

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

the class EzyAppSetupImplTest method test.

@Test
public void test() {
    EzySimpleApplication app = new EzySimpleApplication();
    EzyAppSetupImpl cmd = new EzyAppSetupImpl(app);
    cmd.setRequestController((ctx, event) -> {
    });
}
Also used : EzySimpleApplication(com.tvd12.ezyfoxserver.EzySimpleApplication) EzyAppSetupImpl(com.tvd12.ezyfoxserver.command.impl.EzyAppSetupImpl) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 18 with EzySimpleApplication

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

the class EzyAppFireEventImplTest method test.

@Test
public void test() {
    EzySimpleAppSetting app = mock(EzySimpleAppSetting.class);
    EzyAppContext context = mock(EzyAppContext.class);
    EzySimpleApplication application = new EzySimpleApplication();
    application.setEventControllers(new EzyEventControllersImpl());
    application.setSetting(app);
    when(context.getApp()).thenReturn(application);
}
Also used : EzySimpleAppSetting(com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting) EzySimpleApplication(com.tvd12.ezyfoxserver.EzySimpleApplication) EzyEventControllersImpl(com.tvd12.ezyfoxserver.wrapper.impl.EzyEventControllersImpl) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) BaseCoreTest(com.tvd12.ezyfoxserver.testing.BaseCoreTest) Test(org.testng.annotations.Test)

Example 19 with EzySimpleApplication

use of com.tvd12.ezyfoxserver.EzySimpleApplication 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 20 with EzySimpleApplication

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

the class EzyServerContextsTest method test.

@Test
public void test() {
    EzySimpleApplication app = new EzySimpleApplication();
    app.setUserManager(EzyAppUserManagerImpl.builder().maxUsers(1).appName("test").build());
    EzyAppContext appContext = mock(EzyAppContext.class);
    when(appContext.getApp()).thenReturn(app);
    EzySimpleUser user = new EzySimpleUser();
    assert !EzyServerContexts.containsUser(appContext, user);
    assert !EzyServerContexts.containsUser(appContext, "test");
    assert EzyServerContexts.getUserManager(appContext) != null;
}
Also used : EzySimpleApplication(com.tvd12.ezyfoxserver.EzySimpleApplication) EzySimpleUser(com.tvd12.ezyfoxserver.entity.EzySimpleUser) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Aggregations

EzySimpleApplication (com.tvd12.ezyfoxserver.EzySimpleApplication)22 Test (org.testng.annotations.Test)19 BaseTest (com.tvd12.test.base.BaseTest)13 EzySimpleAppSetting (com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting)12 EzySimpleAppContext (com.tvd12.ezyfoxserver.context.EzySimpleAppContext)11 EzySimpleZoneContext (com.tvd12.ezyfoxserver.context.EzySimpleZoneContext)9 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)8 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)7 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)6 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)6 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)6 EzyAppUserManager (com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager)6 EzyEventControllers (com.tvd12.ezyfoxserver.wrapper.EzyEventControllers)6 EzyErrorScheduledExecutorService (com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService)5 EzySimpleAppEntry (com.tvd12.ezyfoxserver.support.entry.EzySimpleAppEntry)5 EzyAppsStarter (com.tvd12.ezyfoxserver.EzyAppsStarter)4 EzyAppRequestController (com.tvd12.ezyfoxserver.app.EzyAppRequestController)4 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)4 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)4 EzySimpleAppsSetting (com.tvd12.ezyfoxserver.setting.EzySimpleAppsSetting)4