Ejb Test

Discussions

General J2EE: Ejb Test

  1. Ejb Test (3 messages)

    Does anyone know how can i test my ejb without any container?
    Is there any tool or configuration that easy?

    Threaded Messages (3)

  2. Ejb Test[ Go to top ]

    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.
  3. Ejb Test[ Go to top ]

    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
  4. How about OpenEJB ?[ Go to top ]

    Does anyone know how can i test my ejb without any container?
    Is there any tool or configuration that easy?
    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/