Problem: Struts ActionContext
is null during test
Using Struts2 JUnit plugin I have the following test:
public class MainActionIT extend
Action context is created during the action execution. You should check this code to proof the concept.
@Test
public void shouldAdditionalContextParamsBeAvailable() throws Exception {
// given
String key = "application";
assertNull(ActionContext.getContext().get(key));
// when
String output = executeAction("/home");
// then
assertNotNull(ActionContext.getContext().get(key));
}
@Override
protected void applyAdditionalParams(ActionContext context) {
Map<String, Object> application = new HashMap<String, Object>();
application.put("options","home");
context.put("application", application);
}
About the template
applyAdditionalParams(ActionContext)
Can be overwritten in subclass to provide additional params and settings used during action invocation