Version 1.2.3: getVersion, openResource, fixes
[nikiroo-utils.git] / src / be / nikiroo / utils / test / TestCase.java
index e4860fa11f51e0f5e4cda5d366fffa8db0eef285..b37ea987ffca27677a32eb5d31d05e2632974c52 100644 (file)
@@ -233,6 +233,29 @@ abstract public class TestCase {
                assertEquals(errorMessage, new Double(expected), new Double(actual));
        }
 
+       /**
+        * 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) {
+                       if (errorMessage == null) {
+                               errorMessage = String.format("" //
+                                               + "Assertion failed!\n" //
+                                               + "Object should have been NULL: [%s]", actual);
+                       }
+                       throw new AssertException(errorMessage);
+               }
+       }
+
        /**
         * Generate the default assert message for 2 different values that were
         * supposed to be equals.