tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Fryer <apfr...@hotmail.com>
Subject Re: Difference of initializing context
Date Sun, 23 Sep 2012 03:25:57 GMT
You don't need the application-client.xml file if you use the @ManagedBean
annotation on your unit test classes instead of @LocalClient.  Using
@ManagedBean also means @Inject will work in your test cases and you can
re-use the same container across mutlipe junit tests.

Using @LocalClient you bind using this code...

Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
InitialContext ctx = new InitialContext(p);
ctx.bind("inject", this);


Using @ManagedBean you have to bind like this...

ejbContainer.getContext().bind("inject", this);

I recommend replacing @LocalClient with @ManagedBean, get rid of
application-client.xml and changing your test cases to use
ejbContainer.getContext().bind("inject", this);




--
View this message in context: http://openejb.979440.n4.nabble.com/Difference-of-initializing-context-tp4657559p4657604.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Mime
View raw message