Results 1 to 2 of 2

Thread: Controller's onSubmit method unit testing with EasyMock

  1. #1
    Join Date
    Mar 2008
    Location
    India
    Posts
    12

    Red face Controller's onSubmit method unit testing with EasyMock

    Hi spring guys,
    I want to write unit test case for my spring project.
    can anybody tell me how to write unit test for onSubmit() method of controller that is returning a list of objects for success view using EasyMock?

    Please help me .

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

    Default

    You can only call the handleRequest method on a Controller.

    So you basically need to

    1) Create a HttpServletRequest and HttpServletResponse (available in spring-test.jar)
    2) setup the properties and correct method (POST or GET)
    3) Mock the services/dao for you controller
    4) setup your controller
    5) call the method
    6) interpret the returned ModelAndView
    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

Posting Permissions

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