<?xml version="1.0" encoding="EUC-JP"?>

<!DOCTYPE document SYSTEM "./dtd/document-v10.dtd">

<document>
  <header>
    <title>Ant からの Cactus テストの実行/Running Cactus tests from Ant</title>
    <authors>
      <person name="Vincent Massol" email="vmassol@apache.org"/>
    </authors>
    <translators><person name="漆島賢二"/></translators>
  </header>

  <body>

    <s1 title="はじめに/Introduction">

      <note>
        <strong>You need to have a good understanding of Ant before
        reading this tutorial. If you don't, I suggest you read the
        <link href="http://jakarta.apache.org/ant/manual/index.html">Ant
        User Manual</link> first</strong>.
      </note>
      <note>
        <strong>このチュートリアルを読む前に Ant についての深い知識が必要です。
	そうでない場合、<link href="http://jakarta.apache.org/ant/manual/index.html">Ant ユーザーマニュアル</link>をあらかじめ読まれる事をお勧めします。
	</strong>
      </note>

      <p>
        This tutorial explains how start Cactus tests from your Ant build
        script (i.e. <code>build.xml</code>).
      </p>
      <p>
	本チュートリアルでは、自分の Ant ビルドファイル
	(即ち<code>build.xml</code>)から、
	どのように Cactus テストを起動するのかについて説明します。
      </p>
      <p>
        The Ant tasks involved for running a Cactus test are the following :
      </p>
      <p>
	Cactus テストの実行するようにする Ant の作業手順は次の通りです : 
      </p>
      <ul>
        <li>
          <em>Step 0</em> : (optional) Deploy configuration files for your
          container,
        </li>
        <li>
          <em>ステップ 0</em> : (オプション) 自分のコンテナに設定ファイルを配備します。
        </li>
        <li>
          <em>Step 1</em> : Package your Cactus tests as a WAR file and
          deploy it to your servlet engine webapps directory,
        </li>
        <li>
          <em>ステップ 1</em> : 自分の Cactus テストを WAR ファイルとしてパッケージ化し、
	  サーブレットエンジンの webapps ディレクトリに配備します。
        </li>
        <li>
          <em>Step 2</em> : Start your servlet engine if it is not already
          started,
         </li>
        <li>
          <em>ステップ 2</em> : まだ起動されていない場合、サーブレットエンジンを起動します。
         </li>
         <li>
           <em>Step 3</em> : Run the tests using JUnit,
         </li>
         <li>
           <em>ステップ 3</em> : JUnit を使ってテストを実行します
         </li>
         <li>
           <em>Step 4</em> : Stop the servlet engine (if need be)
         </li>
         <li>
           <em>ステップ 4</em> : (必要であれば)サーブレットエンジンを停止します
         </li>
       </ul>
       <p>
         Cactus provides a custom Ant task (called the
         <code>runservertests</code> task) that helps perform all these tasks.
         The rest of this tutorial will explain how to write an Ant build
         file (<code>build.xml</code>) that performs these tasks and use
         the Cactus custom Ant task.
       </p>
       <p>
	Cactus では、これらのタスクを実行するのを助けるカスタムタスク
	(<code>runservertests</code>タスクと呼んでいます)を提供しています。
	このチュートリアルの残り部分では、
	これらのタスクを行う Ant ビルドファイル
	(<code>build.xml</code>)の書き方、
	Cactus カスタム Ant タスクの使い方について説明します。
       </p>
        <p>
          During the remainder of this tutorial we will show examples for
          Tomcat 4.0. However, the principle can be applied to any other
          container. Ant Scripts for other containers can be found in the
          <code>/sample/build</code> directory where you have unpacked the
          Cactus distribution.
        </p>
        <p>
	このチュートリアルの残り部分で、
	Tomcat 4.0 の例を示しますが、
	原理的には他のコンテナについても当てはまります。
	他のコンテナ用の Ant ビルドファイルは、
	Cactus ディストリビューションを解凍した、
	<code>/sample/build</code> ディレクトリにあります。
        </p>

     </s1>

     <s1 title="'runservertests' タスク/The 'runservertests' task">

        <p>
          This task will perform several actions, in the following order :
        </p>
        <p>
	このタスクは幾つかのアクションを次に示す順序で実行します : 
        </p>
        <ul>
          <li>
            Check if a server is already started by constantly trying to
            call the test URL defined by the <code>testURL</code>
            attribute (see the example below),
          </li>
          <li>
	     <code>testURL</code> 属性で定義された test URL を継続的に呼びつづけることにより、
	     サーバーが既に起動されているかチェックします。
	     (下の例をご覧ください)
          </li>
          <li>
            If a server is not started, call the Ant target defined by the
            <code>startTarget</code> attribute (see the example below). This
            target is
            supposed to start your container. The <code>runservertests</code>
            task will then constantly poll the server by calling the test URL
            until the server answers back,
          </li>
          <li>
	    サーバーが起動されていない場合、
	    <code>startTarget</code> 属性により定義された Ant ターゲットを呼び出します。
	    (下の例を参照)
	    このターゲットは、コンテナを起動するためのものです。
	    次に、<code>runservertests</code> タスクは、
	    server からのレスポンスがあるまで test URL を呼び出すことにより、
            サーバーをポーリングし続けます。
          </li>
          <li>
            It will then call the Ant target defined by the
            <code>testTarget</code> attribute (see the example below). This
            target is
            supposed to start the unit tests. This is usually implemented
            by using the Ant <code>junit</code> task,
          </li>
          <li>
	    そして、<code>testTarget</code> 属性により定義された Ant
	    ターゲットを呼び出します。(下の例を参照)
            このターゲットは単体テストを起動するためのものです。
	    これは通常 Ant <code>junit</code> タスクを使って実装されています。
          </li>
          <li>
            Once the tests are finished (i.e. when the
            <code>testTarget</code> has finished executing), it will then
            call the Ant target defined by the <code>stopTarget</code>
            attribute (see the example below). This target is supposed to stop
            the container. The <code>runservertests</code>
            task will then constantly poll the server by calling the test URL
            until the server stops answering, at which point it will consider
            the server to be stopped. Note that the <code>stopTarget</code>
            will only get called if the server was not already started when
            the <code>runservertests</code> task began executing. This is to
            allow keeping running servers for intensive debugging phases.
          </li>
          <li>
	    テストが終了したら(即ち、<code>testTarget</code>
	    が実行終了したら)、<code>stopTarget</code> 属性により定義されている
	    Ant ターゲットを呼び出します。(下の例を参照)
	    このターゲットはコンテナを停止させるためのものです。
	    <code>runservertests</code> タスクは、
	    その時点でサーバーが停止したと見なせる、
	    サーバーのレスポンスがなくなるまで、
	    test URL を呼び出すことによりサーバーをポーリングし続けます。
	    <code>stopTarget</code> は、
	    <code>runservertests</code> タスクが実行し始めた時点で、
	    サーバーが既に起動されていなかった場合にのみ呼び出されることに注意してください。
	    何回も続けてデバッグフェーズを行うために、
	    これは、サーバーを起動したままにしておくためのものです。
          </li>
        </ul>
        <p>
          The <code>runservertests</code> task is generic in the sense that
          you are free to implement the <code>startTarget</code>,
          <code>testTarget</code> and <code>stopTarget</code> as you wish and
          they will get called at the right time.
        </p>
        <p>
          <code>runservertests</code> タスクは、
	  開発者が自由に、好きなように<code>startTarget</code>、
          <code>testTarget</code>、<code>stopTarget</code>を実装でき、
          定められた時に呼び出されるという意味において一般形なものと言えます。
        </p>
        <p>
          Example :
        </p>
        <p>
          例 :
        </p>

