Search in sources :

Example 1 with MyTestServerBootstrapBuilder

use of com.tvd12.ezyfoxserver.testing.MyTestServerBootstrapBuilder in project ezyfox-server by youngmonkeys.

the class EzyAbstractServerBootstrapBuilderTest method test.

@Test
public void test() {
    EzySimpleServer server = newServer();
    MyTestServerBootstrapBuilder builder = (MyTestServerBootstrapBuilder) new MyTestServerBootstrapBuilder().server(server);
    // noinspection ConstantConditions
    Asserts.assertFalse(builder.equals(null));
    EzySslConfigSetting sslConfigSetting = server.getSettings().getWebsocket().getSslConfig();
    MethodInvoker.create().object(builder).method("newSslContext").param(EzySslConfigSetting.class, sslConfigSetting).invoke();
    MethodInvoker.create().object(builder).method("getSettings").invoke();
    MethodInvoker.create().object(builder).method("getSocketSetting").invoke();
    MethodInvoker.create().object(builder).method("getWebsocketSetting").invoke();
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) MyTestServerBootstrapBuilder(com.tvd12.ezyfoxserver.testing.MyTestServerBootstrapBuilder) BaseCoreTest(com.tvd12.ezyfoxserver.testing.BaseCoreTest) Test(org.testng.annotations.Test)

Example 2 with MyTestServerBootstrapBuilder

use of com.tvd12.ezyfoxserver.testing.MyTestServerBootstrapBuilder in project ezyfox-server by youngmonkeys.

the class EzyAbstractServerBootstrapBuilderTest method newSslContextTest.

@Test
public void newSslContextTest() {
    // given
    EzySimpleServer server = newServer();
    EzySimpleWebSocketSetting webSocketSetting = (EzySimpleWebSocketSetting) server.getSettings().getWebsocket();
    webSocketSetting.setSslActive(true);
    MyTestServerBootstrapBuilder builder = (MyTestServerBootstrapBuilder) new MyTestServerBootstrapBuilder().server(server);
    EzySimpleSslConfigSetting setting = new EzySimpleSslConfigSetting();
    // when
    SSLContext sslContext = MethodInvoker.create().object(builder).method("newSslContext").param(EzySslConfigSetting.class, setting).invoke(SSLContext.class);
    Asserts.assertNotNull(sslContext);
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) MyTestServerBootstrapBuilder(com.tvd12.ezyfoxserver.testing.MyTestServerBootstrapBuilder) SSLContext(javax.net.ssl.SSLContext) BaseCoreTest(com.tvd12.ezyfoxserver.testing.BaseCoreTest) Test(org.testng.annotations.Test)

Example 3 with MyTestServerBootstrapBuilder

use of com.tvd12.ezyfoxserver.testing.MyTestServerBootstrapBuilder in project ezyfox-server by youngmonkeys.

the class EzyServerBootstrapTest method test.

@SuppressWarnings("rawtypes")
@Test
public void test() throws Exception {
    EzyServerBootstrap bt = new MyTestServerBootstrapBuilder().server(newServer()).build();
    bt.destroy();
    assert MethodInvoker.create().object(bt).method("getServer").invoke() != null;
    assert MethodInvoker.create().object(bt).method("getServerSettings").invoke() != null;
    assert MethodInvoker.create().object(bt).method("getHttpSetting").invoke() != null;
    assert MethodInvoker.create().object(bt).method("getSocketSetting").invoke() != null;
    assert MethodInvoker.create().object(bt).method("getWebSocketSetting").invoke() != null;
    EzyServerBootstrap bootstrap = new EzyServerBootstrap() {

        @Override
        protected void startOtherBootstraps(Runnable callback) {
            callback.run();
        }
    };
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzySimpleServer server = new EzySimpleServer();
    EzySimpleConfig config = new EzySimpleConfig();
    server.setConfig(config);
    when(serverContext.getServer()).thenReturn(server);
    EzySimpleSettings settings = new EzySimpleSettings();
    server.setSettings(settings);
    EzySessionManager sessionManager = new ExEzySimpleSessionManager.Builder().objectFactory(() -> spy(EzyAbstractSession.class)).build();
    server.setSessionManager(sessionManager);
    EzyBootstrap localBootstrap = EzyBootstrap.builder().context(serverContext).build();
    bootstrap.setContext(serverContext);
    bootstrap.setLocalBootstrap(localBootstrap);
    bootstrap.start();
}
Also used : EzySimpleConfig(com.tvd12.ezyfoxserver.config.EzySimpleConfig) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyBootstrap(com.tvd12.ezyfoxserver.EzyBootstrap) EzySessionManager(com.tvd12.ezyfoxserver.wrapper.EzySessionManager) EzyServerBootstrap(com.tvd12.ezyfoxserver.EzyServerBootstrap) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) Test(org.testng.annotations.Test)

Example 4 with MyTestServerBootstrapBuilder

use of com.tvd12.ezyfoxserver.testing.MyTestServerBootstrapBuilder in project ezyfox-server by youngmonkeys.

the class EzyAbstractServerBootstrapBuilderTest method commonTest.

@Test
public void commonTest() {
    // given
    EzySimpleServer server = newServer();
    MyTestServerBootstrapBuilder builder = (MyTestServerBootstrapBuilder) new MyTestServerBootstrapBuilder().server(server);
    // when
    EzyThreadPoolSizeSetting threadPoolSizeSetting = (EzyThreadPoolSizeSetting) ReflectMethodUtil.invokeMethod("getThreadPoolSizeSetting", builder);
    // then
    Asserts.assertEquals(server.getSettings().getThreadPoolSize(), threadPoolSizeSetting);
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) MyTestServerBootstrapBuilder(com.tvd12.ezyfoxserver.testing.MyTestServerBootstrapBuilder) BaseCoreTest(com.tvd12.ezyfoxserver.testing.BaseCoreTest) Test(org.testng.annotations.Test)

Aggregations

EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)4 Test (org.testng.annotations.Test)4 BaseCoreTest (com.tvd12.ezyfoxserver.testing.BaseCoreTest)3 MyTestServerBootstrapBuilder (com.tvd12.ezyfoxserver.testing.MyTestServerBootstrapBuilder)3 EzyBootstrap (com.tvd12.ezyfoxserver.EzyBootstrap)1 EzyServerBootstrap (com.tvd12.ezyfoxserver.EzyServerBootstrap)1 EzySimpleConfig (com.tvd12.ezyfoxserver.config.EzySimpleConfig)1 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)1 EzySimpleSettings (com.tvd12.ezyfoxserver.setting.EzySimpleSettings)1 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)1 SSLContext (javax.net.ssl.SSLContext)1