We employ both Spring and Hibernate to implement business and data access layers in our current project. Our aim is to bring clear separation between those two layers. The beans in business layer act as service entry points.They realize simply our use case scenarios. They are also good candidates as start and end points for business transactions and authorization level security checks to allow or deny who will execute business logic.
Testability is our main concern as well and actually, I want to bring discussion to that point. We have clearly separated layers, and each one should be tested in isolation. Unit testing using mock objects or using Cactus to run tests in container appears as two distinct alternatives at first. For example, business logic in our service layer objects are tested simply mocking data access layer objects. But when it comes to test those required behaviour while security and transactional contexts are available, things get a little bit complicated. We need to provide an environment in which those services should be up and running or provide the test base with their mock implementations. This is obviously a difficult task and things could get more complicated if our system depends more and more on such components.
Assume that we provided our system with those required services or their mock implementations, but we could never be sure that our system act as if it were in real production environment. Another point with this kind of unit testing is that our tests could be so fine grained that we never see any interactions between objects in different layers. Each object is tested in isolation from other depended objects. For example, when we test service objects in business layer, we only check business logic in them. We do not hit real data access objects and database either. This may not seem to be a problem, but anyway we cannot be hundred percent sure that our system will work as complete in the target environment.
I think, Cactus relieves us from problems/difficulties mentioned above. I actually do not see using Cactus to do in container testing and testing with mock objects as opponents, but complementary to each other. Cactus tests appear more as integration unit tests, while mock objects are used mainly in testing code logic in isolation.