The Torque test project

The test project tests all aspects of the Torque main distribution and checks whether the different parts of Torque (runtime, generator, templates, maven-plugin) work together. The test project is almost a normal Torque project, with the following differences:

  • It contains additional maven goals to run the tests
  • Instead of directly using the schema files from the src/schema directory, the schema files are copied to the directory target/schema, and some tokens are replaced during copying. For the tests, the schema files from target/schema with the replaced tokens are used.
  • The test project POM extends the POM of one of the test profiles (which in turn extend the POM of the Torque runtime in order to include all dependencies of the runtime). To choose the parent POM out of the many profiles, the maven parameter torque.test.profile must be set to the name of the directory containing the chosen profile (see below for instructions and an example).

Running the test project using Maven 1

In order to run the test project, the following procedure is recommended:

  • Check out the trunks module from the svn repository
  • Change into the directory trunks/test/profile, and change one of the profiles to match the database which you want to test against. The file project.xml contains the location of the jdbc driver (you might need to install the driver manually to the local maven repository, see the Tutorial on how to do this). The file project.properties contains the settings for the maven plugin (and thus the generator), and the file Torque.properties contains the settings for the runtime.
  • Change into the directory trunks/test/test-project, and run the command maven -Dtorque.test.profile=${profile} to run the test, replacing the variable ${profile} with the name of your chosen profile directory. For example, if you want to test against mysql, run maven -Dtorque.test.profile=mysql

    If you want to build all Torque modules from source, install them in your local maven repository, and run the test using the newly installed Torque components all in one rush, use the command maven -Dtorque.test.profile=${profile} torque-test:install-run

Common pitfalls when using Maven 1

If maven complains about not being able to load its parent POM, this is probably due to one of the following:

  • The maven parameter torque.test.profile is either not set or set to the wrong value. Set it to a valid value, for example by using the command line parameter -Dtorque.test.profile=mysql when running maven.
  • You have not checked out the whole trunks module. The test project indirectly extends the runtime POM (via the profile POMs) to include the libary the runtime depends on. Either check out the whole trunks directory, or get the runtime POM from somewhere else and refer to it in the <extend> part of the profile.

Running the test project using Maven 2

In order to run the test project with maven 2, use the following procedure:

  • Check out the trunks module from the svn repository.
  • Change into the each of the directories runtime, templates, generator and maven2-plugin and run the command mvn install in each of the directories (in the order above).
  • Change into the directory trunks/test/test-project, and change one of the profiles in the file profiles.xml to match the database which you want to test against.
  • In the directory trunks/test/test-project, run the command mvn -P${profile} test to run the test, replacing the variable ${profile} with the name of your chosen profile. For example, if you want to test against mysql, run mvn -Pmysql test