Object
Assertions
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertAnyTitleEquals
(String expected, Citation actual, String message) Asserts that the title or an alternate title of the given citation is equal to the given string.static void
assertAxisDirectionsEqual
(CoordinateSystem cs, AxisDirection... expected) Asserts that all axes in the given coordinate system are pointing toward the given directions, in the same order.static void
assertAxisDirectionsEqual
(CoordinateSystem cs, AxisDirection[] expected, String message) Asserts that all axes in the given coordinate system are pointing toward the given directions, in the same order.static void
assertBetween
(double minimum, double maximum, double value, String message) Asserts that the given value is inside the given range.static void
assertBetween
(int minimum, int maximum, int value, String message) Asserts that the given value is inside the given range.static <T> void
assertBetween
(Comparable<T> minimum, Comparable<T> maximum, T value, String message) Asserts that the given value is inside the given range.static void
assertContains
(Collection<?> collection, Object value, String message) Asserts that the given value is contained in the given collection.static void
assertIdentifierEquals
(String authority, String codeSpace, String version, String code, Identifier actual, String message) Asserts that the given identifier is equal to the given authority, code space, version and code.static void
assertMatrixEquals
(Matrix expected, Matrix actual, double tolerance, String message) Asserts that the given matrix is equal to the expected one, up to the given tolerance value.static void
assertPathEquals
(PathIterator expected, PathIterator actual, double toleranceX, double toleranceY, String message) Asserts that all control points in two geometric paths are equal.static void
assertPositive
(int value, String message) Asserts that the given integer value is positive, including zero.static void
assertSampleValuesEqual
(RenderedImage expected, RenderedImage actual, double tolerance, String message) Asserts that all sample values in the given images are equal.static void
assertShapeEquals
(Shape expected, Shape actual, double toleranceX, double toleranceY, String message) Asserts that all control points of two shapes are equal.static void
assertStrictlyPositive
(int value, String message) Asserts that the given integer value is strictly positive, excluding zero.static void
assertUnicodeIdentifierEquals
(CharSequence expected, CharSequence actual, boolean ignoreCase, String message) Asserts that the character sequences are equal, ignoring any characters that are not valid for Unicode identifiers.static void
assertValidRange
(double minimum, double maximum, String message) Asserts that the given minimum is smaller or equals to the given maximum.static void
assertValidRange
(int minimum, int maximum, String message) Asserts that the given minimum is smaller or equals to the given maximum.static <T> void
assertValidRange
(Comparable<T> minimum, Comparable<T> maximum, String message) Asserts that the given minimum and maximum values make a valid range.
-
Method Details
-
assertPositive
Asserts that the given integer value is positive, including zero.- Parameters:
value
- the value to test.message
- header of the exception message in case of failure, ornull
if none.
-
assertStrictlyPositive
Asserts that the given integer value is strictly positive, excluding zero.- Parameters:
value
- the value to test.message
- header of the exception message in case of failure, ornull
if none.
-
assertValidRange
public static <T> void assertValidRange(Comparable<T> minimum, Comparable<T> maximum, String message) Asserts that the given minimum and maximum values make a valid range. More specifically asserts that if both values are non-null, then the minimum value is not greater than the maximum value.- Type Parameters:
T
- the type of values being compared.- Parameters:
minimum
- the lower bound of the range to test, ornull
if unbounded.maximum
- the upper bound of the range to test, ornull
if unbounded.message
- header of the exception message in case of failure, ornull
if none.
-
assertValidRange
Asserts that the given minimum is smaller or equals to the given maximum.- Parameters:
minimum
- the lower bound of the range to test.maximum
- the upper bound of the range to test.message
- header of the exception message in case of failure, ornull
if none.
-
assertValidRange
Asserts that the given minimum is smaller or equals to the given maximum. If one bound is or both bounds are NaN, then the test fails.- Parameters:
minimum
- the lower bound of the range to test.maximum
- the upper bound of the range to test.message
- header of the exception message in case of failure, ornull
if none.
-
assertBetween
public static <T> void assertBetween(Comparable<T> minimum, Comparable<T> maximum, T value, String message) Asserts that the given value is inside the given range. This method does not test the validity of the given [minimum
…maximum
] range.- Type Parameters:
T
- the type of values being compared.- Parameters:
minimum
- the lower bound of the range (inclusive), ornull
if unbounded.maximum
- the upper bound of the range (inclusive), ornull
if unbounded.value
- the value to test, ornull
(which is a failure).message
- header of the exception message in case of failure, ornull
if none.
-
assertBetween
Asserts that the given value is inside the given range. This method does not test the validity of the given [minimum
…maximum
] range.- Parameters:
minimum
- the lower bound of the range, inclusive.maximum
- the upper bound of the range, inclusive.value
- the value to test.message
- header of the exception message in case of failure, ornull
if none.
-
assertBetween
Asserts that the given value is inside the given range. If the givenvalue
is NaN, then this test passes silently. This method does not test the validity of the given [minimum
…maximum
] range.- Parameters:
minimum
- the lower bound of the range, inclusive.maximum
- the upper bound of the range, inclusive.value
- the value to test.message
- header of the exception message in case of failure, ornull
if none.
-
assertContains
Asserts that the given value is contained in the given collection. If the given collection is null, then this test passes silently (a null collection is considered as "unknown", not empty). If the given value is null, then the test passes only if the given collection contains the null element.- Parameters:
collection
- the collection where to look for inclusion, ornull
if unrestricted.value
- the value to test for inclusion.message
- header of the exception message in case of failure, ornull
if none.
-
assertAnyTitleEquals
Asserts that the title or an alternate title of the given citation is equal to the given string. This method is typically used for testing if a citation stands for the OGC, OGP or EPSG authority for instance. Such abbreviations are often declared as alternate titles rather than the main title, but this method tests both for safety.- Parameters:
expected
- the expected title or alternate title.actual
- the citation to test.message
- header of the exception message in case of failure, ornull
if none.
-
assertIdentifierEquals
public static void assertIdentifierEquals(String authority, String codeSpace, String version, String code, Identifier actual, String message) Asserts that the given identifier is equal to the given authority, code space, version and code. If any of the above-cited properties is""##unrestricted"
, then it will not be verified. This flexibility is useful in the common case where a test accepts anyversion
value.- Parameters:
authority
- the expected authority title or alternate title (may benull
), or"##unrestricted"
.codeSpace
- the expected code space (may benull
), or"##unrestricted"
.version
- the expected version (may benull
), or"##unrestricted"
.code
- the expected code value (may benull
), or"##unrestricted"
.actual
- the identifier to test.message
- header of the exception message in case of failure, ornull
if none.
-
assertUnicodeIdentifierEquals
public static void assertUnicodeIdentifierEquals(CharSequence expected, CharSequence actual, boolean ignoreCase, String message) Asserts that the character sequences are equal, ignoring any characters that are not valid for Unicode identifiers. First, this method locates the Unicode identifier start in each sequences, ignoring any other characters before them. Then, starting from the identifier starts, this method compares only the Unicode identifier parts until the end of character sequences.Examples:
"WGS 84"
and"WGS84"
as equal according this method.- Parameters:
expected
- the expected character sequence (may benull
), or"##unrestricted"
.actual
- the character sequence to compare, ornull
.ignoreCase
-true
for ignoring case.message
- header of the exception message in case of failure, ornull
if none.
-
assertAxisDirectionsEqual
Asserts that all axes in the given coordinate system are pointing toward the given directions, in the same order.- Parameters:
cs
- the coordinate system to test.expected
- the expected axis directions.
-
assertAxisDirectionsEqual
public static void assertAxisDirectionsEqual(CoordinateSystem cs, AxisDirection[] expected, String message) Asserts that all axes in the given coordinate system are pointing toward the given directions, in the same order.- Parameters:
cs
- the coordinate system to test.expected
- the expected axis directions.message
- header of the exception message in case of failure, ornull
if none.
-
assertMatrixEquals
public static void assertMatrixEquals(Matrix expected, Matrix actual, double tolerance, String message) Asserts that the given matrix is equal to the expected one, up to the given tolerance value.- Parameters:
expected
- the expected matrix, which may benull
.actual
- the matrix to compare, ornull
.tolerance
- the tolerance threshold.message
- header of the exception message in case of failure, ornull
if none.- See Also:
-
assertShapeEquals
public static void assertShapeEquals(Shape expected, Shape actual, double toleranceX, double toleranceY, String message) Asserts that all control points of two shapes are equal. This method performs the following checks:- Ensures that the shape bounds are equal, up to the given tolerance thresholds.
- Gets the path iterator of each shape.
- Ensures that the winding rules are equal.
- Iterates over all path segments until the iteration is done.
For each iteration step:
- Invokes
PathIterator.currentSegment(double[])
. - Ensures that the segment type (one of the
SEG_*
constants) is the same. - Ensures that the coordinate values are equal, up to the given tolerance thresholds.
- Invokes
- Parameters:
expected
- the expected shape, which may benull
.actual
- the actual shape, ornull
.toleranceX
- the tolerance threshold for x coordinate values.toleranceY
- the tolerance threshold for y coordinate values.message
- header of the exception message in case of failure, ornull
if none.
-
assertPathEquals
public static void assertPathEquals(PathIterator expected, PathIterator actual, double toleranceX, double toleranceY, String message) Asserts that all control points in two geometric paths are equal. This method performs the following checks:- Ensures that the winding rules are equal.
- Iterates over all path segments until the iteration is done.
For each iteration step:
- Invokes
PathIterator.currentSegment(double[])
. - Ensures that the segment type (one of the
SEG_*
constants) is the same. - Ensures that the coordinate values are equal, up to the given tolerance thresholds.
- Invokes
assertShapeEquals(Shape, Shape, double, double, String)
when the tester needs to compare the shapes with a non-null affine transform or a flatness factor. in such case, the tester needs to invoke theShape.getPathIterator(AffineTransform, double)
method himself.- Parameters:
expected
- the expected path, which may benull
.actual
- the actual path, ornull
.toleranceX
- the tolerance threshold for x coordinate values.toleranceY
- the tolerance threshold for y coordinate values.message
- header of the exception message in case of failure, ornull
if none.
-
assertSampleValuesEqual
public static void assertSampleValuesEqual(RenderedImage expected, RenderedImage actual, double tolerance, String message) Asserts that all sample values in the given images are equal. This method requires the images width, height and the number of bands to be equal, but does not require the minimal x value, minimal y value, tiling, color model or datatype to be equal.- Parameters:
expected
- an image containing the expected values, which may benull
.actual
- the actual image containing the sample values to compare, ornull
.tolerance
- tolerance threshold for floating point comparisons. This threshold is ignored if both images use integer datatype.message
- header of the exception message in case of failure, ornull
if none.- See Also:
-