<?xml version="1.0"?>
<!--
	Ant script for running a batch test that uses "testCases"
-->
<project default="">
	
	<!-- import the global configuration file -->
	<property file="../shared/ant.config"/>
	
	
	<!-- test directory where you put your files like "relaxNNN.rlx" -->
	<property name="testRoot" value="../testCases" />
	
	<!-- test configuration -->
	<path id="commonTestDir">
		<pathelement path="${testRoot}/suites/JepaX"/>
		<pathelement path="${testRoot}/suites/NITF"/>
		<pathelement path="${testRoot}/suites/errorRELAXGrammar/lrgErrRatio"/>
		<pathelement path="${testRoot}/suites/errorRELAXGrammar/smlErrRatio" />
	</path>
	
	<path id="RELAXBatchTestDir">
		<path refid="commonTestDir"/>
		<pathelement path="${testRoot}/relax"/>
	</path>
	<property name="RELAXBatchTestDir" refid="RELAXBatchTestDir"/>
	
	<path id="RELAXNGBatchTestDir">
		<path refid="commonTestDir"/>
		<pathelement path="${testRoot}/relaxng"/>
		<!-- '@' instructs the recursive subdirectory processing -->
		<pathelement path="${testRoot}/relaxng/jamesClark@"/>
	</path>
	<property name="RELAXNGBatchTestDir" refid="RELAXNGBatchTestDir"/>
	
	<path id="TREXBatchTestDir">
		<path refid="commonTestDir"/>
		<pathelement path="${testRoot}/trex"/>
	</path>
	<property name="TREXBatchTestDir" refid="TREXBatchTestDir"/>
	
	<path id="DTDBatchTestDir">
		<path refid="commonTestDir"/>
		<pathelement path="${testRoot}/dtd/XHTMLm12n/examples"/>
		<pathelement path="${testRoot}/dtd/XHTML1.0"/>
	</path>
	<property name="DTDBatchTestDir" refid="DTDBatchTestDir"/>
	
	<path id="XSDBatchTestDir">
		<path refid="commonTestDir"/>
		<pathelement path="${testRoot}/xmlschema"/>
		<pathelement path="${testRoot}/xmlschema/contrib"/>
		<pathelement path="${testRoot}/xmlschema/tutorialExamples"/>
		<pathelement path="${testRoot}/xmlschema/identity" />
	</path>
	<property name="XSDBatchTestDir" refid="XSDBatchTestDir"/>
	
	
	
	
	
<!--
	PatternSets for the partial test
	========================================================================
	
	This pattern specifies which test codes should be executed.
	The same pattern is used to test both the working copy and the release package.
-->
	<!-- all -->
	<patternset id="tps.all">
		<include name="**/*Test.class"/>
		<include name="**/*TestG.class"/>
	</patternset>
	
	<!-- XSDLib -->
	<patternset id="tps.xsdlib">
		<include name="com/sun/msv/datatype/**/*Test.class" />
	</patternset>
	
	<!-- MSV core -->
	<patternset id="tps.msv">
		<include name="batch/verifier/**/*Test.class" />
		<include name="com/sun/msv/util/*Test.class" />
	</patternset>
	
	<!-- generator -->
	<patternset id="tps.generator">
		<include name="**/generator/**/*TestG.class" />
	</patternset>
	
	<!--  RELAX converter -->
	<patternset id="tps.rngconv">
		<include name="batch/writer/relaxng/**/*Test.class"/>
	</patternset>
	
	<!-- TREX converter -->
	<patternset id="tps.trexconv">
		<include name="batch/writer/trex/**/*Test.class"/>
	</patternset>
	
	
	
	
<!--
	run the current batch tests against
	the working directory.
	
	./bin/**/*Test.class is executed
-->
	<target name="test">
		<mkdir dir="./testLog" />
		<!--
			please remove jaxp.jar from ant directory,
			because it uses an old one, and this test needs the latest one
		-->
		<junit haltonfailure="no" printsummary="yes" fork="yes"
			haltonerror="no" failureProperty="hadError">
			<sysproperty key="RELAXBatchTestDir"	value="${RELAXBatchTestDir}"/>
			<sysproperty key="TREXBatchTestDir"		value="${TREXBatchTestDir}"/>
			<sysproperty key="DTDBatchTestDir"		value="${DTDBatchTestDir}"/>
			<sysproperty key="XSDBatchTestDir"		value="${XSDBatchTestDir}"/>
			<sysproperty key="RELAXNGBatchTestDir"	value="${RELAXNGBatchTestDir}"/>
			
			<!-- perform strict check on schema.
				do not define MSV_STRICT_CHECK to turn off the check -->
			<sysproperty key="MSV_STRICT_CHECK" value="yes"/>
			
			<formatter type="plain" />
			<formatter type="xml" />
			
			<classpath>
				<pathelement location="bin" />
				<pathelement location="src" />
				<pathelement location="test" />
				<pathelement location="../xsdlib/bin/" />
				<pathelement location="../xsdlib/src/" />
				<pathelement location="../msv/bin/" />
				<pathelement location="../msv/src/" />
				<pathelement location="../testharness/bin/" />
				<pathelement location="${relaxngDatatype.jar}" />
				<pathelement location="${isorelax.jar}" />
				<pathelement location="${resolver.jar}" />
				<pathelement path="${java.class.path}" />
				<!--include CatalogManager.properties into the class path -->
				<pathelement path="${testRoot}"/>
			</classpath>
			
			<batchtest todir="./testLog">
				<fileset dir="bin">
					<include name="**/*Test.class"/>
				</fileset>
			</batchtest>
		</junit>
	</target>
	
	
	
