|
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
コード規約
ビルドの結果
|
| HttpUnit との統合/HttpUnit integration |
 |
The HttpUnit integration is only available for Cactus v1.2 and
later. It won't work with version 1.1 and earlier.
|
 |
HttpUnit との統合は Cactus 1.2 以上でのみ利用可能です。
バージョン 1.1 以前では動作しません。
|
Cactus test cases allow to assert the results of the returned server
output stream in an endXXX() method (where XXX
is the name of your test case).
Cactus テストケースでは、
endXXX()
メソッドにより返されたサーバー出力ストリームの結果のアサーションを記述することができます。
(XXXはテストケース名です)
Cactus proposes 2 ways of writing your endXXX() methods,
Cactus は endXXX()メソッドを記述する方法を 2 通り提案しています。
-
Method 1 : it allows you to do simple check on the
returned stream like checking for returned cookies, HTTP headers and
to do assertions on the returned content as a String,
-
方法1 :
返されたストリームに対し、
クッキーやHTTP ヘッダといった単純なチェックを行い、
戻り値を文字列として検証できるようにするもの
-
Method 2 : it allows you to do complex and
powerful assertions on the returned content. For example, you can
get an HTML DOM view of your returned HTML page and check that a given
named table has the correct number of columns, ....
-
メソッド 2 :
返された内容に対し、複雑で強力なアサーションを可能にするもの。
例えば、返された HTML ページの HTML DOM のビューを得たり、
与えられた名前のテーブルが正しいカラム数であるかチェックするなどです。
Method 2 is supported through the integration with
HttpUnit, meaning
you'll benefit from the full assertion power of HttpUnit in your
endXXX() method. Method 1 is a class provided by Cactus.
Depending on your need you can choose, on a per test case basis, the
method you want to use.
必要に応じて、使いたい方法を、テストケース単位で選択することができます。
|
| 使い方/Usage |
The signature of an endXXX() method is always :
endXXX() メソッドの書式は常に次のようになります:
public void endXXX(WebResponse theResponse)
{
[...]
}
|
The WebResponse object is passed by the Cactus framework
to your endXXX() method. What changes between the 2
methods described above is the class of the WebResponse
object that is passed :
WebResponse オブジェクトは
Cactus フレームワークにより
上述の 2 つの方法の違いは、
渡される WebResponse オブジェクトのクラスです :
What changes between the 2
methods described above is the class of the WebResponse
object that is passed :
-
org.apache.cactus.WebResponse for Method 1,
-
方法1では
org.apache.cactus.WebResponse
-
com.meterware.httpunit.WebResponse for Method 2
(HttpUnit)
-
方法2(HttpUnit)では
com.meterware.httpunit.WebResponse
| 方法1 : Cactus が提供する WebResponse オブジェクト/Method 1 : Cactus provided WebResponse object |
An example :
例 :
public void endXXX(org.apache.cactus.WebResponse theResponse)
{
// Get the returned cookies
// 返されたクッキーを得る
Hashtable cookies = theResponse.getCookies();
// Get the returned content as a string
// 返されたコンテンツを文字列として得る
String content = theResponse.getText();
// Do some asserts
// アサーションを行う
assertEquals(content, "<html><body><h1>Hello world!</h1></body></html>");
[...]
}
|
 |
For the complete list of all methods available on the
WebResponse object, see the associated Javadoc.
|
 |
WebResponse オブジェクトで利用可能なメソッドの完全な一覧は、対応する javadoc をご覧ください。
|
|
| メソッド 2 : HttpUnit により提供される WebResponse オブジェクト/Method 2 : HttpUnit provided WebResponse object |
An example :
例 :
public void endXXX(com.meterware.httpunit.WebResponse theResponse)
{
WebTable table = theResponse.getTables()[0];
assertEquals("rows", 4, table.getRowCount());
assertEquals("columns", 3, table.getColumnCount());
assertEquals("links", 1, table.getTableCell(0, 2).getLinks().length);
[...]
}
|
 |
For the complete list of all methods available on the
HttpUnit WebResponse object, see the HttpUnit
documentation.
|
 |
HttpUnit の
WebResponse オブジェクトで利用可能なメソッドの完全な一覧は、HttpUnit のドキュメントをご覧ください。
|
|
|
|
|