Just of the top of my head I have two surgestions. One is to Do the
full association of the validator to a field which is then associated
with a form and then, using the FormTester, submit the form and check
the messages.
A more easy sollution is to, in your test, subclass your validator and
override error() in that and check if that is invoked correctly.

Frank

On 10/17/06, Erik van Oosten <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I wrote a custom validator for Dutch burger service numbers. However,
> whatever I try, I can't seem to be able to write a JUnit test for the
> onValidate method. An abstract of the code is included below.
>
> I tried using EasyMock to mock the form component. However this is not
> possible because the error method I am calling from my validator is final.
>
> Any suggestions on how to test this thing?
>
> Regards,
>      Erik.
>
>
> ------------------------8<-------------------------------
> public class SofiNummerValidator extends NumberValidator {
>     public void onValidate(FormComponent formComponent, Number value) {
>         if (value.longValue() < 10000000L) {
>             error(formComponent, "SofiNummerValidator.TooSmall",
> messageModel(formComponent));
>         }
>         int sum = ..some number magic..;
>         if (sum != 0) {
>             error(formComponent, "SofiNummerValidator.NotValid",
> messageModel(formComponent));
>         }
>     }
> }
>
> ------------------------8<-------------------------------
>
> --
> Erik van Oosten
> http://www.day-to-day-stuff.blogspot.com/
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to