Search in sources :

Example 81 with EzyServerContext

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

the class EzySimplePluginEntryTest method scanPackages.

@Test
public void scanPackages() {
    // given
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyPluginSetup pluginSetup = mock(EzyPluginSetup.class);
    EzyPlugin plugin = mock(EzyPlugin.class);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    EzyPluginSetting pluginSetting = mock(EzyPluginSetting.class);
    when(plugin.getSetting()).thenReturn(pluginSetting);
    InternalPluginEntry sut = new InternalPluginEntry();
    // when
    when(pluginContext.get(ScheduledExecutorService.class)).thenReturn(executorService);
    when(pluginContext.getParent()).thenReturn(zoneContext);
    when(zoneContext.getParent()).thenReturn(serverContext);
    when(pluginContext.get(EzyPluginSetup.class)).thenReturn(pluginSetup);
    sut.config(pluginContext);
    // then
    EzyBeanContext beanContext = sut.beanContext;
    MongoConfig mongoConfig = (MongoConfig) beanContext.getBean(MongoConfig.class);
    Set<String> expectedPackages = Sets.newHashSet(EzySupportConstants.DEFAULT_PACKAGE_TO_SCAN, "com.tvd12.ezyfoxserver.support.v120.test.entry");
    Asserts.assertEquals(expectedPackages, mongoConfig.packagesToScan);
    Singleton singleton = (Singleton) beanContext.getBean(Singleton.class);
    Asserts.assertNotNull(singleton);
}
Also used : EzyPluginSetup(com.tvd12.ezyfoxserver.command.EzyPluginSetup) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzySingleton(com.tvd12.ezyfox.bean.annotation.EzySingleton) Test(org.testng.annotations.Test)

Example 82 with EzyServerContext

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

the class EzySimplePluginEntryTest method disallowRequestTest.

@Test
public void disallowRequestTest() {
    // given
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyPluginSetup pluginSetup = mock(EzyPluginSetup.class);
    EzyPlugin plugin = mock(EzyPlugin.class);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    EzyPluginSetting pluginSetting = mock(EzyPluginSetting.class);
    when(plugin.getSetting()).thenReturn(pluginSetting);
    DisAllowRequestEntry sut = new DisAllowRequestEntry();
    // when
    when(pluginContext.get(ScheduledExecutorService.class)).thenReturn(executorService);
    when(pluginContext.getParent()).thenReturn(zoneContext);
    when(zoneContext.getParent()).thenReturn(serverContext);
    when(pluginContext.get(EzyPluginSetup.class)).thenReturn(pluginSetup);
    sut.config(pluginContext);
    // then
    verify(pluginContext, times(0)).get(EzyPluginSetup.class);
}
Also used : EzyPluginSetup(com.tvd12.ezyfoxserver.command.EzyPluginSetup) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting) Test(org.testng.annotations.Test)

Example 83 with EzyServerContext

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

the class EzyZoneUserManagerImplTest method newZoneUserManager.

private EzyZoneUserManagerImpl newZoneUserManager() {
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    when(serverContext.getZoneContext(1)).thenReturn(zoneContext);
    TestBlockingSocketUserRemovalQueue queue = new TestBlockingSocketUserRemovalQueue();
    EzySimpleUserDelegate userDelegate = new EzySimpleUserDelegate(serverContext, queue);
    return (EzyZoneUserManagerImpl) EzyZoneUserManagerImpl.builder().idleValidationDelay(10).idleValidationInterval(10).idleValidationThreadPoolSize(1).userDelegate(userDelegate).build();
}
Also used : EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzySimpleUserDelegate(com.tvd12.ezyfoxserver.delegate.EzySimpleUserDelegate) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyZoneUserManagerImpl(com.tvd12.ezyfoxserver.wrapper.impl.EzyZoneUserManagerImpl) TestBlockingSocketUserRemovalQueue(com.tvd12.ezyfoxserver.testing.socket.TestBlockingSocketUserRemovalQueue)

Example 84 with EzyServerContext

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

the class EzyNioServerBootstrapTest method startUdpServerBootstrapNotActive.

@Test
public void startUdpServerBootstrapNotActive() {
    // given
    EzySimpleServer server = new EzySimpleServer();
    EzySimpleSettings settings = new EzySimpleSettings();
    settings.getUdp().setActive(false);
    server.setSettings(settings);
    EzyServerContext context = mock(EzyServerContext.class);
    when(context.getServer()).thenReturn(server);
    EzyNioServerBootstrap sut = new EzyNioServerBootstrap();
    sut.setContext(context);
    // when
    MethodUtil.invokeMethod("startUdpServerBootstrap", sut);
    // then
    Asserts.assertNull(FieldUtil.getFieldValue(sut, "udpServerBootstrap"));
    sut.destroy();
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) EzyNioServerBootstrap(com.tvd12.ezyfoxserver.nio.EzyNioServerBootstrap) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 85 with EzyServerContext

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

the class EzyNioServerBootstrapTest method startSocketServerBootstrapNotActive.

@Test
public void startSocketServerBootstrapNotActive() {
    // given
    EzySimpleServer server = new EzySimpleServer();
    EzySimpleSettings settings = new EzySimpleSettings();
    settings.getSocket().setActive(false);
    server.setSettings(settings);
    EzyServerContext context = mock(EzyServerContext.class);
    when(context.getServer()).thenReturn(server);
    EzyNioServerBootstrap sut = new EzyNioServerBootstrap();
    sut.setContext(context);
    // when
    MethodUtil.invokeMethod("startSocketServerBootstrap", sut);
    // then
    Asserts.assertNull(FieldUtil.getFieldValue(sut, "socketServerBootstrap"));
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) EzyNioServerBootstrap(com.tvd12.ezyfoxserver.nio.EzyNioServerBootstrap) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Aggregations

EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)72 Test (org.testng.annotations.Test)67 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)46 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)25 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)25 BaseTest (com.tvd12.test.base.BaseTest)23 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)22 EzyZoneUserManager (com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager)21 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)20 EzyServer (com.tvd12.ezyfoxserver.EzyServer)17 EzySettings (com.tvd12.ezyfoxserver.setting.EzySettings)16 EzyArray (com.tvd12.ezyfox.entity.EzyArray)14 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)14 EzyResponse (com.tvd12.ezyfoxserver.response.EzyResponse)13 BaseCoreTest (com.tvd12.ezyfoxserver.testing.BaseCoreTest)13 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)12 EzyChannel (com.tvd12.ezyfoxserver.socket.EzyChannel)12 EzyZone (com.tvd12.ezyfoxserver.EzyZone)11 EzyController (com.tvd12.ezyfoxserver.controller.EzyController)11 EzyLoggerSetting (com.tvd12.ezyfoxserver.setting.EzyLoggerSetting)11