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)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.yahoo.com/

Reply via email to