CallServiceManagerTest.java 文件源码

java
阅读 33 收藏 0 点赞 0 评论 0

项目:ocelot 作者:
/**
 * Test of sendMessageToClient method, of class CallServiceManager.
 */
@Test
public void testSendMessageToClient() {
    System.out.println("sendMessageToClient");
    Session client = mock(Session.class);
    MessageToClient mtc = mock(MessageToClient.class);
    RemoteEndpoint.Async async = mock(RemoteEndpoint.Async.class);
    when(client.getAsyncRemote()).thenReturn(async);
    when(messageToClientService.createMessageToClient(any(MessageFromClient.class), any(Session.class))).thenReturn(mtc).thenReturn(null);

    boolean result = instance.sendMessageToClient(new MessageFromClient(), client);
    assertThat(result).isTrue();

    result = instance.sendMessageToClient(new MessageFromClient(), client);
    assertThat(result).isFalse();

    ArgumentCaptor<MessageToClient> captureMsg = ArgumentCaptor.forClass(MessageToClient.class);
    verify(async).sendObject(captureMsg.capture());

    assertThat(captureMsg.getValue()).isEqualTo(mtc);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号