Search in sources :

Example 1 with EzyConfig

use of com.tvd12.ezyfoxserver.config.EzyConfig in project ezyfox-server by youngmonkeys.

the class EzyStarterTest method notPrintSettings.

@Test
public void notPrintSettings() {
    // given
    EzyStarter starter = new ExEzyStarter.Builder().build();
    EzyConfig config = mock(EzyConfig.class);
    when(config.isPrintSettings()).thenReturn(false);
    EzySimpleServer server = new EzySimpleServer();
    server.setConfig(config);
    EzySimpleSettings settings = new EzySimpleSettings();
    server.setSettings(settings);
    // when
    MethodInvoker.create().object(starter).method("startEzyFox").param(EzyServer.class, server).call();
    // then
    verify(config, times(1)).isPrintSettings();
}
Also used : EzyStarter(com.tvd12.ezyfoxserver.EzyStarter) EzyConfig(com.tvd12.ezyfoxserver.config.EzyConfig) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) EzyServer(com.tvd12.ezyfoxserver.EzyServer) Test(org.testng.annotations.Test)

Example 2 with EzyConfig

use of com.tvd12.ezyfoxserver.config.EzyConfig in project ezyfox-server by youngmonkeys.

the class EzyStarter method startEzyFox.

protected void startEzyFox(EzyServer server) throws Exception {
    EzyConfig config = server.getConfig();
    if (config.isPrintSettings()) {
        getLogger().info("settings: \n{}", server);
    }
    EzyServerBootstrap serverBoostrap = newServerBoostrap(server);
    serverBoostrap.start();
    serverContext = serverBoostrap.getContext();
    serverContext.setProperty(EzyServerBootstrap.class, serverBoostrap);
}
Also used : EzyConfig(com.tvd12.ezyfoxserver.config.EzyConfig)

Example 3 with EzyConfig

use of com.tvd12.ezyfoxserver.config.EzyConfig in project ezyfox-server by youngmonkeys.

the class EzyLoaderTest method newAppClassLoaderNotEnableClassLoader.

@Test
public void newAppClassLoaderNotEnableClassLoader() {
    // given
    InternalLoader sut = new InternalLoader();
    FieldUtil.setFieldValue(sut, "classLoader", Thread.currentThread().getContextClassLoader());
    EzyConfig config = mock(EzyConfig.class);
    when(config.isEnableAppClassLoader()).thenReturn(false);
    FieldUtil.setFieldValue(sut, "config", config);
    // when
    ClassLoader classLoader = MethodUtil.invokeMethod("newAppClassLoader", sut, new File(""));
    // then
    Asserts.assertEquals(Thread.currentThread().getContextClassLoader(), classLoader);
}
Also used : EzyConfig(com.tvd12.ezyfoxserver.config.EzyConfig) File(java.io.File) Test(org.testng.annotations.Test)

Example 4 with EzyConfig

use of com.tvd12.ezyfoxserver.config.EzyConfig in project ezyfox-server by youngmonkeys.

the class EzyLoaderTest method getEntryFoldersEmptyTest.

@Test
public void getEntryFoldersEmptyTest() {
    // given
    InternalLoader sut = new InternalLoader();
    EzyConfig config = mock(EzyConfig.class);
    when(config.isEnableAppClassLoader()).thenReturn(false);
    FieldUtil.setFieldValue(sut, "config", config);
    // when
    File[] folders = MethodUtil.invokeMethod("getEntryFolders", sut);
    // then
    Asserts.assertEquals(new File[0], folders);
}
Also used : EzyConfig(com.tvd12.ezyfoxserver.config.EzyConfig) File(java.io.File) Test(org.testng.annotations.Test)

Example 5 with EzyConfig

use of com.tvd12.ezyfoxserver.config.EzyConfig in project ezyfox-server by youngmonkeys.

the class EzyStarter method startSystem.

protected void startSystem() throws Exception {
    EzyConfig config = readConfig(configFile);
    startSystem(config);
}
Also used : EzyConfig(com.tvd12.ezyfoxserver.config.EzyConfig)

Aggregations

EzyConfig (com.tvd12.ezyfoxserver.config.EzyConfig)8 Test (org.testng.annotations.Test)6 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)2 File (java.io.File)2 EzyServer (com.tvd12.ezyfoxserver.EzyServer)1 EzyStarter (com.tvd12.ezyfoxserver.EzyStarter)1 EzyConfigBuilder (com.tvd12.ezyfoxserver.config.EzyConfigBuilder)1 EzySimpleConfigLoader (com.tvd12.ezyfoxserver.config.EzySimpleConfigLoader)1 EzySimpleSettings (com.tvd12.ezyfoxserver.setting.EzySimpleSettings)1