Automatically creating DynaActionForms in Mockrunner via struts-config.xml

Posted by T Reddy on Stack Overflow See other posts from Stack Overflow or by T Reddy
Published on 2010-04-21T20:59:23Z Indexed on 2010/04/21 21:03 UTC
Read the original article Hit count: 229

Filed under:
|
|
|

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!

© Stack Overflow or respective owner

Related posts about mockrunner

Related posts about mock