Vishwanath Krishnamurthi's blog

A blog on Java EE, clean code, open source and TDD

What’s cool about using OpenEJB for testing EJBs ?

with 2 comments

You have two forms of OpenEJB servers.

  1. Embedded
  2. Standalone

The embedded server comes in very handy when you want to test your EJBs.

Yes. Testing your EJBs become as simple as including the openejb-core dependency and writing 3 lines of setUp code in your test.

private InitialContext initialContext;

   protected void setUp() throws Exception {
       Properties properties = new Properties();
       properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");

       initialContext = new InitialContext(properties);

And the tests run in milliseconds 🙂

Links from the docs:

  • See here for an example bean and a test.
  • And if you wanted to dig in and make some more changes / configurations this doc might help


Used to scribble the diagram. Love this one 🙂


Written by Vishwanath Krishnamurthi

June 23, 2011 at 8:11 pm

Posted in Java EE

Tagged with , , , ,

2 Responses

Subscribe to comments with RSS.

  1. how do you work on 10 tools in a day 🙂


    June 24, 2011 at 6:56 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: