use of com.tvd12.ezyfoxserver.wrapper.EzyEventControllers in project ezyfox-server by youngmonkeys.
the class EzyPluginSetupImplTest method addEventControllerTest.
@SuppressWarnings("rawtypes")
@Test
public void addEventControllerTest() {
// given
EzySimplePlugin plugin = new EzySimplePlugin();
EzyEventControllers eventControllers = mock(EzyEventControllers.class);
plugin.setEventControllers(eventControllers);
EzyPluginSetupImpl sut = new EzyPluginSetupImpl(plugin);
EzyEventController controller = mock(EzyEventController.class);
// when
sut.addEventController(EzyEventType.SERVER_INITIALIZING, controller);
// then
verify(eventControllers, times(1)).addController(EzyEventType.SERVER_INITIALIZING, controller);
}
use of com.tvd12.ezyfoxserver.wrapper.EzyEventControllers in project ezyfox-server by youngmonkeys.
the class EzyChildComponentTest method test.
@Test
public void test() {
EzyChildComponent component = spy(EzyChildComponent.class);
EzyEntry entry = mock(EzyEntry.class);
component.setEntry(entry);
assert component.getEntry() == entry;
EzyEventControllers eventControllers = mock(EzyEventControllers.class);
component.setEventControllers(eventControllers);
assert component.getEventControllers() == eventControllers;
component.destroy();
component.destroy();
}
use of com.tvd12.ezyfoxserver.wrapper.EzyEventControllers in project ezyfox-server by youngmonkeys.
the class EzySimplePluginEntryTest 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);
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 EzyPluginEntryEx2();
entry.config(pluginContext);
entry.start();
entry.destroy();
}
use of com.tvd12.ezyfoxserver.wrapper.EzyEventControllers in project ezyfox-server by youngmonkeys.
the class EzyNioServerBootstrapTest method test.
@Test
public void test() throws Exception {
SSLContext sslContext = SSLContext.getDefault();
EzyResponseApi responseApi = mock(EzyResponseApi.class);
EzyStreamingApi streamingApi = mock(EzyStreamingApi.class);
EzySocketStreamQueue streamQueue = new EzyBlockingSocketStreamQueue();
EzyHandlerGroupManager handlerGroupManager = mock(EzyHandlerGroupManager.class);
EzySessionTicketsQueue socketSessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
EzySessionTicketsQueue websocketSessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
EzySocketDisconnectionQueue socketDisconnectionQueue = new EzySocketDisconnectionQueue() {
final BlockingQueue<EzySocketDisconnection> queue = new LinkedBlockingQueue<>();
@Override
public EzySocketDisconnection take() throws InterruptedException {
return queue.take();
}
@Override
public int size() {
return 0;
}
@Override
public void remove(EzySocketDisconnection disconnection) {
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public void clear() {
}
@Override
public boolean add(EzySocketDisconnection disconnection) {
return false;
}
};
EzySimpleConfig config = new EzySimpleConfig();
EzySimpleSettings settings = new EzySimpleSettings();
EzySimpleStreamingSetting streaming = settings.getStreaming();
streaming.setEnable(true);
settings.getUdp().setActive(true);
EzySimpleServer server = new EzySimpleServer();
EzyServerControllers serverControllers = EzyServerControllersImpl.builder().build();
server.setControllers(serverControllers);
EzyEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
EzyEventControllers eventControllers = EzyEventControllersImpl.create(eventControllersSetting);
server.setEventControllers(eventControllers);
server.setConfig(config);
server.setSettings(settings);
EzySimpleServerContext serverContext = new EzySimpleServerContext();
serverContext.setProperty(EzySocketUserRemovalQueue.class, new EzyBlockingSocketUserRemovalQueue());
serverContext.setServer(server);
serverContext.init();
ExBootstrap localBootstrap = new ExBootstrap(new EzyBootstrap.Builder().context(serverContext));
EzyNioServerBootstrap bootstrap = new EzyNioServerBootstrap();
bootstrap.setContext(serverContext);
bootstrap.setLocalBootstrap(localBootstrap);
bootstrap.setSslContext(sslContext);
bootstrap.setResponseApi(responseApi);
bootstrap.setStreamingApi(streamingApi);
bootstrap.setStreamQueue(streamQueue);
bootstrap.setHandlerGroupManager(handlerGroupManager);
bootstrap.setSocketSessionTicketsQueue(socketSessionTicketsQueue);
bootstrap.setWebsocketSessionTicketsQueue(websocketSessionTicketsQueue);
bootstrap.setSocketDisconnectionQueue(socketDisconnectionQueue);
bootstrap.setSocketSessionTicketsRequestQueues(sessionTicketsRequestQueues);
bootstrap.start();
bootstrap.destroy();
bootstrap.destroy();
}
use of com.tvd12.ezyfoxserver.wrapper.EzyEventControllers in project ezyfox-server by youngmonkeys.
the class EzyUserRequestPluginSingletonControllerTest 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);
EzyZoneUserManager zoneUserManager = EzyZoneUserManagerImpl.builder().zoneName("test").build();
zone.setUserManager(zoneUserManager);
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);
EzyBeanContext beanContext = pluginContext.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.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();
}
Aggregations