Setting the Cactus CLASSPATH

Last update : July 6 2002
Doc for : v1.3

Cactusについて
  • Cactus とは
  • ニュース
  • 変更履歴
  • 特徴/開発状況
  • 目標
  • ロードマップ/ToDo
  • 協力者
  • 協力者募集
  • Cactus ユーザ
  • テスト済環境 ...
  • ライセンス


  • ダウンロード
  • ダウンロード


  • ドキュメント
  • Cactus の仕組み
  • さぁ始めよう
  • モック対コンテナ
  • Javadocs
  • └Javadocs
  • よくある質問


  • Howto ガイド
  • クラスパス Howto
  • 設定 Howto
  • アップグレードHowto
  • テストケース Howto
  • セキュリティHowto
  • Ant Howto
  • HttpUnit Howto
  • サンプル Howto
  • EJB Howto
  • IDE Howto
  • JUnitEE Howto


  • サポート
  • Bug DB
  • メーリングリスト


  • その他
  • 名前の由来
  • ロゴコンテスト
  • 参考文献
  • アクセス状況
  • └WebAlizer


  • 開発者向け
  • CVS
  • コード規約
  • ビルドの結果


  • Cactus クラスパスの設定/Setting up Cactus Classpaths

    You must understand that your Cactus tests are started by a JUnit Test Runner (in the client JVM) and that the Cactus TestCase that you have extended will connect to the Cactus Redirector (in the server JVM), where your testXXX() methods will be executed. See How it works to understand the mechanism.

    自分の Cactus テストは (クライアント側JVMにおいて) JUnit の Test Runner により起動され、 拡張した Cactus テストケースは (サーバー側JVMにおいて)自分のtestXXX()が実行される Cactus リダイレクタに接続ことを理解していなければなりません。 そのメカニズムを理解するには、 Cactusの仕組みを見てください。

    Note It is very important that you understand what files you need to put in the client and server classpaths, as 99% of Cactus errors come from an incorrect classpath !

    Note Cactus のエラーの 99% はクラスパスの誤りに起因するので、 クライアントおよびサーバーのクラスパスにどのファイルを置くか理解していることは、 大変重要なことです。

    Classpaths

    クライアント側クラスパス/Client side classpath

    The Cactus tests are started by running a JUnit Test Runner (For explanations on how JUnit works see the JUnit web site). As pictured in figure 1, you need to have the following jars and classes in your client side classpath :

    Cactus のテストは JUnit の Test Runner を実行することにより、 起動されます。 (JUnit 仕組みについての説明は、 JUnitウェブサイト をご覧ください。) 図 1 に示した通り、 クライアント側クラスパスに次の jar ファイルを置かなければなりません :

    • junit.jar : obviously this is needed for the JUnit Test Runner and because the Cactus XXXTestCase classes extend the JUnit org.junit.framework.TestCase class.
    • junit.jar : これが JUnit の Test Runner のために明らかに必要です。 何故なら、Cactus XXXTestCase クラスは JUnit の org.junit.framework.TestCase クラスを拡張するからです。
    • cactus.jar : well, this is the Cactus jar containing all Cactus classes,
    • cactus.jar : そう、これは全ての Cactus のクラスを含んでいる Cactus jar ファイルです。
    • your test classes : these are your test classes that extend the Cactus XXXTestCase classes,
    • 自分のテストクラス : これらは、Cactus の XXXTestCase クラスを 拡張した自分のテストクラスです。
    • servlet.jar or j2ee.jar : these are the Servlet API / J2EE API interfaces. This is needed on the client side classpath because your test cases extend one or several of XXXTestCase which use class variables that are Servlet / J2EE objects (HttpSevletRequest, PageContext, ...). You can get this jar either from your servlet engine or from the Sun Web Site ( Servlet download page or J2EE download page).
    • servlet.jar or j2ee.jar : これらは Servlet API / J2EE API インターフェースです。 これらはクライアント側のクラスパスに置いてある必要があります。 何故なら、 自分のテストケースは、一つあるいは幾つかの Servlet / J2EE オブジェクト (HttpSevletRequestPageContextなど) であるXXXTestCase を拡張したものだからです。 この jar ファイルは、 インストールしたサーブレットエンジンや、 Sun ウェブサイト ( Servlet ダウンロードページ または J2EE ダウンロードページ) で得ることができます。
    • httpclient.jar : needed for Cactus Cookie handling.
    • httpclient.jar : Cactus が Cookie を扱うのに必要です。
    • log4j.jar (optional) : only needed when you want Cactus to output debugging information on the client side.
    • log4j.jar (optional) : Cactus にクライアント側でデバッグ情報を出力させたい場合にのみ必要です。
    • httpunit.jar, Tidy.jar and xerces.jar (optional) : only needed if you wish to use HttpUnit in your endXXX() methods (see the HttpUnit Howto tutorial). The 3 jars mentioned above are part of the HttpUnit distribution.
    • httpunit.jar, Tidy.jar and xerces.jar (optional) : 自分の endXXX() メソッド中で、 HttpUnit を使いたい場合にのみ必要です。 (HttpUnit Howto チュートリアルをご覧ください) 上述の 3 つの jar ファイルは HttpUnit ディストリビューションに含まれています。
    • aspectjrt.jar : AspectJ runtime jar.
    • aspectjrt.jar : AspectJ ランタイム jar ファイル

    Note If you have the habit of using class variables for the classes to test (as opposed to declaring them within the testXXX() method), you'll also need to put your classes under test in the client side classpath.

    Note テストしたいクラスのために、クラス変数を使う習慣がある場合 (testXXX() メソッド中でそれらを宣言する別の方法に対して)、 クライアント側クラスパスにテスト中のクラスを置かなければなりません。

    In addition to the above mentionned jars and classes, you will also need to put the cactus.properties configuration file in your classpath (because it is a java properties file). Details are described in the Config Howto tutorial).

    上述の jar およびクラスに加えて、 cactus.properties 設定ファイルをクラスパスに置かなければなりません。 (何故ならこれは java のプロパティファイルだからです。) 詳しくは 設定 Howto チュートリアルに書かれています。

    Note In theory you would also need to put the log_client.properties properties file in your classpath. However a default one is provided in cactus.jar (and thus is on the classpath as cactus.jar is itself in the classpath !).

    Note 理論的には、 log_client.properties プロパティファイルもクラスパスに置かなければなりませんが、 デフォルトの物が cactus.jar にあります。 (従って、cactus.jar がクラスパスにあるので、 このファイルもクラスパスにあることになります。)


    サーバー側クラスパス/Server side classpath

    The server side part is a webapp. It can be packaged as a .war file or as expanded war. It should have the following structure, which will ensure that the classpath is correct :

    サーバー側の部分はウェブアプリケーションです。 これは、.war ファイル、あるいは war を解凍したものとしてパッケージ化されています。 クラスパスが正しいか確認するためには、 次に示すようなディレクトリ構造でなければなりません :

    • WEB-INF/lib/cactus.jar : the Cactus main jar,
    • WEB-INF/lib/cactus.jar : Cactus のメインの jar ファイル
    • WEB-INF/lib/junit.jar : this is needed because the Cactus XXXTestCase extends the JUnit org.junit.framework.TestCase class.
    • WEB-INF/lib/junit.jar : Cactus XXXTestCase は、 JUnit の org.junit.framework.TestCase を拡張するため、これが必要となります。
    • WEB-INF/classes/<your test classes> : obviously as their testXXX() methods will get executed in the container.
    • WEB-INF/classes/<自分のテストクラス> : 明らかに、 その中の testXXX() メソッドがコンテナ上で実行されるので
    • WEB-INF/classes/<your classes under test> : will be called by your test classes.
    • WEB-INF/classes/<テストを行うクラス> : テストクラスにより呼び出されます
    • WEB-INF/lib/log4j.jar (optional) : only needed when you want Cactus to output debugging information on the server side.
    • WEB-INF/lib/log4j.jar (オプション) : Cactus にサーバー側にデバッグ情報を出力させたい場合にのみ必要です。

    Note If you have several webapps that use cactus you may be tempted to place the cactus.jar in your container's shared library folder. However, this approach will not work in many cases because code in a shared location (cactus) cannot access code in a specific webapp (your test cases). This restriction makes sense since you would not want com.foo.EvilClass in webapp A to conflict with com.foo.EvilClass in webapp B.

    Note Cactus を使った幾つかのウェブアプリケーションがあるとき、 コンテナ共有のライブラリフォルダに cactus.jar を 置きたくなることがあるかもしれませんが、 この方法では多くの場合動作しません。 なぜなら、 共有場所にある(cactus の)コードが特定のウェブアプリケーション(あなたのテストケース)のコードを参照できないからです。 ウェブアプリケーション A の com.foo.EvilClass が、 ウェブアプリケーション B の com.foo.EvilClass と競合させたくないために、 この制限は意味があります。

    Note In theory you would also need to put the log_server.properties configuration file in your classpath. However a default one is provided in cactus.jar (and thus is on the classpath as cactus.jar is itself in the classpath !).

    Note 理論的には、 log_server.properties 設定ファイルも自分のクラスパスに置く必要がありますが、 デフォルトのものが cactus.jar で提供されています。 (従って、cactus.jar自身がクラスパスにあるので、 そのファイルもクラスパスにあるということです。)





    [訳注:これは 漆島賢二 が翻訳しました。日本語訳に対するコメントがあれば こちらに送ってください]
    Copyright © 2000-2002 The Apache Software Foundation. All Rights Reserved.