2006-04-13 13:36:54 UTC
Here is my code that works, I test a DispatchAction with a DynaActionForm and I mock the service, next Step integrate with JMock, Thanks Alwin:
public class UserActionTest extends BasicActionTestCaseAdapter {
private DynaActionForm form;
private UserAction action;
protected void setUp() throws Exception {
super.setUp();
FormBeanConfig config = new FormBeanConfig();
config.setName("userForm");
config.setType(DynaActionForm.class.getName());
FormPropertyConfig property1 = new FormPropertyConfig();
property1.setName("user");
property1.setType("fr.canam.demo.model.User");
config.addFormPropertyConfig(property1);
getActionMockObjectFactory().getMockActionMapping().setParameter("method");
form = createDynaActionForm(config);
action = new UserAction();
action.setUserService(new UserServiceMock());
}
public void testTest() {
addRequestParameter("method","test");
actionPerform(action, form);
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward("detail");
}
}
Regards,
Jeff