Search in sources :

Example 6 with EzyWsHandlerGroup

use of com.tvd12.ezyfoxserver.nio.websocket.EzyWsHandlerGroup in project ezyfox-server by youngmonkeys.

the class EzySimpleWsHandlerGroupTest method newDecodeBytesCallbackCallTest.

@Test
public void newDecodeBytesCallbackCallTest() throws Exception {
    // given
    EzyWsHandlerGroup sut = newHandlerGroup();
    EzyCallback<Object> decodeBytesCallback = FieldUtil.getFieldValue(sut, "decodeBytesCallback");
    // when
    Throwable e = Asserts.assertThrows(() -> decodeBytesCallback.call(new Object()));
    // then
    Asserts.assertEquals(UnsupportedOperationException.class, e.getClass());
}
Also used : EzyWsHandlerGroup(com.tvd12.ezyfoxserver.nio.websocket.EzyWsHandlerGroup) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 7 with EzyWsHandlerGroup

use of com.tvd12.ezyfoxserver.nio.websocket.EzyWsHandlerGroup in project ezyfox-server by youngmonkeys.

the class EzySimpleWsHandlerGroupTest method handleReceivedSessionStreamNotEnable.

@Test
public void handleReceivedSessionStreamNotEnable() throws Exception {
    // given
    EzyWsHandlerGroup sut = newHandlerGroup();
    EzySession session = FieldUtil.getFieldValue(sut, "session");
    byte[] bytes = new byte[] { 1 << 4, 2, 3 };
    int offset = 0;
    int len = 3;
    // when
    MethodInvoker.create().object(sut).method("handleReceivedBytes").param(byte[].class, bytes).param(int.class, offset).param(int.class, len).call();
    // then
    verify(session, times(1)).isStreamingEnable();
}
Also used : EzyWsHandlerGroup(com.tvd12.ezyfoxserver.nio.websocket.EzyWsHandlerGroup) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 8 with EzyWsHandlerGroup

use of com.tvd12.ezyfoxserver.nio.websocket.EzyWsHandlerGroup in project ezyfox-server by youngmonkeys.

the class EzySimpleWsHandlerGroupTest method handleReceivedStreamEnableAndSessionStream.

@Test
public void handleReceivedStreamEnableAndSessionStream() throws Exception {
    // given
    EzyWsHandlerGroup sut = newHandlerGroup();
    EzySession session = FieldUtil.getFieldValue(sut, "session");
    when(session.isStreamingEnable()).thenReturn(true);
    byte[] bytes = new byte[] { 1 << 4, 2, 3 };
    int offset = 0;
    int len = 3;
    // when
    MethodInvoker.create().object(sut).method("handleReceivedBytes").param(byte[].class, bytes).param(int.class, offset).param(int.class, len).call();
    // then
    verify(session, times(1)).isStreamingEnable();
}
Also used : EzyWsHandlerGroup(com.tvd12.ezyfoxserver.nio.websocket.EzyWsHandlerGroup) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Aggregations

EzyWsHandlerGroup (com.tvd12.ezyfoxserver.nio.websocket.EzyWsHandlerGroup)8 Test (org.testng.annotations.Test)8 BaseTest (com.tvd12.test.base.BaseTest)6 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)4 EzySocketDataReceiver (com.tvd12.ezyfoxserver.nio.socket.EzySocketDataReceiver)2 EzyHandlerGroupManager (com.tvd12.ezyfoxserver.nio.wrapper.EzyHandlerGroupManager)2 Session (org.eclipse.jetty.websocket.api.Session)2