我们是否需要在websocket服务器端pont中为ONOpen,OnMessage方法编写Junit

时间:2016-08-19 05:05:57

标签: java for-loop junit websocket

我需要帮助为我的班级编写Junit,为此编写Junit是否有任何价值,如果是,请帮助如何用示例编写。     提前谢谢。

my code is :

@ServerEndpoint(
    value="/mysocketServer", 
    encoders = { MessageEncoder.class }, 
    decoders = { MessageDecoder.class })
public class WebSocketService {
    @OnOpen
    public void onOpen(Session session) throws IOException, EncodeException, FTPWebSocketException {
        session.getBasicRemote().sendObject(ackResponse);       
    }


    @OnError
    public void onError(Session session, Throwable t) {
        logger.error("OnError ocurred for session: " + session.getId(), t);
    }

    @OnMessage
    public void onMessage(FTPWebSocketRequest request, Session session) throws IOException, EncodeException, FTPWebSocketException {
        session.getBasicRemote().sendObject(ackResponse);
    }

    @OnClose
    public void onClose(CloseReason reason, Session session) throws FTPException {   
        new EndSessionOnMessageHandler().handleMessage(null, session); 
    }
}

0 个答案:

没有答案