3 Replies Latest reply: Sep 14, 2010 6:56 PM by Michael Schuetz RSS

    Would EasyMock Plugin make sense?

    Michael Schuetz Novice

      Hi to all,

       

      wondering, whether EasyMock plugin would make sense for Arquillian tests. It probably would be a ShrinkWrap issue, though.

       

      Why do I need this: I want to ejb-test one special focus and am not interested to add all referenced classes just because the test needs this.

       

      Thinking of something like the following:

       

       

       

       

      final JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "test.jar")

                      .addClasses(MyService.class, MyServiceBean.class, MyReferenced2ndService.class)                .addMockClass(MyReferenced2ndServiceMockBean.class);

       

       

       

       

      I would expect the test to use mock implementation of  MyReferenced2ndService, than.

      This would help keep the test nice and small and test only what I want to test.

       

       

      What do you think?

       

       

      Thanks and regards

      Michael

        • 1. Re: Would EasyMock Plugin make sense?
          Michael Schuetz Novice

          Or an even more EasyMock like approach:

           

           

          final JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "test.jar")

                           .addClasses(MyService.class, MyServiceBean.class)

          .addMock(MyReferenced2ndService.class);

           

           

          This would add MyReferenced2ndService class and generated mock implementation, additionally. So, this might be even extended, if you like: addStrictMock, addSimpleMock and so on...

           

           

          Sorry, wiki formatting does not occur like expected.

          • 2. Re: Would EasyMock Plugin make sense?
            Aslak Knutsen Master

            Have been playing with the thought in relation to some MC Bean Service mocking.

             

            But can EasyMock generate a complete Mock Class?

             

            I was looking into Mockito at the time, and as far as i found it could only generate a Serialized object of the Mock it self. To be able to get for instance the EJB Container to load it as a bean, we need to have the Mock not as a Object Stream but as a Class. (think javassist, not java Proxy)

            • 3. Re: Would EasyMock Plugin make sense?
              Michael Schuetz Novice

              Hm, ok I see. Yes, EasyMock uses java proxy for generating mock objects.

              I'll try to find help finding a mock framework that suits for this usecase.

               

              MockEJB (http://www.mockejb.org) seems to behave like expected but is outdated and does not support EJB3.