I'm testing my Struts 2 web application using Struts 2 JUnit plugin, following Unit Testing.
In my web application I use fullHibernateCore-plugin-1.4
to integrate Hibernate functionality.
When I test an action that do some Hibernate stuff, it returns NullPointerException
.
From what I've understood, since Struts 2 JUnit plugin use a fake container to execute actions, the HibernateSession
don't get fired.
How can I solve this problem?
This is a test example:
public class testRegisterAction extends StrutsTestCase {
public void testGetActionProxy() throws Exception {
//set parameters before calling getActionProxy
request.setParameter("user.name", "TestName");
ActionProxy proxy = getActionProxy("/userRegister.action");
assertNotNull(proxy);
RegistrationAction action = (RegistrationAction) proxy.getAction();
assertNotNull(action);
}