Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-92

Support mock-based unit testing of Roo-provided static @Entity methods

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.0.M2
    • Component/s: TESTING
    • Labels:
      None

      Description

      Roo uses static methods on entities as follows:

      • countPlural():long
      • findAllPlural():List<TheEntity>
      • findTheEntity(Identifier id):TheEntity
      • findTheEntityEntries(int first, int maxResults):List<TheEntity>

      Spring has always adopted a strong test focus. It is important this is also reflected by Roo.

      Because the above are static methods, they are difficult to mock and therefore test using conventional mocking techniques.

      Roo should offer some facility to dynamically implement mock-based stubs of these methods during tests. This should only happen on demand, so as to not interfere with the normal Roo implementations of the methods. Using AspectJ offers us the flexibility of using an around advice to replace the Roo implementation of the method as required. If the control flow included a newly-defined annotation to activate this dynamic mocking behavior, we would have a flexible solution that doesn't interfere with normal Roo provision of the methods.

      (Logged by Ben Alex on behalf of Rod Johnson, who has provided the code for this new feature)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              balex Ben Alex
              Reporter:
              rod.johnson Rod Johnson
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: