<?xml version="1.0" encoding="EUC-JP"?>

<!DOCTYPE document SYSTEM "./dtd/document-v10.dtd">

<document>
  <header>
    <title>VAJava と WebSphere とのテスト環境/VAJava and WebSphere Test Environment</title>
    <authors>
      <person name="Vincent Massol" email="vmassol@apache.org"/>
    </authors>
    <translators><person name="漆島賢二"/></translators>
  </header>

  <body>

    <s1 title="序文および必要条件/Forewords and Requirements">

      <note>
        <strong>This tutorial is written for Cactus 1.2 only. It will need
        to adapted if you're using Cactus 1.3</strong>
      </note>
      <note>
        <strong>本チュートリアルは、Cactus 1.2 に限定して書かれています。
	Cactus 1.3 を使用している場合は、それに適応させる必要があります。</strong>
      </note>

      <p>
        This tutorial explains how to run Cactus tests within VisualAge for
        Java WebSphere Test Environment.
      </p>
      <p>
	本チュートリアルでは、VisualAge for Java WebSphere Test Environment で
	Cactus テストを実行する方法について説明します。
      </p>
      <p>
        We have received reports that the following tutorial works with
        VAJava 3.5.2 and 3.5.3. Please tell us if you find that it works with
        other versions.
      </p>
      <p>
	次に示すチュートリアルは、VAJava 3.5.2 および 3.5.3 での動作が報告されています。
	他のバージョンで動作が確認された場合、教えてください。
      </p>

    </s1>

    <s1 title="ステップ 1 : VAJava への正しいパッケージのインポート/Step 1 : Import the correct packages in VAJava">

      <p>
        Let's assume the following conventions :
        <strong><code>{Cactus dir}</code></strong> is the directory where you
        have unzipped the Cactus distribution or sources and
        <strong><code>{VAJava dir}</code></strong> is the directory where
        VAJava is installed. Let's also define <strong><code>{WTE dir}</code>
        </strong> to be the WebSphere Test Environment directories, i.e.
        <code>{VAJava dir}/ide/project_resources/IBM WebSphere Test
        Environment</code>.
      </p>
      <p>
	次の取り決めをしましょう : 
        <strong><code>{Cactus dir}</code></strong> は、
	Cactus ディストリビューションやソースを解凍したディレクトリで、	
        <strong><code>{VAJava dir}</code></strong> は、
	VAJava がインスト−ルされたディレクトリとします。
	また、
	<strong><code>{WTE dir}</code></strong> 
	WebSphere Test Environment ディレクトリ、
	即ち、
        <code>{VAJava dir}/ide/project_resources/IBM WebSphere Test
        Environment</code> としましょう。
      </p>

      <p>
        You need to create 3 projects : one for JUnit, one for Cactus (
        let's call it "Cactus") and
        optionally one for Log4j. Note that the Log4j one is useful only if
        wish to get some Cactus runtime logs. If you don't import the Log4j
        classes, some Cactus classes will appear with a red cross in VAJava
        but you can safely ignore them as they won't be executed.
      </p>
      <p>
	3 つのプロジェクトを作る必要があります : 
	一つは JUnit のため、
	一つは Cactus のため(これを "Cactus" と呼ぶことにします)、
	オプションとして、もう一つは Log4j のためにです。
	Log4j プロジェクトは、
	Cactus 実行時のログを取得したい場合にのみ便利です。
	Log4j クラスをインポートしない場合、
	VAJava において、幾つかの Cactus のクラスに赤いばつ印が現れるかもしれませんが、それらは実行されないので無視してしまっても問題ありません。
      </p>

      <note>
        You can either import the source files or the compiled classes as you
        wish. If you import the source file, you should import the following
        directories : <code>{Cactus dir}/src/framework/servlet22</code> and
        <code>{Cactus dir}/src/framework/share</code>. You also need to
        copy the following files into
        <code>{VAJava dir}/ide/project_resources/Cactus</code> :
        <code>log_client.properties</code> and
        <code>log_server.properties</code> which are located in
        <code>{Cactus dir}/sample/conf/test</code>. If you have imported from
        the Cactus jar file, and you have selected to import resources files
        then they have been automatically imported for you.
      </note>
      <note>
	ソースファイルでも、コンパイルされたクラスでも、
	好きなほうをインポートすることができます。
	ソースファイルをインポートした場合、
	<code>{Cactus dir}/src/framework/servlet22</code> および
	<code>{Cactus dir}/src/framework/share</code>
	のディレクトリをインポートしなければなりません。
	また、次の
	<code>{Cactus dir}/sample/conf/test</code> にある
        <code>log_client.properties</code> および
        <code>log_server.properties</code> のファイルを
	<code>{VAJava dir}/ide/project_resources/Cactus</code>
	にコピーしなければなりません。
	Cactus jar ファイルからインポートし、
	リソースファイルをインポートするために選択した場合、
	自動的にインポートがなされます。
      </note>

    </s1>

    <s1 title="ステップ 2 : cactus.properties ファイルの設定/Step 2 : Set up the cactus.properties file">

      <p>
        Copy your <code>cactus.properties</code> file (see the
        <link href="howto_config.html">Configuration Howto</link>
        tutorial for details on <code>cactus.properties</code>) to
        <code>{VAJava dir}/ide/project_resources/Cactus</code>.
      </p>
      <p>
	自分の <code>cactus.properties</code> ファイルを
	<code>{VAJava dir}/ide/project_resources/Cactus</code> へコピーします。
	(<code>cactus.properties</code> について詳しくは
        <link href="howto_config.html">設定 Howto</link>
	チュートリアルをご覧ください。)
      </p>

      <note>
        As WebSphere does not support the <code>jsp-file</code> tag in
        <code>web.xml</code>, we cannot map the redirector JSP to a name, so
        instead of writing
        "<code>cactus.jspRedirectorURL =
        http://localhost:8080/test/JspRedirector</code>" in
        <code>cactus.properties</code>, you should simply
        put the JSP file name, as in
        "<code>cactus.jspRedirectorURL =
        http://localhost:8080/test/jspRedirector.jsp</code>". This is only needed
        if you have test cases that extend <code>JspTestCase</code>.
      </note>
      <note>
	WebSphere では、<code>web.xml</code> において
	<code>jsp-file</code> タグをサポートしないので、
	JSP リダイレクタから名前へマップできません。
	そこで、
	<code>cactus.properties</code> ファイルで
        "<code>cactus.jspRedirectorURL =
        http://localhost:8080/test/JspRedirector</code>" と書く代わりに、
	単に
	"<code>cactus.jspRedirectorURL =
        http://localhost:8080/test/jspRedirector.jsp</code>"
	のように JSP ファイル名を設定しなければなりません。
	<code>JspTestCase</code> を拡張したテストケースがあるとき、
	しなければならないのはこれだけです。
      </note>


    </s1>

    <s1 title="ステップ 3 : WebSphere Test Environment の変更/Step 3 : Modify WebSphere Test Environment">

      <s2 title="default.servlet_engine の編集/Edit default.servlet_engine">

        <p>
          Edit <code>{WTE dir}/properties/default.servlet_engine</code> and
          add the following under the <code>default_app</code> webgroup :
        </p>
        <p>
	  <code>{WTE dir}/properties/default.servlet_engine</code> を編集し、
	  <code>default_app</code> webgroup の下に次を加えます : 
        </p>

<source><![CDATA[
    <websphere-webgroup name="test">
       <description>Cactus Testing Web Application</description>
       <document-root>$approot$/web</document-root>
       <classpath>$approot$/servlets</classpath>
       <root-uri>/test</root-uri>
       <auto-reload enabled="true" polling-interval="3000"/>
       <shared-context>false</shared-context>
    </websphere-webgroup>
]]></source>

        <note>
          The <code>init-parameter</code> is only needed if you wish to run
          sample application provided in the Cactus distribution. Also, in
          order to run this sample application you'll need to copy the
          <code>{Cactus dir}/sample/web/test/test.jsp</code> file to
          <code>{WTE dir}/hosts/default_host/test/web/test</code> as it is
          used by a test case.
        </note>
        <note>
	  Cactus ディストリビューションで提供されるサンプルアプリケーションを実行したい場合にのみ、
	  <code>init-parameter</code> が必要です。
	  また、サンプルアプリケーションを実行するには、
	  テストケースで使用するため、
	  <code>{Cactus dir}/sample/web/test/test.jsp</code> ファイルを
	  <code>{WTE dir}/hosts/default_host/test/web/test</code>
	  へコピーする必要があります。
        </note>

      </s2>

      <s2 title="test ディレクトリの作成/Create a test directory">

        <p>
          Create a directory called <code>test</code> under
          <code>{WTE dir}/hosts/default_host</code>. Under <code>test</code>
          create another 2 subdirectories : <code>servlets</code> and
          <code>web</code>.
        </p>
        <p>
	  <code>test</code> という名前のディレクトリを
	  <code>{WTE dir}/hosts/default_host</code>
	  ディレクトリの下に作成します。
	  さらに、<code>test</code> の下に、
	  <code>servlets</code> と <code>web</code> の 2 
	  つのサブディレクトリを作成します。
        </p>

      </s2>

      <s2 title="test.webapp ファイルの作成/Create a test.webapp file">

        <p>
          Create a <code>test.webapp</code> file in
          <code>{WTE dir}/host/default_app/servlets</code> and put the following
          content :
        </p>
        <p>
	  <code>test.webapp</code> ファイルを
	  <code>{WTE dir}/host/default_app/servlets</code> に作成し、
	  次の内容を設定します : 
        </p>

<source><![CDATA[
<?xml version="1.0"?>
<webapp>
   <name>test</name>
   <description>Cactus testing web application</description>
   <error-page>/ErrorReporter</error-page>

   <servlet>
      <name>ServletRedirector</name>
      <description>Cactus Testing ServletRedirector</description>
      <code>org.apache.cactus.server.ServletTestRedirector</code>
      <servlet-path>/ServletRedirector</servlet-path>
      <autostart>false</autostart>
      <init-parameter>
        <name>param1</name>
        <value>value1 used for testing</value>
    </init-parameter>
   </servlet>

   <!-- Note: We don't provide a mapping for the JSP Redirector because
        WebSphere does not support the jsp-file tag of the Servlet 2.2
        specification -->
   <!-- メモ: WebSphere では Servlet 2.2 仕様の jsp-file タグを
	サポートしていないので、JSP リダイレクタのマッピングを提供しません -->

   <servlet>
      <name>ErrorReporter</name>
      <description>Default error reporter servlet</description>
      <code>com.ibm.servlet.engine.webapp.DefaultErrorReporter</code>
      <servlet-path>/ErrorReporter</servlet-path>
      <autostart>true</autostart>
   </servlet>

   <servlet>
      <name>jsp</name>
      <description>JSP support servlet</description>

      <!--
        WARNING:

        If you use the JSP 1.0 compiler, use the following
          <code>com.ibm.ivj.jsp.runtime.JspDebugServlet</code>

        If you use the JSP 1.1 compiler (VAJava 3.5.3 only), use the following
          <code>com.ibm.ivj.jsp.jasper.runtime.JspDebugServlet</code>
      -->
      <!--
        警告:

	JSP 1.0 コンパイラを使う場合、
	  <code>com.ibm.ivj.jsp.runtime.JspDebugServlet</code> を使います。

	JSP 1.1 コンパイラ(VAJava 3.5.3 のみ) を使う場合、
          <code>com.ibm.ivj.jsp.jasper.runtime.JspDebugServlet</code> を使います
      -->
      <code>com.ibm.ivj.jsp.jasper.runtime.JspDebugServlet</code>

      <init-parameter>
         <name>workingDir</name>
         <value>$server_root$/temp/default_app</value>
      </init-parameter>
      <init-parameter>
         <name>jspemEnabled</name>
         <value>true</value>
      </init-parameter>
      <init-parameter>
         <name>scratchdir</name>
         <value>$server_root$/temp/JSP1_1/default_app</value>
      </init-parameter>
      <init-parameter>
         <name>keepgenerated</name>
         <value>true</value>
      </init-parameter>
      <autostart>true</autostart>
      <servlet-path>*.jsp</servlet-path>
   </servlet>

   <servlet>
      <name>file</name>
      <description>File serving servlet</description>
      <code>com.ibm.servlet.engine.webapp.SimpleFileServlet</code>
      <servlet-path>/</servlet-path>
      <init-parameter>
         <name></name>
         <value></value>
      </init-parameter>
      <autostart>true</autostart>
   </servlet>
</webapp>
]]></source>

      </s2>

      <s2 title="Cactus リダイレクタファイルのコピー/Copy the Cactus JSP Redirector file">

        <p>
          Copy the <code>{Cactus dir}/sample/web/test/jspRedirector.jsp</code>
          file to <code>{WTE dir}/hosts/default_host/test/web</code>.
        </p>
        <p>
	  <code>{Cactus dir}/sample/web/test/jspRedirector.jsp</code>
	  ファイルを
	  <code>{WTE dir}/hosts/default_host/test/web</code> 
	  へコピーします。
        </p>

      </s2>

    </s1>

    <s1 title="ステップ 4 : VAJava workspace classpath の編集/Step 4 : Edit VAJava workspace classpath">

      <p>
        Add the following to the VAJava workspace classpath (select menu
        "Window... | Resources" under VAJava) :
      </p>
      <p>
	次のものを VAJava workspace classpath に加えます
	(VAJava で "Window... | Resources" メニューを選びます) : 
      </p>

<source><![CDATA[
{VAJava dir}\ide\project_resources\JUnit\;
{VAJava dir}\ide\project_resources\Cactus\;
{VAJava dir}\ide\project_resources\Log4j\;
{VAJava dir}\ide\project_resources\Servlet API Classes\;
]]></source>

    </s1>

    <s1 title="ステップ 5 : VAJava workspace classpath の編集/Step 5 : Edit VAJava workspace classpath">

      <p>
        In the WebSphere Test Environment under Servlet Engine, add Cactus,
        JUnit, Log4j, and the project that contained the tests to the
        classpath.
      </p>
      <p>
	サーブレットエンジン上の WebSphere Test Environment において、
	クラスパスに Cactus、JUnit、Log4j およびテストを含むプロジェクトを加えます。
      </p>

    </s1>

    <s1 title="最後のノート/Final note">

      <note>
        With this configuration, you'll find <code>cactus_client.log</code>
        under <code>{VAJava dir}/ide/project_resources/{project being
        tested}</code> and <code>cactus_server.log</code> under
        <code>{VAJava dir}/ide/tools/com-ibm-ivj-ui-webcontrolcenter</code>
        when you run your tests.
      </note>
      <note>
	この設定により、
	テストを行った場合に、
	<code>{VAJava dir}/ide/project_resources/{project being
        tested}</code> ディレクトリの下に
	<code>cactus_client.log</code> ファイルが、そして、
	<code>{VAJava dir}/ide/tools/com-ibm-ivj-ui-webcontrolcenter</code>
	ディレクトリの下に
	<code>cactus_server.log</code> ファイルができます。
      </note>

    </s1>

  </body>
</document>
