Search in sources :

Example 61 with EzyZoneContext

use of com.tvd12.ezyfoxserver.context.EzyZoneContext 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);
}
Also used : EzyZone(com.tvd12.ezyfoxserver.EzyZone) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzySimpleListenEvents(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting.EzySimpleListenEvents) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyBroadcastPluginsEventImpl(com.tvd12.ezyfoxserver.command.impl.EzyBroadcastPluginsEventImpl) EzySimpleServerReadyEvent(com.tvd12.ezyfoxserver.event.EzySimpleServerReadyEvent) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) EzyServerReadyEvent(com.tvd12.ezyfoxserver.event.EzyServerReadyEvent) EzySimplePluginSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 62 with EzyZoneContext

use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.

the class EzyBroadcastPluginsEventImplTest method pluginContextsNullCaseTest.

@Test
public void pluginContextsNullCaseTest() {
    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);
    EzyBroadcastPluginsEventImpl cmd = new EzyBroadcastPluginsEventImpl(zoneContext);
    EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
    cmd.fire(EzyEventType.SERVER_READY, event, true);
}
Also used : EzyZone(com.tvd12.ezyfoxserver.EzyZone) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyBroadcastPluginsEventImpl(com.tvd12.ezyfoxserver.command.impl.EzyBroadcastPluginsEventImpl) EzySimpleServerReadyEvent(com.tvd12.ezyfoxserver.event.EzySimpleServerReadyEvent) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) EzyServerReadyEvent(com.tvd12.ezyfoxserver.event.EzyServerReadyEvent) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 63 with EzyZoneContext

use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.

the class EzyZoneBroadcastEventImplTest method firePluginEventNoCatchExceptionCaseTest.

@Test
public void firePluginEventNoCatchExceptionCaseTest() {
    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);
    when(zoneContext.getPluginContexts()).thenReturn(Lists.newArrayList(pluginContext));
    EzyZoneBroadcastEventImpl cmd = new EzyZoneBroadcastEventImpl(zoneContext);
    EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
    cmd.fire(EzyEventType.SERVER_READY, event, false);
}
Also used : EzyZone(com.tvd12.ezyfoxserver.EzyZone) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyZoneBroadcastEventImpl(com.tvd12.ezyfoxserver.command.impl.EzyZoneBroadcastEventImpl) EzySimpleServerReadyEvent(com.tvd12.ezyfoxserver.event.EzySimpleServerReadyEvent) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) EzyServerReadyEvent(com.tvd12.ezyfoxserver.event.EzyServerReadyEvent) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 64 with EzyZoneContext

use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.

the class EzyZoneBroadcastEventImplTest method fireAppEventCatchExceptionCaseTest.

@Test
public void fireAppEventCatchExceptionCaseTest() {
    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);
    EzyAppContext appContext = mock(EzyAppContext.class);
    when(zoneContext.getAppContexts()).thenReturn(Lists.newArrayList(appContext));
    doThrow(new IllegalStateException("server maintain")).when(appContext).handleEvent(any(), any());
    EzyZoneBroadcastEventImpl cmd = new EzyZoneBroadcastEventImpl(zoneContext);
    EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
    cmd.fire(EzyEventType.SERVER_READY, event, true);
}
Also used : EzyZone(com.tvd12.ezyfoxserver.EzyZone) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyZoneBroadcastEventImpl(com.tvd12.ezyfoxserver.command.impl.EzyZoneBroadcastEventImpl) EzySimpleServerReadyEvent(com.tvd12.ezyfoxserver.event.EzySimpleServerReadyEvent) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) EzyServerReadyEvent(com.tvd12.ezyfoxserver.event.EzyServerReadyEvent) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 65 with EzyZoneContext

use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.

the class EzyZoneBroadcastEventImplTest method fireAppEventNoCatchExceptionCaseTest.

@Test
public void fireAppEventNoCatchExceptionCaseTest() {
    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);
    EzyAppContext appContext = mock(EzyAppContext.class);
    when(zoneContext.getAppContexts()).thenReturn(Lists.newArrayList(appContext));
    EzyZoneBroadcastEventImpl cmd = new EzyZoneBroadcastEventImpl(zoneContext);
    EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
    cmd.fire(EzyEventType.SERVER_READY, event, false);
}
Also used : EzyZone(com.tvd12.ezyfoxserver.EzyZone) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyZoneBroadcastEventImpl(com.tvd12.ezyfoxserver.command.impl.EzyZoneBroadcastEventImpl) EzySimpleServerReadyEvent(com.tvd12.ezyfoxserver.event.EzySimpleServerReadyEvent) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) EzyServerReadyEvent(com.tvd12.ezyfoxserver.event.EzyServerReadyEvent) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Aggregations

EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)77 Test (org.testng.annotations.Test)65 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)42 BaseTest (com.tvd12.test.base.BaseTest)26 EzyZoneUserManager (com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager)24 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)23 EzyZone (com.tvd12.ezyfoxserver.EzyZone)21 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)21 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)20 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)20 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)18 EzySimpleZoneSetting (com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting)18 EzyArray (com.tvd12.ezyfox.entity.EzyArray)17 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)17 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)15 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)13 EzyPluginContext (com.tvd12.ezyfoxserver.context.EzyPluginContext)13 EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)12 EzyResponseApi (com.tvd12.ezyfoxserver.api.EzyResponseApi)12 EzyServer (com.tvd12.ezyfoxserver.EzyServer)11