public abstract class TestBase
extends org.junit.Assert
The TestBase provides simplified assertion methods.
| Modifier and Type | Field and Description |
|---|---|
static osgl.version.Version |
VERSION |
| Constructor and Description |
|---|
TestBase() |
| Modifier and Type | Method and Description |
|---|---|
static void |
eq(double[] expecteds,
double[] actuals,
double delta)
Alias of
Assert.assertArrayEquals(double[], double[], double). |
static void |
eq(double[] expecteds,
double[] actuals,
double delta,
String message,
Object... messageArgs)
Asserts that two double arrays are equal.
|
static void |
eq(double expected,
double actual,
double delta)
Asserts that two doubles or floats are equal to within a positive delta.
|
static void |
eq(double expected,
double actual,
double delta,
String message,
Object... messageArgs)
Asserts that two doubles or floats are equal to within a positive delta.
|
static void |
eq(float[] expecteds,
float[] actuals,
float delta)
Asserts that two float arrays are equal.
|
static void |
eq(float[] expecteds,
float[] actuals,
float delta,
String message,
Object... messageArgs)
Asserts that two float arrays are equal.
|
static void |
eq(Object expected,
Object actual)
Asserts that two objects (including arrays) are equal.
|
static void |
eq(Object expected,
Object actual,
String message,
Object... messageArgs)
Asserts that two objects (including arrays) are equal.
|
static void |
fail(String message,
Object... args)
Fails a test with the given message.
|
static void |
isBlank(String str)
Asserts that a string is blank.
|
static void |
isBlank(String str,
String message,
Object... messageArgs)
Asserts that a string is blank.
|
static void |
isEmpty(Collection<?> col)
Asserts that a collection is empty.
|
static void |
isEmpty(Collection<?> col,
String message,
Object... messageArgs)
Asserts that a collection is empty.
|
static void |
isEmpty(Map<?,?> map)
Asserts that a Map is empty.
|
static void |
isEmpty(Map<?,?> map,
String message,
Object... messageArgs)
Asserts that a map is empty.
|
static void |
isEmpty(String str)
Asserts that a string is empty.
|
static void |
isEmpty(String str,
String message,
Object... messageArgs)
Asserts that a string is empty.
|
static <T> void |
isEmpty(T[] array)
Asserts that an array is empty.
|
static <T> void |
isEmpty(T[] array,
String message,
Object... messageArgs)
Asserts that an array is empty.
|
static void |
isNull(Object object)
Alias of
Assert.assertNull(Object). |
static void |
isNull(Object object,
String message,
Object... messageArgs)
Asserts that an object is null.
|
static void |
ne(double[] unexpecteds,
double[] actuals,
double delta)
Asserts that two double arrays are not equal.
|
static void |
ne(double[] unexpecteds,
double[] actuals,
double delta,
String message,
Object... messageArgs)
Asserts that two double arrays are not equal.
|
static void |
ne(double unexpected,
double actual,
double delta)
Asserts that two doubles or floats are not equal to within a positive delta.
|
static void |
ne(double unexpected,
double actual,
double delta,
String message,
Object... messageArgs)
Asserts that two doubles or floats are not equal to within a positive delta.
|
static void |
ne(float[] unexpecteds,
float[] actuals,
float delta)
Asserts that two float arrays are not equal.
|
static void |
ne(float[] unexpecteds,
float[] actuals,
float delta,
String message,
Object... messageArgs)
Asserts that two float arrays are not equal.
|
static void |
ne(Object unexpected,
Object actual)
Asserts that two objects (including arrays) are not equal.
|
static void |
ne(Object unexpected,
Object actual,
String message,
Object... messageArgs)
Asserts that two objects (including arrays) are not equal.
|
static void |
no(boolean condition)
Alias of
Assert.assertFalse(boolean). |
static void |
no(boolean condition,
String message,
Object... messageArgs)
Asserts that a condition is
false. |
static <T> void |
no(T actual,
org.hamcrest.Matcher<T> matcher)
Require
actual NOT satisfied the condition specified by matcher. |
static <T> void |
no(T actual,
org.hamcrest.Matcher<T> matcher,
String message,
Object... messageArgs)
Require
actual NOT satisfied the condition specified by matcher. |
static void |
notBlank(String str)
Asserts that a string isn’t blank.
|
static void |
notBlank(String str,
String message,
Object... messageArgs)
Asserts that a string isn’t blank.
|
static void |
notEmpty(Collection<?> col)
Asserts that a collection isn’t empty.
|
static void |
notEmpty(Collection<?> col,
String message,
Object... messageArgs)
Asserts that a collection isn’t empty.
|
static void |
notEmpty(Map<?,?> map)
Asserts that a map isn’t empty.
|
static void |
notEmpty(Map<?,?> map,
String message,
Object... messageArgs)
Asserts that a map isn’t empty.
|
static void |
notEmpty(String str)
Asserts that a string isn’t empty.
|
static void |
notEmpty(String str,
String message,
Object... messageArgs)
Asserts that a string isn’t empty.
|
static <T> void |
notEmpty(T[] array)
Asserts that an array isn’t empty.
|
static <T> void |
notEmpty(T[] array,
String message,
Object... messageArgs)
Asserts that an array isn’t empty.
|
static void |
notNull(Object object)
Alias of
Assert.assertNotNull(Object). |
static void |
notNull(Object object,
String message,
Object... messageArgs)
Asserts that an object isn’t null.
|
static void |
notSame(Object unexpected,
Object actual)
Alias of
Assert.assertNotSame(Object, Object). |
static void |
notSame(Object unexpected,
Object actual,
String message,
Object... messageArgs)
Asserts that two objects do not refer to the same object.
|
static void |
same(Object expected,
Object actual)
Alias of
Assert.assertSame(Object, Object). |
static void |
same(Object expected,
Object actual,
String message,
Object... messageArgs)
Asserts that two objects refer to the same object.
|
static void |
yes(boolean condition)
Alias of
Assert.assertTrue(boolean). |
static void |
yes(boolean condition,
String message,
Object... messageArgs)
Asserts that a condition is
true. |
static <T> void |
yes(T actual,
org.hamcrest.Matcher<T> matcher)
Alias of
Assert.assertThat(Object, Matcher). |
static <T> void |
yes(T actual,
org.hamcrest.Matcher<T> matcher,
String message,
Object... messageArgs)
Require
actual satisfied the condition specified by matcher. |
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, assertTrue, assertTrue, fail, failpublic static void yes(boolean condition,
String message,
Object... messageArgs)
Asserts that a condition is true. If it isn’t then throws an AssertionError with the given message.
condition - condition to be checkedmessage - The error message. null OkaymessageArgs - the error message argumentspublic static void yes(boolean condition)
Alias of Assert.assertTrue(boolean).
condition - condition to be checkedpublic static <T> void yes(T actual,
org.hamcrest.Matcher<T> matcher)
Alias of Assert.assertThat(Object, Matcher).
T - the static type accepted by the matcher (this can flag obvious compile-time problems such as yes(1, is("a"))actual - the computed value being comparedmatcher - an expression, built of Matchers, specifying allowed valuesCoreMatchers,
org.junit.matchers.JUnitMatcherspublic static <T> void yes(T actual,
org.hamcrest.Matcher<T> matcher,
String message,
Object... messageArgs)
Require actual satisfied the condition specified by matcher. If not an AssertionError is thrown with the reason string and information about the matcher and failing value. Example:
int n = 0;
yes(n, is(not(1))) // passes
yes(n, is(1), "Help! Integers don't work"); // fails:
// failure message:
// Help! Integers don't work
// expected: is <1>
// got value: <0>
T - the static type accepted by the matcher (this can flag obvious compile-time problems such as yes(1, is("a"))actual - the computed value being comparedmatcher - an expression, built of Matchers, specifying allowed valuesmessage - additional information about the errormessageArgs - message argumentsCoreMatchers,
org.junit.matchers.JUnitMatcherspublic static void no(boolean condition)
Alias of Assert.assertFalse(boolean).
condition - condition to be checkedpublic static void no(boolean condition,
String message,
Object... messageArgs)
Asserts that a condition is false. If it isn’t then throws an AssertionError with the given message.
condition - condition to be checkedmessage - The error message. null OkaymessageArgs - the error message argumentspublic static <T> void no(T actual,
org.hamcrest.Matcher<T> matcher)
Require actual NOT satisfied the condition specified by matcher. Otherwise an AssertionError is thrown with the reason string and information about the matcher and failing value. Example:
int n = 0;
no(n, is(1)) // passes
no(n, is(0)); // fails:
// failure message:
// expected: not is <0>
// got value: <0>
T - the static type accepted by the matcher (this can flag obvious compile-time problems such as no(1, is("a"))actual - the computed value being comparedmatcher - an expression, built of Matchers, specifying disallowed valuesCoreMatchers,
org.junit.matchers.JUnitMatcherspublic static <T> void no(T actual,
org.hamcrest.Matcher<T> matcher,
String message,
Object... messageArgs)
Require actual NOT satisfied the condition specified by matcher. Otherwise an AssertionError is thrown with the reason string and information about the matcher and failing value. Example:
int n = 0;
no(n, is(1)) // passes
no(n, is(0), "Help! Integers don't work"); // fails:
// failure message:
// Help! Integers don't work
// expected: not is <0>
// got value: <0>
T - the static type accepted by the matcher (this can flag obvious compile-time problems such as no(1, is("a"))actual - the computed value being comparedmatcher - an expression, built of Matchers, specifying disallowed valuesmessage - additional information about the errormessageArgs - message argumentsCoreMatchers,
org.junit.matchers.JUnitMatcherspublic static void fail(String message, Object... args)
Fails a test with the given message.
message - the failure messageargs - the failure message argumentsAssertionErrorpublic static void eq(Object expected, Object actual, String message, Object... messageArgs)
Asserts that two objects (including arrays) are equal. If they are not, an AssertionError is thrown with the given message. Ifexpected and actual are null, they are considered equal.
expected - expected value, could be any object including arrayactual - actual valuemessage - the failure message. null OkaymessageArgs - the failure message argumentspublic static void eq(Object expected, Object actual)
Asserts that two objects (including arrays) are equal. If they are not, an AssertionError is thrown with the given message. Ifexpected and actual are null, they are considered equal.
expected - expected value, could be any object including arrayactual - actual valuepublic static void eq(double[] expecteds,
double[] actuals,
double delta,
String message,
Object... messageArgs)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two double arrays are equal. If they are not, an AssertionError is thrown with the given message.
expecteds - double array with expected values.actuals - double array with actual valuesdelta - the maximum delta between expected and actual for which both numbers are still considered equal.message - the identifying message for the AssertionError (null okay)messageArgs - the failure message argumentsorg.junit.internal.ArrayComparisonFailurepublic static void eq(double[] expecteds,
double[] actuals,
double delta)
throws org.junit.internal.ArrayComparisonFailure
Alias of Assert.assertArrayEquals(double[], double[], double).
expecteds - double array with expected values.actuals - double array with actual valuesdelta - the maximum delta between expected and actual for which both numbers are still considered equal.org.junit.internal.ArrayComparisonFailurepublic static void eq(float[] expecteds,
float[] actuals,
float delta,
String message,
Object... messageArgs)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two float arrays are equal. If they are not, an AssertionError is thrown with the given message.
expecteds - double array with expected values.actuals - double array with actual valuesdelta - the maximum delta between expected and actual for which both numbers are still considered equal.message - the identifying message for the AssertionError (null okay)messageArgs - the failure message argumentsorg.junit.internal.ArrayComparisonFailurepublic static void eq(float[] expecteds,
float[] actuals,
float delta)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two float arrays are equal. If they are not, an AssertionError is thrown with the given message.
expecteds - double array with expected values.actuals - double array with actual valuesdelta - the maximum delta between expected and actual for which both numbers are still considered equal.org.junit.internal.ArrayComparisonFailurepublic static void eq(double expected,
double actual,
double delta,
String message,
Object... messageArgs)
Asserts that two doubles or floats are equal to within a positive delta. If they are not, an AssertionError is thrown with the given message. If the expected value is infinity then the delta value is ignored. NaNs are considered equal:
eq(Double.NaN, Double.NaN, *) passes
expected - expected valueactual - the value to check against expecteddelta - the maximum delta between expected and actual for which both numbers are still considered equal.message - the failure message for the AssertionError (null okay)messageArgs - the failure message argumentspublic static void eq(double expected,
double actual,
double delta)
Asserts that two doubles or floats are equal to within a positive delta. If they are not, an AssertionError is thrown with the given message. If the expected value is infinity then the delta value is ignored. NaNs are considered equal:
eq(Double.NaN, Double.NaN, *) passes
expected - expected valueactual - the value to check against expecteddelta - the maximum delta between expected and actual for which both numbers are still considered equal.public static void ne(Object unexpected, Object actual, String message, Object... messageArgs)
Asserts that two objects (including arrays) are not equal. If they are, an AssertionError is thrown with the given message. If unexpected and actual are null, they are considered equal.
unexpected - unexpected value, could be any object including arrayactual - actual valuemessage - the failure message. null OkaymessageArgs - the failure message argumentspublic static void ne(Object unexpected, Object actual)
Asserts that two objects (including arrays) are not equal. If they are, an AssertionError is thrown with the given message. If unexpected and actual are null, they are considered equal.
unexpected - unexpected value, could be any object including arrayactual - actual valuepublic static void ne(double[] unexpecteds,
double[] actuals,
double delta,
String message,
Object... messageArgs)
throws AssertionError
Asserts that two double arrays are not equal. If they are, an AssertionError is thrown with the given message.
unexpecteds - unexpected double arrayactuals - actual double arraydelta - the maximum delta between expected and actual for which both numbers are still considered equal.message - the identifying message for the AssertionError (null okay)messageArgs - the failure message argumentsAssertionErrorpublic static void ne(double[] unexpecteds,
double[] actuals,
double delta)
throws AssertionError
Asserts that two double arrays are not equal. If they are, an AssertionError is thrown.
unexpecteds - unexpected double arrayactuals - actual double arraydelta - the maximum delta between expected and actual for which both numbers are still considered equal.AssertionErrorpublic static void ne(float[] unexpecteds,
float[] actuals,
float delta,
String message,
Object... messageArgs)
throws AssertionError
Asserts that two float arrays are not equal. If they are, an AssertionError is thrown with the given message.
unexpecteds - unexpected double arrayactuals - actual double arraydelta - the maximum delta between expected and actual for which both numbers are still considered equal.message - the identifying message for the AssertionError (null okay)messageArgs - the failure message argumentsAssertionErrorpublic static void ne(float[] unexpecteds,
float[] actuals,
float delta)
throws AssertionError
Asserts that two float arrays are not equal. If they are, an AssertionError is thrown.
unexpecteds - unexpected double arrayactuals - actual double arraydelta - the maximum delta between expected and actual for which both numbers are still considered equal.AssertionErrorpublic static void ne(double unexpected,
double actual,
double delta,
String message,
Object... messageArgs)
Asserts that two doubles or floats are not equal to within a positive delta. If they are, an AssertionError is thrown with the given message. If the expected value is infinity then the delta value is ignored. NaNs are considered equal:
ne(Double.NaN, Double.NaN, *) fails
unexpected - expected valueactual - the value to check against expecteddelta - the maximum delta between expected and actual for which both numbers are still considered equal.message - the failure message for the AssertionError (null okay)messageArgs - the failure message argumentspublic static void ne(double unexpected,
double actual,
double delta)
Asserts that two doubles or floats are not equal to within a positive delta. If they are, an AssertionError is thrown with the given message. If the expected value is infinity then the delta value is ignored. NaNs are considered equal:
ne(Double.NaN, Double.NaN, *) fails
unexpected - expected valueactual - the value to check against expecteddelta - the maximum delta between expected and actual for which both numbers are still considered equal.public static void notNull(Object object, String message, Object... messageArgs)
Asserts that an object isn’t null. If it is an AssertionError is thrown with the given message.
object - Object to check or nullmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentspublic static void notNull(Object object)
Alias of Assert.assertNotNull(Object).
object - Object to check or nullpublic static void isNull(Object object, String message, Object... messageArgs)
Asserts that an object is null. If it is not, an AssertionError is thrown with the given message.
object - Object to check or nullmessage - Failure messagemessageArgs - Failure message argumentspublic static void isNull(Object object)
Alias of Assert.assertNull(Object).
public static void notEmpty(String str, String message, Object... messageArgs)
Asserts that a string isn’t empty. If it is an AssertionError is thrown with the given message.
A string is said to be empty when either one of the following cases is true:
null""str - a string to be checkedmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentspublic static void notEmpty(String str)
Asserts that a string isn’t empty. If it is an AssertionError is thrown.
A string is said to be empty when either one of the following cases is true:
null""str - a string to be checkedpublic static void notEmpty(Collection<?> col, String message, Object... messageArgs)
Asserts that a collection isn’t empty. If it is an AssertionError is thrown with the given message.
col - a collection to be checkedmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentsNullPointerException - if the collection specified is nullpublic static void notEmpty(Collection<?> col)
Asserts that a collection isn’t empty. If it is an AssertionError is thrown.
col - a collection to be checkedNullPointerException - if the collection specified is nullpublic static void notEmpty(Map<?,?> map, String message, Object... messageArgs)
Asserts that a map isn’t empty. If it is an AssertionError is thrown with the given message.
map - a map to be checkedmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentsNullPointerException - if the collection specified is nullpublic static void notEmpty(Map<?,?> map)
Asserts that a map isn’t empty. If it is an AssertionError is thrown.
map - a map to be checkedNullPointerException - if the collection specified is nullpublic static <T> void notEmpty(T[] array,
String message,
Object... messageArgs)
Asserts that an array isn’t empty. If it is an AssertionError is thrown with the given message.
array - an array to be checkedmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentsNullPointerException - if the array specified is nullpublic static <T> void notEmpty(T[] array)
Asserts that an array isn’t empty. If it is an AssertionError is thrown.
array - an array to be checkedNullPointerException - if the array specified is nullpublic static void isEmpty(String str, String message, Object... messageArgs)
Asserts that a string is empty. If it isn’t an AssertionError is thrown with the given message.
A string is said to be empty when either one of the following cases is true:
null""str - a string to be checkedmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentspublic static void isEmpty(String str)
Asserts that a string is empty. If it isn’t an AssertionError is thrown.
A string is said to be empty when either one of the following cases is true:
null""str - a string to be checkedpublic static void isEmpty(Collection<?> col, String message, Object... messageArgs)
Asserts that a collection is empty. If it is not an AssertionError is thrown with the given message.
col - a collection to be checkedmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentsNullPointerException - if the collection specified is nullpublic static void isEmpty(Collection<?> col)
Asserts that a collection is empty. If it is not an AssertionError is thrown.
col - a collection to be checkedNullPointerException - if the collection specified is nullpublic static void isEmpty(Map<?,?> map, String message, Object... messageArgs)
Asserts that a map is empty. If it is not an AssertionError is thrown with the given message.
map - a map to be checkedmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentsNullPointerException - if the collection specified is nullpublic static void isEmpty(Map<?,?> map)
Asserts that a Map is empty. If it is not an AssertionError is thrown.
map - a collection to be checkedNullPointerException - if the collection specified is nullpublic static <T> void isEmpty(T[] array,
String message,
Object... messageArgs)
Asserts that an array is empty. If it is not an AssertionError is thrown with the given message.
array - an array to be checkedmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentsNullPointerException - if the array specified is nullpublic static <T> void isEmpty(T[] array)
Asserts that an array is empty. If it is not an AssertionError is thrown.
array - an array to be checkedNullPointerException - if the array specified is nullpublic static void notBlank(String str, String message, Object... messageArgs)
Asserts that a string isn’t blank. If it is an AssertionError is thrown with the given message.
A string is said to be blank when either one of the following cases is true:
null""'\t' and backspace '\b'str - a string to be checkedmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentspublic static void notBlank(String str)
Asserts that a string isn’t blank. If it is an AssertionError is thrown.
A string is said to be blank when either one of the following cases is true:
null""'\t' and backspace '\b'str - a string to be checkedpublic static void isBlank(String str, String message, Object... messageArgs)
Asserts that a string is blank. If it isn’t an AssertionError is thrown with the given message.
A string is said to be blank when either one of the following cases is true:
null""'\t' and backspace '\b'str - a string to be checkedmessage - the identifying message for the AssertionError (null okay)messageArgs - the message argumentspublic static void isBlank(String str)
Asserts that a string is blank. If it isn’t an AssertionError is thrown.
A string is said to be blank when either one of the following cases is true:
null""'\t' and backspace '\b'str - a string to be checkedpublic static void same(Object expected, Object actual, String message, Object... messageArgs)
Asserts that two objects refer to the same object. If they are not, an AssertionError is thrown with the given message.
expected - the expected objectactual - the object to compare to expectedmessage - Failure messagemessageArgs - the failure message argumentspublic static void same(Object expected, Object actual)
Alias of Assert.assertSame(Object, Object).
expected - the expected objectactual - the object to compare to expectedpublic static void notSame(Object unexpected, Object actual, String message, Object... messageArgs)
Asserts that two objects do not refer to the same object. If they do refer to the same object, an AssertionError is thrown with the given message.
unexpected - the object you don’t expectactual - the object to compare to unexpectedmessage - the failure messagemessageArgs - the failure message argumentsCopyright © 2017–2018 OSGL (Open Source General Library). All rights reserved.