Part 2. Testing J2EE
Most “serious” Java development these days revolves around J2EE: enterprise components for Java. This part of the book explores testing techniques for the core J2EE technologies: servlets, JavaServer Pages, Velocity templates, Enterprise JavaBeans, and Java Messaging Service. It also covers concepts common to web application platforms: page flow, dynamic content, distributed objects, as well as the separation of application logic, business logic, and persistence. The recipes in this part of the book generally fall into two categories: refactoring towards testing J2EE designs, and dealing with legacy J2EE designs, where legacy generally means “you are afraid to change it.” From this point forward, recipes build on the foundations in part 1, so you will see numerous references here to earlier recipes. In a way, the goal of the remaining recipes is to reduce every testing problem to a smaller number of recipes from part 1. Enjoy.
We originally conceived this part as “JUnit and Frameworks,” because there are a few general guidelines that govern how to test code that lives in a framework. With J2EE, frameworks are everywhere: servlets, EJBs, JMS message listeners—these are all objects we code within a component framework and execute in the context of containers. This raises two main issues: performance and dependency; and a testable design is one that manages both effectively.