bito-code-review[bot] commented on PR #16490:
URL: https://github.com/apache/grails-core/pull/16490#issuecomment-5972276532

   <!-- Bito Reply -->
   The current test suite for `GrailsMockHttpServletResponse` verifies that 
`reset()` correctly clears the `webRequest` output, allowing for subsequent 
selection of either a writer or an output stream. To address the concern 
regarding character encoding, you can add a test case that sets the character 
encoding to UTF-8 after `reset()` and verifies that non-ASCII text is correctly 
handled.
   
   Here is an example of how you could implement this test:
   
   ```groovy
       @Test
       void testResetAllowsUtf8OutputAfterReset() {
           withBoundWebRequest { response, webRequest ->
               response.reset()
               response.characterEncoding = 'UTF-8'
               String text = '€'
               webRequest.out.write(text)
               webRequest.out.flush()
   
               assertArrayEquals text.getBytes('UTF-8'), 
response.contentAsByteArray
           }
       }
   ```
   
   This test ensures that the lazily opened writer respects the character 
encoding set after the `reset()` call.
   
   
**grails-test-suite-uber/src/test/groovy/org/grails/plugins/testing/GrailsMockHttpServletResponseTests.groovy**
   ```
   @Test
       void testResetAllowsUtf8OutputAfterReset() {
           withBoundWebRequest { response, webRequest ->
               response.reset()
               response.characterEncoding = 'UTF-8'
               String text = '€'
               webRequest.out.write(text)
               webRequest.out.flush()
   
               assertArrayEquals text.getBytes('UTF-8'), 
response.contentAsByteArray
           }
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to