use of com.tvd12.ezyfoxserver.EzySimplePlugin in project ezyfox-server by youngmonkeys.
the class EzyPluginInfoControllerTest method test.
@Test
public void test() {
EzyPluginInfoController controller = new EzyPluginInfoController();
EzyServerContext serverContext = mock(EzyServerContext.class);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
when(serverContext.getZoneContext(1)).thenReturn(zoneContext);
EzySimplePluginInfoRequest request = new EzySimplePluginInfoRequest();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
user.setZoneId(1);
request.setSession(session);
request.setUser(user);
EzyArray data = EzyEntityFactory.newArrayBuilder().append("test").build();
request.deserializeParams(data);
controller.handle(serverContext, request);
EzyPluginContext pluginContext = mock(EzyPluginContext.class);
EzySimplePlugin plugin = new EzySimplePlugin();
EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
plugin.setSetting(pluginSetting);
when(pluginContext.getPlugin()).thenReturn(plugin);
when(zoneContext.getPluginContext("test")).thenReturn(pluginContext);
controller.handle(serverContext, request);
}
use of com.tvd12.ezyfoxserver.EzySimplePlugin 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.EzySimplePlugin 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();
}
use of com.tvd12.ezyfoxserver.EzySimplePlugin in project ezyfox-server by youngmonkeys.
the class EzyUserRequestPluginSingletonControllerTest method handleClientRequest.
private void handleClientRequest(EzyPluginContext context) {
EzySimplePlugin plugin = (EzySimplePlugin) context.getPlugin();
EzyPluginRequestController requestController = plugin.getRequestController();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
EzyArray data = EzyEntityFactory.newArrayBuilder().append("hello").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
EzyUserRequestPluginEvent event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("responseFactoryTest").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("no command").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("hello2").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("plugin/c_hello").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestSend").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestNotSend").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("plugin/requestException4").append(EzyEntityFactory.newObjectBuilder().append("who", "Mr.Young Monkey!")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
try {
data = EzyEntityFactory.newArrayBuilder().append("exception").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
} catch (Exception e) {
assert e instanceof IllegalStateException;
}
}
use of com.tvd12.ezyfoxserver.EzySimplePlugin in project ezyfox-server by youngmonkeys.
the class EzyDefaultPluginEntryTest method handleClientRequest.
private void handleClientRequest(EzyPluginContext context) {
EzySimplePlugin plugin = (EzySimplePlugin) context.getPlugin();
EzyPluginRequestController requestController = plugin.getRequestController();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
EzyArray data = EzyEntityFactory.newArrayBuilder().append("chat").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
EzyUserRequestPluginEvent event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("chat").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("no command").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noUser").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noSession").append(EzyEntityFactory.newObjectBuilder().append("message", "greet")).build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("noDataBinding").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestSend").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("badRequestNoSend").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
data = EzyEntityFactory.newArrayBuilder().append("exception").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
try {
requestController.handle(context, event);
} catch (Exception e) {
assert e instanceof IllegalStateException;
}
data = EzyEntityFactory.newArrayBuilder().append("plugin").build();
event = new EzySimpleUserRequestPluginEvent(user, session, data);
requestController.handle(context, event);
}
Aggregations