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)
.
精彩评论