|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.iternine.jeppetto.testsupport.FileSystemFixtureSupport
public class FileSystemFixtureSupport
This prvoides a convenient way to manage files for unit tests.
It allows for creating a per-test directory structure that can be used for temporary data as well as
load directory/file structures using zip archives.
To use:
Create a FileSystemFixtureSupport. You can either specify a root directory or a name prefix to use
when creating the temporary directory. Your test can create new directories using createDirectory()
or load pre-built zip archives of directory structures into the temporary directory. In your test's
@Before method, you can cleanup the files/directories created during the test through the
teardown() method. You can also delete the temporary directory by calling the
destroy() method from an @AfterClass method. Once this is called, the fixture support
cannot be used.
| Constructor Summary | |
|---|---|
FileSystemFixtureSupport(File rootDir)
Create a FileSystemFixtureSupport that will manage the specified File as its temporary root directory. |
|
FileSystemFixtureSupport(String prefix)
Create a FileSystemFixtureSupport that will create a new temporary directory using the specified name prefix. |
|
| Method Summary | |
|---|---|
File |
createDirectory(String path)
Creates a new directory that is relative to the temporary testing root. |
void |
destroy()
Deletes all of the fixture files as well as the temporary root directory. |
File |
getTestingRoot()
|
void |
loadFileFixtures(List<String> resourcesToLoad)
Loads a directory structure from a zip archive. |
void |
teardown()
Deletes any directories or files that have been created by this class. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileSystemFixtureSupport(String prefix)
prefix - the prefix used when naming the temporary directory this will managepublic FileSystemFixtureSupport(File rootDir)
rootDir - the temporary root directory. This will be created if it does not already exist.| Method Detail |
|---|
public File createDirectory(String path)
path - the relative path of the new directory.
public void loadFileFixtures(List<String> resourcesToLoad)
throws IOException
resourcesToLoad - the names of zip archives in the classpath that should be loaded.
IOException - if we cannot unarchive the files
public void teardown()
throws IOException
IOException - if we are unable to delete the data
public void destroy()
throws IOException
IOException - if deletion failspublic File getTestingRoot()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||