| java.lang.Object com.tc.util.Assert
Assert | public class Assert (Code) | | A general purpose assertion utility. By default it is on, but you can disable the throwing of exceptions by giving
the system property "tcassert" a value of 'false'.
|
Method Summary | |
public static void | assertConsistentCollection(Collection collection, Class elementClass, boolean allowNullElements) Assert that all items in collection are of type elementClass, also if !allowNullElements, check that all items in
the collection are non-null. | public static void | assertContainsElement(Object[] objectArray, Object requiredElement) Tests for equality using the == operator, not Object.equals(Object) . | public static void | assertEquals(int expected, int actual) | public static void | assertEquals(Object msg, int expected, int actual) | public static void | assertEquals(double expected, double actual) | public static void | assertEquals(double expected, double actual, double epsilon) | public static void | assertEquals(boolean expected, boolean actual) | public static void | assertEquals(byte[] expected, byte[] actual) | public static void | assertEquals(Object expected, Object actual) | public static void | assertEquals(Object msg, Object expected, Object actual) | public static void | assertFalse(boolean expr) | public static void | assertFalse(Object message, boolean expr) | public static void | assertNoBlankElements(String[] array) | public static void | assertNoNullElements(Object[] array) | public static void | assertNotBlank(Object what, String s) | public static void | assertNotBlank(String s) | public static void | assertNotEmpty(Object what, String s) | public static void | assertNotEmpty(String s) | public static void | assertNotNull(Object what, Object o) | public static void | assertNotNull(Object o) | public static void | assertNull(Object o) | public static void | assertNull(Object what, Object o) | public static void | assertSame(Object lhs, Object rhs) | public static void | assertTrue(boolean expr) | public static void | assertTrue(Object message, boolean expr) | public static void | eval(boolean expr) | public static void | eval(Object message, boolean expr) | public static void | fail() | public static void | fail(String message) | public static TCAssertionError | failure(Object message, Throwable t) This returns an exception, instead of throwing one, so that you can do (e.g.):
public Object foo() { throw Assert.failure("doesn't work"); }
or whatever. | public static TCAssertionError | failure(Object message) This returns an exception, instead of throwing one, so that you can do (e.g.):
public Object foo() { throw Assert.failure("doesn't work"); }
or whatever. | public static void | inv(boolean v) | public static void | post(boolean v) | public static void | pre(boolean v) |
assertConsistentCollection | public static void assertConsistentCollection(Collection collection, Class elementClass, boolean allowNullElements)(Code) | | Assert that all items in collection are of type elementClass, also if !allowNullElements, check that all items in
the collection are non-null.
Parameters: collection - The collection Parameters: elementClass - The expected super type of all items in collection Parameters: allowNullElements - Flag for whether null elements are allowed or not |
assertContainsElement | public static void assertContainsElement(Object[] objectArray, Object requiredElement)(Code) | | Tests for equality using the == operator, not Object.equals(Object) .
null is a valid element.
Parameters: objectArray - Array of objects Parameters: requiredElement - Must be in objectArray |
assertEquals | public static void assertEquals(int expected, int actual)(Code) | | Assert expected and actual values are equal
Parameters: expected - Expected value Parameters: actual - Actual value |
assertEquals | public static void assertEquals(Object msg, int expected, int actual)(Code) | | Assert expected and actual values are equal and return what as a message
Parameters: expected - Expected value Parameters: actual - Actual value Parameters: msg - Message, should be non-null |
assertEquals | public static void assertEquals(double expected, double actual)(Code) | | Assert expected and actual values are equal
Parameters: expected - Expected value Parameters: actual - Actual value |
assertEquals | public static void assertEquals(double expected, double actual, double epsilon)(Code) | | Assert expected and actual values are equal within epsilon
Parameters: expected - Expected value Parameters: actual - Actual value Parameters: epsilon - Maximum allowed difference between expected and actual |
assertEquals | public static void assertEquals(boolean expected, boolean actual)(Code) | | Assert expected and actual values are equal
Parameters: expected - Expected value Parameters: actual - Actual value |
assertEquals | public static void assertEquals(byte[] expected, byte[] actual)(Code) | | Assert expected and actual values are equal or both null
Parameters: expected - Expected value Parameters: actual - Actual value |
assertEquals | public static void assertEquals(Object expected, Object actual)(Code) | | Assert expected and actual values are equal or both null
Parameters: expected - Expected value Parameters: actual - Actual value |
assertFalse | public static void assertFalse(boolean expr)(Code) | | Evaluate the boolean exception and throw an assertion error if true
Parameters: expr - Expression Parameters: message - Message for assertion error if true |
assertFalse | public static void assertFalse(Object message, boolean expr)(Code) | | Evaluate the boolean exception and throw an assertion error if true
Parameters: expr - Expression Parameters: message - Message for assertion error if true |
assertNoBlankElements | public static void assertNoBlankElements(String[] array)(Code) | | Validate that the given array of strings contains no nulls or empty strings
Parameters: array - Array of strings |
assertNoNullElements | public static void assertNoNullElements(Object[] array)(Code) | | Validate that the given (1 dimensional) array of references contains no nulls
Parameters: array - Array |
assertNotBlank | public static void assertNotBlank(Object what, String s)(Code) | | Validate that s is not blank and throw what as a message
Parameters: s - String Parameters: what - Message |
assertNotBlank | public static void assertNotBlank(String s)(Code) | | Validate that s is not blank
Parameters: s - String |
assertNotEmpty | public static void assertNotEmpty(Object what, String s)(Code) | | Validate that s is not null or empty and throw what as a message
Parameters: s - String Parameters: what - Message |
assertNotEmpty | public static void assertNotEmpty(String s)(Code) | | Validate that s is not null or empty
Parameters: s - String |
assertNotNull | public static void assertNotNull(Object what, Object o)(Code) | | If o is null, throw assertion error with message what
Parameters: o - Object Parameters: what - Message for error |
assertNotNull | public static void assertNotNull(Object o)(Code) | | If o is null, throw assertion error
Parameters: o - Object |
assertNull | public static void assertNull(Object o)(Code) | | If o is non-null, throw assertion error
Parameters: o - Object |
assertNull | public static void assertNull(Object what, Object o)(Code) | | If o is non-null, throw assertion error
Parameters: o - Object Parameters: what - Message for error |
assertSame | public static void assertSame(Object lhs, Object rhs)(Code) | | Validate that lhs and rhs are identical object references or both are null
Parameters: lhs - Left hand side Parameters: rhs - Right hand side |
assertTrue | public static void assertTrue(boolean expr)(Code) | | Evaluate the boolean exception and throw an assertion error if false
Parameters: expr - Expression |
assertTrue | public static void assertTrue(Object message, boolean expr)(Code) | | Evaluate the boolean exception and throw an assertion error if false
Parameters: expr - Expression Parameters: message - Message for assertion error if false |
eval | public static void eval(boolean expr)(Code) | | Evaluate the boolean exception and throw an assertion error if false
Parameters: expr - Expression |
eval | public static void eval(Object message, boolean expr)(Code) | | Evaluate the boolean exception and throw an assertion error if false
Parameters: expr - Expression Parameters: message - Message for assertion error if false |
fail | public static void fail()(Code) | | Throw assertion error with generic message
|
fail | public static void fail(String message)(Code) | | Throw assertion error with specified message
Parameters: message - Message |
failure | public static TCAssertionError failure(Object message, Throwable t)(Code) | | This returns an exception, instead of throwing one, so that you can do (e.g.):
public Object foo() { throw Assert.failure("doesn't work"); }
or whatever. If this just threw the exception itself, the compiler would complain (above) that there's no value
being returned.
Parameters: message - The message to put in the assertion error Parameters: t - The exception to wrap New TCAssertionError, ready to throw |
failure | public static TCAssertionError failure(Object message)(Code) | | This returns an exception, instead of throwing one, so that you can do (e.g.):
public Object foo() { throw Assert.failure("doesn't work"); }
or whatever. If this just threw the exception itself, the compiler would complain (above) that there's no value
being returned.
Parameters: message - The message to put in the assertion error New TCAssertionError, ready to throw |
inv | public static void inv(boolean v)(Code) | | Assert invariant
Parameters: v - Invariant |
post | public static void post(boolean v)(Code) | | Assert postcondition
Parameters: v - Postcondition |
pre | public static void pre(boolean v)(Code) | | Assert precondition
Parameters: v - Precondition |
|
|