use of com.tvd12.ezyfoxserver.EzyPlugin 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.EzyPlugin in project ezyfox-server by youngmonkeys.
the class EzySimplePluginEntryTest method notAllowRequestTest.
@Test
public void notAllowRequestTest() {
// 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);
NotAllowRequestEntry sut = new NotAllowRequestEntry();
// 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.EzyPlugin in project ezyfox-server by youngmonkeys.
the class EzyRequestPluginControllerTest method test.
@Test
public void test() {
EzyRequestPluginController controller = new EzyRequestPluginController();
EzyServerContext serverContext = mock(EzyServerContext.class);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
when(serverContext.getZoneContext(1)).thenReturn(zoneContext);
EzyPluginContext pluginContext = mock(EzyPluginContext.class);
when(zoneContext.getPluginContext(1)).thenReturn(pluginContext);
EzyPlugin plugin = mock(EzyPlugin.class);
when(pluginContext.getPlugin()).thenReturn(plugin);
EzyPluginRequestController requestController = mock(EzyPluginRequestController.class);
when(plugin.getRequestController()).thenReturn(requestController);
EzySimpleRequestPluginRequest request = new EzySimpleRequestPluginRequest();
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
user.setZoneId(1);
user.setId(1);
user.setName("test");
request.setSession(session);
request.setUser(user);
EzyArray array = EzyEntityFactory.newArrayBuilder().append(1).append(EzyEntityFactory.newArrayBuilder()).build();
request.deserializeParams(array);
controller.handle(serverContext, request);
}
use of com.tvd12.ezyfoxserver.EzyPlugin in project ezyfox-server by youngmonkeys.
the class EzyPluginsStarter method startPlugin.
protected void startPlugin(String pluginName) {
try {
logger.debug("plugin: {} loading...", pluginName);
EzyPluginContext context = zoneContext.getPluginContext(pluginName);
EzyPlugin plugin = context.getPlugin();
EzyPluginEntry entry = startPlugin(pluginName, newPluginEntryLoader(pluginName));
((EzyEntryAware) plugin).setEntry(entry);
logger.debug("plugin: {} loaded", pluginName);
} catch (Exception e) {
logger.error("can not start plugin: {}", pluginName, e);
}
}
use of com.tvd12.ezyfoxserver.EzyPlugin in project ezyfox-server by youngmonkeys.
the class EzyBroadcastPluginsEventImplTest method firePluginEventExceptionCase.
@Test
public void firePluginEventExceptionCase() {
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
EzyZone zone = mock(EzyZone.class);
when(zoneContext.getZone()).thenReturn(zone);
EzySimpleZoneSetting setting = new EzySimpleZoneSetting();
setting.setName("test");
when(zone.getSetting()).thenReturn(setting);
EzyPluginContext pluginContext = mock(EzyPluginContext.class);
EzyPlugin plugin = mock(EzyPlugin.class);
when(pluginContext.getPlugin()).thenReturn(plugin);
EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
when(plugin.getSetting()).thenReturn(pluginSetting);
EzySimpleListenEvents listenEvents = pluginSetting.getListenEvents();
listenEvents.setEvent("SERVER_READY");
doThrow(new IllegalStateException("server maintain")).when(pluginContext).handleEvent(any(), any());
when(zoneContext.getPluginContexts()).thenReturn(Lists.newArrayList(pluginContext));
EzyBroadcastPluginsEventImpl cmd = new EzyBroadcastPluginsEventImpl(zoneContext);
EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
cmd.fire(EzyEventType.SERVER_READY, event, true);
}
Aggregations