org.opengis.test
Class Assert

Show UML class diagram
Object
  extended by Assert
      extended by Assert

public class Assert
extends Assert

Assertion methods to be used by GeoAPI tests. This class inherits all assertion methods from the JUnit Assert class. Consequently, developers can replace the following statement:

import static org.junit.Assert.*
by
import static org.opengis.test.Assert.*
if they wish to use the assertion methods defined here in addition of JUnit methods.

Since:
2.2

Constructor Summary
protected Assert()
          For subclass constructors only.
 
Method Summary
static void assertAxisDirectionsEqual(String message, CoordinateSystem cs, AxisDirection... expected)
          Asserts that all axes in the given coordinate system are pointing toward the given directions, in the same order.
static
<T> void
assertBetween(String message, Comparable<T> minimum, Comparable<T> maximum, T value)
          Asserts that the given value is between the given range.
static void assertBetween(String message, double minimum, double maximum, double value)
          Asserts that the given value is between the given range.
static void assertBetween(String message, int minimum, int maximum, int value)
          Asserts that the given value is between the given range.
static void assertContains(String message, Collection<?> collection, Object value)
          Asserts that the given value is contained in the given collection.
static void assertIdentifierEquals(String message, CharSequence expected, CharSequence value)
          Asserts that the identifiers in the given character sequences are equal, ignoring non-identifier characters.
static void assertInstanceOf(String message, Class<?> expectedType, Object value)
          Asserts that the given value is an instance of the given class.
static void assertPathEquals(String message, PathIterator expected, PathIterator actual, double toleranceX, double toleranceY)
          Asserts that all control points in two geometric paths are equal.
static void assertPositive(String message, int value)
          Asserts that the given integer value is positive, including zero.
static void assertSampleValuesEqual(String message, RenderedImage expected, RenderedImage actual, double tolerance)
          Asserts that all sample values in the given images are equal.
static void assertShapeEquals(String message, Shape expected, Shape actual, double toleranceX, double toleranceY)
          Asserts that all control points of two shapes are equal.
static void assertStrictlyPositive(String message, int value)
          Asserts that the given integer value is strictly positive, excluding zero.
static
<T> void
assertValidRange(String message, Comparable<T> minimum, Comparable<T> maximum)
          Asserts that the given minimum and maximum values make a valid range.
static void assertValidRange(String message, double minimum, double maximum)
          Asserts that the given minimum and maximum values make a valid range.
static void assertValidRange(String message, int minimum, int maximum)
          Asserts that the given minimum and maximum values make a valid range.
 
Methods inherited from class Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Assert

protected Assert()
For subclass constructors only.

Method Detail

assertInstanceOf

public static void assertInstanceOf(String message,
                                    Class<?> expectedType,
                                    Object value)
Asserts that the given value is an instance of the given class. No tests are performed if the type is null. If the type is not-null but the value is null, this is considered as a failure.

Parameters:
message - Header of the exception message in case of failure, or null if none.
expectedType - The expected parent class of the value, or null.
value - The value to test, or null (which is a failure).

assertPositive

public static void assertPositive(String message,
                                  int value)
Asserts that the given integer value is positive, including zero.

Parameters:
message - Header of the exception message in case of failure, or null if none.
value - The value to test.

assertStrictlyPositive

public static void assertStrictlyPositive(String message,
                                          int value)
Asserts that the given integer value is strictly positive, excluding zero.

Parameters:
message - Header of the exception message in case of failure, or null if none.
value - The value to test.

assertValidRange

public static <T> void assertValidRange(String message,
                                        Comparable<T> minimum,
                                        Comparable<T> maximum)
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:
message - Header of the exception message in case of failure, or null if none.
minimum - The lower bound of the range to test, or null if unbounded.
maximum - The upper bound of the range to test, or null if unbounded.

assertValidRange

public static void assertValidRange(String message,
                                    int minimum,
                                    int maximum)
Asserts that the given minimum and maximum values make a valid range. More specifically asserts that the minimum value is not greater than the maximum value.

Parameters:
message - Header of the exception message in case of failure, or null if none.
minimum - The lower bound of the range to test.
maximum - The upper bound of the range to test.

assertValidRange

public static void assertValidRange(String message,
                                    double minimum,
                                    double maximum)
Asserts that the given minimum and maximum values make a valid range. More specifically asserts that the minimum value is not greater than the maximum value. If one bound is or both bounds are NaN, then the test fails.

Parameters:
message - Header of the exception message in case of failure, or null if none.
minimum - The lower bound of the range to test.
maximum - The upper bound of the range to test.

assertBetween

public static <T> void assertBetween(String message,
                                     Comparable<T> minimum,
                                     Comparable<T> maximum,
                                     T value)
Asserts that the given value is between the given range. This method do not tests the validity of the given range.

