use of com.tvd12.ezyfoxserver.context.EzyServerContext in project ezyfox-server by youngmonkeys.
the class EzyAbstractServerControllerTest method test.
@SuppressWarnings("rawtypes")
@Test
public void test() {
EzySimpleServer server = mock(EzySimpleServer.class);
EzyAppContext appContext = mock(EzyAppContext.class);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
ServerController controller = new ServerController();
EzyServerContext serverContext = mock(EzyServerContext.class);
when(serverContext.getZoneContext("example")).thenReturn(zoneContext);
when(serverContext.getZoneContext(1)).thenReturn(zoneContext);
when(serverContext.getAppContext(1)).thenReturn(appContext);
when(zoneContext.getAppContext("abc")).thenReturn(appContext);
when(zoneContext.getAppContext(1)).thenReturn(appContext);
assertEquals(controller.getAppContext(serverContext, 1), appContext);
when(zoneContext.getAppContext("abc")).thenReturn(appContext);
EzyServerControllers controllers = mock(EzyServerControllers.class);
when(server.getControllers()).thenReturn(controllers);
when(serverContext.getServer()).thenReturn(server);
EzyController ctr = mock(EzyController.class);
when(controllers.getController(EzyCommand.APP_ACCESS)).thenReturn(ctr);
assertEquals(controller.getControllers(serverContext), controllers);
assertEquals(controller.getController(serverContext, EzyCommand.APP_ACCESS), ctr);
}
use of com.tvd12.ezyfoxserver.context.EzyServerContext in project ezyfox-server by youngmonkeys.
the class EzyPluginSendResponseImplTest method test.
@Test
public void test() {
EzyPluginContext pluginContext = mock(EzyPluginContext.class);
EzyPlugin plugin = mock(EzyPlugin.class);
when(pluginContext.getPlugin()).thenReturn(plugin);
EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
pluginSetting.setName("test");
when(plugin.getSetting()).thenReturn(pluginSetting);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
when(pluginContext.getParent()).thenReturn(zoneContext);
EzyServerContext serverContext = mock(EzyServerContext.class);
when(zoneContext.getParent()).thenReturn(serverContext);
EzyPluginSendResponseImpl cmd = new EzyPluginSendResponseImpl(pluginContext);
EzyObject data = EzyEntityFactory.newObjectBuilder().build();
EzyAbstractSession session = spy(EzyAbstractSession.class);
cmd.execute(data, session, false);
cmd.execute(data, Lists.newArrayList(session), false);
}
use of com.tvd12.ezyfoxserver.context.EzyServerContext in project ezyfox-server by youngmonkeys.
the class EzyServerBootstrapTest method test.
@SuppressWarnings("rawtypes")
@Test
public void test() throws Exception {
EzyServerBootstrap bt = new MyTestServerBootstrapBuilder().server(newServer()).build();
bt.destroy();
assert MethodInvoker.create().object(bt).method("getServer").invoke() != null;
assert MethodInvoker.create().object(bt).method("getServerSettings").invoke() != null;
assert MethodInvoker.create().object(bt).method("getHttpSetting").invoke() != null;
assert MethodInvoker.create().object(bt).method("getSocketSetting").invoke() != null;
assert MethodInvoker.create().object(bt).method("getWebSocketSetting").invoke() != null;
EzyServerBootstrap bootstrap = new EzyServerBootstrap() {
@Override
protected void startOtherBootstraps(Runnable callback) {
callback.run();
}
};
EzyServerContext serverContext = mock(EzyServerContext.class);
EzySimpleServer server = new EzySimpleServer();
EzySimpleConfig config = new EzySimpleConfig();
server.setConfig(config);
when(serverContext.getServer()).thenReturn(server);
EzySimpleSettings settings = new EzySimpleSettings();
server.setSettings(settings);
EzySessionManager sessionManager = new ExEzySimpleSessionManager.Builder().objectFactory(() -> spy(EzyAbstractSession.class)).build();
server.setSessionManager(sessionManager);
EzyBootstrap localBootstrap = EzyBootstrap.builder().context(serverContext).build();
bootstrap.setContext(serverContext);
bootstrap.setLocalBootstrap(localBootstrap);
bootstrap.start();
}
use of com.tvd12.ezyfoxserver.context.EzyServerContext in project ezyfox-server by youngmonkeys.
the class EzyLoginController method responseLoginError.
protected void responseLoginError(EzyServerContext ctx, EzySession session, EzyILoginError error) {
EzyResponse response = newLoginErrorResponse(error);
ctx.send(response, session, false);
}
use of com.tvd12.ezyfoxserver.context.EzyServerContext in project ezyfox-server by youngmonkeys.
the class EzyPingController method handle.
@Override
public void handle(EzyServerContext ctx, EzyPingRequest request) {
EzyResponse response = EzyPongResponse.getInstance();
EzySession session = request.getSession();
ctx.send(response, session, false);
}
Aggregations