Grails
  1. Grails
  2. GRAILS-7995

How to set JSON Object in request.JSON for Integration testing

    Details

    • Type: Task Task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: 1.3.7
    • Fix Version/s: None
    • Component/s: Testing
    • Environment:
      Windows XP

      Description

      I have to perform Integration test on a Controller, where an action signIn() defines a JSON Object as:

      << def jsonObj = request.JSON; >>

      How do I pass a JSON Object in request.JSON from my controllerTests file?

      I tried the following but it ain't working:

      ...
      JSONObject jsonObj = new JSONObject();
      jsonObj.put("user", createUserJsonObj());
      controller.request.parameters['user'] = jsonObj
      controller.signIn()
      ...

      private JSONObject createUserJsonObj() {
      JSONObject json = new JSONObject();
      json.put("id", "id01");
      json.put("displayName", "Test Display Name..");
      return json;
      }

        Activity

        Hide
        Burt Beckwith added a comment -

        Please ask usage questions on the User mailing list

        Show
        Burt Beckwith added a comment - Please ask usage questions on the User mailing list
        Hide
        Anubhaw Shrivastav added a comment -

        My apologies.
        Doing the same.

        Show
        Anubhaw Shrivastav added a comment - My apologies. Doing the same.

          People

          • Assignee:
            Unassigned
            Reporter:
            Anubhaw Shrivastav
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development