Search in sources :

Example 11 with EzySimplePluginSetting

use of com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting in project ezyfox-server by youngmonkeys.

the class EzyPluginInfoResponseTest method test.

@Test
public void test() {
    EzySimplePluginSetting setting = new EzySimplePluginSetting();
    setting.setName("test");
    EzyPluginInfoParams params = new EzyPluginInfoParams();
    params.setPlugin(setting);
    assert params.getPlugin() == setting;
    EzyPluginInfoResponse response = new EzyPluginInfoResponse(params);
    assert response.getParams() == params;
    response.serialize();
    response.release();
}
Also used : EzyPluginInfoResponse(com.tvd12.ezyfoxserver.response.EzyPluginInfoResponse) EzyPluginInfoParams(com.tvd12.ezyfoxserver.response.EzyPluginInfoParams) EzySimplePluginSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 12 with EzySimplePluginSetting

use of com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting in project ezyfox-server by youngmonkeys.

the class EzySimplePluginSettingTest method test.

@Test
public void test() {
    EzySimplePluginSetting setting = new EzySimplePluginSetting();
    setting.setZoneId(1);
    assert setting.getZoneId() == 1;
    setting.setHomePath("home");
    assert setting.getHomePath().equals("home");
    setting.setName("name");
    setting.setFolder("folder");
    assert setting.getFolder().equals("folder");
    setting.setFolder("");
    assert setting.getFolder().equals("name");
    System.out.println(setting.getLocation());
    System.out.println(setting.getConfigFile());
    // noinspection EqualsWithItself
    assert setting.equals(setting);
    setting.setPriority(1);
    setting.setListenEvents(new EzySimpleListenEvents());
}
Also used : EzySimpleListenEvents(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting.EzySimpleListenEvents) EzySimplePluginSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 13 with EzySimplePluginSetting

use of com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting 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 14 with EzySimplePluginSetting

use of com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting in project ezyfox-server by youngmonkeys.

the class EzySimpleServerContextBuilderTest method test.

@SuppressWarnings("rawtypes")
@Test
public void test() {
    EzySimpleServerContextBuilder instance = new EzySimpleServerContextBuilder();
    MethodInvoker.create().object(instance).method("newAppExecutorService").param(EzyAppSetting.class, new EzySimpleAppSetting()).invoke();
    MethodInvoker.create().object(instance).method("newPluginExecutorService").param(EzyPluginSetting.class, new EzySimplePluginSetting()).invoke();
}
Also used : EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting) EzySimpleAppSetting(com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting) EzySimpleServerContextBuilder(com.tvd12.ezyfoxserver.builder.EzySimpleServerContextBuilder) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting) EzySimplePluginSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 15 with EzySimplePluginSetting

use of com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting in project ezyfox-server by youngmonkeys.

the class EzyZonesStarterTest method normalCaseTest.

@Test
public void normalCaseTest() {
    EzySimpleSettings settings = new EzySimpleSettings();
    EzySimpleZonesSetting zonesSetting = settings.getZones();
    EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
    zoneSetting.setName("test");
    zonesSetting.setItem(zoneSetting);
    EzySimpleAppsSetting appsSetting = new EzySimpleAppsSetting();
    EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
    appSetting.setName("apps");
    appSetting.setFolder("apps");
    appSetting.setEntryLoader(ExEntryLoader.class.getName());
    appsSetting.setItem(appSetting);
    zoneSetting.setApplications(appsSetting);
    EzySimplePluginsSetting pluginsSetting = new EzySimplePluginsSetting();
    EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
    pluginSetting.setName("plugins");
    pluginSetting.setFolder("plugins");
    pluginSetting.setEntryLoader(ExPluginEntryLoader.class.getName());
    pluginsSetting.setItem(pluginSetting);
    zoneSetting.setPlugins(pluginsSetting);
    EzySimpleServer server = new EzySimpleServer();
    server.setSettings(settings);
    server.setConfig(new EzySimpleConfig());
    EzyServerContext serverContext = mock(EzyServerContext.class);
    when(serverContext.getServer()).thenReturn(server);
    EzySimpleZone zone = new EzySimpleZone();
    zone.setSetting(zoneSetting);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    when(zoneContext.getZone()).thenReturn(zone);
    when(serverContext.getZoneContext("test")).thenReturn(zoneContext);
    EzySimpleApplication app = new EzySimpleApplication();
    app.setSetting(appSetting);
    EzyAppContext appContext = mock(EzyAppContext.class);
    when(appContext.getApp()).thenReturn(app);
    when(zoneContext.getAppContext("apps")).thenReturn(appContext);
    EzySimplePlugin plugin = new EzySimplePlugin();
    plugin.setSetting(pluginSetting);
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    when(zoneContext.getPluginContext("plugins")).thenReturn(pluginContext);
    Map<String, ClassLoader> appClassLoaders = new HashMap<>();
    appClassLoaders.put("apps", new EzyAppClassLoader(new File("test-data"), getClass().getClassLoader()));
    server.setAppClassLoaders(appClassLoaders);
    EzyZonesStarter starter = EzyZonesStarter.builder().serverContext(serverContext).build();
    starter.start();
}
Also used : EzyAppClassLoader(com.tvd12.ezyfoxserver.ccl.EzyAppClassLoader) HashMap(java.util.HashMap) EzyAppClassLoader(com.tvd12.ezyfoxserver.ccl.EzyAppClassLoader) EzySimpleConfig(com.tvd12.ezyfoxserver.config.EzySimpleConfig) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) File(java.io.File) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Aggregations

Test (org.testng.annotations.Test)21 EzySimplePluginSetting (com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting)14 BaseTest (com.tvd12.test.base.BaseTest)14 EzySimplePlugin (com.tvd12.ezyfoxserver.EzySimplePlugin)13 EzySimplePluginContext (com.tvd12.ezyfoxserver.context.EzySimplePluginContext)8 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)7 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)6 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)6 EzySimpleZoneContext (com.tvd12.ezyfoxserver.context.EzySimpleZoneContext)6 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)6 EzyErrorScheduledExecutorService (com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService)5 EzySimplePluginEntry (com.tvd12.ezyfoxserver.support.entry.EzySimplePluginEntry)5 EzyEventControllers (com.tvd12.ezyfoxserver.wrapper.EzyEventControllers)5 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)5 EzyPluginContext (com.tvd12.ezyfoxserver.context.EzyPluginContext)4 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)4 EzyPluginHandleExceptionImpl (com.tvd12.ezyfoxserver.command.impl.EzyPluginHandleExceptionImpl)3 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)3 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)3 EzySimpleListenEvents (com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting.EzySimpleListenEvents)3