mardi 29 septembre 2015

How can I test the below websocket server method when there are internal dependencies?

I have a web socket server code. How can I test these using JUnit? Below would be the implementation of the onOpen method.How can I test this method to see if each and every line got executed correctly? I can create a client and see if the connection was successful. But how can I check if the lines inside the below method code got executed as intended? Also there is an internal dependency on the object messageBroker.Without removing this line from this method, how can I test it? I am new to unit testing. Please advice.

if (ws.isOpen()) {
        System.out.println("WebSocketServer->OnOpen : OnOpen method called by client");
        MessageBroker = new MessageBroker(messageBus);
        MessageBroker.SetWebClient(ws);
        sessionIdMap.put(ws,MessageBroker);

    }

Aucun commentaire:

Enregistrer un commentaire