Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Development/Testing/JPA

< EclipseLink‎ | Development‎ | Testing
Revision as of 16:36, 26 November 2008 by Eric.gwin.oracle.com (Talk | contribs) (Running the JPA tests)

Running the JPA tests

The JPA tests can be run in several ways.

  • Ant (1.7 or greater)
  • Eclipse JUnit
  • Testing Browser
  • Server testing

Ant

The eclipselink.jpa.test/build.xml contains several ant targets for testing. The "test" target will run the JPA LRG. Ensure that the eclipselink.jpa.test/test.properties file has been configured for your database and environment. You may overwrite this file in {user.home}/test.properties.

 ant test

This will run the JPA LRG, the results will be output into the eclipselink.jpa.test/report directory as html.

The following ant test targets are defined:

  • test (runs FullRegressionTestSuite using agent)
  • test-no-weave (runs FullRegressionTestSuite without any weaving)
  • test-static-weave (runs FullRegressionTestSuite with static weaving)

Eclipse JUnit

The JPA test suite is written using JUnit. It consists of a set of jars that contain various persistence units and a number of tests. The JPA tests are contained in the eclipselink.jpa.test project

  1. Ensure you have an eclipselink jar available on your classpath. This jar is checked in to the foundation component in the SVN repository and can be created by running the ant build located in the eclipselink.core project.
  2. Run the build.xml in base directory of eclipselink.jpa.test. This will create a set of jar files containing the persistence units.
  3. Edit eclipselink.jpa.test/test.properties to include information necessary to connect to your database
  4. Use the JUnit run target provided, or create your own:
    1. The project will be: eclipselink.jpa.test
    2. The test class will be: org.eclipse.persistence.testing.tests.jpa.FullRegressionTestSuite
    3. Add the JVM argument "-javaagent:<eclipselink-jar-location>/eclipselink.jar" - This will allow the test models to run with weaving enabled
    4. Add to your classpath the following:
      1. Your JDBC driver
      2. A library that includes all the jar files generated by the build.xml in jpa.test you ran earlier
  5. Run the run/debug target you created

Testing Browser

The JPA tests can also be run through the foundation Testing Browser. This provides additional debugging capabilities so is sometimes desired. There are some JPA tests that extend the foundation test framework, which are not run through the normal JUnit test target. The "JPA Tests" in the Testing Browser include these tests.

Note: Before testing in Eclipse using the Testing Browser - you will need to a full root build of EclipseLink in 'trunk>ant' so that the test jars eclipse*model.jar get created and placed on the root of jpa/eclipselink.jpa.test. Please refresh your eclipselink.jpa.test project to pick these up before running the Testing Browser eclipse launch target.

The eclipselink.jpa.test Eclipse project contains a launch file for running the testing browser. The database login information and logging level can be configured. If you have previously run the JPA tests on the same database the "Fast" checkbox can be used to avoid recreating the database.

Server Testing

The JPA tests can be run on any JEE EJB 3 compatible server (in theory). The server tests are run through ant as they require building and deployment.

The following ant test targets are defined:

  • server-start
  • server-stop
  • server-test-sessionbean
  • server-test-fieldaccess-advanced

To run JPA tests on a server do the following:

  • Install your JEE server.
  • Define a "EclipseLinkDS" JTA DataSource in your server.
  • Add the eclipselink.jar and your JDBC jar to your server applications classpath.
  • Edit your eclipselink.jpa.test/test.properties and set the "server.name" to your server.
  • Create an eclipselink.jpa.test/<server.name>.xml ant file and define, start, stop, deploy, undeploy
  • Create an eclipselink.jpa.test/<server.name>.properties file to store any required configuration properties including, server.user, server.pwd, server.url, server.lib, server.depend, server.platform.
  • Run "ant server.start" (or start your server manually).
  • Run "ant server.test.<test>".

The ant files already exist for the following servers:

  • OC4J

OC4J

To run JPA tests on OC4J configure the following:

  • Add the eclipselink.jar and JDBC driver (even if Oracle) to <oc4j>j2ee/home/applib.
  • Edit the datasource.xml and define a JTA datasource "EclipseLinkDS".
  • Edit eclipselink.jpa.test/oc4j.properties and set the paths and ports for your server.

Back to the top