开发者

Unit test fail when result type is tile

开发者 https://www.devze.com 2023-03-16 02:51 出处:网络
I am trying to test my action classes with the jUnit plugin. The action looks like this: @Action(value = \"default\", results = {

I am trying to test my action classes with the jUnit plugin. The action looks like this:

@Action(value = "default", results = {
    @Result(name = "success", type="tiles", location = "login") })
public String defaultAction() {
    return SUCCESS;
}

When I call the proxy.execute(), the test crashes. I am probably forgetting something that makes my test run with tiles, but i have no clue about what that may be. I get the following stack trace:开发者_Go百科

java.lang.NullPointerException
at org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:105)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
...

When I change the action as below, the test executes normally:

@Action(value = "default", results = {
    @Result(name = "success", type="redirectAction", location = "login") })
public String defaultAction() {
    return SUCCESS;
}


Before proxy.execute(), the executeResult should be set false value: proxy.setExecuteResult(false).

0

精彩评论

暂无评论...
验证码 换一张
取 消