|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.seasar.framework.unit.S2FrameworkTestCase
org.seasar.extension.unit.S2TestCase
org.seasar.framework.unit.S2TigerTestCase
org.seasar.cubby.unit.CubbyTestCase
public abstract class CubbyTestCase
CubbyのActionクラスの単体テスト用のクラスです。
このクラスを継承して、それぞれのActionクラス用の単体テストを作成します。 詳細はCubbyドキュメントの「アクションのテスト」を参照下さい。
public class HelloActionTest extends CubbyTestCase {
// 対象のアクション
private HelloAction action;
// 初期化処理
protected void setUp() throws Exception {
// diconファイルの読み込み
include("app.dicon");
}
public void testIndex() throws Exception {
// アクションの実行
ActionResult result = processAction("/hello/");
// 結果のチェック
assertPathEquals(Forward.class, "input.jsp", result);
}
public void setUpMessage() {
// リクエストパラメータのセット
getRequest().addParameter("name", "name1");
}
public void testMessage() throws Exception {
// アクションの実行
ActionResult result = processAction("/hello/message");
// 結果のチェック
assertPathEquals(Forward.class, "result.jsp", result);
// 実行後のアクションの状態を確認
assertEquals("name1", action.name);
}
}
public class TodoActionTest extends CubbyTestCase {
private TodoAction action;
public void setUpShow() throws Exception {
emulateLogin();
}
private void emulateLogin() throws Exception {
User user = new User();
user.setId("mock");
user.setName("mock");
user.setPassword("mock");
getRequest().getSession().setAttribute("user", user);
}
public void testShow() throws Exception {
this.readXlsAllReplaceDb("TodoActionTest_PREPARE.xls");
// CoolURIの場合のテスト
ActionResult result = processAction("/todo/1");
assertPathEquals(Forward.class, "show.jsp", result);
assertEquals(new Integer(1), action.id);
assertEquals("todo1", action.text);
assertEquals("todo1 memo", action.memo);
assertEquals(new Integer(1), action.todoType.getId());
assertEquals("type1", action.todoType.getName());
assertEquals("2008-01-01", action.limitDate);
}
}
| 入れ子のクラスの概要 |
|---|
| クラス org.seasar.framework.unit.S2TigerTestCase から継承された入れ子のクラス/インタフェース |
|---|
S2TigerTestCase.Subsequence |
| フィールドの概要 |
|---|
| クラス org.seasar.framework.unit.S2TigerTestCase から継承されたフィールド |
|---|
easyMockSupport |
| クラス org.seasar.framework.unit.S2FrameworkTestCase から継承されたフィールド |
|---|
ENV_PATH, ENV_VALUE |
| コンストラクタの概要 | |
|---|---|
CubbyTestCase()
|
|
| メソッドの概要 | |
|---|---|
static void |
assertPathEquals(Class<? extends ActionResult> resultClass,
String expectedPath,
ActionResult actualResult)
ActionResultの型とパスをチェックします。 |
static void |
assertPathEquals(Class<? extends ActionResult> resultClass,
String expectedPath,
ActionResult actualResult,
String characterEncoding)
ActionResultの型とパスをチェックします。 |
protected ActionResult |
processAction(String originalPath)
アクションメソッドを実行します。 |
protected String |
routing(MockHttpServletRequest request,
MockHttpServletResponse response)
CubbyFilterで行っているルーティングをエミュレートして、内部フォワードパスをリクエストにセットします。 |
protected String |
routing(String orginalPath)
推奨されていません。 |
protected void |
setupThreadContext()
ThreadContextにリクエストをセットします。 |
| クラス org.seasar.framework.unit.S2TigerTestCase から継承されたメソッド |
|---|
addAspecDef, applyMockInterceptor, applyMockInterceptor, createExpression, createMock, createNiceMock, createStrictMock, doRecord, doRunTest, runBare, setUpForEachTestMethod, tearDownForEachTestMethod |
| クラス junit.framework.TestCase から継承されたメソッド |
|---|
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, toString |
| クラス junit.framework.Assert から継承されたメソッド |
|---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format |
| クラス java.lang.Object から継承されたメソッド |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| コンストラクタの詳細 |
|---|
public CubbyTestCase()
| メソッドの詳細 |
|---|
public static void assertPathEquals(Class<? extends ActionResult> resultClass,
String expectedPath,
ActionResult actualResult)
resultClass - ActionResultの型expectedPath - 期待されるパスactualResult - チェックするActionResult
public static void assertPathEquals(Class<? extends ActionResult> resultClass,
String expectedPath,
ActionResult actualResult,
String characterEncoding)
resultClass - ActionResultの型expectedPath - 期待されるパスactualResult - チェックするActionResultcharacterEncoding - URI のエンコーディング
protected ActionResult processAction(String originalPath)
throws Exception
originalPath - オリジナルパス
null
Exception - アクションメソッドの実行時に例外が発生した場合
protected String routing(MockHttpServletRequest request,
MockHttpServletResponse response)
request - リクエストresponse - レスポンス
protected void setupThreadContext()
ThreadContextにリクエストをセットします。
@Deprecated protected String routing(String orginalPath)
orginalPath - オリジナルパス
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||