<!--
	run the batch tests
	against the release package.
	
	./bin/**/*Test.class are executed against ${testJar} file.
-->
	<target name="test_release">
		<!-- create temporary directory -->
		<mkdir dir="./temp"/>
		
		<!-- extract the contents of the jar file to be tested -->
		<unjar src="${testJar}" dest="temp" />
		
		<!--
			compile test harnesses into it.
			It is ok to rely on the working copy at this stage.
		-->
		<javac
			srcdir="./test"
			destdir="./temp"
			debug="on"
			optimize="off"
			classpath="temp:bind"
			/>
		
		<!-- run JUnit -->
		<mkdir dir="./testLog" />
		<junit haltonfailure="yes" printsummary="yes" fork="yes"
			haltonerror="yes">
			<sysproperty key="RELAXBatchTestDir"	value="${RELAXBatchTestDir}"/>
			<sysproperty key="TREXBatchTestDir"		value="${TREXBatchTestDir}"/>
			<sysproperty key="DTDBatchTestDir"		value="${DTDBatchTestDir}"/>
			<sysproperty key="XSDBatchTestDir"		value="${XSDBatchTestDir}"/>
			<sysproperty key="RELAXNGBatchTestDir"	value="${RELAXNGBatchTestDir}"/>
			
  				<formatter type="plain" />
			
			<classpath>
				<!-- do not refer to the working copy -->
				<pathelement location="./test" />
				<pathelement location="./temp" />
				<pathelement location="${junit.jar}"/>
				<pathelement location="${ant.jar}"/>
				<pathelement location="${relaxngDatatype.jar}"/>
				<!-- do not let whatever binaries in your classpath interfer with it. -->
			<!-- DO NOT: <pathelement path="${java.class.path}" />-->
			</classpath>
			
			<batchtest todir="./testLog">
				<fileset dir="temp">
					<include name="**/*Test.class"/>
				</fileset>
			</batchtest>
		</junit>
		
		<delete dir="./temp"/>
	</target>
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	<!-- run xsdlib test                                                 -->
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<target name="test_xsdlib">
		<antcall target="doTest">
			<param name="testPattern" value="tps.xsdlib"/>
		</antcall>
	</target>
	<target name="test_xsdlib_package">
		<antcall target="doReleaseTest">
			<param name="testPattern" value="tps.xsdlib" />
			<param name="testJar" value="./package/xsdlib.jar"/>
		</antcall>
	</target>
	
	
	<!-- run core msv test                                               -->
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<target name="test_msv">
		<antcall target="doTest">
			<param name="testPattern" value="tps.msv"/>
		</antcall>
	</target>
	<target name="test_msv_package">
		<antcall target="doReleaseTest">
			<param name="testPattern" value="tps.msv" />
			<param name="testJar" value="./package/msv.jar"/>
		</antcall>
	</target>
	
	
	<!-- run generator test                                              -->
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<target name="test_xmlgen">
		<antcall target="doTest">
			<param name="testPattern" value="tps.generator" />
		</antcall>
	</target>
	<target name="test_xmlgen_package">
		<antcall target="doReleaseTest">
			<param name="testPattern" value="tps.generator" />
			<param name="testJar" value="./package/xmlgen.jar"/>
		</antcall>
	</target>
	
	
	<!-- run RELAX NG converter test                                     -->
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<target name="test_rngconv">
		<antcall target="doTest">
			<param name="testPattern" value="tps.rngconv" />
		</antcall>
	</target>
	<target name="test_rngconv_package">
		<antcall target="doReleaseTest">
			<param name="testPattern" value="tps.rngconv" />
			<param name="testJar" value="./package/rngconv.jar"/>
		</antcall>
	</target>
	
	
	<!-- run TREX converter test                                         -->
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<target name="test_trexconv">
		<antcall target="doTest">
			<param name="testPattern" value="tps.trexconv" />
		</antcall>
	</target>
	<target name="test_trexconv_package">
		<antcall target="doReleaseTest">
			<param name="testPattern" value="tps.trexconv" />
			<param name="testJar" value="./package/trexconv.jar"/>
		</antcall>
	</target>
	
	
	
	
	
	
	
</project>