org.seasar.cubby.plugins.s2.unit
クラス CubbyTestCase
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.seasar.framework.unit.S2FrameworkTestCase
org.seasar.extension.unit.S2TestCase
org.seasar.framework.unit.S2TigerTestCase
org.seasar.cubby.plugins.s2.unit.CubbyTestCase
- すべての実装されたインタフェース:
- Test
public abstract class CubbyTestCase
- extends S2TigerTestCase
CubbyのActionクラスの単体テスト用のクラスです。
このクラスを継承して、それぞれのActionクラス用の単体テストを作成します。詳細はドキュメントの「アクションのテスト」を参照下さい。
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);
}
}
- 作成者:
- agata, baba
メソッドの概要 |
static void |
assertPathEquals(Class<? extends ActionResult> expectedType,
String expectedPath,
ActionResult actual)
指定された ActionResult の型とパスを検証します。 |
static void |
assertPathEquals(Class<? extends ActionResult> expectedType,
String expectedPath,
ActionResult actual,
String characterEncoding)
指定された ActionResult の型とパスを検証します。 |
static void |
assertPathEquals(String message,
Class<? extends ActionResult> expectedType,
String expectedPath,
ActionResult actual)
指定された ActionResult の型とパスを検証します。 |
static void |
assertPathEquals(String message,
Class<? extends ActionResult> expectedType,
String expectedPath,
ActionResult actual,
String characterEncoding)
指定された ActionResult の型とパスを検証します。 |
protected ActionResult |
processAction(HttpServletRequest request,
HttpServletResponse response)
アクションメソッドを実行します。 |
protected ActionResult |
processAction(String path)
指定されたパスのアクションメソッドを実行します。 |
クラス org.seasar.framework.unit.S2TigerTestCase から継承されたメソッド |
addAspecDef, applyMockInterceptor, applyMockInterceptor, createExpression, createMock, createNiceMock, createStrictMock, doRecord, doRunTest, runBare, setUpForEachTestMethod, tearDownForEachTestMethod |
クラス org.seasar.extension.unit.S2TestCase から継承されたメソッド |
assertBeanEquals, assertBeanListEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertMapEquals, assertMapListEquals, deleteDb, deleteTable, getConnection, getDatabaseMetaData, getDataSource, getSqlWriter, needTransaction, readDb, readDbBySql, readDbByTable, readDbByTable, readXls, readXls, readXlsAllReplaceDb, readXlsAllReplaceDb, readXlsReplaceDb, readXlsReplaceDb, readXlsWriteDb, readXlsWriteDb, reload, reload, reloadOrReadDb, setUpAfterContainerInit, setupDataSource, tearDownBeforeContainerDestroy, tearDownDataSource, writeDb, writeXls |
クラス org.seasar.framework.unit.S2FrameworkTestCase から継承されたメソッド |
bindField, bindFields, convertPath, getComponent, getComponent, getComponentDef, getComponentDef, getContainer, getNamingConvention, getOriginalClassLoader, getRequest, getResponse, getRootDicon, getServlet, getServletConfig, getServletContext, getTargetMethod, getTargetName, include, invoke, isAutoBindable, isRegisterNamingConvention, isWarmDeploy, normalizeName, register, register, register, register, register, resolveRootDicon, setRegisterNamingConvention, setRequest, setResponse, setServlet, setServletConfig, setServletContext, setUpAfterBindFields, setUpContainer, setWarmDeploy, tearDownBeforeUnbindFields, tearDownContainer, unbindFields |
クラス 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 |
CubbyTestCase
public CubbyTestCase()
assertPathEquals
public static void assertPathEquals(Class<? extends ActionResult> expectedType,
String expectedPath,
ActionResult actual)
- 指定された
ActionResult
の型とパスを検証します。
- パラメータ:
expectedType
- 期待する ActionResult
の型expectedPath
- 期待する ActionResult
のパスactual
- 実際の ActionResult
assertPathEquals
public static void assertPathEquals(String message,
Class<? extends ActionResult> expectedType,
String expectedPath,
ActionResult actual)
- 指定された
ActionResult
の型とパスを検証します。
- パラメータ:
message
- メッセージexpectedType
- 期待する ActionResult
の型expectedPath
- 期待する ActionResult
のパスactual
- 実際の ActionResult
- 導入されたバージョン:
- 2.0.2
assertPathEquals
public static void assertPathEquals(Class<? extends ActionResult> expectedType,
String expectedPath,
ActionResult actual,
String characterEncoding)
- 指定された
ActionResult
の型とパスを検証します。
- パラメータ:
expectedType
- 期待する ActionResult
の型expectedPath
- 期待する ActionResult
のパスactual
- 実際の ActionResult
characterEncoding
- URI のエンコーディング
assertPathEquals
public static void assertPathEquals(String message,
Class<? extends ActionResult> expectedType,
String expectedPath,
ActionResult actual,
String characterEncoding)
- 指定された
ActionResult
の型とパスを検証します。
- パラメータ:
message
- メッセージexpectedType
- 期待する ActionResult
の型expectedPath
- 期待する ActionResult
のパスactual
- 実際の ActionResult
characterEncoding
- URI のエンコーディング- 導入されたバージョン:
- 2.0.2
processAction
protected ActionResult processAction(String path)
throws Exception
- 指定されたパスのアクションメソッドを実行します。
- パラメータ:
path
- パス
- 戻り値:
- アクションメソッドの実行結果。アクションメソッドが見つからなかった場合は
null
- 例外:
Exception
- アクションメソッドの実行時に例外が発生した場合
processAction
protected ActionResult processAction(HttpServletRequest request,
HttpServletResponse response)
throws Exception
- アクションメソッドを実行します。
- パラメータ:
request
- 要求response
- 応答
- 戻り値:
- アクションメソッドの実行結果。アクションメソッドが見つからなかったり結果がない場合は
null
- 例外:
Exception
- アクションメソッドの実行時に例外が発生した場合
Copyright © 2006-2010 The Seasar Foundation. All Rights Reserved.