I think I got the problem

first, the test I provided is wrong, the 2nd FormTester should instantiated without
fill blank string on FormComponets, or it will overwrite all FormComponent's input.

  // disable filling blank string for all FormComponents
  FormTester formTesterContinue = tester.newFormTester("createForm", false);

But even with this fix, the problem still persist.

After debugging/traceing, I found that MockWebApplication didn't convert exist
field values into request parameters even in previous Wicket release. FormComponent
just get null rawInput, and validation passed just because previous version's RequiredValidator will bypass it:

// previous RequiredValidator
    public final void onValidate(FormComponent formComponent, String value)
    {
        //bypass if value is null
        if (formComponent instanceof AbstractTextComponent && value == null)
        {
            return;
        }
        //...omit rest....
   }

// latest RequiredValidator , implementation changed.
    public final void onValidate(final FormComponent formComponent, final String value)
    {
        // Check value only if form component can take on a null value
        if (formComponent.isInputNullable())
        {
            // Check value
            if (Strings.isEmpty(value))
            {
                error(formComponent);
            }
        }
    }

So basically my test worked before is relying on I miss interpret RequiredValidator's
behavior. I always think that MockWebApplication will gather exist values of field into
request parameters and so my formTester could continue to process. :(

Is it possible to make Mock enviroment to gather field values already on Page ?
I believe this is more natural. and it makes testing more smoothly.


On 2/19/06, Juergen Donnerstag < [EMAIL PROTECTED]> wrote:
It looks like a namespace issue. We recently started using a kind of
namespace for various "resources" including url parameter. Reason:
avoiding issues due to users using wicket "preserved" names.

Juergen

On 2/18/06, Ingram Chen < [EMAIL PROTECTED]> wrote:
> I upgrade to latest CVS, but found behavior of FormTester changed.
> below is small test case for
> wicket.util.tester.WicketTesterTest:
>
> public void testCreateBook_submit() throws Exception
> {
>     MyMockApplication tester = new MyMockApplication();
>     tester.startPage(CreateBook.class);
>
>     FormTester formTester = tester.newFormTester("createForm");
>
>      // two fields are required, one is "name", the other is "id"
>     // and we only fill one:
>      formTester.setValue("name", "xxName");
>     formTester.submit ();
>
>     // we got validation error message:
>     tester.assertErrorMessages (new String[] { "id is required" });
>
>     // now we continue test the same page, the "name" Field should
>     // contains value "xxName" on the page
>     FormTester formTesterContinue = tester.newFormTester("createForm");
>
>     // fill "id" with value "xxId", so all validations should be passed
>     formTesterContinue.setValue("id", "xxId");
>     formTesterContinue.submit();
>
>     // but test failed ! I got "name is required" message because
>     // there is no "name" in request parameter.
>     tester.assertNoErrorMessage();
> }
>
> FormTester can not convert exist values of fields into request parameters.
> Are there changes on MockHttpServletRequest or something recently ?
>
> --
> Ingram Chen
> Java [EMAIL PROTECTED]
> Institue of BioMedical Sciences Academia Sinica Taiwan
> blog: http://www.javaworld.com.tw/roller/page/ingramchen


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmdlnk&kid3432&bid#0486&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



--
Ingram Chen
Java [EMAIL PROTECTED]
Institue of BioMedical Sciences Academia Sinica Taiwan
blog: http://www.javaworld.com.tw/roller/page/ingramchen

Reply via email to