2 Replies Latest reply on Nov 3, 2005 9:15 AM by Cameron Ross

    Testing, mock objects and ejb3 entity beans

    Cameron Ross Newbie

      I'm doing some experimenting with ejb3 and I have a question regarding how to test entity beans that refer to other entity beans using mock objects. In the POJO world I would do something like this:

      public class Whole {
       private IPart part;
       public IPart getPart() { return part; }
       public void setPart(IPart part) { this.part=part; }
      public interface IPart {
       void foo();
      public class Part implements IPart {
       public void foo() { // some complex processing logic }
      public class PartMock implements IPart {
       public void foo() {}

      I would then use PartMock when unit testing Whole. However, if I take a similar approach with my entity beans, the container will barf when I try to deploy. Specifically, JBoss will complain it is:
      Unable to find entity IPart

      Are there any thoughts out there on a general approach to unit testing entity beans using mock objects?