Class Assert

java.lang.Object
org.junit.Assert
org.opengis.test.Assert

public class Assert extends org.junit.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
Version:
3.0
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    For subclass constructors only.
  • Method Summary

    Modifier and Type
    Method
    Description
    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 <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
    assertContains(String message, Collection<?> collection, Object value)
    Asserts that the given value is contained in the given collection.
    static void
    assertInstanceOf(String message, Class<?> expectedType, Object value)
    Asserts that the given value is an instance of the given class.
    static void
    assertPositive(String message, int value)
    Asserts that the given integer value is positive, including zero.
    static void
    assertStrictlyPositive(String message, int value)
    Asserts that the given integer value is strictly positive, excluding zero.
    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.
    static <T> void
    assertValidRange(String message, Comparable<T> minimum, Comparable<T> maximum)
    Asserts that the given minimum and maximum values make a valid range.

    Methods inherited from class org.junit.Assert

    assertArrayEquals, assertArrayEquals, 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, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertThrows, assertThrows, assertTrue, assertTrue, fail, fail

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Assert

      protected Assert()
      For subclass constructors only.
  • Method Details

    • 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 - The message to send in case of failure.
      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 - The message to send in case of failure.
      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 - The message to send in case of failure.
      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 - The message to send in case of failure.
      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 - The message to send in case of failure.
      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 - The message to send in case of failure.
      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 - The message to send in case of failure.
      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 - The message to send in case of failure.
      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 - The message to send in case of failure.
      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 - The message to send in case of failure.
      collection - The collection where to look for inclusion, or null.
      value - The value to test for inclusion.