Hello, I am trying to Junit test my Struts code. Not sure how many people have tried to do this. If there is a more appropriate forum to send this to please let me know. Here is my test code. When it gets to: dynaValidatorForm.set("areaId", "-1"); it crashes. I never tried to instantiate a DynaValidatorForm before (I always just cast ActionForm in the action method to a DynaValidatorForm). Is there something tricky about instantiating a DynaValidatorForm ?
public void testSaveEdit() { try { appbean.login("admin", "project"); addRequestParameter("method","Save"); addRequestParameter("areaId","-1"); setRequestPathInfo("/saveArea.do"); DynaValidatorForm dynaValidatorForm = new DynaValidatorForm(); dynaValidatorForm.set("areaId", "-1"); dynaValidatorForm.set("description", "area1"); dynaValidatorForm.set("projectCoordinatorContactName", "new name 1"); dynaValidatorForm.set("projectCoordinatorContactPhoneNumber", "new number 1"); dynaValidatorForm.set("maintenanceManagerContactName", "new name 2"); dynaValidatorForm.set("maintenanceManagerContactPhoneNumber", "new number 2"); setActionForm(dynaValidatorForm); actionPerform(); verifyForward("success"); verifyNoActionErrors(); verifyActionErrors(new String[]{"message.saved"}); appbean.logout(); } catch(Exception e) { fail("Unexpected Exception - " + e.getMessage()); } }