Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2398

No way to access raw ByteArrayOutputStream in TestableResponse

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Incomplete
    • 5.3.7
    • None
    • tapestry-test

    Description

      Request: Give access to the underlying ByteArrayOutputStream object in TestableResponse.

      I have a few pages that return raw protocolbuffer. I contribute a ComponentEventResultProcessor which simply takes the response.getOutput() and writes the data to it.

      So here is the real issue. When i run my test via PageTester, the only way to get the outputstream data is by calling TestableResponse.getOutput() which returns a string. This string is malformed. What i really want is to be able to access the TestableResponse.output field and then call toByteArray() which i can then feed into my parse method of the protocol buffer object.

      Example:

        1. This doesn't work
          TestableResponse res = tester.renderResponse("api/quote");
          Message.Response messageResponse = Message.Response.parseFrom(res.getOutput().getBytes());
        1. This would work if i had access to the underlying ByteArrayOutputStream
          TestableResponse res = tester.renderResponse("api/quote");
          Message.Response messageResponse = Message.Response.parseFrom(res.getOutputStream().toByteArray());

      protocolbuffer is tricky. I didn't hit this problem until a value got encoded that didn't decode properly via the "toString()" with the first example.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sarhanm Mohammad Sarhan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: