Class MockOutputTool
java.lang.Object
org.codehaus.groovy.tools.groovydoc.MockOutputTool
- All Implemented Interfaces:
OutputTool
In-memory
OutputTool used by tests. Nothing is written to disk
by default, so test runs leave no filesystem artifacts.
Debugging: pass the groovydoc.mockOutputTool.dumpDir
system property to also mirror every output call to that directory.
Example (from the groovy-groovydoc module):
./gradlew :groovy-groovydoc:test -Dgroovydoc.mockOutputTool.dumpDir=build/mock-dumpWhen the property is unset, all calls are captured only in the in-memory
output and outputAreas maps; inspect them via
getText(String) or via a debugger breakpoint.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyResource(String srcPath, String dstPath) Copy a resource file (doc-files/, snippet-files/ content) fromsrcPathtodstPath.Returns the content written to the given filename bywriteToOutput(java.lang.String, java.lang.String, java.lang.String), ornullif no content has been written.booleanisValidOutputArea(String fileName) ReturnstrueifmakeOutputArea(java.lang.String)was previously called with the given filename.voidmakeOutputArea(String filename) Ensures that the supplied output location exists.toString()voidwriteToOutput(String fileName, String text, String charset) Writes rendered text to the supplied output file.
-
Constructor Details
-
MockOutputTool
public MockOutputTool()
-
-
Method Details
-
makeOutputArea
Ensures that the supplied output location exists.- Specified by:
makeOutputAreain interfaceOutputTool- Parameters:
filename- the output directory or root path to prepare
-
writeToOutput
Writes rendered text to the supplied output file.- Specified by:
writeToOutputin interfaceOutputTool- Parameters:
fileName- the file to writetext- the rendered contentcharset- the character set to use when writing- Throws:
Exception- if the output cannot be written
-
copyResource
Copy a resource file (doc-files/, snippet-files/ content) fromsrcPathtodstPath. Routed through the tool rather than callingFiles.copydirectly so that alternative tools (notablyMockOutputTool) can intercept the side-effect.- Specified by:
copyResourcein interfaceOutputTool- Throws:
IOException
-
isValidOutputArea
ReturnstrueifmakeOutputArea(java.lang.String)was previously called with the given filename. -
getText
Returns the content written to the given filename bywriteToOutput(java.lang.String, java.lang.String, java.lang.String), ornullif no content has been written. -
toString
-