Search in sources :

Example 6 with EzySimpleWebSocketSetting

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

the class EzyWebSocketSecureServerCreatorTest method test.

@Test
public void test() throws Exception {
    SSLContext sslContext = SSLContext.getDefault();
    EzySimpleWebSocketSetting webSocketSetting = new EzySimpleWebSocketSetting();
    EzyWebSocketSecureServerCreator creator = new EzyWebSocketSecureServerCreator(sslContext);
    creator.setting(webSocketSetting);
    creator.create();
    EzyWsHandler wsHandler = MethodInvoker.create().object(creator).method("newWsHandler").invoke(EzyWsHandler.class);
    WebSocketCreator webSocketCreator = MethodInvoker.create().object(creator).method("newWebSocketCreator").param(EzyWsHandler.class, wsHandler).invoke(WebSocketCreator.class);
    webSocketCreator.createWebSocket(null, null);
}
Also used : EzySimpleWebSocketSetting(com.tvd12.ezyfoxserver.setting.EzySimpleWebSocketSetting) EzyWsHandler(com.tvd12.ezyfoxserver.nio.websocket.EzyWsHandler) EzyWebSocketSecureServerCreator(com.tvd12.ezyfoxserver.nio.builder.impl.EzyWebSocketSecureServerCreator) SSLContext(javax.net.ssl.SSLContext) WebSocketCreator(org.eclipse.jetty.websocket.servlet.WebSocketCreator) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 7 with EzySimpleWebSocketSetting

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

the class EzySimpleCodecFactoryTest method test.

@Test
public void test() {
    EzySimpleSocketSetting socketSetting = new EzySimpleSocketSetting();
    socketSetting.setActive(false);
    EzySimpleWebSocketSetting webSocketSetting = new EzySimpleWebSocketSetting();
    webSocketSetting.setActive(false);
    EzyCodecFactory factory = EzySimpleCodecFactory.builder().socketSetting(socketSetting).websocketSetting(webSocketSetting).build();
    assert factory.newEncoder(EzyConnectionType.SOCKET) == null;
    assert factory.newEncoder(EzyConnectionType.WEBSOCKET) == null;
    assert factory.newDecoder(EzyConnectionType.SOCKET) == null;
    assert factory.newDecoder(EzyConnectionType.WEBSOCKET) == null;
    socketSetting.setActive(true);
    socketSetting.setCodecCreator(ExBytesCodecCreator.class.getName());
    webSocketSetting.setActive(true);
    webSocketSetting.setCodecCreator(ExStringCodecCreator.class.getName());
    factory = EzySimpleCodecFactory.builder().socketSetting(socketSetting).websocketSetting(webSocketSetting).build();
    assert factory.newEncoder(EzyConnectionType.SOCKET) != null;
    assert factory.newEncoder(EzyConnectionType.WEBSOCKET) != null;
    assert factory.newDecoder(EzyConnectionType.SOCKET) != null;
    assert factory.newDecoder(EzyConnectionType.WEBSOCKET) != null;
}
Also used : EzySimpleWebSocketSetting(com.tvd12.ezyfoxserver.setting.EzySimpleWebSocketSetting) EzySimpleSocketSetting(com.tvd12.ezyfoxserver.setting.EzySimpleSocketSetting) EzyCodecFactory(com.tvd12.ezyfoxserver.codec.EzyCodecFactory) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 8 with EzySimpleWebSocketSetting

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

the class EzyWebSocketSettingBuilderTest method test.

@Test
public void test() {
    // given
    EzyWebSocketSettingBuilder sut = new EzyWebSocketSettingBuilder().managementEnable(true);
    // when
    EzySimpleWebSocketSetting setting = sut.build();
    // then
    Asserts.assertEquals(true, setting.isManagementEnable());
}
Also used : EzySimpleWebSocketSetting(com.tvd12.ezyfoxserver.setting.EzySimpleWebSocketSetting) EzyWebSocketSettingBuilder(com.tvd12.ezyfoxserver.setting.EzyWebSocketSettingBuilder) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)7 EzySimpleWebSocketSetting (com.tvd12.ezyfoxserver.setting.EzySimpleWebSocketSetting)4 EzyEmbeddedServer (com.tvd12.ezyfoxserver.embedded.EzyEmbeddedServer)2 EzyWsHandler (com.tvd12.ezyfoxserver.nio.websocket.EzyWsHandler)2 EzyMaxRequestPerSecondBuilder (com.tvd12.ezyfoxserver.setting.EzySessionManagementSettingBuilder.EzyMaxRequestPerSecondBuilder)2 EzySimpleMaxRequestPerSecond (com.tvd12.ezyfoxserver.setting.EzySimpleSessionManagementSetting.EzySimpleMaxRequestPerSecond)2 BaseTest (com.tvd12.test.base.BaseTest)2 SSLContext (javax.net.ssl.SSLContext)2 WebSocketCreator (org.eclipse.jetty.websocket.servlet.WebSocketCreator)2 MsgPackCodecCreator (com.tvd12.ezyfox.codec.MsgPackCodecCreator)1 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)1 EzyCodecFactory (com.tvd12.ezyfoxserver.codec.EzyCodecFactory)1 EzyWebSocketSecureServerCreator (com.tvd12.ezyfoxserver.nio.builder.impl.EzyWebSocketSecureServerCreator)1 EzyWebSocketServerCreator (com.tvd12.ezyfoxserver.nio.builder.impl.EzyWebSocketServerCreator)1 EzySimpleSocketSetting (com.tvd12.ezyfoxserver.setting.EzySimpleSocketSetting)1 EzyWebSocketSettingBuilder (com.tvd12.ezyfoxserver.setting.EzyWebSocketSettingBuilder)1 BaseCoreTest (com.tvd12.ezyfoxserver.testing.BaseCoreTest)1 MyTestServerBootstrapBuilder (com.tvd12.ezyfoxserver.testing.MyTestServerBootstrapBuilder)1