JBoss SeamTest 断言问题
关键字: jboss seam testpackage org.jboss.seam.example.registration.test;
import javax.faces.context.FacesContext;
import org.jboss.seam.mock.SeamTest;
import org.testng.annotations.Test;
public class RegisterTest extends SeamTest
{
@Test
public void testLogin() throws Exception
{
new FacesRequest("/register.jspx") {
@Override
protected void processValidations() throws Exception
{
validateValue("#{user.username}", "1ovthafew");
validateValue("#{user.name}", "Gavin King");
validateValue("#{user.password}", "secret");
assert !isValidationFailure();
}
@Override
protected void updateModelValues() throws Exception
{
setValue("#{user.username}", "1ovthafew");
setValue("#{user.name}", "Gavin King");
setValue("#{user.password}", "secret");
}
@Override
protected void invokeApplication()
{
assert invokeMethod("#{register.register}").equals("/registered.jspx");
setOutcome("/registered.jspx");
}
@Override
protected void afterRequest()
{
assert isInvokeApplicationComplete();
assert !isRenderResponseBegun();
assert IsRenderResponseComplete();
}
}.run();
new NonFacesRequest("/registered.jspx")
{
@Override
protected void renderResponse()
{
assert getValue("#{user.username}").equals("1ovthafew");
assert getValue("#{user.password}").equals("secret");
assert getValue("#{user.name}").equals("Gavin King");
}
}.run();
new FacesRequest("/register.jspx") {
@Override
protected void processValidations() throws Exception
{
validateValue("#{user.username}", "1ovthafew");
validateValue("#{user.name}", "Gavin A King");
validateValue("#{user.password}", "password");
}
@Override
protected void updateModelValues() throws Exception
{
setValue("#{user.username}", "1ovthafew");
setValue("#{user.name}", "Gavin A King");
setValue("#{user.password}", "password");
}
@Override
protected void invokeApplication()
{
assert invokeMethod("#{register.register}")==null;
}
@Override
protected void renderResponse() throws Exception
{
assert FacesContext.getCurrentInstance().getMessages().hasNext();
}
@Override
protected void afterRequest()
{
assert isInvokeApplicationComplete();
assert isRenderResponseComplete();
}
}.run();
}
}
以上是seam框架包自带的registration项目的测试用例, 上面带红线的一行代码,isRenderResponseBegun(); 我浏览SeamTest的时候发现
private void renderResponsePhase() throws Exception
{
phases.beforePhase(new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE));
try
{
updateConversationId();
renderResponseBegun = true;
renderResponse();
renderResponseComplete = true;
facesContext.getApplication().getStateManager().saveView(facesContext);
updateConversationId();
}
finally
{
phases.afterPhase(new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE));
}
}
在这个阶段的时候 renderResponseBegun = true; 为什么断言中是false? 即(是 assert !isRenderResponseBegun(); 而不是assert isRenderResponseBegun()? ) 请问高手解释一下?
这行代码 assert isRenderResponseComplete(); 是我添加上的,但是测试的时候断言失败, 也就是 renderResponseComplete值是false,明明在上面的阶段设置为true了 ? 这又是怎么回事呀?
- 16:13
- 浏览 (183)
- 评论 (0)
- 分类: JSF 1.2
- 发布在 JBoss SEAM 圈子
- 相关推荐
发表评论
- 浏览: 10237 次
- 性别:

- 来自: 合肥

- 详细资料
搜索本博客
我的相册
共 7 张
最近加入圈子
链接
最新评论
-
晚上思考人生千条路,白天 ...
一夜思量千条路,明朝依旧卖豆芽。呵呵!同感!
-- by pure -
晚上思考人生千条路,白天 ...
同感~~
-- by hanssonlan -
成功人需要的三要素
成功是个过程。一路上有很多的汗水和泪水。
-- by xiaozmn -
勒紧裤腰带 买了两百书
无语。上当被耍!
-- by bruce.peng -
JBPM JPA Spring 闹别 ...
如何保证事务?我觉得事务是最大的问题.
-- by fuwang






评论排行榜