public class WorkFolder extends org.junit.rules.TemporaryFolder implements WorkFolderInterface
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 |
|---|---|
java.lang.String |
absolutePath() |
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
java.io.File |
asFile() |
static WorkFolder |
basic()
Creates a new instance of
WorkFolder. |
void |
clean() |
java.lang.ClassLoader |
getClassLoaderForResources() |
java.lang.ClassLoader |
getClassLoaderForResources(java.lang.ClassLoader parentClassLoader) |
WorkFolderInterface |
getRootFolder() |
void |
installContextClassLoaderForResources(java.lang.ClassLoader parentClassLoader) |
java.io.File |
newFile() |
java.io.File |
newFile(java.lang.String targetPath,
java.lang.CharSequence initialContents) |
java.io.File |
newFile(java.lang.String targetPath,
InitialContentsProvider contentsProvider) |
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) |
java.lang.String |
relativePath() |
WorkFolderInterface |
subfolder(java.lang.String... pathComponents) |
static WorkFolder |
subfolderOf(java.io.File parentFolder) |
static WorkFolder |
subfolderOf(java.lang.String parentFolderPath) |
WorkFolder |
withResourceSearchBase(java.lang.Class<?> searchBase) |
after, before, create, delete, getRoot, newFile, newFolder, newFolder, newFolderclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnewFileprotected 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 asFile()
asFile in interface WorkFolderInterfacepublic java.lang.String absolutePath()
absolutePath in interface WorkFolderInterfacepublic java.lang.String relativePath()
relativePath in interface WorkFolderInterfacepublic WorkFolderInterface getRootFolder()
getRootFolder in interface WorkFolderInterfacepublic java.io.File newFile()
throws java.io.IOException
newFile in class org.junit.rules.TemporaryFolderjava.io.IOExceptionpublic java.io.File newFile(java.lang.String targetPath,
java.lang.CharSequence initialContents)
throws java.io.IOException
newFile in interface WorkFolderInterfacejava.io.IOExceptionpublic java.io.File newFile(java.lang.String targetPath,
java.io.InputStream initialContents)
throws java.io.IOException
newFile in interface WorkFolderInterfacejava.io.IOExceptionpublic java.io.File newFile(java.lang.String targetPath,
InitialContentsProvider contentsProvider)
throws java.io.IOException
newFile in interface WorkFolderInterfacejava.io.IOExceptionpublic java.io.File newResourceCopy(java.lang.String targetPath,
java.lang.String resourceName)
throws java.io.IOException
newResourceCopy in interface WorkFolderInterfacejava.io.IOExceptionpublic java.io.File newResourceCopy(java.lang.String resourceName)
throws java.io.IOException
newResourceCopy in interface WorkFolderInterfacejava.io.IOExceptionpublic WorkFolderInterface subfolder(java.lang.String... pathComponents) throws java.io.IOException
subfolder in interface WorkFolderInterfacejava.io.IOExceptionpublic void clean()
throws java.io.IOException
clean in interface WorkFolderInterfacejava.io.IOExceptionpublic java.lang.ClassLoader getClassLoaderForResources()
public java.lang.ClassLoader getClassLoaderForResources(java.lang.ClassLoader parentClassLoader)
public void installContextClassLoaderForResources(java.lang.ClassLoader parentClassLoader)