[ https://issues.apache.org/jira/browse/WW-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16371077#comment-16371077 ]
Michael Hintenaus commented on WW-4921: --------------------------------------- with Struts 2.5.14.1 it works fine, with Struts 2.5.15 the test will fail {code:java} @Action(results = @Result(location="http://struts.apache.org", type="redirect")) public class MyAction extends ActionSupport { } {code} {code:java} public class MyTest extends StrutsJUnit4TestCase<MyAction> { @Test public void test() throws Exception { request.getSession(true); final ActionProxy proxy = getActionProxy("/my-action.action"); final ActionInvocation invocation = proxy.getInvocation(); invocation.invoke(); assertTrue(invocation.isExecuted()); assertEquals(MyAction.SUCCESS, invocation.getResultCode()); } }{code} {code:java} java.lang.NullPointerException at org.apache.struts2.interceptor.I18nInterceptor$SessionLocaleHandler.read(I18nInterceptor.java:308) at org.apache.struts2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:107) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:167) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) at com.silbergrau.cal6.MyTest.test(MyTest.java:20){code} > NPE in I18nInterceptor$SessionLocaleHandler.read > ------------------------------------------------ > > Key: WW-4921 > URL: https://issues.apache.org/jira/browse/WW-4921 > Project: Struts 2 > Issue Type: Bug > Components: Core Interceptors > Reporter: Michael Hintenaus > Priority: Major > Labels: test > Fix For: 2.5.16 > > > Calling > {code:java} > getActionProxy("/index.action").getInvocation().invoke(){code} > in a TestCase which extends from StrutsJUnit4TestCase will lead to a > NullPointerException. > Overriding getActionProxy like this will help: > {code:java} > @Override > protected ActionProxy getActionProxy(final String uri) { > final ActionProxy proxy = super.getActionProxy(uri); > final ActionContext context = > proxy.getInvocation().getInvocationContext(); > if (context.getSession() == null) { > context.setSession(new SessionMap<>(request)); > } > return proxy; > }{code} > -- This message was sent by Atlassian JIRA (v7.6.3#76005)