Grails
  1. Grails
  2. GRAILS-6712

Integration Testing - controller response does not change when calling second time

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: 1.3.2
    • Fix Version/s: None
    • Component/s: Testing
    • Labels:
      None
    • Environment:
      Windows 7 Pro
    • Testcase included:
      yes

      Description

      I have created an integration test for a controller.
      I wanted to call the controller twice within one test* method however I can see that when called second time, the response [ controller.response ] is appended with new response.
      I have tried creating two instances of the controller but even the second one has the response from first controller appended with new response.
      I think this is a bug as I cannot see any way of clearing the response before calling the controller second time.
      Besides, new instance of the controller should not share the same response imo.

        Activity

        Hide
        James O'Beirne added a comment -

        Yeah, it works fine. I just think the fact that we have to call response.reset() is a kludge and should be amended.

        Show
        James O'Beirne added a comment - Yeah, it works fine. I just think the fact that we have to call response.reset() is a kludge and should be amended.
        Hide
        Burt Beckwith added a comment -

        To be fair, using it twice in a test is a kludge since it's not representative of how it works in a real application.

        Show
        Burt Beckwith added a comment - To be fair, using it twice in a test is a kludge since it's not representative of how it works in a real application.
        Hide
        James O'Beirne added a comment -

        In order to test a REST interface, I have to do both GET}}s and {{POST}}s on the same controller. This, of course, requires hitting two different actions with an HTTP request each. Having two separate {{GroovyTestCase classes for each would be ridiculous. Are you saying that I should be issuing one HTTP request per test class?

        Show
        James O'Beirne added a comment - In order to test a REST interface, I have to do both GET}}s and {{POST}}s on the same controller. This, of course, requires hitting two different actions with an HTTP request each. Having two separate {{GroovyTestCase classes for each would be ridiculous. Are you saying that I should be issuing one HTTP request per test class?
        Hide
        Graeme Rocher added a comment -

        No Burt is saying you have to call response.reset()

        Show
        Graeme Rocher added a comment - No Burt is saying you have to call response.reset()
        Hide
        Olaf Geibig added a comment -

        Calling myController.response.reset() within the integration test method is throwing an exception:

        java.lang.IllegalStateException: Cannot reset buffer - response is already committed

        I'm using grails 1.3.7.

        Show
        Olaf Geibig added a comment - Calling myController.response.reset() within the integration test method is throwing an exception: java.lang.IllegalStateException: Cannot reset buffer - response is already committed I'm using grails 1.3.7.

          People

          • Assignee:
            Unassigned
            Reporter:
            Krystian Szczesny
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development