国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
怎樣用Ant測試Spring項(xiàng)目(Ant測試自動化--下

怎樣用Ant測試Spring項(xiàng)目

 


 


   對于Spring項(xiàng)目,還有另外的講究。

一、可以運(yùn)行,但是要設(shè)置Eclipse,以使Eclipse自動往我的    <property name="run.classpath" value="${home.dir}/bin"></property>

中復(fù)制Spring配置文件。

   <?xml version="1.0"?>

<!--

   設(shè)置了路徑以后就正常了

   Eclipse中,java構(gòu)建路徑.java源:src,test,WebRoot;

     缺省輸出文件夾  為/bin  這個目錄,否則會報Spring的bean未定義錯誤!

        原因就是因?yàn)镾pring配置文件無法在classpath中找到!

-->

<project name="project" default="junit">

<!--      chu shi hua , ti gong huan jing bian liang  deng  zhun bei   -->

   <target name="init">

  

         <property name="home.dir" value="."/>

         

         <property name="run.classpath" value="${home.dir}/bin"></property>

    

       <!--

          <property name="run.classpath" value="${home.dir}/build/classes"></property>

          -->

         <property name="run.srcpath" value="${home.dir}/src"></property>


 


         <property name="test.srcpath" value="${home.dir}/test"></property>

        

         <property name="test.report" value="${home.dir}/report"></property>

          <!--

          <property name="test.config" value="${home.dir}/WebRoot"></property>

           -->

         <property name="lib.dir" value="${home.dir}/lib"/>   


 


       


 


         <path id="compile.path">


 


                  <fileset dir="${lib.dir}">

                     <include name="**/*.jar"/>

                      </fileset>


 


         </path>

     </target>  

<!-- Compilation Classpath

    <path id="compile.classpath">

       <fileset dir="${telecom_LDBS.lib}">

           <include name="**/*.jar"/>

       </fileset>

    </path>

  -->     

 

  <!-- Compile ,wei JUnit ti gong .class wen jian.  zai jia shang yu xian ti gong de

     jar zhong de .class  wen jian , ji ke yun xing JUnit. 

       dang ran, hai xu yao junit.jar he ant-junit.jar(huo  optional.jar) he ant.jar zhe 3 ge jar bao de zhi chi

    -->

         <target name="compile"  depends="init">


 


                   <javac destdir="${run.classpath}" srcdir="${run.srcpath}"


 


                            classpathref="compile.path"/>


 


                   <javac destdir="${run.classpath}" srcdir="${test.srcpath}"


 


                            classpathref="compile.path"/>


 


         </target>


 


       

<!-- junit renwu, zhi xing junit ce shi  .  bie wang le,classpath ,the classpath to use.

  xu yao zhi ding classpath yuansu ,ta bao kuo compile lu jing,he  bian yi de jie gou classpath

  (bao kuo sheng cheng de suo you .class  wen jian)

 -->

         <target name="junit" depends="compile">


 


                   <tstamp/>

                <mkdir dir="${test.report}"/>

                <mkdir dir="${test.report}/framework-${DSTAMP}-${TSTAMP}"/>

 

                   <junit printsummary="true">


 


                            <classpath >

                              <pathelement path="${run.classpath}"/>

                              <!-- 

                              <pathelement path="${test.config}"/>

                              -->

                             <fileset dir="${lib.dir}">

                             <include name="**/*.jar"/>

                            </fileset>


 


                            

                            </classpath>

                           

                           

                        <!--

                            <test name="Ldbs1AdslSectionBaseinfoModelServiceTest"></test>

                         -->

    <formatter type="plain"/>

         <!-- she zhi yao ce shi de wen jian ji he .-->

         <batchtest fork="yes" todir="${test.report}/framework-${DSTAMP}-${TSTAMP}">

         <fileset dir="${test.srcpath}">

             <include name="**/*Test.java"/>

            

         </fileset>

         </batchtest>


 


                   </junit>


 


         </target>

<!-- =============================== all ==================================== -->

  <target name="all" depends="junit" />

</project>


 

 

 


二、不需要借助于Eclipse自動構(gòu)建功能的Ant文件:

<?xml version="1.0"?>

 


 


