Thanks for the patch! I'll have this fixed as part of the 2.1.0-M2 release.
On Sun, Nov 22, 2009 at 8:34 AM, Sudhir N <sudhir_nima...@yahoo.com> wrote: > I just created a JIRA and attached patch... > > Have a look at http://issues.appfuse.org/browse/APF-1172 > > Thanks > SN > > > > > *Sudhir Nimavat* > *Senior software engineer. ** > Quick start global PVT LTD. > Baroda - 390007* > *Gujarat, India > > Personally I'm always ready to learn, although I do not always like being > taught > * > > > > ------------------------------ > *From:* Sudhir N <sudhir_nima...@yahoo.com> > *To:* Appfuse <users@appfuse.dev.java.net> > *Sent:* Thu, 19 November, 2009 4:28:28 PM > *Subject:* [appfuse-user] Generated Web tests won't work when entities > have members with prefix _ (underscore) > > I think this is a catch in > BaseControllerTestCase.objectToRequestParameters() > > When I instance variables are prefixed with underscore Controller test for > form submission will fail. > > Appfuse would create mock request with parameters which are prefixed with > underscore and spring > (WebDataBinder<http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/web/bind/WebDataBinder.html#setFieldMarkerPrefix%28java.lang.String%29>)would > not bind those parameters but instead set to null. > > Here's an example > > I have a Profile entity > > @Entity > @Table(name="profiles") > public class Profile { > > private Long _id; > private int _age; > private Date _dob; > > public Profile() { > > } > > @Id > @GeneratedValue(strategy=GenerationType.AUTO) > public Long getId() { > return _id; > } > > public void setId(Long id) { > _id = id; > } > > @Column(name="age") > public int getAge() { > return _age; > } > > public void setAge(int age) { > _age = age; > } > > @Column(name="dob") > public Date getDob() { > return _dob; > } > > public void setDob(Date dob) { > _dob = dob; > } > > > } > > I have to prefix all the instance variables with underscore.. this is a > coding convention in our organization and I can not change it. > > I generated CRUD using AMP and run tests.. but tests failed.. there were > few problems > > 1. AMP created following empty form tag into validation.xml which caused > SAXParserException when loading application context > <form name="profile"> > </form> > <!--Profile-END--> > > An empty form tag is not allowed it must have at least one child <field>. > Either AMP should not put this form tag into validation.xml at all if no > field requires validation, or I dont knw.. :) > > <form name="profile"> > <field property="age" depends="required"> > <arg0 key="profile.age"/> > </field> > </form> > <!--Profile-END--> > > > 2. ProfileFormControllerTest fails > Errors errors = (Errors) > mv.getModel().get(BindException.MODEL_KEY_PREFIX + "profile"); > assertNull(errors); > > assertion fails because There are binding errors.. Appfuse had created mock > request with paramaters prefixed with underscore which caused WebDataBinder > to ignore it and hence... > > > > > *Personally I'm always ready to learn, although I do not always like being > taught > * > > > > ------------------------------ > The INTERNET now has a personality. YOURS! See your Yahoo! > Homepage<http://in.rd.yahoo.com/tagline_yyi_1/*http://in.yahoo.com/> > . > > ------------------------------ > The INTERNET now has a personality. YOURS! See your Yahoo! > Homepage<http://in.rd.yahoo.com/tagline_yyi_1/*http://in.yahoo.com/> > . >