Type Parameters:
T - The type of values being compared.
Parameters:
message - Header of the exception message in case of failure, or null if none.
minimum - The lower bound of the range (inclusive), or null if unbounded.
maximum - The upper bound of the range (inclusive), or null if unbounded.
value - The value to test, or null (which is a failure).

assertBetween

public static void assertBetween(String message,
                                 int minimum,
                                 int maximum,
                                 int value)
Asserts that the given value is between the given range. This method do not tests the validity of the given range.

Parameters:
message - Header of the exception message in case of failure, or null if none.
minimum - The lower bound of the range, inclusive.
maximum - The upper bound of the range, inclusive.
value - The value to test.

assertBetween

public static void assertBetween(String message,
                                 double minimum,
                                 double maximum,
                                 double value)
Asserts that the given value is between the given range. If the value is NaN, then this test passes silently. This method do not tests the validity of the given range.

Parameters:
message - Header of the exception message in case of failure, or null if none.
minimum - The lower bound of the range, inclusive.
maximum - The upper bound of the range, inclusive.
value - The value to test.

assertContains

public static void assertContains(String message,
                                  Collection<?> collection,
                                  Object value)
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:
message - Header of the exception message in case of failure, or null if none.
collection - The collection where to look for inclusion, or null.
value - The value to test for inclusion.

assertIdentifierEquals

public static void assertIdentifierEquals(String message,
                                          CharSequence expected,
                                          CharSequence value)
Asserts that the identifiers in the given character sequences are equal, ignoring non-identifier characters. First, this method locates the Unicode identifier start in each sequences, ignoring every characters before them. Then, starting from the identifier starts, this method compares only the Unicode identifier parts in a case-insensitive way until the end of character sequences.

Parameters:
message - Header of the exception message in case of failure, or null if none.
expected - The expected character sequence.
value - The character sequence to compare.

assertAxisDirectionsEqual

public static void assertAxisDirectionsEqual(String message,
                                             CoordinateSystem cs,
                                             AxisDirection... expected)
Asserts that all axes in the given coordinate system are pointing toward the given directions, in the same order.

Parameters:
message - Header of the exception message in case of failure, or null if none.
cs - The coordinate system to test.
expected - The expected axis directions.
Since:
3.1

assertShapeEquals

public static void assertShapeEquals(String message,
                                     Shape expected,
                                     Shape actual,
                                     double toleranceX,
                                     double toleranceY)
Asserts that all control points of two shapes are equal. This method performs the following checks:
  1. Ensures that the shape bounds are equal, up to the given tolerance thresholds.
  2. Gets the path iterator of each shape.
  3. Ensures that the winding rules are equal.
  4. Iterates over all path segments until the iteration is done. For each iteration step:
    1. Invokes PathIterator.currentSegment(double[]).
    2. Ensures that the segment type (one of the SEG_* constants) is the same.
    3. Ensures that the ordinate values are equal, up to the given tolerance thresholds.

Parameters:
message - Header of the exception message in case of failure, or null if none.
expected - The expected shape.
actual - The actual shape.
toleranceX - The tolerance threshold for x ordinate values.
toleranceY - The tolerance threshold for y ordinate values.
Since:
3.1

assertPathEquals

public static void assertPathEquals(String message,
                                    PathIterator expected,
                                    PathIterator actual,
                                    double toleranceX,
                                    double toleranceY)
Asserts that all control points in two geometric paths are equal. This method performs the following checks:
  1. Ensures that the winding rules are equal.
  2. Iterates over all path segments until the iteration is done. For each iteration step:
    1. Invokes PathIterator.currentSegment(double[]).
    2. Ensures that the segment type (one of the SEG_* constants) is the same.
    3. Ensures that the ordinate values are equal, up to the given tolerance thresholds.
This method can be used instead of assertShapeEquals(String, Shape, Shape, double, double) 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 the Shape.getPathIterator(AffineTransform, double) method himself.

Parameters:
message - Header of the exception message in case of failure, or null if none.
expected - The expected path.
actual - The actual path.
toleranceX - The tolerance threshold for x ordinate values.
toleranceY - The tolerance threshold for y ordinate values.
Since:
3.1

assertSampleValuesEqual

public static void assertSampleValuesEqual(String message,
                                           RenderedImage expected,
                                           RenderedImage actual,
                                           double tolerance)
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 tiling, color model or datatype to be equal.

Parameters:
message - Header of the exception message in case of failure, or null if none.
expected - An image containing the expected values.
actual - The actual image containing the sample values to compare.
tolerance - Tolerance threshold for floating point comparisons. This threshold is ignored if both images use integer datatype.
Since:
3.1
See Also:
PixelIterator.assertSampleValuesEqual(PixelIterator, double)


Copyright © 1994-2013 Open Geospatial Consortium. All Rights Reserved.