<project name="project" default="junit">

 

<!--      chu shi hua , ti gong huan jing bian liang  deng  zhun bei   -->

 

   <target name="init">

 

  

 

         <property name="home.dir" value="."/>

 

         

 

         <property name="test.war" value="${home.dir}/build/war"></property>

 

        

 

       <property name="run.classpath" value="${home.dir}/build/war/WEB-INF/classes"></property>

 

       <!--

 

          <property name="run.classpath" value="${home.dir}/build/classes"></property>

 

          -->

 

         <property name="run.srcpath" value="${home.dir}/src"></property>

 


 


         <property name="test.srcpath" value="${home.dir}/test"></property>

 

        

 

         <property name="test.report" value="${home.dir}/report"></property>

 

        

 

          <property name="test.config" value="${home.dir}/WebRoot"></property>

 

        

 

         <property name="lib.dir" value="${home.dir}/lib"/>   

 


 


        <property name="telecom_LDBS.config" value="${test.war}/WEB-INF/classes/config"/>

 


 


         <path id="compile.path">

 


 


                  <fileset dir="${lib.dir}">

 

                      <include name="**/*.jar"/>

 

                       </fileset>

 


 


         </path>

 

     </target>  

 

<!-- Compilation Classpath

 

    <path id="compile.classpath">

 

        <fileset dir="${telecom_LDBS.lib}">

 

            <include name="**/*.jar"/>

 

        </fileset>

 

    </path>

 

  -->     

 

 

 

  <!-- Compile ,wei JUnit ti gong .class wen jian.  zai jia shang yu xian ti gong de

 

     jar zhong de .class  wen jian , ji ke yun xing JUnit. 

 

       dang ran, hai xu yao junit.jar he ant-junit.jar(huo  optional.jar) he ant.jar zhe 3 ge jar bao de zhi chi

 

    -->

 

         <target name="compile"  depends="init">

 


 


                   <javac destdir="${run.classpath}" srcdir="${run.srcpath}"

 


 


                            classpathref="compile.path"/>

 


 


                   <javac destdir="${run.classpath}" srcdir="${test.srcpath}"

 


 


                            classpathref="compile.path"/>

 


 


         </target>

 


 


   <!-- =============================== war ==================================== -->

 

     <target name="war" depends="compile">

 

    <mkdir dir="${test.war}/WEB-INF"/>

 

    <mkdir dir="${test.war}/WEB-INF/classes/config/db"/>

 

    <mkdir dir="${test.war}/WEB-INF/classes/config/acl"/>

 

    <copy todir="${test.war}">

 

        <fileset dir="${test.config}"  excludes="**/vssver.scc">

 

            <include name="**/*.*"/>

 

             <exclude name="**/vssver.scc"/>

 

             <exclude name="**/build.xml"/>

 

            <exclude name="**/build.properties"/>

 

            <exclude name="**/targets.xml"/>

 

        </fileset>

 

    </copy>

 

   

 

   

 

    <copy todir="${test.war}/WEB-INF/classes/config/db">

 

      <fileset dir="${telecom_LDBS.config}/db">          

 

      </fileset>

 

    </copy>

 

    <copy todir="${test.war}/WEB-INF/classes/config/acl">

 

       <fileset dir="${telecom_LDBS.config}/acl">

 

            <include name="*.xml" />

 

             <exclude name="**/vssver.scc" />

 

       </fileset>

 

    </copy>

 


 


  </target>

 

       

 

