Enum PathStrategy
- All Implemented Interfaces:
Serializable
,Comparable<PathStrategy>
This is used to define whether to use a totally isolated in-memory file system, or whether to use temporary directories on the default file system.
- Since:
- 0.0.1
- Author:
- Ashley Scopes
-
Enum Constant Summary
Enum ConstantDescriptionUse RAM-based directories for any created directories.Use OS-level temporary directories for any created directories. -
Method Summary
Modifier and TypeMethodDescriptionstatic PathStrategy
Determine the default strategy to fall back onto.newInstance
(String name) Create a new instance of the test directory type with the given name.static PathStrategy
Returns the enum constant of this type with the specified name.static PathStrategy[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
RAM_DIRECTORIES
Use RAM-based directories for any created directories.This is faster as everything remains in-memory. It also prevents the risk of resources not being tidied up correctly if the JVM is suddenly shut down. Test directories are also kept isolated from other tests that may be running in parallel, and isolated from the host operating system.
If any annotation processors rely on being run in the
default file system
rather than usingthe NIO path API
orfilers
directly, then they will not be compatible with reading files from this implementation of test directory. In this situation, users should opt to useTEMP_DIRECTORIES
instead.Some non-Javac compiler implementations (such as ECJ) may also have some difficulties dealing with these paths.
-
TEMP_DIRECTORIES
Use OS-level temporary directories for any created directories.This will write files to the OS temporary directory. These files will be deleted once the owning workspace is closed, but may be missed if the JVM is forcefully terminated or crashes.
There are fewer guarantees of speed and isolation compared to using
RAM_DIRECTORIES
. However, you do gain the ability to set a breakpoint and inspect the contents of the directory in a file explorer.Since the temporary directories are usually created on the
default file system
, they are compatible with any annotation processors or compiler implementations that expect to be run on the default file system only.Some restrictions regarding file naming may be present depending on the platform that is in use, such as file name lengths on Windows. See your system documentation for more details.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
newInstance
Create a new instance of the test directory type with the given name.Note that calling this directly will return an object that you will have to manually manage the lifetime for. Failing to do so will result in resources being leaked.
Users should not call this method by default unless they know what they are doing. As a result of this constraint, this method is not part of the public API and may be subject to change without notice.
- Parameters:
name
- the name to use.- Returns:
- the new test directory.
-
defaultStrategy
Determine the default strategy to fall back onto.This will be
RAM_DIRECTORIES
by default, but this may be subject to change between minor versions without notice, so do not rely on this if you are testing code that may be sensitive to the type of file system being used.- Returns:
- the path strategy to use by default.
-