public interface DirectoryFixture
Modifier and Type | Method and Description |
---|---|
Path |
copyFromClasspath(String resourcePath)
Copies a file from classpath using the contextClass to load the resource.
|
Path |
copyFromClasspath(String resourcePath,
Class<?> contextClass)
Copies a file from classpath using the contextClass to load the resource.
|
Path |
copyFromClasspath(String resourcePath,
String targetName)
Copies a file from classpath using the contextClass to load the resource.
|
Path |
copyFromClasspath(String resourcePath,
String targetName,
Class<?> contextClass)
Copies a file from classpath using the contextClass to load the resource.
|
Path |
dir(String dir)
Creates a directory, creates the ancestors as necessary.
|
Path |
dir(String dir,
Closure<?> dirSpec)
Creates a directory, creates the ancestors as necessary.
|
Path |
file(String file)
Creates a file object relative to the enclosing fixture or directory,
but not the physical File, it will eagerly create parent directories if necessary.
|
Path dir(String dir) throws IOException
dir
- path to the directory, can either be a single level or multilevelIOException
- if the directories could not be created.Path dir(String dir, @DelegatesTo(value=DirectoryFixture.class,strategy=1) Closure<?> dirSpec) throws IOException
dirSpec
closure, that can create files and directories in the scope of this one.
Example:
dir('src') {
dir('main') {
dir('groovy') {
file('HelloWorld.java') << 'println "Hello World"'
}
}
dir('test/resources') {
file('META-INF/MANIFEST.MF') << 'bogus entry'
}
}
dir
- path to the directory, can either be a single level or multileveldirSpec
- a closure within the scope of this directory.IOException
- if the directories could not be created.Path file(String file) throws IOException
file
- the (path and) filenamePath
object pointing to the fileIOException
- if the parent directories could not be created.Path copyFromClasspath(String resourcePath) throws IOException
This will use the Closure.getOwner()
of the enclosing closure to determine the contextClass.
The target name will be the same as the last path element of the resourcePath
.
resourcePath
- the path to the resource to loadPath
pointing to the copied fileIOException
- if the parent directories could not be created or the resource could not be foundPath copyFromClasspath(String resourcePath, String targetName) throws IOException
This will use the Closure.getOwner()
of the enclosing closure to determine the contextClass.
resourcePath
- the path to the resource to loadtargetName
- the name of the target to usePath
pointing to the copied fileIOException
- if the parent directories could not be created or the resource could not be foundPath copyFromClasspath(String resourcePath, Class<?> contextClass) throws IOException
The target name will be the same as the last path element of the resourcePath
.
resourcePath
- the path to the resource to loadcontextClass
- the class to use to load the resourcePath
pointing to the copied fileIOException
- if the parent directories could not be created or the resource could not be foundPath copyFromClasspath(String resourcePath, String targetName, Class<?> contextClass) throws IOException
resourcePath
- the path to the resource to loadtargetName
- the name of the target to usecontextClass
- the class to use to load the resourcePath
pointing to the copied fileIOException
- if the parent directories could not be created or the resource could not be found