I am
testing my application using
JUNIT and my application is based on
struts.
I am getting an NullPointerException ,while testing using JUNIT
Code snippet from PAAction.javs
NullPointerException is due to the following line of code:
StrPageSize = getResources (req).getMessage ("pricing.pageSize");
I am setting the page size using properties file (ApplicationResources.properties) which I have stored in the dcomm-ui/JavaSource/com/sbc/dcomm/ui/resources /
Code snippet from ApplicationResources.properties
pricing.pageSize=5
If web server executes action class for the application, it will not throw any exception; it takes value from the properties file and executes the method properly.
How do I set this value in my test case method for testing it using JUNIT?
How do I fix this problem by setting pagesize in my test case method?
My Test case method is as follows:
public void testApplyChanges()
{
UserProfile profile=SessionDAOFactory.getUserProfile(request);
setRequestPathInfo("/pricingMain");
PAActionForm nPopUpForm = new PAActionForm();
setActionForm(nPopUpForm);
addRequestParameter("method","applyChanges");
addRequestParameter("id","2863");
addRequestParameter("cartSiteId","-1");
addRequestParameter("page","1");
nPopUpForm.setEditableField("textCostPrice");
nPopUpForm.setEditValues("2320.0,2320.0,352.0,352.0,0.0");
nPopUpForm.setPromoCode("12");
nPopUpForm.setPromoDesc("2356");
nPopUpForm.setId(2863);
nPopUpForm.setCartSiteId("-1");
actionPerform();
verifyForward("success");
verifyForwardPath("/cart/pa/paMain.jsp");
verifyNoActionErrors();
}
Expecting your solution ..