Unit test – when the result type is tile, the unit test fails

I tried to test my action class with the JUnit plug - in This action is as follows:

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

When I call proxy The test crashed while executing () I may have forgotten to let my test run with tiles, but I don't know what it might be I get the following stack trace:

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)
...

The test runs normally when I change the following operations:

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

Solution

In proxy Before execute (), you should set executeresult to false value: proxy setExecuteResult(false).

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>