<source><![CDATA[
<!--
   ========================================================================
     Run Tomcat 4.0 tests
   ========================================================================
-->
<target name="test.tomcat.40" depends="prepare.test.tomcat.40"
    if="tomcat.home.40" description="Run tests on Tomcat 4.0">

    <!-- Start the servlet engine, wait for it to be started, run the
         unit tests, stop the servlet engine, wait for it to be stopped.
         The servlet engine is stopped if the tests fail for any reason -->

    <runservertests
        testURL="http://localhost:${test.port}/test/ServletRedirector?Cactus_Service=RUN_TEST"
        startTarget="start.tomcat.40"
        stopTarget="stop.tomcat.40"
        testTarget="test"/>

</target>
]]></source>

<source><![CDATA[
<!--
   ========================================================================
     Tomcat 4.0 テストの実行
   ========================================================================
-->
<target name="test.tomcat.40" depends="prepare.test.tomcat.40"
    if="tomcat.home.40" description="Tomcat 4.0でのテスト実行">

    <!-- サーブレットエンジンを起動し、正しく起動されるまで待ち、
	単体テストを実行し、サーブレットエンジンを停止し、
	正しく停止されるまで待ちます。
	何らかの理由でテストが失敗した場合、サーブレットエンジンは停止します -->

    <runservertests
        testURL="http://localhost:${test.port}/test/ServletRedirector?Cactus_Service=RUN_TEST"
        startTarget="start.tomcat.40"
        stopTarget="stop.tomcat.40"
        testTarget="test"/>

</target>
]]></source>

       <p>
         Before you can execute the <code>runservertests</code> task, you
         need to define it for Ant as it is not a standard Ant task. A
         good place to do this is in an <code>init</code> target.
       </p>
       <p>
	 <code>runservertests</code> タスクを実行する前に、
	 標準 Ant タスクでないようなタスクを定義する必要があるとします。
	 これを行う良い場所は、<code>init</code> ターゲットです。
       </p>
       <p>
         Example :
       </p>
       <p>
         例 :
       </p>

