Results 1 to 3 of 3

Thread: @Controller and testing

  1. #1

    Default @Controller and testing

    Hi all,

    I have a small design problem with annotations and testing.
    I am using the @Requestmapping and @Initbinder in my controller object and the name of the function is free then. I have an abstract test case that can test a random controller and tests the output result of it.

    But for testing purpose how can i call the function the onSubmit(@RequestMapping) function from my testcase if the name of the function is not known before?

    Same problem with the @initBinder. It is not even required to use this in the controller. How can i call them and what if it isn't used.

    If the controller extends from SimpleFormController the problem is solved because all function exists with a static name, doesn't matter that the programmer would implements this.

    How to solve this for annotations ?


    Thanks for looking at this

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    A @Controller based controller is a POJO.

    So you simply call the method as you would an anyother java class. There is no default method, also you don't need to use the MockHttp* stuff anymore because it is a pojo.

    So the initBinder and binding isn't needed anymore (which still was the case with Spring 2.0 style controllers).

    So you probably need to rewrite some of your testing code/framework...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Quote Originally Posted by Marten Deinum View Post
    A @Controller based controller is a POJO.

    So you simply call the method as you would an anyother java class. There is no default method, also you don't need to use the MockHttp* stuff anymore because it is a pojo.

    So the initBinder and binding isn't needed anymore (which still was the case with Spring 2.0 style controllers).

    So you probably need to rewrite some of your testing code/framework...
    Ok thanks for the answer. Seems i will indeed need to rewrite some things.

    I suppose that you mean with binding is not needed anymore that its done automaticly but if you want to implement you own way you can do it. Spring is nice.

    Think Petclinic can help me with the rest

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •