Loading ...
Sorry, an error occurred while loading the content.

2621[XP] Testing EJB

Expand Messages
  • Gareth Reeves
    Feb 29, 2000
    • 0 Attachment
      This came up at the XPImmersionTwo course today.

      It is also something similar to what I have been doing with testing
      servlets.

      The servlet problem:
      The functionality of my servlets relies on some of the services that the
      servlet engine provides. The servlet engine creates the HttpServletRequest
      and HttpServletResponse and passes them to the servlet when executed. These
      objects are the way to get information in and out of the servlet. The
      servlet is rendered useless without these objects. The servlet engine offers
      other services like session management, the use of those services needs to
      be unit tested.

      Testing EJBs (same problem):
      To test these things we need to replace these APIs with a testable
      implementation. Polymorphism (thanks Uncle Bob). But... I can't imagine
      anyone is going to implement EJB API's just for testing.

      I was able to do implement the JSDK API's for testing by reusing a lot of
      code from a real servlet engine that I had been working on, this worked out
      quite well. Maybe there is a open source EJB container out there that can be
      leveraged for testing purposes.

      There is a very fine line here between Unit testing and Functional testing
      and I want to be careful not to cross it. I think that in general Functional
      tests can be implemented using the real container or servlet engine, however
      this is usually not appropriate or not possible for Unit tests.

      So again, the problem is, how do we unit test the code that relies on a
      service provided by a container? Dummy implementations of those services can
      be created but in EJB's case I think this is an unrealistic amount of work.
      The JSDK API was a significant amount of work even with a 50% code reuse.

      Any comments are appreciated.

      I will make the JSDK API code available to anyone who thinks they can make
      good use of it.

      Happy Testing

      Gareth


      ------------------------------------------------------
      'Sufficient to the day are the troubles thereof'
    • Show all 4 messages in this topic