<source><![CDATA[
<!--
   ======================================================================
     Initialize the build. Must be called by all targets
   ======================================================================
-->
<target name="init">
    [...]
    <taskdef name="runservertests" classname="org.apache.cactus.ant.RunServerTestsTask">
        <classpath>
            <pathelement location="${cactus.ant.jar}"/>
        </classpath>
    </taskdef>
    [...]
</target>
]]></source>

<source><![CDATA[
<!--
   ======================================================================
     ビルドの初期化。全てのターゲットにより呼び出されます
   ======================================================================
-->
<target name="init">
    [...]
    <taskdef name="runservertests" classname="org.apache.cactus.ant.RunServerTestsTask">
        <classpath>
            <pathelement location="${cactus.ant.jar}"/>
        </classpath>
    </taskdef>
    [...]
</target>
]]></source>

       <p>
         where <code>${cactus.ant.jar}</code> is an Ant property that points
         to the <code>cactus-ant.jar</code> file found in the
         <code>lib/</code> directory where you unpacked the Cactus
         distribution.
       </p>
       <p>
	 ここで <code>${cactus.ant.jar}</code> は、
         Cactus ディストリビューションを解凍した
	 <code>lib/</code> ディレクトリにある
	 <code>cactus-ant.jar</code> ファイルを参照している
	 Ant のプロパティです。
       </p>

       <note>
         The <code>prepare.test.tomcat.40</code> target is described in
         Step 0 below.
       </note>
       <note>
	 <code>prepare.test.tomcat.40</code> ターゲットは下のステップ 0
	 で述べられています。
       </note>

       <note>
         The <code>tomcat.home.40</code> is simply an Ant property that
         points to the directory where Tomcat 4.0 has been installed. If this
         property is not defined we don't run the tests.
       </note>
       <note>
	 <code>tomcat.home.40</code> は単に、
	 Tomcat 4.0 がインストールされたディレクトリを参照 Ant のプロパティです。
	 このプロパティが定義されていない場合、
	 テストを実行しません。
       </note>

     </s1>

     <s1 title="ステップ 0: コンテナ設定ファイルの配備/Step 0: Deploy container configuration files">

       <p>
         There are 2 possibilities for configuring your application server :
       </p>
       <p>
	 アプリケーションサーバーの設定には 2 つの方法があります : 
       </p>
       <ol>
         <li>
           You install it somewhere on your computer (or on another machine)
           and you deploy your test WAR (see Step 1 below) by copying it
           to the right subdirectory within it. Your WAR will then be placed
           alongside with others and your webapp will use the configuration
           files common to all webapps,
         </li>
         <li>
	   サーバーを自分のマシン(あるいは他のマシン)のどこかにインストールして、
	   (その正しいサブディレクトリに自分のテスト用 WAR を配備します。
	   (下のステップ 1 を参照)
	   自分の WAR は他の WAR と共に置かれ、自分のウェブアプリケーションが、
	   全てのウェブアプリケーションに共通な設定ファイルを使います。
         </li>
         <li>
           Or, you can create your own set of container configuration files,
           hosted within your project, that you copy to your own deployment
           subdirectory (i.e. not shared).
         </li>
         <li>
	   あるいは、
	   テスト用の配備用の(即ち共有されていない)サブディレクトリにコピーするよう、
	   自分のプロジェクトに、
	   テスト用のコンテナ設定ファイルのセットを作成します。
         </li>
       </ol>
       <p>
         In the provided Cactus Ant scripts, we have decided to follow
         approach 2 for the following reasons :
       </p>
       <p>
	 与えられた Cactus の Ant ビルドファイルでは、
	 次に示す理由により、上述の 2 番目の方法を採用しました : 
       </p>
       <ul>
         <li>
           We keep the control of our project files as they are deployed
           within the directory of our project and thus it is easy to
           perform a clean of all generated files,
         </li>
         <li>
           生成されたファイルのクリーンが簡単に実行できるように、
	   プロジェクトのファイルは、自分のプロジェクトのディレクトリに配備されるよう、
	   制御し続けたいです。
         </li>
         <li>
           We do not "pollute" the installed container by dropping files
           within it and we do not need to modify global configuration
           files that may prevent other applications we are developing
           from not running someday (because we would have made an
           incompatible change),
         </li>
         <li>
	   余計なファイルを入れることにより、インストールされているコンテナを
	   汚染したくありませんし、
	   我々が開発している他のアプリケーションが、
	   いつの日か動かなくなるのを避けるため、
	   全体の設定ファイルを変更する必要が無いからです。
	   (何故なら、我々は互換性の無い変更をしようとしていたかもしれないのです。)
         </li>
         <li>
           We completely control our needed container configuration.
         </li>
         <li>
           必要なコンテナの設定を完全に操作します。
         </li>
         <li>
           We can guarantee to the user who wants to try the Cactus sample
           application that it will not deploy anything outside the scope of
           the Sample directory. Unlike windows applications that you install
           and that copies tens of DLL to shared directory, overwrite existing
           files, ... :(
         </li>
         <li>
           Cactus サンプルアプリケーションを試したいユーザーに対して、
	   サンプルディレクトリの範囲外には何も配備しない事を保障できます。
	   インストールして、何十ものDLLを共有ディレクトリコピーして、
	   既存のファイルを置き換えてしまう、、、と、いった Windows 
	   アプリケーションのようにはしたくないのです :(
         </li>
       </ul>
       <p>
         However, this may not be the best approach for all cases, as :
       </p>
       <p>
	 しかしながら、これは全ての場合に対する最適な方法とは言えません、なぜなら :
       </p>
       <ul>
         <li>
           It is more difficult to set up as you need to understand how your
           container is configured (However, we have already done the job for
           you for most of the existing containers),
         </li>
         <li>
	   自分のコンテナがどのように設定されているか理解しなければならず、
	   インストールがより難しくなります。
	   (でも、我々は既に、ほとんどの既存のコンテナに対して対応しています。)
         </li>
         <li>
           You have only a single application to run and test and have
           dedicated your application server installation for it so you don't
           care about putting files in there and modifying global
           configuration,
         </li>
         <li>
	   開発者は、実行およびテストすべきアプリケーションが、
	   たった一つしかなく、それだけのために、
	   アプリケーションサーバーをインストールするつもりであり、
	   そこに一緒にファイルを置いてしまったり、
	   全体の設定を変更しても構わない場合。
         </li>
         <li>
           You want to be able to deploy in production several webapps that
           share the same server and thus must coexist and share common
           configuration files.
         </li>
         <li>
	   同じサーバーを共有する幾つかの
	   ウェブアプリケーション製品を配備できるようにしたいと考えているので、
	   共通の設定ファイルを共存および共有させなければならない場合。
         </li>
       </ul>

       <p>
         If you choose solution 1, then you can simply skip this step. The
         only actions to perform will be, for some containers, to edit their
         configuration files to tell them about your webapp (some will
         automatically pick you test WAR if you drop it in the correct
         directory).
       </p>
       <p>
	 解決策の 1 を選んだ場合、
	 このステップは単に飛ばしてしまうことができます。
	 幾つかのコンテナの場合、
	 行わなければならないことは、
	 自分のウェブアプリケーションの事をコンテナに知らせるために、
         設定ファイルを編集することです。
	 (自分のテスト WAR を正しいディレクトリに置けば、
	 自動的に認識するものもあります。)
       </p>

       <p>
         Example :
       </p>
       <p>
         例 :
       </p>

<source><![CDATA[
<!--
   ========================================================================
     Prepare directories and variables for running the tests
   ========================================================================
-->
<target name="prepare.test.tomcat.40"
    depends="check.test.tomcat.40,testwar" if="tomcat.home.40">

    <echo message="tomcat.home.40 = ${tomcat.home.40}"/>

    <property name="target.tomcat40.dir"
        value="${target.test.dir}/tomcat40"/>
    <property name="conf.tomcat40.dir" value="${conf.test.dir}/tomcat40"/>

    <!-- Create work and conf directories and copy configuration files -->
    <mkdir dir="${target.tomcat40.dir}/conf"/>
    <mkdir dir="${target.tomcat40.dir}/work"/>
    <mkdir dir="${target.tomcat40.dir}/webapps"/>

    <!-- Delete some config file so that they will be copied every time -->
    <delete file="${target.tomcat40.dir}/conf/server.xml"/>

    <!-- Remove the auto deployed webapp so that it is redeployed every
         time -->
    <delete dir="${target.tomcat40.dir}/webapps/test"/>

    <copy todir="${target.tomcat40.dir}/conf" filtering="on">
        <fileset dir="${conf.tomcat40.dir}"/>
    </copy>

    <!-- Copy the Tomcat web.xml -->
    <copy file="${tomcat.home.40}/conf/web.xml"
        todir="${target.tomcat40.dir}/conf"/>

    <!-- Copy the war file -->
    <copy file="${target.test.dir}/test.war"
        tofile="${target.tomcat40.dir}/webapps/test.war"/>

</target>
]]></source>

<source><![CDATA[
<!--
   ========================================================================
     テスト実行のためのディレクトリと変数の準備
   ========================================================================
-->
<target name="prepare.test.tomcat.40"
    depends="check.test.tomcat.40,testwar" if="tomcat.home.40">

    <echo message="tomcat.home.40 = ${tomcat.home.40}"/>

    <property name="target.tomcat40.dir"
        value="${target.test.dir}/tomcat40"/>
    <property name="conf.tomcat40.dir" value="${conf.test.dir}/tomcat40"/>

    <!-- work, conf ディレクトリの生成、設定ファイルのコピー -->
    <mkdir dir="${target.tomcat40.dir}/conf"/>
    <mkdir dir="${target.tomcat40.dir}/work"/>
    <mkdir dir="${target.tomcat40.dir}/webapps"/>

    <!-- 何時でもコピーされるよう、設定ファイルの削除 -->
    <delete file="${target.tomcat40.dir}/conf/server.xml"/>

    <!-- 何時でも再配備できるよう自動配備webappの削除 -->
    <delete dir="${target.tomcat40.dir}/webapps/test"/>

    <copy todir="${target.tomcat40.dir}/conf" filtering="on">
        <fileset dir="${conf.tomcat40.dir}"/>
    </copy>

    <!-- Tomcat の web.xml のコピー -->
    <copy file="${tomcat.home.40}/conf/web.xml"
        todir="${target.tomcat40.dir}/conf"/>

    <!-- war ファイルのコピー -->
    <copy file="${target.test.dir}/test.war"
        tofile="${target.tomcat40.dir}/webapps/test.war"/>

</target>
]]></source>

       <note>
         The <code>${target.test.dir}</code> Ant property needs to be
         defined prior to calling this target and needs to be set to the
         location where the tests will be deployed. It should be set to any
         subdirectory of your output directory. This property will also be
         used later on in step 1 to copy the test WAR file.
       </note>
       <note>
	 Ant のプロパティ <code>${conf.test.dir}</code> は、
	 このターゲットが呼ばれる前に定義され、
         サーバー設定の場所を表す必要があります。
	 (Tomcat 4.0 の現在の例では、
	 これらは、<code>web.xml</code>と<code>server.xml</code>です。)
       </note>

     </s1>

     <s1 title="ステップ 1: WAR ファイルの生成と配備/Step 1: create and deploy test WAR file">

        <p>
          Creating a WAR file is the preferred way of deploying Cactus tests
          to your servlet engine. Check the
          <link href="getting_started.html">Getting Started</link> guide and
          the example below for details on what files to include in the WAR.
        </p>
        <p>
	  WAR ファイルを作成するのは、
	  サーブレットエンジンに Cactus テストを配備する推奨される方法です。
	  どのファイルを WAR に入れるかについての詳細は、
	  <link href="getting_started.html">Getting Started</link> ガイド、
	  および、下の例をご覧ください。
        </p>
        <p>
          Example :
        </p>
        <p>
          例 :
        </p>

<source><![CDATA[
<!--
   ========================================================================
     Create a Cactus test war file for the sample application.
   ========================================================================
-->
<target name="testwar" depends="compile">

    <!-- Create the war file -->
    <war warfile="${target.test.dir}/test.war"
         webxml="${conf.test.dir}/web.xml">

        <classes dir="${target.classes.sample.dir}"/>
        <classes dir="${target.classes.unit.dir}"/>

        <!-- log_server.properties need to be in the server classpath -->
        <classes dir="${conf.test.dir}">
            <include name="log_server.properties"/>
            <include name="cactus.properties"/>
        </classes>

        <lib dir="${target.lib.dir}"/>
        <fileset dir="${web.dir}"/>
   </war>

</target>
]]></source>

<source><![CDATA[
<!--
   ========================================================================
     サンプルアプリケーション用の Cactus WAR ファイルの生成
   ========================================================================
-->
<target name="testwar" depends="compile">

    <!-- WAR ファイルの生成 -->
    <war warfile="${target.test.dir}/test.war"
         webxml="${conf.test.dir}/web.xml">

        <classes dir="${target.classes.sample.dir}"/>
        <classes dir="${target.classes.unit.dir}"/>

        <!-- log_server.properties をサーバーのクラスパスに
	     入れる必要があります -->
        <classes dir="${conf.test.dir}">
            <include name="log_server.properties"/>
            <include name="cactus.properties"/>
        </classes>

        <lib dir="${target.lib.dir}"/>
        <fileset dir="${web.dir}"/>
   </war>

</target>
]]></source>

       <p>
         where :
       </p>
       <p>
         ここで、各変数の意味は :
       </p>
       <ul>
         <li>
           <code>${conf.test.dir}</code> : directory containing configuration
           files for the test,
         </li>
         <li>
           <code>${conf.test.dir}</code> : テスト用の設定ファイルの入っているディレクトリ
         </li>
         <li>
           <code>${target.classes.*.dir}</code> : directory where the java
           classes have been compiled. These are the classes under test + the
           test classes,
         </li>
         <li>
           <code>${target.classes.*.dir}</code> : 
	   java クラスがコンパイルされたディレクトリ。
	  test にクラスがあり、テストクラスがあります。
         </li>
         <li>
           <code>${target.lib.dir}</code> : directory containing the needed jars
           (<code>junit.jar</code>, <code>cactus.jar</code>, ...).
         </li>
         <li>
           <code>${target.lib.dir}</code> : 
           必要な jar (<code>junit.jar</code>, <code>cactus.jar</code>, ...)
	   のあるディレクトリ
         </li>
         <li>
           <code>${web.dir}</code> : directory containing the web files to
           include in the test webapp (JSPs, HTML, ...).
         </li>
         <li>
           <code>${web.dir}</code> : 
	   test ウェブアプリケーションに入れるウェブファイル(JSPs, HTML, ...)
	   のあるディレクトリ
         </li>
       </ul>

       <note>
         The <code>compile</code> target is used to compile all java classes
         into the <code>${target.classes.*.dir}</code> directory.
       </note>
       <note>
         <code>compile</code> ターゲットは
	 全 java クラスをコンパイルして、
	 <code>${target.classes.*.dir}</code>
	 ディレクトリに置くのに使われます。
       </note>

     </s1>

     <s1 title="ステップ 2: コンテナの起動/Step 2: Start the container">

       <p>
         Example :
       </p>
       <p>
         例 :
       </p>

<source><![CDATA[
<!--
   ========================================================================
     Start Tomcat 4.0
   ========================================================================
-->
<target name="start.tomcat.40">

    <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
        <jvmarg value="-Dcatalina.home=${tomcat.home.40}"/>
        <jvmarg value="-Dcatalina.base=${target.tomcat40.dir}"/>
        <arg value="start"/>
        <classpath>
          <fileset dir="${tomcat.home.40}">
              <include name="bin/bootstrap.jar"/>
          </fileset>
        </classpath>
    </java>

</target>
]]></source>

<source><![CDATA[
<!--
   ========================================================================
     Tomcat 4.0 の起動
   ========================================================================
-->
<target name="start.tomcat.40">

    <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
        <jvmarg value="-Dcatalina.home=${tomcat.home.40}"/>
        <jvmarg value="-Dcatalina.base=${target.tomcat40.dir}"/>
        <arg value="start"/>
        <classpath>
          <fileset dir="${tomcat.home.40}">
              <include name="bin/bootstrap.jar"/>
          </fileset>
        </classpath>
    </java>

</target>
]]></source>

     </s1>

     <s1 title="ステップ 3: 単体テストの実行/Step 3: Run the unit tests">

       <p>
         We start the unit test by calling a JUnit test runner (we use the
         text runner in this example). Example :
       </p>
       <p>
	 JUnit test runner を呼び出すことにより、
	 単体テストを起動します。
	 (この例では test runner を使います)
         We start the unit test by calling a JUnit test runner (we use the
         text runner in this example). 例は次の通りです :
       </p>

<source><![CDATA[
<!--
   ========================================================================
     Run the client JUnit test cases.
   ========================================================================
-->
<target name="test">

    <junit printsummary="yes" haltonfailure="yes" haltonerror="yes"
        fork="yes">

        <classpath>
            <!-- Cactus.propertie and log_client.properties need to be in
                 the classpath -->
            <pathelement location="${target.conf.dir}"/>
            <pathelement location="${target.classes.sample.dir}"/>
            <pathelement location="${target.classes.unit.dir}"/>
            <path refid="project.class.path"/>
        </classpath>

        <formatter type="plain" usefile="false"/>
        <test name="org.apache.cactus.unit.TestAll"/>
        <test name="org.apache.cactus.sample.TestAll"/>

    </junit>

</target>
]]></source>

<source><![CDATA[
<!--
   ========================================================================
     クライアント側 JUnit テストケースの実行
   ========================================================================
-->
<target name="test">

    <junit printsummary="yes" haltonfailure="yes" haltonerror="yes"
        fork="yes">

        <classpath>
            <!-- Cactus.propertie および log_client.properties を
		 クラスパスに含める必要があります -->
            <pathelement location="${target.conf.dir}"/>
            <pathelement location="${target.classes.sample.dir}"/>
            <pathelement location="${target.classes.unit.dir}"/>
            <path refid="project.class.path"/>
        </classpath>

        <formatter type="plain" usefile="false"/>
        <test name="org.apache.cactus.unit.TestAll"/>
        <test name="org.apache.cactus.sample.TestAll"/>

    </junit>

</target>
]]></source>

       <note>
         The list of jars to include in your classpath is explained and
         detailed in the <link href="howot_classpath.html">Classpath
         Howto</link> guide.
       </note>
       <note>
	 自分のクラスパスに入れる jar のリストは、
	 <link href="howot_classpath.html">Classpath Howto</link> ガイドで詳しく述べられています。
       </note>

     </s1>

     <s1 title="ステップ 4: コンテナの停止/Step 4: Stop the container">

       <p>
         Example :
       </p>
       <p>
         例 :
       </p>

<source><![CDATA[
<!--
   ========================================================================
     Stop Tomcat 4.0
   ========================================================================
-->
<target name="stop.tomcat.40">

    <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
        <jvmarg value="-Dcatalina.home=${tomcat.home.40}"/>
        <jvmarg value="-Dcatalina.base=${target.tomcat40.dir}"/>
        <arg value="stop"/>
        <classpath>
          <fileset dir="${tomcat.home.40}">
              <include name="bin/bootstrap.jar"/>
          </fileset>
        </classpath>
    </java>

</target>
]]></source>

<source><![CDATA[
<!--
   ========================================================================
     Tomcat 4.0 の停止
   ========================================================================
-->
<target name="stop.tomcat.40">

    <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
        <jvmarg value="-Dcatalina.home=${tomcat.home.40}"/>
        <jvmarg value="-Dcatalina.base=${target.tomcat40.dir}"/>
        <arg value="stop"/>
        <classpath>
          <fileset dir="${tomcat.home.40}">
              <include name="bin/bootstrap.jar"/>
          </fileset>
        </classpath>
    </java>

</target>
]]></source>

     </s1>

  </body>
</document>

