[ 
https://issues.apache.org/jira/browse/TAP5-2398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mohammad Sarhan updated TAP5-2398:
----------------------------------
    Summary: No way to access raw ByteArrayOutputStream in TestableResponse  
(was: No way to access raw ByteArrayOutputStream)

> No way to access raw ByteArrayOutputStream in TestableResponse
> --------------------------------------------------------------
>
>                 Key: TAP5-2398
>                 URL: https://issues.apache.org/jira/browse/TAP5-2398
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-test
>    Affects Versions: 5.3.7
>            Reporter: Mohammad Sarhan
>            Priority: Minor
>
> 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:
> ## This doesn't work
> TestableResponse res = tester.renderResponse("api/quote");
> Message.Response messageResponse = 
> Message.Response.parseFrom(res.getOutput().getBytes());
> ## 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to