public final class TestHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
TEST_DATA_RELATIVE_DIR |
Modifier and Type | Method and Description |
---|---|
static void |
assumeNonDeterministic()
Used at the start of a test to make it one that should only be executed when the
assertNonDeterministic
system property is set to true . |
static String |
cleanPathSegment(String toClean)
Removes characters that aren't acceptable in a file path (mostly for windows).
|
static String |
convertPackageToResourcePath(Class clazz)
Takes a class and converts its package name to a path that can be used to access a resource in that package.
|
static String |
convertToRelative(Class clazz,
File f) |
static void |
createRandomGraph(Graph graph,
int numberOfVertices,
int maxNumberOfEdgesPerVertex) |
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 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)
Internally calls
makeTestDataPath(Class, String...) but returns the path as a string with the system
separator appended to the end. |
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. |
static void |
validateEdgeEquality(Edge originalEdge,
Edge otherEdge) |
static void |
validateEquality(Object original,
Object other) |
static void |
validatePropertyEquality(Property originalProperty,
Property otherProperty) |
static void |
validateVertexEquality(Vertex originalVertex,
Vertex otherVertex,
boolean testEdges) |
static void |
validateVertexPropertyEquality(VertexProperty originalVertexProperty,
VertexProperty otherVertexProperty) |
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.public static String makeTestDataDirectory(Class clazz, String... childPath)
makeTestDataPath(Class, String...)
but returns the path as a string with the system
separator appended to the end.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 String convertPackageToResourcePath(Class clazz)
public static String cleanPathSegment(String toClean)
public static void assumeNonDeterministic()
assertNonDeterministic
system property is set to true
. Tests that call this method are ones that may sometimes fail in certain
environments or behave in other random ways. Usually such tests should be removed or re-worked, but there are
situations where that may not be possible as there is no other good way to test the feature. In these cases, the
tests won't fail a standard build. For this benefit, the downside is that the feature isn't tested as often as
it would otherwise, since the assertNonDeterministic
option is not used often and definitely not in
automated builds like Travis.public static void validateVertexEquality(Vertex originalVertex, Vertex otherVertex, boolean testEdges)
public static void validateVertexPropertyEquality(VertexProperty originalVertexProperty, VertexProperty otherVertexProperty)
public static void validatePropertyEquality(Property originalProperty, Property otherProperty)
public static void createRandomGraph(Graph graph, int numberOfVertices, int maxNumberOfEdgesPerVertex)
Copyright © 2013–2017 Apache Software Foundation. All rights reserved.