There are a lot of tests for some EJBs.
Starting an J2EE server is slow. I wanted to test the business logic faster.
Most of the beans reference only each other and a persistence context.
So what should the mock worry about - transaction demarcation and dependency injection. And... exception wrapping and unwrapping.
- First just add some setters or change the access level modifiers (from private to protected for example).
- Know your transaction authority.
- Count started transactions. If 0, begin. If 0, commit. Rollback when necessary.
- Listen for all the exceptions and wrap and unwrap them.
- Reuse as much as possible of the code.
If I have some spare time left, I'll write some code.