Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

re: junit test for entity beans ... ejb 3.0

843830Apr 5 2006 — edited Apr 11 2006
I'm confused. I'm trying to test my entity bean.

I have:

- an entity bean
- a stateless session bean for accessing the entity bean (facade)
- an interface for accessing the the stateless bean

And I'm trying to write a JUnit test class to test this bean. However, I am uncertain as to how to test this (I'm new to EJB 3.0, JBoss and Eclipse).

What would the JUnit test look like? I'm confused as to whether or not I should be injecting the interface/bean/what???

I've tried several variations. I either get "NameNotFound" - not bound exceptions or Null pointer exceptions.

What would the @EJB syntax look like or how would I do it through the context?

For Example:

@EJB private TestFacade myTest; //interface to stateless bean ?

OR

InitialContext ctx = new InitialContext();
TestResultFacadeBean myTest = (TestResultFacadeBean) ctx.lookup("localTest");

I'm confused at to which method I should be using and what object I should be accessing. If I could get either one to work, I'd be happy. :)

How do I ensure my bean is deployed to the container? What do I need to do?

If anyone has a simple example or explanation as to which method I should use and how to use it, I'd be very grateful.

Thanks very much,
LisaD
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 9 2006
Added on Apr 5 2006
4 comments
225 views