Assert (fawkeZ - Developer's Documentation)

org.jcoderz.commons.util
Class Assert

  extended by org.jcoderz.commons.util.Assert

public final class Assert
extends

Utility class for assertions.

Author:
Andreas Mandel

Method Summary
static void assertEquals( message, int expected, int actual)
          Asserts that two integers are equal.
static void assertEquals( message,  expected,  actual)
          Asserts that two objects are equal.
static void assertTrue( message, boolean condition)
          Asserts that a condition is true.
static void fail( message)
          Can be called if an assertion already failed.
static void fail( message,  ex)
          Can be called if an exception is unexpectedly caught.
static void notNull( parameter,  argumentName)
          Asserts that an object isn't null.
 
Methods inherited from class java.lang.
, , , , , , , , , ,
 

Method Detail

notNull

public static void notNull( parameter,
                            argumentName)
Asserts that an object isn't null. If it is a null reference an ArgumentMalformedException is thrown with a appropriate message.

Parameters:
parameter - object to be tested against null.
argumentName - name of the provided argument within the used interface.

assertEquals

public static void assertEquals( message,
                                int expected,
                                int actual)
                         throws AssertionFailedException
Asserts that two integers are equal. If they are not an AssertionFailedException is thrown with the given message.

Parameters:
message - The message for the condition. This message is used in the exception if the integers are not equal.
expected - the expected integer.
actual - the actual integer.
Throws:
AssertionFailedException - if the two objects are not equal.

assertEquals

public static void assertEquals( message,
                                 expected,
                                 actual)
                         throws AssertionFailedException
Asserts that two objects are equal. If they are not an AssertionFailedException is thrown with the given message.

Parameters:
message - The message for the condition. This message is used in the exception if the objects are not equal.
expected - the expected object.
actual - the actual object.
Throws:
AssertionFailedException - if the two objects are not equal.

assertTrue

public static void assertTrue( message,
                              boolean condition)
                       throws AssertionFailedException
Asserts that a condition is true. If it isn't it throws an AssertionFailedException with the given message.

Parameters:
message - The message for the condition. This message is used in the exception if the condition is false.
condition - the condition to test.
Throws:
AssertionFailedException - if the condition is false.

fail

public static void fail( message)
                 throws AssertionFailedException
Can be called if an assertion already failed. This can be used at code positions that should never be reached at all. It throws an AssertionFailedException with the given message.

Parameters:
message - The message to be used in the exception.
Throws:
AssertionFailedException - always.

fail

public static void fail( message,
                         ex)
                 throws AssertionFailedException
Can be called if an exception is unexpectedly caught. This can be used at catch blocks that should never be reached at all. It throws an AssertionFailedException with the given nested exception.

Parameters:
message - The message to be used in the exception.
ex - the exception that was not expected
Throws:
AssertionFailedException - always.


Copyright 2007 The jCoderZ Project.