[xmlparser]Code-Test

博客介绍了在项目中创建Cactus测试类和配置文件的方法。需在项目里创建目录放置Cactus测试类,其源文件位置可通过属性配置;还需在项目根目录创建文件,定义测试所用容器的位置,如在Tomcat 4.1.24和Resin 2.6上运行测试的配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/------------------------------
|  xmlparser.bat
|------------------------------
@echo off
java -jar xmlparser.jar com.xml.XMLParser using.xml


/------------------------------
|  测试输出
|------------------------------
version=1.0
encoding=null
root=#2 document
Level=0 [type=2]document
Level=1 [type=3]

  
Level=1 [type=2]properties
Level=2 [type=3]
    
Level=2 [type=2]title
Level=3 [type=3]Using the Maven Cactus plugin
Level=2 [type=3]
    
Level=2 [type=2]author
		Attributes: [email=vmassol@apache.org]
Level=3 [type=3]Vincent Massol
Level=2 [type=3]
  
Level=1 [type=3]

  
Level=1 [type=2]body
Level=2 [type=3]
    
Level=2 [type=2]section
		Attributes: [name=Using the Cactus plugin]
Level=3 [type=3]
      
Level=3 [type=2]ol
Level=4 [type=3]
        
Level=4 [type=2]li
Level=5 [type=3]
          Create a 
Level=5 [type=2]code
Level=6 [type=3]src/test-cactus
Level=5 [type=3] directory in your project and
          put your Cactus test classes in it (with the normal package directory
          structure). Note that the location of the Cactus test sources can be
          configured through the 
Level=5 [type=2]code
Level=6 [type=3]cactus.src.dir
Level=5 [type=3] property.
        
Level=4 [type=3]
        
Level=4 [type=2]li
Level=5 [type=3]
          Create a 
Level=5 [type=2]code
Level=6 [type=3]build.properties
Level=5 [type=3] file in your project root
          directory (where 
Level=5 [type=2]code
Level=6 [type=3]project.xml
Level=5 [type=3] is located) and define in
          it the location of the container you wish to use for the tests. For
          example, if you wish to run the Cactus tests on Tomcat 4.1.24 and on
          Resin 2.6, you will write:
        
Level=4 [type=3]

Level=4 [type=2]source
Level=5 [type=5]<![CDATA[
cactus.home.tomcat4x = C:/Apps/jakarta-tomcat-4.1.24
cactus.home.resin2x = C:/Apps/resin-2.1.6
]]>
Level=4 [type=3]
      
Level=3 [type=3]
      
Level=3 [type=2]subsection
		Attributes: [name=Running tests packaged in a WAR]
Level=4 [type=3]
        
Level=4 [type=2]p
Level=5 [type=3]
          If you're testing Servlets, Filters, JSPs or Taglibs, simply type
          
Level=5 [type=2]code
Level=6 [type=3]maven cactus:test
Level=5 [type=3] (or 
Level=5 [type=2]code
Level=6 [type=3]maven cactus
Level=5 [type=3] for 
          short) to run the Cactus tests.
        
Level=4 [type=3]
      
Level=3 [type=3]
      
Level=3 [type=2]subsection
		Attributes: [name=Running tests packaged in an EAR]
Level=4 [type=3]
        
Level=4 [type=2]p
Level=5 [type=3]
          Make sure you have created a 
Level=5 [type=2]code
Level=6 [type=3]src/webapp/WEB-INF/web.xml
Level=5 [type=3]
          file. You can put inside the 
Level=5 [type=2]code
Level=6 [type=3]&lt;ejb-ref&gt;
Level=5 [type=3] entries 
          required to call your EJBs from your Cactus test case classes.
        
Level=4 [type=3]
        
Level=4 [type=2]p
Level=5 [type=3]
          To start your EJB unit tests, simply type 
          
Level=5 [type=2]code
Level=6 [type=3]maven cactus:test-ear
Level=5 [type=3].
        
Level=4 [type=3]
      
Level=3 [type=3]
      
Level=3 [type=2]subsection
		Attributes: [name=Custom test jars]
Level=4 [type=3]
        
Level=4 [type=2]p
Level=5 [type=3]
          Some jars are used only for testing (for example, DbUnit). These
          jars can be entered as dependencies in the 
Level=5 [type=2]code
Level=6 [type=3]project.xml
Level=5 [type=3]
          and tagged with 
Level=5 [type=2]code
Level=6 [type=3]cactus.bundle
Level=5 [type=3]. When the Cactus plugin 
          finds such jars it will automatically add them to the deployed war. 
          For example:          
        
Level=4 [type=3]

Level=4 [type=2]source
Level=5 [type=5]<![CDATA[
    <dependency>
      <groupId>dbunit</groupId>>
      <artifactId>dbunit</artifactId>>
      <version>1.5.5</version>
      <properties>
        <cactus.bundle>true</cactus.bundle>
      </properties>
    </dependency>
]]>
Level=4 [type=3]
      
Level=3 [type=3]
    
Level=2 [type=3]

 
Level=1 [type=3]







/------------------------------
|  测试文件using.xml
|------------------------------
<?xml version="1.0"?>
<document>

  <properties>
    <title>Using the Maven Cactus plugin</title>
    <author email="vmassol@apache.org">Vincent Massol</author>
  </properties>

  <body>
    <section name="Using the Cactus plugin">
      <ol>
        <li>
          Create a <code>src/test-cactus</code> directory in your project and
          put your Cactus test classes in it (with the normal package directory
          structure). Note that the location of the Cactus test sources can be
          configured through the <code>cactus.src.dir</code> property.
        </li>
        <li>
          Create a <code>build.properties</code> file in your project root
          directory (where <code>project.xml</code> is located) and define in
          it the location of the container you wish to use for the tests. For
          example, if you wish to run the Cactus tests on Tomcat 4.1.24 and on
          Resin 2.6, you will write:
        </li>
<source><![CDATA[
cactus.home.tomcat4x = C:/Apps/jakarta-tomcat-4.1.24
cactus.home.resin2x = C:/Apps/resin-2.1.6
]]></source>
      </ol>
      <subsection name="Running tests packaged in a WAR">
        <p>
          If you're testing Servlets, Filters, JSPs or Taglibs, simply type
          <code>maven cactus:test</code> (or <code>maven cactus</code> for 
          short) to run the Cactus tests.
        </p>
      </subsection>
      <subsection name="Running tests packaged in an EAR">
        <p>
          Make sure you have created a <code>src/webapp/WEB-INF/web.xml</code>
          file. You can put inside the <code>&lt;ejb-ref&gt;</code> entries 
          required to call your EJBs from your Cactus test case classes.
        </p>
        <p>
          To start your EJB unit tests, simply type 
          <code>maven cactus:test-ear</code>.
        </p>
      </subsection>
      <subsection name="Custom test jars">
        <p>
          Some jars are used only for testing (for example, DbUnit). These
          jars can be entered as dependencies in the <code>project.xml</code>
          and tagged with <code>cactus.bundle</code>. When the Cactus plugin 
          finds such jars it will automatically add them to the deployed war. 
          For example:          
        </p>
<source><![CDATA[
    <dependency>
      <groupId>dbunit</groupId>>
      <artifactId>dbunit</artifactId>>
      <version>1.5.5</version>
      <properties>
        <cactus.bundle>true</cactus.bundle>
      </properties>
    </dependency>
]]></source>
      </subsection>
    </section>

 </body>
</document>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值