views:

71

answers:

0

I'm switching from MockStrutsTestCase to Mockrunner and I'm finding that having to manually re-create all of my DynaActionForms in Mockrunner is a pain...there has to be an easier way?!

Can somebody offer a tip to simplify this process?

For instance, this form bean definition in struts-config.xml:

<form-bean name="myForm" type="org.apache.struts.action.DynaActionForm">
    <form-property name="property" type="java.lang.String"/>
</form-bean>

results in this code in Mockrunner:

//define form config
FormBeanConfig config = new FormBeanConfig();
config.setName("myForm");
config.setType(DynaActionForm.class.getName());
FormPropertyConfig property = new FormPropertyConfig();
property.setName("property");
property.setType("java.lang.String");
config.addFormPropertyConfig(property);
//create mockrunner objects
ActionMockObjectFactory factory = new ActionMockObjectFactory();
ActionTestModule module = new ActionTestModule(factory);
DynaActionForm form = module.createDynaActionForm(config);

Now imagine that I have dozens of DynaActionForms with dozens of attributes...that stinks!