I am working in Scala/Java.
I'm testing the messaging infrastructure of a part of my system that I did several years ago with CXF and Java. More specifically, I'm re-writing the specification of the message exchange. This is because i'm changing few part of it. At the time, I was not using TDD/BDD. Now I'm driving out everything with BDD. Actually, the owner of the system specifically wants to have the BDD style Specification before i'm done with the project. I also find it actually useful anyway.
I'm particularly interested in writing an end-to-end test, where I would check that the server read the message properly.
Optionally I would like to send a message and in the middle check that what is sent is conform and forward the message to the server. (Actually i think that unit testing the sending on one side and the receiving on the other side should be enough here)
The end to end test should be something like:
->Client one prepare a message
->Client one send a message to the Server
->On reception of the message on the server verify, that the message received correspond to is expected to have been sent. In particular, check that resulting composite object constructed out of the raw message is right.
This, on its own, should drive out several unit test in the middle. The other nonfunctional constraint will also help for the matter.
The problem here is that the end-to-end test describe here actually involve writing a Test with asynchronous code. I saw things like awaitlity or scala future to handle that. However, the part is bogging me down, is the observation of an the new message received inside the server. I read things about polling the system through a probe, but i still can't figure out the probe part. In any case, in all and all, the problem is that the message received is an internal variable of the server, well encapsulated. I'm wondering how to deal with that ? What techniques could be recommended here ??? There must be some existing hooks for that? Any one has any idea? Serializing the object in a log file :), making the variable publicly accessible trough some getter? Creating some trace object for the matter. etc.... I would appreciate if someone could suggest something.