Announcement Announcement Module
Collapse
No announcement yet.
@Controller and testing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @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
    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...

    Comment


    • #3
      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

      Comment

      Working...
      X