|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 2 of 6

Figure 1. Running your test inside a container vs. running the container inside your test
The figure on the left shows traditional EJB development, where the application and the test are deployed to a running EJB container. The figure on the right shows that the application and the EJB container can start and terminate inside the test.
Most EJB containers have a footprint too large to be embedded in an application. However, OpenEJB was designed to be embedded and has a small footprint. I found OpenEJB to be a perfect choice for EJB development.
As an embedded EJB container, OpenEJB starts in a just a couple of seconds (on a laptop with a 2.2 GHz Mobile Intel Pentium 4 Processor). When running, OpenEJB is like any other full-featured EJB container.
But what if your project has already chosen a particular EJB container? Can you still benefit from OpenEJB? Can your tests be carried both in OpenEJB and your choice of EJB container? If yes, do you have to make many adjustments? How much effort is required to embed OpenEJB? As an answer to the above questions, let me assert that it takes only a few minutes to set up OpenEJB, and your tests can run unmodified both on OpenEJB and your choice of EJB container.
Let's first review the tools we need:
In the development project I participate in, we use Eclipse as the IDE and Oracle OC4J as the EJB container for production. Furthermore, we use XStream to persist Java objects to XML files. These XML files are used for simulating input data for our tests.
Below is a summary of the steps you should take in testing your EJB components:

Figure 2. A JUnit test can be fed with hard-coded Java objects, or XStream can dynamically create Java objects from XML and feed the JUnit test
The following sequence diagram illustrates how the JUnit test gets a reference to a bean by embedding OpenEJB as the EJB container.
Archived Discussions (Read only)