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:

  • Instead of directly using the schema files from the src/main/schema directory, the schema files are copied to the directory target/torque/test/schema, and some tokens are replaced during copying. For the tests, the schema files from target/torque/test/schema with the replaced tokens are used.
  • The test project checks whether the book table exists in the database by executing the command select count(*) from book. If it fails, it is assumed that we work on an empty database and no drop commands are generated. If it succeeds, we assume that all tables have been dropped and generate all drop commands. Should the database be in an inconsitent state, you can add -DonSqlError=continue to execute all sql statements nonetheless.

Running the test project

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

  • Check out the trunk containing the Torque modules from the svn repository.
  • Run the command mvn install in the directory you just checked out.
  • Change into the directory torque-test, and change one of the profiles in the file pom.xml to match the database which you want to test against.
  • Also change the file Torque.properties in the directory torque-test/src/test/profile/${profile} (where ${profile} is the name of the profile you have chosen) to match the database settings.
  • In the directory torque-test, run the command mvn -P${profile} clean test to run the test, replacing the variable ${profile} with the name of your chosen database profile.
    For example, if you want to test against mysql, run mvn -Pmysql clean test.

The standard database profiles do not generate managers and beans, nor do they execute the corresponding tests. For generating beans, activate the beans profile. This will generate the bean classes and run the corresponding test. For using manager classes, activate the managers profile. This will generate the manager classes and run the corresponding test.
For example, if you want to run the test against mysql and use beans and managers, run mvn -Pmysql,beans,managers clean test.

Running mvn eclipse:eclipse on the test project

Because dependency information is pulled from the profiles, you need to enable a profile from the profiles.xml for generating the eclipse files. Running mvn eclipse:eclipse without a profile will result in the following error:
org.apache.maven.reactor.MavenExecutionException: Failed to validate POM for project org.apache.torque:torque-test

The profile you choose will also pull the database driver from the profile into your eclipse project. E.G. if you want to use the mysql driver dependency in your eclipse project, run mvn -Pmysql eclipse:eclipse