<?xml version="1.0" encoding="Shift_JIS"?>

<project name="terasoluna_thin" basedir=".." default="junit">

  <!-- 仠仠仠仠仠 娐嫬愝掕 仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭 -->

  <!-- build僨傿儗僋僩儕 -->
  <property name="build.dir" value="${basedir}/ant" />

  <!-- 仠仠仠仠仠 僾儘僷僥傿僼傽僀儖愝掕 仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭 -->
  <property file="${build.dir}/testbuild.properties" />

  <!-- 仠仠仠仠仠 僾儘僷僥傿 仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭 -->

  <!--奐敪娐嫬僾儘僷僥傿-->
  <property name="project.root" value="${basedir}" />
  <property name="project.src.dir" value="${project.root}/sources" />
  <property name="project.classpath" value="${project.root}/classes" />
  <property name="project.lib.dir" value="${terasoluna.lib.home}/lib" />
  <property name="terasoluna.lib.dir" value="${terasoluna.lib.home}/dist" />
  <property name="terasoluna.class" value="jp/terasoluna" />

  <!-- test娐嫬偺僾儘僷僥傿 -->
  <property name="test.root" value="${project.root}/testcases" />
  <property name="test.src.dir" value="${test.root}/testsources" />
  <property name="test.class.dir" value="${test.root}/testclasses" />
  <property name="test.lib.dir" value="${project.lib.dir}" />
  <property name="testreports.dir" value="${test.root}/reports" />
  <property name="coveragereports.dir" value="${test.root}/coverageReports" />

  <!-- Cobertura偺僷僗 -->
  <!-- terasoluna.utlib.spring.home偼build.properties偵愝掕 -->
  <property name="cobertura.dir" value="${terasoluna.lib.home}/cobertura" />

  <!-- Cobertura 僇僶儗僢僕寁應 -->
  <taskdef classpath="${cobertura.dir}/cobertura.jar" resource="tasks.properties"/>

  <!-- 仠仠仠仠仠 僋儔僗僷僗偺愝掕 仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭 -->

  <property name="project.lib.classpath"
	        value="${project.lib.dir}/commons-beanutils-1.7.0.jar;
                   ${project.lib.dir}/commons-digester-1.8.jar;
                   ${project.lib.dir}/commons-fileupload-1.2.jar;
                   ${project.lib.dir}/commons-jxpath-1.2.jar;
   	               ${project.lib.dir}/commons-logging-1.1.jar;
                   ${project.lib.dir}/commons-lang-2.3.jar;
                   ${project.lib.dir}/commons-validator-1.3.1.jar;
                   ${project.lib.dir}/antlr-2.7.6.jar;
                   ${project.lib.dir}/jakarta-oro-2.0.8.jar;
                   ${project.lib.dir}/spring.jar;
                   ${project.lib.dir}/struts.jar;
                   ${terasoluna.lib.dir}/terasoluna-commons.jar"/>

  <property name="test.lib.classpath"
            value="${test.lib.dir}/junit-3.8.2.jar;
                   ${test.lib.dir}/junit-addons-1.4.jar;
                   ${test.lib.dir}/mockrunner-servlet.jar;
                   ${test.lib.dir}/mockrunner-jdbc.jar;
                   ${test.lib.dir}/mockrunner-tag.jar;
                   ${test.lib.dir}/mockrunner-struts.jar;
                   ${test.lib.dir}/spring-mock.jar;
                   ${test.lib.dir}/terasoluna-utlib.jar;
  	               ${test.lib.dir}/servlet-api.jar;
                   ${test.lib.dir}/jsp-api.jar;
                   ${test.lib.dir}/ojdbc14.jar;
                   ${test.lib.dir}/terasoluna-utlib-spring.jar"/>

  <!-- Cobertura梡 -->
  <property name="cobertura.class.path"
            value="${cobertura.dir}/cobertura.jar;
                   ${cobertura.dir}/lib/asm/asm-2.1.jar;
                   ${cobertura.dir}/lib/log4j/1.2.9/log4j-1.2.9.jar;
                   ${cobertura.dir}/lib/ncss/21.41/ccl.jar;
                   ${cobertura.dir}/lib/ncss/21.41/javancss.jar;
                   ${cobertura.dir}/lib/oro/jakarta-oro-2.0.8.jar" />

  <!-- 仠仠仠仠仠 Cobertura 僇僶儗僢僕寁應幚峴   仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭 -->
  <target name="coverage" depends="src_compile,test_compile">

    <!--慜夞嶌惉偟偨僇僶儗僢僕寁應寢壥偍傛傃ear僼傽僀儖傪嶍彍-->
    <delete dir="${coveragereports.dir}"/>
    <mkdir dir="${coveragereports.dir}" />
    <mkdir dir="${coveragereports.dir}/instrument" />
    <delete dir="${project.root}">
      <include name="cobertura.ser" />
    </delete>
    <mkdir  dir="${coveragereports.dir}/xmlfile" />

    <cobertura-instrument todir="${coveragereports.dir}/instrument">
      <classpath>
        <pathelement path="${cobertura.class.path}" />
      	<pathelement path="${test.class.dir}" />
      </classpath>
  
      <!-- 偙偙偱巜掕偝傟偨僋儔僗偑丄儗億乕僩昞帵懳徾偲側傞 -->
      <fileset dir="${project.classpath}">
        <include name="${terasoluna.class}/fw/**/*.class"/>
        
        <!-- 埲壓丄弌椡懳徾奜僋儔僗 -->
        <exclude name="${terasoluna.class}/fw/web/taglib/DateTei.class"/>
        <exclude name="${terasoluna.class}/fw/web/taglib/JDateTei.class"/>
        <exclude name="${terasoluna.class}/fw/web/taglib/LTrimTei.class"/>
        <exclude name="${terasoluna.class}/fw/web/taglib/LeftTei.class"/>
        <exclude name="${terasoluna.class}/fw/web/taglib/RTrimTei.class"/>
        <exclude name="${terasoluna.class}/fw/web/taglib/TrimTei.class"/>
        <!-- 弌椡懳徾奜僋儔僗 偙偙傑偱 -->
      </fileset>
    </cobertura-instrument>

    <!--僾儘僷僥傿僼傽僀儖傪instrument僨傿儗僋僩儕傊僐僺乕丂-->
    <copy todir="${coveragereports.dir}/instrument">
      <fileset dir="${project.classpath}">
        <include name="*.properties" />
      </fileset>
    </copy>
    <copy todir="${coveragereports.dir}/instrument">
      <fileset dir="${test.class.dir}">
        <include name="*.properties" />
      </fileset>
    </copy>

    <junit printsummary="yes" fork="yes" dir="${project.root}" filtertrace="off" showoutput="true">
      <classpath>
        <pathelement path="${coveragereports.dir}/instrument" />
        <pathelement path="${cobertura.class.path}" />
      	<pathelement path="${project.lib.classpath}" />
        <pathelement path="${test.lib.classpath}" />
      	<pathelement path="${project.classpath}" />
        <pathelement path="${test.class.dir}" />
      </classpath>
      
      <!--
          junit僞僗僋偵偰幚峴偝傟偨JUnit僥僗僩偺寢壥傪弌椡偡傞曽朄傪掕媊偡傞丅
           丒type懏惈偵偰弌椡僼僅乕儅僢僩傪xml偵巜掕丅
           丒usefile懏惈偵偰弌椡偺懳徾傪僼傽僀儖偵偡傞偐偳偆偐傪巜掕丅
      -->
      <formatter type="xml" usefile="true"/>
      
      <batchtest fork="yes" todir="${build.dir}">
        <fileset dir="${test.src.dir}">
          <!--僥僗僩懳徾-->
          <include name="${terasoluna.class}/fw/**/*Test*.java" />
        </fileset>
      </batchtest>
    </junit>

    <!--
        僥僗僩寢壥偺xml傪傕偲偵HTML傪嶌惉偡傞丅
        丂丒srcdir懏惈偵偰僜乕僗偺僨傿儗僋僩儕傪巜掕丅
        丂丒destdir偵偰丄嶌惉偡傞HTML偺弌椡愭傪巜掕丅
    -->
    <cobertura-report srcdir="${project.src.dir}" destdir="${coveragereports.dir}">
      <classpath>
        <pathelement path="${cobertura.class.path}" />
      </classpath>
    </cobertura-report>
  	
    <!--乽TEST-*.xml乿僼傽僀儖傪嶌嬈梡僨傿儗僋僩儕傊僐僺乕丂-->
    <copy todir="${coveragereports.dir}/xmlfile">
      <fileset dir="${build.dir}" >
        <include name="TEST*.xml" />
      </fileset>
    </copy>

    <delete>
      <fileset dir="${build.dir}">
        <include name="TEST*.xml" />
      </fileset>
    </delete>

  </target>

  <!-- 仠仠仠仠仠 JUnit幚峴   仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭 -->
  <target name="junit" depends="src_compile,test_compile">
  	
    <junit printsummary="on" fork="yes">
      <jvmarg value="-Xmx256M"/>

      <batchtest fork="yes">
        <fileset dir="${test.src.dir}">
          <include name="${terasoluna.class}/fw/**/*Test*.java" />
        </fileset>
      </batchtest>

      <formatter type="xml" usefile="true" />

      <classpath>
        <pathelement path="${project.lib.classpath}" />
        <pathelement path="${test.lib.classpath}" />
        <pathelement path="${project.classpath}" />
      	<pathelement path="${test.class.dir}" />
      </classpath>

    </junit>

  	<!-- 慜夞嶌惉偟偨僨傿儗僋僩儕傪嶍彍偟丄怴偟偔惗惉 -->
    <delete dir="${testreports.dir}" />
    <mkdir  dir="${testreports.dir}" />
    <mkdir  dir="${testreports.dir}/xmlfile" />

    <!-- Junit儗億乕僩嶌惉 -->
    <junitreport>
      <fileset dir="./">
        <include name="TEST*.xml" />
      </fileset>
      <report format="frames" todir="${testreports.dir}" />
    </junitreport>

    <!--乽TEST-*.xml乿僼傽僀儖傪嶌嬈梡僨傿儗僋僩儕傊僐僺乕丂-->
    <copy todir="${testreports.dir}/xmlfile">
      <fileset dir="./">
        <include name="TEST*.xml" />
      </fileset>
    </copy>

    <delete>
      <fileset dir="./">
        <include name="TEST*.xml" />
      </fileset>
    </delete>
  </target>

  <!-- 仠仠仠仠仠 僜乕僗僼傽僀儖僐儞僷僀儖幚峴 仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭 -->
  <target name="src_compile">
  	<echo level="info" message="僜乕僗僼傽僀儖傪僐儞僷僀儖偟傑偡丅"/>
  	<ant antfile="${build.dir}/build.xml" target="compile" inheritall="false"/>
  	<echo level="info" message="僜乕僗僼傽僀儖偺僐儞僷僀儖偑姰椆偟傑偟偨丅"/>
  </target>

  <!-- 仠仠仠仠仠 Testcase僐儞僷僀儖幚峴 仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭 -->
  <target name="test_compile">
  	<echo level="info" message="屆偄僋儔僗僼傽僀儖傪嶍彍偟傑偡丅"/>
  	<delete includeEmptyDirs="true" failonerror="false">
	  <fileset dir="${test.class.dir}" includes="**/*"/>
	</delete>
  	<mkdir dir="${test.class.dir}"/>
  	
  	<echo level="info" message="僥僗僩働乕僗傪僐儞僷僀儖偟傑偡丅"/>
  	<javac srcdir="${test.src.dir}" destdir="${test.class.dir}" debug="on" deprecation="off" nowarn="true">
      <classpath>
        <pathelement path="${project.lib.classpath}" />
        <pathelement path="${project.classpath}" />        
        <pathelement path="${test.lib.classpath}" />
      </classpath>
    </javac>
  	
  	<echo level="info" message="僜乕僗僼僅儖僟偺愝掕僼傽僀儖傪僐僺乕偟傑偡丅"/>
  	<copy todir="${test.class.dir}">
      <fileset dir="${test.src.dir}">
        <include name="*" />
      </fileset>
    </copy>
  	<copy todir="${test.class.dir}/jp/terasoluna/fw/web/thin">
  	  <fileset dir="${test.src.dir}/jp/terasoluna/fw/web/thin">
  	    <include name="*.xml"/>
  	  </fileset>
  	</copy>
  	<copy todir="${test.class.dir}/jp/terasoluna/fw/web/taglib">
  	  <fileset dir="${test.src.dir}/jp/terasoluna/fw/web/taglib">
  	    <include name="*.xml"/>
  	  </fileset>
  	</copy>
  	<copy todir="${test.class.dir}/jp/terasoluna/fw/service/thin">
  	  <fileset dir="${test.src.dir}/jp/terasoluna/fw/service/thin">
  	    <include name="*.xml"/>
  	  </fileset>
  	</copy>
  	<copy todir="${test.class.dir}/jp/terasoluna/fw/web/struts/action">
  	  <fileset dir="${test.src.dir}/jp/terasoluna/fw/web/struts/action">
  	    <include name="*.xml"/>
  	    <include name="*.properties"/>
  	  </fileset>
  	</copy>
  	<copy todir="${test.class.dir}/jp/terasoluna/fw/web/struts/form">
  	  <fileset dir="${test.src.dir}/jp/terasoluna/fw/web/struts/form">
  	    <include name="*.xml"/>
  	  </fileset>
  	</copy>
  	<copy todir="${test.class.dir}/jp/terasoluna/fw/web/struts/plugins">
  	  <fileset dir="${test.src.dir}/jp/terasoluna/fw/web/struts/plugins">
  	    <include name="*.xml"/>
  	  </fileset>
  	</copy>
  	<copy todir="${test.class.dir}/jp/terasoluna/fw/web/struts/reset">
  	  <fileset dir="${test.src.dir}/jp/terasoluna/fw/web/struts/reset">
  	    <include name="*.xml"/>
  	  </fileset>
  	</copy>
  	
  	
  	<echo level="info" message="僥僗僩働乕僗偺僐儞僷僀儖偑姰椆偟傑偟偨丅"/>
  </target>
 </project>
 