1 Reply Latest reply on Apr 10, 2006 8:53 AM by lisad

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

    lisad

      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. :)

      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