OpenEJB

Tuesday April 28, 2009

Alternate descriptors for testing

Inspired by some user blog posts, we've added a new feature so support for altDD (alternative deployment descriptors) can be done in a test or other environment without much work.

Basically, just set the new "openejb.altdd.prefix" system property or initialcontext property to something like "test", then any descriptors in your META-INF/ directory that start with "test." will override the regular descriptor. So for example with an app like this:

  • META-INF/ejb-jar.xml
  • META-INF/test.ejb-jar.xml
  • META-INF/persistence.xml
  • META-INF/test.env-entry.properties

    Just initialize your test case like so:

     Properties properties = new Properties();
     properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
          "org.apache.openejb.client.LocalInitialContextFactory");
     properties.setProperty("openejb.altdd.prefix", "test");
    
     InitialContext initialContext = new InitialContext(properties);
    
    The logical result will be:

  • META-INF/ejb-jar.xml (via test.ejb-jar.xml)
  • META-INF/persistence.xml
  • META-INF/env-entry.properties (via test.env-entry.properties)

    This will work in any environment in which OpenEJB works (embedded, standalone, tomcat, geronimo, etc.).

  • Comments:

    Post a Comment:
    • HTML Syntax: NOT allowed

    Calendar

    Search

    Hot Blogs (today's hits)

    Tag Cloud

    Categories

    Feeds

    Links

    Navigation