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);
}
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);
}
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();
}
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();
}
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"));
}
Aggregations