Package io.debezium.util
Interface Testing.Files
- Enclosing interface:
- Testing
public static interface Testing.Files
File system utility methods.
-
Field Summary
Fields -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic FilecreateTestingDirectory(String relativePath) Create a directory within the test data directory at the given relative path.static FilecreateTestingDirectory(String relativePath, boolean removeExistingContent) Create a directory within the test data directory at the given relative path.static FileCreate a randomly-named file within the test data directory.static FilecreateTestingFile(String relativePath) Create a file within the test data directory at the given relative path.static FilecreateTestingFile(Path relativePath) Create a file within the test data directory at the given relative path.static PathcreateTestingPath(String relativePath) Create the path to a file within the test data directory at the given relative path.static StringdataDir()Returns the name of the directory where tests are storing their data.static voidA method that will delete a file or folder only if it is within the 'target' directory (for safety).static voidA method that will delete a file or folder only if it is within the 'target' directory (for safety).static voidA method that will delete a file or folder only if it is within the 'target' directory (for safety).static Stringstatic booleaninTestDataDir(File file) Verify that the supplied file or directory is within the test data directory.static booleaninTestDataDir(Path path) Verify that the supplied file or directory is within the test data directory.static InputStreamreadResourceAsStream(String pathOnClasspath) Obtain an InputStream to a named resource on the classpath used to load thisTestingclass.static InputStreamreadResourceAsStream(String pathOnClasspath, Class<?> testClass) Obtain an InputStream to a named resource on the given classpath.static StringreadResourceAsString(String pathOnClasspath) Read a classpath resource into a string.
-
Field Details
-
DBZ_TEST_DATA_DIR_ENV_VAR_NAME
- See Also:
-
DBZ_TEST_DATA_DIR_SYSTEM_PROPERTY_KEY
- See Also:
-
DATA_DIR
-
-
Method Details
-
determineTestDataDir
-
readResourceAsStream
Obtain an InputStream to a named resource on the given classpath.- Parameters:
pathOnClasspath- the path of the resource on the classpathtestClass- the test class, used for accessing the class loader- Returns:
- the string representation
-
readResourceAsStream
Obtain an InputStream to a named resource on the classpath used to load thisTestingclass.- Parameters:
pathOnClasspath- the path of the resource on the classpath- Returns:
- the string representation
-
readResourceAsString
Read a classpath resource into a string.- Parameters:
pathOnClasspath- the path of the resource on the classpath- Returns:
- the string representation
-
createTestingDirectory
Create a directory within the test data directory at the given relative path.- Parameters:
relativePath- the path of the directory within the test data directory; may not be null- Returns:
- the reference to the existing readable and writable directory
-
dataDir
Returns the name of the directory where tests are storing their data. Default value is'target/data'. This value can be overridden by value of theDBZ_TEST_DATA_DIRsystem or environment variable. -
createTestingFile
Create a randomly-named file within the test data directory.- Returns:
- the reference to the existing readable and writable file
-
createTestingFile
Create a file within the test data directory at the given relative path.- Parameters:
relativePath- the path of the file within the test data directory; may not be null- Returns:
- the reference to the existing readable and writable file
-
createTestingFile
Create a file within the test data directory at the given relative path.- Parameters:
relativePath- the path of the file within the test data directory; may not be null- Returns:
- the reference to the existing readable and writable file
-
createTestingPath
Create the path to a file within the test data directory at the given relative path.- Parameters:
relativePath- the path of the file within the test data directory; may not be null- Returns:
- the reference to the existing readable and writable file
-
createTestingDirectory
static File createTestingDirectory(String relativePath, boolean removeExistingContent) throws IOException Create a directory within the test data directory at the given relative path.- Parameters:
relativePath- the path of the directory within the test data directory; may not be nullremoveExistingContent- true if any existing content should be removed- Returns:
- the reference to the existing readable and writable directory
- Throws:
IOException- if there is a problem deleting the files at this path
-
delete
A method that will delete a file or folder only if it is within the 'target' directory (for safety). Folders are removed recursively.- Parameters:
path- the path to the file or folder in the target directory
-
delete
A method that will delete a file or folder only if it is within the 'target' directory (for safety). Folders are removed recursively.- Parameters:
fileOrFolder- the file or folder in the target directory
-
delete
A method that will delete a file or folder only if it is within the 'target' directory (for safety). Folders are removed recursively.- Parameters:
path- the path to the file or folder in the target directory
-
inTestDataDir
Verify that the supplied file or directory is within the test data directory.- Parameters:
file- the file or directory; may not be null- Returns:
- true if inside the test data directory, or false otherwise
-
inTestDataDir
Verify that the supplied file or directory is within the test data directory.- Parameters:
path- the path to the file or directory; may not be null- Returns:
- true if inside the test data directory, or false otherwise
-