Looking at #28684, it became apparent that Closeable wasn't really an option but that we could make writeGeneratedContent more prominent and let it throws an IOException. This had a knock-off effect on the tests which was easily handled using our internal TestGenerationContext.
This impacts obviously tests outside of the Spring Framework so a public variant of it is needed.
Comment From: sbrannen
Reopening to move TestGenerationContext from spring-test to spring-core-test.
Comment From: snicoll
Fixed by 58b0251af14f177a1acc which also removes the test fixtures copy!