Title: Writing Test Cases For OpenJPA
You are welcome to contribute new test cases. Following are few suggestions and guidelines on how to contribute new test case to OpenJPA repository of 2000 test cases spread across 400 classes.
Unit Tests are JUnit Tests. The base JUnit test case implementation org.junit.TestCase has been extended to facilitate common initialization steps or configuration settings for unit testing OpenJPA. The inheritance hierarchy is:
As a test developer, you should inherit your test class from one of the extended TestCases. In general, SingleEMFTestCase is a good candidate to inherit from. If your test needs to analyze or count number of SQL statements, SQLListenerTestCase should be your choice.
OpenJPA TestCases augment the setUp() method to accept a list of arguments. In this list, you should specify:
the entity classes used by your test
the critical configuration properties
CLEAR_TABLES or DROP_TABLES : these are constants declared in the superclass which clears the existing rows or drops the tables altogether.
The following is an example setUp() method
Prefer annotation over XML Descriptors for O-R Mapping because that helps to collocate relevant information. Unless, of course, the test is specific about variations in behavior across annotation and XML Descriptors.
For verification, use many assertion methods provided by JUnit e.g. assertEquals() or assertTrue() rather than depending on printing trace with System.out.println(). If you want to trace generated SQL or other runtime information, use appropriate openjpa.Log property settings.
Create a JIRA issue. Refer to the JIRA issue in the comments section of the new test case.
Remember to include ASF License header in the comment section of all the new source or resource files.
Package all the *.java files related to your test case in a JAR file and attach it to JIRA issue you have created. You must check in the radio button Grant license to ASF for inclusion in ASF works that appears near the bottom of Attach File JIRA page.