I am getting an error while
testing Action Class using
JUNIT(WSAD 5.1.2)
Details of error are as given below :
servletunit.struts.ExceptionDuringTestError: An uncaught exception was thrown during actionExecute()
at servletunit.struts.CactusStrutsTestCase.actionPerform(CactusStrutsTestCase.java:546)
JUNIT TEST CLASS cose is as given below :
public class PAActionTest extends CactusStrutsTestCase
{
public PAActionTest(
String name)
{
super(name);
}
public void setUp() throws Exception
{
super.setUp();
setConfigFile("/WEB-INF/struts-config-pricing.xml");
UserProfile up=new UserProfile();
up.setUserId(1);
up.setUserName("ngd_user");
up.setOrgId(35);
up.setOrgName("TEST BORG Performance");
UserContainer userContainer=new UserContainer();
userContainer.setUserProfile(up);
session.setAttribute(UserContainer.USER_CONTAINER_KEY, userContainer);
}
public void tearDown() throws Exception
{
super.tearDown();
}
public void testSession()
{
UserProfile profile=SessionDAOFactory.getUserProfile(request);
setRequestPathInfo("/pricingMain");
actionPerform();
/verifyNoActionErrors();
verifyNoActionMessages();
verifyForward("success");
}
public static void main(String[] args)
{
junit.swingui.TestRunner.run(PAActionTest.class);
}
}
Code snippets from
STRUTS CONFIG FILE(struts-config-pricing.xml):
<action
path="/pricingMain"
name="pAActionForm"
type="com.sbc.dcomm.ui.cart.pa.actions.PAAction"
parameter="method">
<forward name="success" path="/cart/pa/paMain.jsp"/>
</action>
Could you please look into this and explain to me the solution ?