<!-- junit renwu, zhi xing junit ce shi  .  bie wang le,classpath ,the classpath to use.

 

  xu yao zhi ding classpath yuansu ,ta bao kuo compile lu jing,he  bian yi de jie gou classpath

 

  (bao kuo sheng cheng de suo you .class  wen jian)

 

 -->

 

         <target name="junit" depends="war">

 


 


                   <tstamp/>

 

                <mkdir dir="${test.report}"/>

 

                <mkdir dir="${test.report}/framework-${DSTAMP}-${TSTAMP}"/>

 

 

 

                   <junit printsummary="true">

 


 


                            <classpath >

 

                              <pathelement path="${test.war}"/>

 

                              <pathelement path="${run.classpath}"/>

 

                              <!-- 

 

                              <pathelement path="${test.config}"/>

 

                              -->

 

                             <fileset dir="${lib.dir}">

 

                              <include name="**/*.jar"/>

 

                             </fileset>

 


 


                            

 

                            </classpath>

 

                           

 

                           

 

                        <!--

 

                            <test name="Ldbs1AdslSectionBaseinfoModelServiceTest"></test>

 

                         -->

 

    <formatter type="plain"/>

 

         <!-- she zhi yao ce shi de wen jian ji he .-->

 

         <batchtest fork="yes" todir="${test.report}/framework-${DSTAMP}-${TSTAMP}">

 

         <fileset dir="${test.srcpath}">

 

             <include name="**/*Test.java"/>

 

            

 

         </fileset>

 

         </batchtest>

 


 


                   </junit>

 


 


         </target>

 

<!-- =============================== all ==================================== -->

 

  <target name="all" depends="junit" />

 

</project>

 


 

 

 


這樣,我手工把Spring等文件復(fù)制到war目錄中。然后,再將這個目錄也加到Junit任務(wù)的classpath路徑中。 

也就是說,現(xiàn)在,classpath中由3部分組成:

1,jar文件集

2,.class文件集

3,Spring、Hibernate等配置文件集。

實(shí)際上,我們也可以進(jìn)一步改進(jìn)。將JUnit任務(wù)和發(fā)布war包的任務(wù)合在一起。


 

 

 


三、下面就是將JUnit融合進(jìn)原有war包發(fā)布的ant文件后的東東:


 


<?xml version="1.0"?>

 


 


<!-- =================================================================== -->

 

<!-- $Id: build.xml,v 1.3 2004/02/08 09:04:42 cvs Exp $              -->

 

<!-- =================================================================== -->

 


 


<project name="telecom_LDBS" default="all" basedir=".">

 


 


<!-- =============================== init ==================================== -->

 

  <target name="init">

 

    <!-- change this property to use a compiler other than javac. -->

 

    <property name="build.compiler" value="modern"/>

 


 


    <!-- The root directory of the workspace -->

 

    <property name="telecom_LDBS.home" value="."/>

 

    <property name="telecom_LDBS.lib" value="${telecom_LDBS.home}/lib"/>

 

   

 

    <property name="telecom_LDBS.src" value="${telecom_LDBS.home}/src"/>

 

    <!-- The destination directory for the build -->

 

    <property name="telecom_LDBS.build" value="${telecom_LDBS.home}/build"/>

 

    <property name="telecom_LDBS.buildconfigdir" value="${telecom_LDBS.home}/build/config"/>

 

    <property name="telecom_LDBS.buildwardir" value="${telecom_LDBS.home}/build/war"/>

 

    <property name="telecom_LDBS.buildeardir" value="${telecom_LDBS.home}/build/ear"/>

 


 


    <!-- The destination directory for all the compiled classes. -->

 

    <property name="telecom_LDBS.classbindir" value="${telecom_LDBS.build}/classes"/>

 

    <property name="telecom_LDBS.srcdocroot" value="${telecom_LDBS.home}/WebRoot"/>

 

    <property name="telecom_LDBS.config" value="${telecom_LDBS.srcdocroot}/WEB-INF/classes/config"/>

 


 


