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.

  • tool recommendations are explicitly off-topic per help center. meta.programmers.stackexchange.com/questions/6483/…
    – gnat
    Jul 30, 2014 at 15:59
  • Well how can i find out how to do this can of testing. If it is not about the tool. It is about how do people test those things?
    – MaatDeamon
    Jul 30, 2014 at 16:13
  • 1
    @gnat is right. You should edit your question to make it clear this is not a tool request, or it will most likely get closed.
    – david.pfx
    Jul 31, 2014 at 0:02
  • @david.pfx I think I wiped tool request part out in rev 4. Do you spot anything slippery in revised question?
    – gnat
    Jul 31, 2014 at 0:05
  • 2
    You've got one close vote for tool or library and one for unclear what you're asking. To avoid getting closed you need to be clear exactly what it is you're asking in the question, not in the comments.
    – david.pfx
    Jul 31, 2014 at 0:32

2 Answers 2


I would recommend to test the client and the server separately.

Client testing

The client connects to a mock server. That server verifies that the request from the client is well-formed according to your XSD specification and additional validation rules and sends a canned response back.
The canned response from the mock server must have been validated beforehand, but that can be done by hand when creating the test case.
The test then verifies that the client sends the right message and correctly processes the response.

Server testing

For testing the server, you create a stub client that sends canned requests to the server and validates that the responses are as expected.
Now, you also have the possibility to test the server's behaviour when unexpected or malformed messages are received, which is far harder in an end-to-end test with a correctly functioning client.


Sounds like you need a proxy to insert between your client and your service. You should be able to generate a skeleton from your WSDL, then stick your validate-and-forward logic in where the service methods are stubbed out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.