+
+ /**
+ * Check that given {@link Object} is not NULL.
+ *
+ * @param the
+ * error message to display if it is NULL
+ * @param actual
+ * the actual value
+ *
+ * @throws AssertException
+ * in case they differ
+ */
+ public void assertNotNull(String errorMessage, Object actual)
+ throws AssertException {
+ if (actual == null) {
+ String defaultReason = String.format("" //
+ + "Assertion failed!\n" //
+ + "Object should have been NULL: [%s]", actual);
+
+ if (errorMessage == null) {
+ throw new AssertException(defaultReason);
+ } else {
+ throw new AssertException(errorMessage, new AssertException(
+ defaultReason));
+ }
+ }
+ }
+
+ /**
+ * Generate the default assert message for 2 different values that were
+ * supposed to be equals.
+ *
+ * @param expected
+ * the expected value
+ * @param actual
+ * the actual value
+ *
+ * @return the message
+ */
+ public static String generateAssertMessage(Object expected, Object actual) {
+ return String.format("" //
+ + "Assertion failed!\n" //
+ + "Expected value: [%s]\n" //
+ + "Actual value: [%s]", expected, actual);
+ }