Q:

How best to enable a web service consumer to integration test a transactional web service? 

I want to allow consumers of a web services layer (web services are written in Java) to create automated integration tests to validate that the version of the web services layer that the consumers will use will still work for the consumer (i.e. the web services are on a different release lifecycle than the consumers and their APIs or behavior might change-- they shouldn't change wihtout notifying the consumer, but the point of this automated test is to validate that they haven't changed)
What would I do if the web service actually executes a transaction (updates database tables).  Is there a common practice for how to handle this without having to put logic into the web service itself to know its in a unit test and rollback the transaction once finished? ( basically baking in the capability to deal with testing of the web service).  Or is that the recommended way to do it? 

A:

Break up your logic and have a REST object delegate to a DAO.   Then have the DAO injected at runtime, if a specific parameter is supplied as part of the REST call (test=true) inject an alternate DAO that will rollback the transaction after the assertions pass.