public class TestLoader extends Object
Modifier and Type | Field and Description |
---|---|
static String |
PATH_RESOURCES
Path to the resources directory, relative to the root of the project.
|
Modifier and Type | Method and Description |
---|---|
void |
copyToDirectory(File destination)
Copies all the data in the test-data folder (recursively), preserving file modification
times.
|
void |
copyToDirectory(String[] subdirectoriesSource,
File directoryDestination)
Copies specific subdirectories from the test-data folder (recursively), preserving file
modification times.
|
TestLoader |
createForSubdirectory(String subdirectory)
Creates a new test-loader for a subdirectory of the current test.
|
static TestLoader |
createFromExplicitDirectory(Path rootDirectory)
Creates a new test-data loader using an explicit file path as root.
|
static TestLoader |
createFromExplicitDirectory(String rootDirectory)
Creates a new test-data loader using an explicit file path as root.
|
static TestLoader |
createFromMavenWorkingDirectory()
Creates a new test-data loader finding
PATH_RESOURCES using the Maven working
directory. |
static TestLoader |
createFromMavenWorkingDirectory(String toAppendToDirectory)
Creates a new test-data loader finding
PATH_RESOURCES/PLUS_SOMETHING using the Maven
working directory. |
boolean |
doesPathExist(String testFilePath)
Does a resource exist with a particular
folderPath + fileName . |
boolean |
doesPathExist(String testDirectoryPath,
String fileName)
Does a resource exist with a particular
folderPath + fileName . |
Path |
getRoot()
Path to where the test-data is stored.
|
static Document |
openXmlAbsoluteFilePath(Path filePath)
Opens a XML document - with an absolute path on the filesystem.
|
static Document |
openXmlAbsoluteFilePath(String filePath)
Opens a XML document - with an absolute path on the filesystem.
|
Document |
openXmlFromTestPath(String testPath)
Opens a XML document - with a path relative to the test root.
|
static Path |
pathMavenWorkingDirectory(String toAppendToDirectory)
Determines the path to a directory inside the Maven Working Directory.
|
void |
printAllFilesFromTestDirectoryPath(String testDirectoryPath)
Prints the names of all files (recursively) in a test-folder to
stdout . |
Path |
resolveTestPath(String testPath)
Resolves a path to test-data (relative path to the test-data root) to an absolute path on the
file system.
|
public static final String PATH_RESOURCES
public static TestLoader createFromMavenWorkingDirectory()
PATH_RESOURCES
using the Maven working
directory.MAVEN_WORKING_DIR/PATH_RESOURCES
public static TestLoader createFromMavenWorkingDirectory(String toAppendToDirectory)
PATH_RESOURCES/PLUS_SOMETHING
using the Maven
working directory.toAppendToDirectory
- appended to Maven working directory to determine final directory.MAVEN_WORKING_DIR/PATH_RESOURCES/PLUS_SOMETHING
public static TestLoader createFromExplicitDirectory(String rootDirectory)
rootDirectory
- the path where the root folder is.public static TestLoader createFromExplicitDirectory(Path rootDirectory)
rootDirectory
- the path where the root folder is.public TestLoader createForSubdirectory(String subdirectory)
subdirectory
- the subdirectory to use (relative path to the current root).public static Path pathMavenWorkingDirectory(String toAppendToDirectory)
It uses the pattern PATH_RESOURCES/PLUS_SOMETHING
inside the Maven working
directory.
toAppendToDirectory
- appended to Maven working directory to determine final directory.public Path resolveTestPath(String testPath)
testPath
- relative-path of a test-data item. It is relative to the test-data root.public boolean doesPathExist(String testFilePath)
folderPath + fileName
.testFilePath
- path to a file in the test-data.public boolean doesPathExist(String testDirectoryPath, String fileName)
folderPath + fileName
.testDirectoryPath
- path to a folder in the test-data (can be empty).fileName
- a filename in the testDirectoryPath
.public void printAllFilesFromTestDirectoryPath(String testDirectoryPath)
stdout
.testDirectoryPath
- path to a folder in the test-data (can be empty).public Document openXmlFromTestPath(String testPath)
testPath
- the path to the XML file (relative to the test root).public static Document openXmlAbsoluteFilePath(String filePath)
filePath
- the path to the XML file (absolute path).public static Document openXmlAbsoluteFilePath(Path filePath)
filePath
- the path to the XML file (absolute path).public void copyToDirectory(File destination) throws IOException
destination
- destination-folder.IOException
- if a copy error occurs.public void copyToDirectory(String[] subdirectoriesSource, File directoryDestination) throws IOException
subdirectoriesSource
- which subdirectories to copy from (their full-path is preserved).directoryDestination
- destination-folder.IOException
- if a copy error occurs.public Path getRoot()
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.