Does anyone know how can i test my ejb without any container?
Is there any tool or configuration that easy?
-
Ejb Test (3 messages)
- Posted by: Boran Karatas
- Posted on: May 27 2004 11:58 EDT
Threaded Messages (3)
- Ejb Test by Paul Strack on May 27 2004 21:01 EDT
- Ejb Test by Tomas Inger on May 28 2004 03:22 EDT
- How about OpenEJB ? by A A on March 09 2010 13:56 EST
-
Ejb Test[ Go to top ]
- Posted by: Paul Strack
- Posted on: May 27 2004 21:01 EDT
- in response to Boran Karatas
Does anyone know how can i test my ejb without any container? Is there any tool or configuration that easy?
As a rule, it is exceptionally difficult to do out-of-container testing for EJBs. There are lots of subtle dependencies to the container, such as depedencies on JNDI resources and configuration data.
The best thing I can suggest is to write the bulk of your logic in regular Java classes, which can be tested out-of-container, and then have the EJBs invoke these classes. -
Ejb Test[ Go to top ]
- Posted by: Tomas Inger
- Posted on: May 28 2004 03:22 EDT
- in response to Paul Strack
I agree,
I also always recommend development teams to wrap all communication to the InitialContext in certain classes. See the Service Locator pattern in the J2EE pattern catalogue.
Then you can write other implementations and connect them when testing outside the EJB container. For example, instead of getting a JDBC connection from the InitialContext you can use DriverManager to get it (and the only thing you loose is the TX support and connection pooling, which does not matter when you debug the JDBC code).
/Tomas -
How about OpenEJB ?[ Go to top ]
- Posted by: A A
- Posted on: March 09 2010 13:56 EST
- in response to Boran Karatas
Does anyone know how can i test my ejb without any container?
You can use OpenEjb the open source framework from Apache to test EJB 3.0 implementations. # Supports EJB 3.0, 2.1, 2.0, 1.1 in all modes; embedded, standalone or otherwise. # JAX-WS support # JMS support # J2EE connector support http://openejb.apache.org/
Is there any tool or configuration that easy?