001 package org.shiftone.jrat.util;
002
003
004 /**
005 * @author jeff@shiftone.org (Jeff Drost)
006 */
007 public class Assert {
008
009 public static void assertNotNull(Object obj) {
010
011 if (obj == null) {
012 throw new AssertionFailedException("value is unexpectedly null");
013 }
014 }
015
016
017 public static void assertNotNull(String message, Object obj) {
018
019 if (obj == null) {
020 throw new AssertionFailedException("value of " + message + " is unexpectedly null");
021 }
022 }
023
024
025 public static void assertSame(String message, Object objA, Object objB) {
026
027 if (objA == objB) {
028 return;
029 }
030
031 if ((objA == null) || (objB == null) || (!objA.equals(objB))) {
032 throw new AssertionFailedException("values of " + message + " are unexpectedly not the same " + objA
033 + " <> " + objB);
034 }
035 }
036
037
038 public static void assertTrue(String message, boolean expression) {
039
040 if (!expression) {
041 throw new AssertionFailedException("value of " + message + " was unexpectedly false");
042 }
043 }
044 }