Struts 2 JUnit Plugin v2.2.3: Test Class Extending StrutsTestCase; 'request' is null

守給你的承諾、 提交于 2019-12-03 21:39:26

I do not use Spring w/in my struts app, but I assume these jars are needed to use the mock request object and such in the StrutsTestCase.

Given the exception messages you're seeing above your application believes that it uses Spring. Do you have the Struts2-Spring-Plugin on your classpath? If you're not using Spring for IoC then you shouldn't include it on your classpath.

You should be able to test your actions by following guide you've referenced without any spring jars if you don't use Spring. Try removing all the spring jars and the struts2-spring-plugin jar. You also certainly don't need:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath*:applicationContext-test.xml"})

in your test class if you don't use spring.

Also check that your struts.xml doesn't contain this line:

<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"/>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!