|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.util.Assert
Utility functions for assertions.
The static methods in this class provide a standard way of asserting certain conditions.
Though it is not right now, this class should be final. Do not subclass it. In a future revision of this software, this class will be made final.
Field Summary | |
static boolean |
ASSERT_ON
Deprecated. in favor of isEnabled() |
static String |
versionId
|
Constructor Summary | |
Assert()
|
Method Summary | |
static void |
assertEquals(int expected,
int actual)
Deprecated. Use truth(boolean, String) instead |
static void |
assertEquals(int expected,
int actual,
String expectedLabel,
String actualLabel)
Deprecated. Use truth(boolean, String) instead |
static void |
assertEquals(Object expected,
Object actual)
Deprecated. Use equal(Object,Object) instead |
static void |
assertEquals(Object expected,
Object actual,
String expectedLabel,
String actualLabel)
Verify that two values are equal (according to their equals method, unless expected is null, then according to ==). |
static void |
assertLocked(Lockable l)
Deprecated. Use locked(Lockable) instead |
static void |
assertNotEmpty(String s)
Deprecated. with no replacement |
static void |
assertNotEmpty(String s,
String label)
Deprecated. with no replacement |
static void |
assertNotLocked(Lockable l)
Deprecated. Use unlocked(Lockable) instead |
static void |
assertNotNull(Object o)
Deprecated. Use exists(Object,Class) instead |
static void |
assertNotNull(Object o,
String label)
Deprecated. Use exists(Object,Class) instead |
static void |
assertTrue(boolean cond)
Deprecated. Use truth(boolean, String) instead |
static void |
assertTrue(boolean cond,
String msg)
Deprecated. Use truth(boolean,String) instead |
static void |
equal(Object value1,
Object value2)
Verifies that two values are equal (according to their equals method, unless value1 is null, then according to
== ). |
static void |
equal(Object value1,
Object value2,
String message)
Verifies that two values are equal (according to their equals method, unless value1 is null, then according to
== ). |
static void |
exists(Object object)
Asserts that an object is not null. |
static void |
exists(Object object,
Class clacc)
Asserts that an object is not null. |
static void |
fail()
Throws an error. |
static void |
fail(String message)
Throws an error. |
static void |
falsity(boolean condition)
Asserts that an arbitrary condition is false and throws an error if the condition is true. |
static void |
falsity(boolean condition,
String message)
Asserts that an arbitrary condition is false and throws an error if the condition is true. |
static boolean |
isAssertEnabled()
Deprecated. Use isEnabled() instead |
static boolean |
isAssertOn()
Deprecated. Use isEnabled() instead |
static boolean |
isEnabled()
Tells whether asserts are turned on. |
static void |
locked(Lockable lockable)
Verifies that Lockable is locked and throws an
error if it is not. |
static void |
truth(boolean condition)
Asserts that an arbitrary condition is true and throws an error with message message if the condition is
false. |
static void |
truth(boolean condition,
String message)
Asserts that an arbitrary condition is true and throws an error with message message if the condition is
false. |
static void |
unequal(Object value1,
Object value2)
Verifies that two values are not equal (according to their equals method, unless value1 is null, then
according to == ). |
static void |
unlocked(Lockable lockable)
Verifies that lockable is not locked and
throws an error if it is. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
public static final boolean ASSERT_ON
isEnabled()
Constructor Detail |
public Assert()
Method Detail |
public static final boolean isEnabled()
public static final void fail(String message)
message
- A String
describing the failure
condition
AssertionError
public static final void fail()
AssertionError
public static final void truth(boolean condition, String message)
message
if the condition is
false.
condition
- The condition assertedmessage
- An error message
AssertionError
- if the condition is falsepublic static final void truth(boolean condition)
message
if the condition is
false.
condition
- The condition asserted
AssertionError
- if the condition is falsepublic static final void falsity(boolean condition, String message)
condition
- The condition assertedmessage
- An error message
AssertionError
- if the condition is falsepublic static final void falsity(boolean condition)
condition
- The condition asserted
AssertionError
- if the condition is falsepublic static final void exists(Object object, Class clacc)
object
- The object that must not be nullclacc
- The Class
of parameter
object
AssertionError
- if the object is nullpublic static final void exists(Object object)
object
- The object that must not be null
AssertionError
- if the object is nullpublic static final void locked(Lockable lockable)
Lockable
is locked and throws an
error if it is not.
lockable
- The object that must be lockedLockable
public static final void unlocked(Lockable lockable)
lockable
is not locked and
throws an error if it is.
lockable
- The object that must not be lockedLockable
public static final void equal(Object value1, Object value2)
value1
is null, then according to
==
).
value1
- The first value to be comparedvalue2
- The second
AssertionError
- if the arguments are unequalpublic static final void equal(Object value1, Object value2, String message)
value1
is null, then according to
==
).
value1
- The first value to be comparedvalue2
- The second
AssertionError
- if the arguments are unequalpublic static final void unequal(Object value1, Object value2)
value1
is null, then
according to ==
).
value1
- The first value to be comparedvalue2
- The second
AssertionError
- if the arguments are unequalpublic static final boolean isAssertOn()
isEnabled()
instead
public static final boolean isAssertEnabled()
isEnabled()
instead
public static final void assertTrue(boolean cond)
truth(boolean, String)
instead
cond
- condition to assert
IllegalStateException
- condition was falsepublic static final void assertTrue(boolean cond, String msg)
truth(boolean,String)
instead
msg
if the condition is
false.
cond
- condition to assertmsg
- failure message
IllegalStateException
- condition was falsepublic static final void assertNotNull(Object o)
exists(Object,Class)
instead
public static final void assertNotNull(Object o, String label)
exists(Object,Class)
instead
public static final void assertNotEmpty(String s)
public static final void assertNotEmpty(String s, String label)
public static final void assertEquals(Object expected, Object actual)
equal(Object,Object)
instead
expected
- Expected value.actual
- Actual value.
IllegalStateException
- condition was falsepublic static final void assertEquals(Object expected, Object actual, String expectedLabel, String actualLabel)
expected
- Expected value.actual
- Actual value.expectedLabel
- Label for first (generally expected) value.actualLabel
- Label for second (generally actual) value.
IllegalStateException
- condition was falsepublic static final void assertEquals(int expected, int actual)
truth(boolean, String)
instead
expected
- Expected value.actual
- Actual value.
IllegalStateException
- condition was falsepublic static final void assertEquals(int expected, int actual, String expectedLabel, String actualLabel)
truth(boolean, String)
instead
expected
- Expected value.actual
- Actual value.expectedLabel
- Label for first (generally expected) value.actualLabel
- Label for second (generally actual) value.
IllegalStateException
- condition was falsepublic static void assertLocked(Lockable l)
locked(Lockable)
instead
public static void assertNotLocked(Lockable l)
unlocked(Lockable)
instead
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |