<project name="integration" default="testAll" basedir=".">

	<!--
		This build file is usually run indirectly via Maven.
		
		When running this build file through Ant directly, you must
		define the currentVersion property on the command line, e.g.:
		
		ant  -DcurrentVersion=1.5.4-SNAPSHOT	
	-->
	
	<echo message="compile classpath: ${compile_classpath}" />
	<echo message="runtime classpath: ${runtime_classpath}" />
	<echo message="test classpath:    ${test_classpath}" />
	<echo message="plugin classpath:  ${plugin_classpath}" />
	<echo message="basedir:  ${basedir}" />


  <!--<property name="path_to_policy" value="file:./integration/src/policy/java-under-ant.policy"/>-->

	<path id="path150Binding">
		<pathelement location="target/test-classes/" />
		<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
		<pathelement location="./lib/slf4j-simple-1.5.0.jar" />
	</path >

	<path id="path1511API">
		<pathelement location="target/test-classes/" />
		<pathelement location="./lib/slf4j-api-1.5.11.jar" />
		<pathelement location="../slf4j-simple/target/slf4j-simple-${currentVersion}.jar" />
	</path >

	<path id="path1511Binding">
		<pathelement location="target/test-classes/" />
		<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
		<pathelement location="./lib/slf4j-simple-1.5.11.jar" />
	</path >

	<path id="pathCurrent">
		<pathelement location="target/test-classes/" />
		<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
		<pathelement location="../slf4j-simple/target/slf4j-simple-${currentVersion}.jar" />
	</path >

  <path id="multiBinding">
 		<pathelement location="target/test-classes/" />
 		<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
    <pathelement location="../slf4j-simple/target/slf4j-simple-${currentVersion}.jar" />
    <pathelement location="../slf4j-nop/target/slf4j-nop-${currentVersion}.jar" />
 	</path >

  <path id="binding166">
		<pathelement location="target/test-classes/" />
		<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
		<pathelement location="./lib/slf4j-simple-1.6.6.jar" />
	</path >

  <path id="binding2099">
		<pathelement location="target/test-classes/" />
		<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
		<pathelement location="./lib/slf4j-simple-2.0.99.jar" />
	</path >


  <path id="api166">
		<pathelement location="target/test-classes/" />
		<pathelement location="../slf4j-simple/target/slf4j-simple-${currentVersion}.jar" />
		<pathelement location="./lib/slf4j-api-1.6.6.jar" />
	</path >


	<!-- this is really very ugly, but it's the only way to circumvent
  	     http://jira.codehaus.org/browse/MANTRUN-95
	-->
  <!--
	<taskdef name="junit" classpath="${plugin_classpath};${compile_classpath}" 
           classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
  -->

	<target name="init">
		<mkdir dir="target/unit-reports" />
	</target>

	<target name="testAll" depends="init, 
		        testNoProvider150,
                testMismatch,
                testMatch,
		        testMultiBinding,                
                testFuture_16Series,
                testActiveSecurityManager">
	</target>


	<target name="testNoProvider150">

        <junit printsummary="yes" fork="no" haltonfailure="yes">
			<classpath refid="path150Binding" />
			<formatter type="plain" />
			<test fork="yes" todir="target/unit-reports" 
            outfile="TEST-150BINDING" 
            name="org.slf4j.NoProviderAssertionTest" />
		</junit>

  </target>


	<target name="testMixed17">

    <junit printsummary="yes" fork="no" haltonfailure="yes">
			<classpath refid="pathMixed17" />
			<formatter type="plain" />
			<test fork="yes" todir="target/unit-reports" 
            outfile="TEST-MIXED-17" 
            name="org.slf4j.VersionMismatchAssertionTest" />
		</junit>
  </target>


	<target name="testMismatch">

    <!--

    <junit printsummary="yes" fork="no" haltonfailure="yes">
			<classpath refid="path1511API" />
			<formatter type="plain" />
			<test fork="yes" todir="target/unit-reports" 
            outfile="TEST-MISMATCH-1511API" 
            name="org.slf4j.OldAPIVersionMismatchAssertionTest" />
		</junit>
   -->

    <!--
    <junit printsummary="yes" fork="no" haltonfailure="yes">
			<classpath refid="path1511Binding" />
			<formatter type="plain" />
			<test fork="yes" todir="target/unit-reports" 
            outfile="TEST-MISMATCH-1511Binding" 
            name="org.slf4j.VersionMismatchAssertionTest" />
		</junit>
    -->

	</target>

	<target name="testMatch">
		<junit printsummary="yes" fork="no" haltonfailure="yes">
			<classpath refid="pathCurrent" />
			<formatter type="plain" />
			<test fork="yes" todir="target/unit-reports" 
            outfile="TEST-Match" 
            name="org.slf4j.CompatibilityAssertionTest" />
		</junit>

	</target>

  <target name="testMultiBinding">
 		<junit printsummary="yes" fork="no" haltonfailure="yes">
 			<classpath refid="multiBinding" />
 			<formatter type="plain" />
 			<test fork="yes" todir="target/unit-reports"
             outfile="TEST-MultiBinding"
             name="org.slf4j.MultiBindingAssertionTest" />
 		</junit>
 	</target>


	<target name="testFuture_16Series">

    <!--  1.8 uses providers and no longer supports bindings ==

    <junit printsummary="yes" fork="no" haltonfailure="yes">
			<classpath refid="binding166" />
			<formatter type="plain" />
			<test fork="yes" todir="target/unit-reports" 
            outfile="TEST-binding166"
            name="org.slf4j.NoProviderAssertionTest" />
		</junit>

    
    <junit printsummary="yes" fork="no" haltonfailure="yes">
      <classpath refid="api166" />
      <formatter type="plain" />
      <test fork="yes" todir="target/unit-reports" 
            outfile="TEST-api166"
            name="org.slf4j.CompatibilityAssertionTest" />
		</junit>
     -->
	</target>


  <condition property="runFromWithinIntegrationModule">
    <contains string="${user.dir}" substring="integration" />
  </condition>

  <target name="setPathToPolicy_FromTop" unless="runFromWithinIntegrationModule">
    <echo>setPathToPolicy_FromTop</echo>
    <property name="path_to_policy" value="file:./integration/src/policy/java-under-ant.policy"/>
  </target>

  <target name="setPathToPolicy_FromIntegration" if="runFromWithinIntegrationModule">
    <echo>setPathToPolicy_FromInegration </echo>
    <property name="path_to_policy" value="file:./src/policy/java-under-ant.policy"/>
  </target>


	<target name="testActiveSecurityManager" depends="setPathToPolicy_FromTop, setPathToPolicy_FromIntegration">
		<junit printsummary="yes" fork="no" haltonfailure="yes">
      <jvmarg value="-Djava.security.manager"/>
      <jvmarg value="-Djava.security.policy=${path_to_policy}"/>
      <jvmarg value="-Dslf4j.detectLoggerNameMismatch=true"/>
			<classpath refid="pathCurrent" />
			<formatter type="plain" />
			<test fork="yes" todir="target/unit-reports" 
            outfile="TEST-SecurityManager" 
            name="org.slf4j.issues.Issue324Test" />
		</junit>
	</target>

</project>