1. glassfish
  2. GLASSFISH-1420

Allow entity-persistence-tests to automatically clean up


    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 9.1pe
    • Fix Version/s: not determined
    • Component/s: entity-persistence
    • Labels:
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:


      The following is a suggestion from Craig Russell that would allow test clean up
      to happen in a much more intuitive way:

      It might be worthwhile to look at adding some behavior to the toplink
      base class JUnitTestCase to allow a subclass to acquire an
      EntityManager that will be cleaned up by the tearDown method in the
      base class.

      Maybe add a protected field EntityManager em to the base class.
      Subclass tests could either clean up their own EntityManager using a
      try finally pattern or if they assigned the base class em field could
      simply throw an exception and exit. At the end of the test, if the em
      field is not null, the base class tearDown would clean it up.

      This pattern provides for cleaning up the EntityManager without
      duplicating or adding code to each test case.

      From my experience, it's difficult to look at a test case that does
      its own cleanup, because each test writer's ideas of what needs to be
      cleaned up tends to be different. Some tests use a try catch where
      the catch cleans up, some don't clean up at all, some use try finally.

      It's more efficient to have common code that can evolve as our
      understanding of how to clean up evolves.


        tware created issue -
        kenaiadmin made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 1420 33024
        Tom Mueller made changes -
        Fix Version/s not determined [ 11149 ]
        Fix Version/s 9.1pe [ 10974 ]


          • Assignee:
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: