Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-131

Include utility base class to simplify JPA testing

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • None
    • None

      Two things are often needed when testing JPA code:
      -1 Counting rows in a table
      -2 Rolling back the transaction after each test (to speed up test execution, while potentially dangerous)

      To simplify testing it would be good to have a set of base classes that implement this common functionality. Test class can extend a base class when this kind of functionality is required. The Spring framework has excellent support for this and can be used for inspiration:
      http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/testing.html#testcontext-support-classes-junit4

      I included some example code that I wrote myself to get a feel how difficult it would be to implement. The code uses an embedded container using the EJB 3.1 API, but should off course integrate with Arquillian.

      By default each testcase runs in a transaction (using the usertransaction) and is rolled back at the end of the test, unless the testcase is annotated @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED). The rollback behavior can be changed with the custom @RollbackAfterTest anotation.

      I would be happy to help implementing this feature.

        1. AbstractJPATest.java
          8 kB
        2. ContactBeanTest.java
          3 kB
        3. RollbackAfterTest.java
          0.3 kB

            pbakker_jira Paul Bakker (Inactive)
            pbakker_jira Paul Bakker (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: