public class TestSupport extends Object
Modifier and Type | Field and Description |
---|---|
static String |
TEST_DATA_RELATIVE_DIR |
Modifier | Constructor and Description |
---|---|
protected |
TestSupport() |
Modifier and Type | Method and Description |
---|---|
static String |
cleanPathSegment(String toClean)
Removes characters that aren't acceptable in a file path (mostly for windows).
|
static File |
generateTempFile(Class<?> clazz,
String fileName,
String fileNameSuffix)
Creates a
File reference in the path returned from makeTestDataPath(java.lang.Class<?>, java.lang.String...) in a subdirectory
called temp . |
static File |
generateTempFileFromResource(Class<?> graphClass,
Class<?> resourceClass,
String resourceName,
String extension)
Copies a file stored as part of a resource to the file system in the path returned from
makeTestDataPath(java.lang.Class<?>, java.lang.String...) in a subdirectory called temp/resources . |
static File |
generateTempFileFromResource(Class<?> graphClass,
Class<?> resourceClass,
String resourceName,
String extension,
boolean overwrite)
Copies a file stored as part of a resource to the file system in the path returned from
makeTestDataPath(java.lang.Class<?>, java.lang.String...) in a subdirectory called temp/resources . |
static File |
generateTempFileFromResource(Class<?> resourceClass,
String resourceName,
String extension)
Copies a file stored as part of a resource to the file system in the path returned from
makeTestDataPath(java.lang.Class<?>, java.lang.String...) in a subdirectory called temp/resources . |
static File |
getRootOfBuildDirectory(Class<?> clazz)
Gets and/or creates the root of the test data directory.
|
static String |
makeTestDataDirectory(Class<?> clazz,
String... childPath)
Creates a
File reference that . |
static String |
makeTestDataFile(Class<?> clazz,
String fileName) |
static String |
makeTestDataFile(Class<?> clazz,
String subdir,
String fileName) |
static File |
makeTestDataPath(Class<?> clazz,
String... childPath)
Creates a
File reference that points to a directory relative to the supplied class in the
/target directory. |
public static final String TEST_DATA_RELATIVE_DIR
public static File makeTestDataPath(Class<?> clazz, String... childPath)
File
reference that points to a directory relative to the supplied class in the
/target
directory. Each childPath
passed introduces a new sub-directory and all are placed
below the TEST_DATA_RELATIVE_DIR
. For example, calling this method with "a", "b", and "c" as the
childPath
arguments would yield a relative directory like: test-case-data/clazz/a/b/c
. It is
a good idea to use the test class for the clazz
argument so that it's easy to find the data if
necessary after test execution.
Avoid using makeTestDataPath(...).getAbsolutePath() and makeTestDataPath(...).toString() that produces
platform-dependent paths, that are incompatible with regular expressions and escape characters.
Instead use Storage.toPath(File)
public static String makeTestDataDirectory(Class<?> clazz, String... childPath)
File
reference that . For example, calling this method with "a", "b", and "c" as the
childPath
arguments would yield a relative directory like: test-case-data/clazz/a/b/c
. It is
a good idea to use the test class for the clazz
argument so that it's easy to find the data if
necessary after test execution.Storage
. The directory is relative to the
supplied class in the /target
directory. Each childPath
passed introduces a new sub-directory
and all are placed below the TEST_DATA_RELATIVE_DIR
public static String makeTestDataFile(Class<?> clazz, String fileName)
clazz
- fileName
- Storage
. The file is relative to the
supplied class in the /target
directory.public static String makeTestDataFile(Class<?> clazz, String subdir, String fileName)
clazz
- subdir
- fileName
- Storage
. The file is relative to the
supplied class in the /target
directory.public static File getRootOfBuildDirectory(Class<?> clazz)
makeTestDataPath(Class, String...)
instead.public static File generateTempFile(Class<?> clazz, String fileName, String fileNameSuffix) throws IOException
File
reference in the path returned from makeTestDataPath(java.lang.Class<?>, java.lang.String...)
in a subdirectory
called temp
.IOException
public static File generateTempFileFromResource(Class<?> resourceClass, String resourceName, String extension) throws IOException
makeTestDataPath(java.lang.Class<?>, java.lang.String...)
in a subdirectory called temp/resources
.IOException
public static File generateTempFileFromResource(Class<?> graphClass, Class<?> resourceClass, String resourceName, String extension) throws IOException
makeTestDataPath(java.lang.Class<?>, java.lang.String...)
in a subdirectory called temp/resources
.IOException
public static File generateTempFileFromResource(Class<?> graphClass, Class<?> resourceClass, String resourceName, String extension, boolean overwrite) throws IOException
makeTestDataPath(java.lang.Class<?>, java.lang.String...)
in a subdirectory called temp/resources
.IOException
Copyright © 2013–2021 Apache Software Foundation. All rights reserved.