Introduce TestGenerationContext
This commit polishes DefaultGenerationContext to make the method that flushes generated classes more explicit. It now throws an IOException and TestGenerationContext has been updated to handle that to ease its use in code that can't throw such an exception. As this use case is likely to happen outside the Spring Framework, this commit adds such a convenience to spring-test as well. Closes gh-28877
This commit is contained in:
@@ -27,6 +27,10 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* Default {@link GenerationContext} implementation.
|
||||
*
|
||||
* <p>Generated classes are flushed out using {@link #writeGeneratedContent()}
|
||||
* and should be called once the generation process using this instance has
|
||||
* completed.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
* @since 6.0
|
||||
@@ -104,13 +108,8 @@ public class DefaultGenerationContext implements GenerationContext {
|
||||
/**
|
||||
* Write any generated content out to the generated files.
|
||||
*/
|
||||
public void writeGeneratedContent() {
|
||||
try {
|
||||
this.generatedClasses.writeTo(this.generatedFiles);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
public void writeGeneratedContent() throws IOException {
|
||||
this.generatedClasses.writeTo(this.generatedFiles);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user