<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project [
   <!ENTITY buildmagic SYSTEM "../tools/etc/buildmagic/buildmagic.ent">
   <!ENTITY libraries  SYSTEM "../thirdparty/libraries.ent">
   <!ENTITY modules SYSTEM "../tools/etc/buildmagic/modules.ent">
   <!ENTITY targets SYSTEM "../tools/etc/buildmagic/targets.ent">
]>

<!-- $Id$ -->

<project default="main" name="JBoss/System Tests">

   <!-- ================================================================== -->
   <!-- Setup                                                              -->
   <!-- ================================================================== -->

   <!--
     | Include the common Buildmagic elements.
     |
     | This defines several different targets, properties and paths.
     | It also sets up the basic extention tasks amoung other things.
   -->

  &buildmagic;

  <!--
     | Include the normal targets.
   -->
  &targets;

  <!-- ================================================================== -->
   <!-- Configuration                                                      -->
   <!-- ================================================================== -->

   <!--
     | Configure the build system.
     |
     | This target is invoked by the Buildmagic initialization logic and
     | should contain module specific configuration elements.
   -->

   <target name="configure" unless="configure.disable">

      <!-- =================== -->
      <!-- Basic Configuration -->
      <!-- =================== -->

      <!-- Module name(s) & version -->
      <property name="module.name" value="system" />
      <property name="source.java" value="${module.source}/tests" />
      <property name="javac.target" value="1.4" />
      <property name="javac.source" value="1.4" />
      <property name="build.classes" value="${module.output}/classes-tests" />
      <property name="build.testlog" value="${module.output}/log" />
      <property name="build-bypass.disabled" value="true" />

      <!-- ========= -->
      <!-- Libraries -->
      <!-- ========= -->

    &libraries;

    <!-- The combined library classpath -->
      <path id="library.classpath">
         <path refid="junit.junit.classpath" />
         <path refid="gnu.getopt.classpath" />
         <path refid="javassist.classpath" />
         <path refid="apache.log4j.classpath" />
         <path refid="oswego.concurrent.classpath" />
         <path refid="jboss.jbossxb.classpath" />
         <path refid="jboss.common.classpath" />
         <path refid="apache.xerces.classpath" />
         <path refid="dom4j.dom4j.classpath" />
      </path>

      <!-- ======= -->
      <!-- Modules -->
      <!-- ======= -->

    &modules;
	<!-- this -->
      <property name="jboss.this.root" value="${module.root}/output" />
      <property name="jboss.this.lib" value="${jboss.this.root}/lib" />
      <path id="jboss.this.classpath">
         <fileset dir="${jboss.this.lib}">
            <include name="*.jar" />
            <exclude name="run.jar" />
         </fileset>
      </path>

      <!-- The combined dependant module classpath -->
      <path id="dependentmodule.classpath">
         <path refid="jboss.jmx.classpath" />
         <path refid="jboss.test.classpath" />
         <pathelement location="output/classes" />
      </path>

      <!-- ===== -->
      <!-- Tasks -->
      <!-- ===== -->

      <call target="_default:task-init" />

      <path id="thirdparty.classpath">
         <path refid="library.classpath" />
         <path refid="dependentmodule.classpath" />
      </path>

   </target>
   <patternset id="compile-resources.pattern">
      <include name="${src.resources}/**" />
   </patternset>

   <!-- ================================================================== -->
   <!-- Compile                                                            -->
   <!-- ================================================================== -->

   <!--
     | Compile everything.
     |
     | This target should depend on other compile-* targets for each
     | different type of compile that needs to be performed, short of
     | documentation compiles.
   -->

   <target name="compile" description="Compile all source files." depends="_default:compile-classes, _default:compile-resources" />

   <!-- ================================================================== -->
   <!-- Archives                                                           -->
   <!-- ================================================================== -->

   <target name="module-jars" depends="init">
       <!-- Build jboss-system-test.jar -->
       <jar jarfile="${build.lib}/jboss-system-test.jar" manifest="${build.etc}/default.mf">
          <fileset dir="${build.classes}"/>
          <fileset dir="${build.resources}/tests">
             <include name="org/**"/>
          </fileset>
       </jar>
   </target>

   <!-- ================================================================== -->
   <!-- Tests                                                              -->
   <!-- ================================================================== -->

   <target name="tests" depends="most"
      description="Execute all tests in the given test directory.">
      <mkdir dir="${build.reports}" />
      <mkdir dir="${build.testlog}" />
      <!-- Remove the test.log so each run has a fresh log -->
      <delete file="${build.testlog}/test.log" />
      <junit dir="${module.output}" printsummary="yes" haltonerror="false" haltonfailure="false" fork="true">

         <sysproperty key="build.testlog" value="${build.testlog}" />
         <syspropertyset id="jbosstest-properties">
            <propertyref prefix="jbosstest" />
         </syspropertyset>

         <classpath>
            <pathelement location="${build.classes}" />
            <pathelement location="${build.resources}/tests" />
            <path refid="javac.classpath" />
            <path refid="apache.xerces.classpath" />
         </classpath>

         <formatter type="plain" usefile="true" />
         <formatter type="xml" usefile="true" />

         <batchtest todir="${build.reports}" haltonerror="false" haltonfailure="false" fork="true">

            <fileset dir="${build.classes}">
               <include name="org/jboss/test/**/*TestCase.class" />
            </fileset>
         </batchtest>
      </junit>
   </target>

   <target name="one-test" depends="init"
      description="Execute the test defined by ${test}">
      <mkdir dir="${build.reports}" />
      <mkdir dir="${build.testlog}" />
      <!-- Remove the test.log so each run has a fresh log -->
      <delete file="${build.testlog}/test.log" />
      <junit dir="${module.output}" printsummary="yes" haltonerror="false" haltonfailure="false" fork="true">

         <sysproperty key="build.testlog" value="${build.testlog}" />
         <syspropertyset id="jbosstest-properties">
            <propertyref prefix="jbosstest" />
         </syspropertyset>

         <classpath>
            <pathelement location="${build.classes}" />
            <pathelement location="${build.resources}/tests" />
            <path refid="thirdparty.classpath" />
            <path refid="apache.xerces.classpath"/>
         </classpath>

         <formatter type="plain" usefile="true" />
         <formatter type="xml" usefile="true" />

         <test todir="${build.reports}" name="${test}" haltonerror="${junit.batchtest.haltonerror}" haltonfailure="${junit.batchtest.haltonfailure}" fork="${junit.batchtest.fork}" />
      </junit>
   </target>

</project>