<!-- junit tina jia-->

 

     <property name="test.report" value="${telecom_LDBS.home}/report"></property>

 

     <property name="test.srcpath" value="${telecom_LDBS.home}/test"></property>

 

 <!--   ^ junit tina jia-->   

 

    

 

    <!-- Compilation Classpath -->

 

    <path id="compile.classpath">

 

        <fileset dir="${telecom_LDBS.lib}">

 

            <include name="**/*.jar"/>

 

        </fileset>

 

    </path>

 


 


 

 

    <!-- The destination appServer for War. -->

 

    <property name="tomcat.deployhome" value="D:\java\tomcat\webapps"/>

 

    <property name="tomcat.deploywar" value="${tomcat.deployhome}\telecom_LDBS_ADSL"/>

 


 


  </target>

 


 


  <!-- =============================== compile ==================================== -->

 

  <target name="compile" depends="init">

 

    <echo message="${telecom_LDBS.classpath}" />

 

    <mkdir dir="${telecom_LDBS.classbindir}"/>

 

    <javac srcdir="${telecom_LDBS.src}"

 

           destdir="${telecom_LDBS.classbindir}"

 

           includes="com/**"

 

           debug="yes">

 

    <classpath refid="compile.classpath"/>

 

    </javac>

 


 


    <!-- Convert resource file's character -->

 

    <copy file="${telecom_LDBS.src}/com/telecom/ldbs/common/util/ApplicationResources_ISO.properties"

 

            tofile="${telecom_LDBS.src}/com/telecom/ldbs/common/util/ApplicationResources.properties"/>

 

    <native2ascii encoding="gb2312" src="${telecom_LDBS.src}" dest="${telecom_LDBS.classbindir}"

 

            includes="**/*Resources.properties"/>

 


 


    <copy todir="${telecom_LDBS.classbindir}">

 

      <fileset dir="${telecom_LDBS.src}">

 

        <include name="**/*_ISO.properties"/>

 

        <include name="**/*Methods.properties"/>

 

      </fileset>

 

    </copy>

 


 


    <copy todir="${telecom_LDBS.classbindir}">

 

      <fileset dir="${telecom_LDBS.src}">

 

      </fileset>

 

    </copy>

 

  </target>

 


 


 

 


 


   <!-- =============================== war ==================================== -->

 

  <target name="war" depends="init">

 

    <mkdir dir="${telecom_LDBS.buildwardir}/WEB-INF"/>

 

    <mkdir dir="${telecom_LDBS.buildwardir}/WEB-INF/classes/config/db"/>

 

    <mkdir dir="${telecom_LDBS.buildwardir}/WEB-INF/classes/config/acl"/>

 

    <copy todir="${telecom_LDBS.buildwardir}">

 

        <fileset dir="${telecom_LDBS.srcdocroot}"  excludes="**/vssver.scc">

 

            <include name="**/*.*"/>

 

             <exclude name="**/vssver.scc"/>

 

             <exclude name="**/build.xml"/>

 

            <exclude name="**/build.properties"/>

 

            <exclude name="**/targets.xml"/>

 

        </fileset>

 

    </copy>

 

    <copy todir="${telecom_LDBS.buildwardir}/WEB-INF/lib">

 

        <fileset dir="${telecom_LDBS.lib}">

 

            <include name="**/*.jar"/>

 

             <exclude name="**/vssver.scc" />

 

            <exclude name="**/servlet.jar" />

 

            <exclude name="**/j2ee.jar" />

 

        </fileset>

 

    </copy>

 

    <copy todir="${telecom_LDBS.buildwardir}/WEB-INF/classes">

 

      <fileset dir="${telecom_LDBS.classbindir}">

 

             <include name="**/**.class" />

 

             <include name="**/**.properties" />

 

             <exclude name="**/vssver.scc" />

 

      </fileset>

 

    </copy>

 

    <copy todir="${telecom_LDBS.buildwardir}/WEB-INF/classes">

 

      <fileset dir="${telecom_LDBS.srcdocroot}/WEB-INF/menu">

 

             <include name="**/**.vm" />

 

      </fileset>

 

    </copy>

 

    <copy todir="${telecom_LDBS.buildwardir}/WEB-INF/classes/config/db">

 

      <fileset dir="${telecom_LDBS.config}/db">          

 

      </fileset>

 

    </copy>

 

    <copy todir="${telecom_LDBS.buildwardir}/WEB-INF/classes/config/acl">

 

       <fileset dir="${telecom_LDBS.config}/acl">

 

            <include name="*.xml" />

 

             <exclude name="**/vssver.scc" />

 

       </fileset>

 

    </copy>

 


 


  </target>

 


 

 

 


  <!-- =============================== deploy ==================================== -->

 

  <target name="deploy" depends=" compile, war">

 

    <mkdir dir="${tomcat.deploywar}" />

 


 


    <copy todir="${tomcat.deploywar}">

 

             <fileset dir="${telecom_LDBS.buildwardir}">

 

                 <include name="**/**.*"/>

 

         </fileset>

 

    </copy>

 

  </target>

 


 


    <target name="deploy_jsp" depends="init">

 

        <copy todir="${tomcat.deploywar}">

 

             <fileset dir="${telecom_LDBS.srcdocroot}">

 

                 <include name="**/*.jsp"/>

 

                 <include name="**/*.inc"/>

 

                 <include name="**/*.xml"/>

 

                 <include name="**/*.js"/>

 

                 <include name="**/*.htm*"/>

 

             </fileset>

 

        </copy>

 

    </target>

 


 


  <!-- =============================== deploy_all ==================================== -->

 

    <target name="deploy_all" depends="init">

 

        <copy todir="${tomcat.deploywar}">

 

             <fileset dir="${telecom_LDBS.srcdocroot}">

 

                 <include name="**/*.jsp"/>

 

                 <include name="**/*.inc"/>

 

                 <include name="**/*.xml"/>

 

                 <include name="**/*.js"/>

 

                 <include name="**/*.htm*"/>

 

                 <include name="**/*.class"/>

 

                 <include name="**/*.properties"/>

 

             </fileset>

 

        </copy>

 

    </target>

 


 


  <!-- =============================== clean ==================================== -->

 

  <target name="clean" depends="init">

 

    <mkdir dir="${telecom_LDBS.build}" />

 

    <mkdir dir="${tomcat.deploywar}" />

 

   

 

    <delete includeEmptyDirs="true">

 

         <fileset dir="${telecom_LDBS.build}" includes="**/**"/>

 

    </delete>

 

    <delete includeEmptyDirs="true" failonerror="false">

 

         <fileset dir="${tomcat.deployhome}/telecom_LDBS" includes="**/**"/>

 

    </delete>

 

  </target>

 

 

 

 

 

  <!-- junit tina jia-->

 

  <!-- junit renwu, zhi xing junit ce shi  .  bie wang le,classpath ,the classpath to use.

 

  xu yao zhi ding classpath yuansu ,ta bao kuo compile lu jing,he  bian yi de jie gou classpath

 

  (bao kuo sheng cheng de suo you .class  wen jian)

 

 -->

 

         <target name="junit" depends="war">

 


 


                   <tstamp/>

 

                <mkdir dir="${test.report}"/>

 

                <mkdir dir="${test.report}/framework-${DSTAMP}-${TSTAMP}"/>

 

 

 

                   <junit printsummary="true">

 


 


                            <classpath >

 

                              <pathelement path="${telecom_LDBS.buildwardir}"/>

 

                              <pathelement path="${telecom_LDBS.classbindir}"/>

 

                              <!-- 

 

                              <pathelement path="${test.config}"/>

 

                              -->

 

                             <fileset dir="${telecom_LDBS.lib}">

 

                              <include name="**/*.jar"/>

 

                             </fileset>

 


 


                            

 

                            </classpath>

 

                           

 

                           

 

                        <!--

 

                            <test name="Ldbs1AdslSectionBaseinfoModelServiceTest"></test>

 

                         -->

 

    <formatter type="plain"/>

 

         <!-- she zhi yao ce shi de wen jian ji he .-->

 

         <batchtest fork="yes" todir="${test.report}/framework-${DSTAMP}-${TSTAMP}">

 

         <fileset dir="${test.srcpath}">

 

             <include name="**/*Test.java"/>

 

            

 

         </fileset>

 

         </batchtest>

 


 


                   </junit>

 


 


         </target>

 

  <!-- ^ junit tina jia-->

 

  <!-- =============================== all ==================================== -->

 

  <target name="all" depends=" clean, compile, war ,junit"/> 

 

</project>

 


 

 

 


只是添加了幾個目錄,然后又加上了junit任務(wù)即可。

 

本文來自CSDN博客,轉(zhuǎn)載請標(biāo)明出處:http://blog.csdn.net/shendl/archive/2005/11/18/532592.aspx

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Ant學(xué)習(xí)指南
Ant的使用
ANT Buildfile快速參考 - e
Apache Ant使用進(jìn)階
博客園 - 喻祥,性情中人 - 試了一次ant
如何使用Abator利器來開發(fā)ibatis應(yīng)用實(shí)例\
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服