<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-->

<document>
  <properties>
    <title>Test project</title>
    <author email="fischer@seitenbau.de">Thomas Fischer</author>
  </properties>

  <body>
    <section name="The Torque test project">
      <p>
        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:
        <ul>
          <li>
            It contains additional maven goals to run the tests
          </li>
          <li>
            Instead of directly using the schema files from the 
            <i>src/schema</i> directory, the schema files are copied to the 
            directory <i>target/schema</i>, and some tokens are replaced during 
            copying. 
            For the tests, the schema files from <i>target/schema</i> with the 
            replaced tokens are used.
          </li>
          <li>
            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 
            <code>torque.test.profile</code> must be set to the name of the 
            directory containing the chosen profile (see below for instructions
            and an example).
          </li>
        </ul>
      </p>

      <subsection name="Running the test project using Maven 1">
        <p>
          In order to run the test project, the following procedure is 
          recommended:
          <ul>
            <li>
              Check out the trunks module from the svn repository
            </li>
            <li>
              Change into the directory <i>trunks/test/profile</i>, and change
              one of the profiles to match the database which you want to test 
              against. The file <i>project.xml</i> 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 <i>project.properties</i> contains the 
              settings for the maven plugin (and thus the generator),
              and the file <i>Torque.properties</i> contains the settings for 
              the runtime.  
            </li>
            <li>
              Change into the directory <i>trunks/test/test-project</i>, 
              and run the command 
              <code>maven -Dtorque.test.profile=${profile}</code>
              to run the test, replacing the variable 
              <code>${profile}</code> with the name of your chosen profile
              directory. For example, if you want to test against mysql, run
              <code>maven -Dtorque.test.profile=mysql</code>
              <br />
              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
              <code>maven -Dtorque.test.profile=${profile} torque-test:install-run</code>
            </li>
          </ul>
        </p>
      </subsection>

      <subsection name="Common pitfalls when using Maven 1">
        <p>
          If maven complains about not being able to load its parent POM, 
          this is probably due to one of the following:
          <ul>
            <li>
              The maven parameter <code>torque.test.profile</code>
              is either not set or set to the wrong value. Set it to a valid
              value, for example by using the command line parameter 
              <code>-Dtorque.test.profile=mysql</code> when running maven.
            </li>
            <li>
              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 &lt;extend&gt; part of the 
              profile.
            </li>
          </ul>
        </p>
      </subsection>

      <subsection name="Running the test project using Maven 2">
        <p>
          In order to run the test project with maven 2, use the following 
          procedure:
          <ul>
            <li>
              Check out the trunks module from the svn repository.
            </li>
            <li>
              Change into the each of the directories <i>runtime</i>, 
              <i>templates</i>, <i>generator</i> and <i>maven2-plugin</i>
              and run the command <code>mvn install</code>
              in each of the directories (in the order above).
            </li>
            <li>
              Change into the directory <i>trunks/test/test-project</i>, 
              and change one of the profiles in the file <i>profiles.xml</i>
              to match the database which you want to test against. 
            </li>
            <li>
              In the directory <i>trunks/test/test-project</i>, 
              run the command <code>mvn -P${profile} test</code>
              to run the test, replacing the variable 
              <code>${profile}</code> with the name of your chosen profile.
              For example, if you want to test against mysql, run
              <code>mvn -Pmysql test</code>
            </li>
          </ul>
        </p>
      </subsection>

    </section>
  </body>
</document>
    
