public class WorkFolder
extends org.junit.rules.TemporaryFolder
TemporaryFolder that has better support for initial content preparation.
Initialization examples:
@Rule public WorkFolder work1 = WorkFolder.basic();
@Rule public WorkFolder work2 = WorkFolder.subfolderOf(new File("/tmp/junit");
@Rule public WorkFolder work3 = WorkFolder.basic().withResourceSearchBase(SomeClass.class);
Usage examples:
File res = work1.newResourceCopy("testResource");
File resWithPath = work1.newResourceCopy("target/dir/copy.bin", "testResource.bin");
| Modifier | Constructor and Description |
|---|---|
protected |
WorkFolder() |
protected |
WorkFolder(java.io.File parentFolder) |
| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
static WorkFolder |
basic()
Creates a new instance of
WorkFolder. |
java.io.File |
newFile(java.lang.String targetPath,
java.io.InputStream initialContents) |
java.io.File |
newResourceCopy(java.lang.String resourceName) |
java.io.File |
newResourceCopy(java.lang.String targetPath,
java.lang.String resourceName) |
static WorkFolder |
subfolderOf(java.io.File parentFolder) |
static WorkFolder |
subfolderOf(java.lang.String parentFolderPath) |
WorkFolder |
withResourceSearchBase(java.lang.Class<?> searchBase) |
protected WorkFolder()
protected WorkFolder(java.io.File parentFolder)
public static WorkFolder basic()
WorkFolder.public static WorkFolder subfolderOf(java.io.File parentFolder)
public static WorkFolder subfolderOf(java.lang.String parentFolderPath)
public WorkFolder withResourceSearchBase(java.lang.Class<?> searchBase)
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
apply in interface org.junit.rules.TestRuleapply in class org.junit.rules.ExternalResourcepublic java.io.File newFile(java.lang.String targetPath,
java.io.InputStream initialContents)
throws java.io.IOException
java.io.IOExceptionpublic java.io.File newResourceCopy(java.lang.String targetPath,
java.lang.String resourceName)
throws java.io.IOException
java.io.IOExceptionpublic java.io.File newResourceCopy(java.lang.String resourceName)
throws java.io.IOException
java.io.IOException