Unit test fails when the result type is a tile

I am trying to test my action classes with the jUnit plugin. The action is as follows:

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

When I call proxy.execute() , the test fails. I probably forget something that makes my test work with tiles, but I don’t know what it can 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) ... 

When I change the action as shown below, the test runs fine:

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

Before proxy.execute() value of executeResult must be set to false : proxy.setExecuteResult(false) .

+8
source

Source: https://habr.com/ru/post/891447/


All Articles