David Rosenstrauch wrote:
A couple of suggestions:

1) I'd think you really shouldn't need to go through the whole process of fully starting up the server (with a socket listener listening on a port) and a client (opening a socket to the server) just to do testing. I don't know your code so well so perhaps I'm wrong here. But I'd think it should be sufficient to just *simulate* network communication by using a DummySession and sending a message down the server's filter chain and seeing what response - or lack thereof - gets generated.

2) If you follow along with that approach, then you won't be in the situation where your client is performing assertions inside the messageReceived method (which are obviously getting swallowed). If you look carefully at the code I posted, you'll see that what I'm doing is to add an "OutputListener" - a class that I use only to assist with testing - at the end of my filter chain when I test. The output listener, true to its name, listens to whatever output/response the server's filter chain processing generates, and saves it. Once that whole server filter chain interaction is complete, and I've "saved" the output from my "communication with the server", only THEN do I go about issuing Asserts to verify that the output was what I expected. And since these asserts get done outside of the MINA filter chain processing they never get swallowed.

Or, more succinctly:

You're trying to do "white-box" testing on your server. Do "black-box" testing instead. Treat the server as a black box: Send it a message, get a response, perform assertions to verify that the response is correct. Do this all from *outside* the server and client, not inside the client. And if you approach it this way, you don't need to involve a client in your testing at all.

HTH,

DR

Reply via email to