[jboss-cvs] JBossAS SVN: r62644 - projects/test/trunk/src/main/java/org/jboss/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 30 12:31:51 EDT 2007
Author: adrian at jboss.org
Date: 2007-04-30 12:31:51 -0400 (Mon, 30 Apr 2007)
New Revision: 62644
Modified:
projects/test/trunk/src/main/java/org/jboss/test/AbstractTestCase.java
Log:
Avoid NPEs for null arrays in the check and add a check for an empty/null array.
Modified: projects/test/trunk/src/main/java/org/jboss/test/AbstractTestCase.java
===================================================================
--- projects/test/trunk/src/main/java/org/jboss/test/AbstractTestCase.java 2007-04-30 16:24:33 UTC (rev 62643)
+++ projects/test/trunk/src/main/java/org/jboss/test/AbstractTestCase.java 2007-04-30 16:31:51 UTC (rev 62644)
@@ -142,7 +142,15 @@
protected void assertEquals(Object[] expected, Object[] actual)
{
if (Arrays.equals(expected, actual) == false)
- throw new AssertionFailedError("expected: " + Arrays.asList(expected) + " actual: " + Arrays.asList(actual));
+ {
+ String expectedString = null;
+ if (expected != null)
+ expectedString = Arrays.asList(expected).toString();
+ String actualString = null;
+ if (actual != null)
+ actualString = Arrays.asList(actual).toString();
+ throw new AssertionFailedError("expected: " + expectedString + " actual: " + actualString);
+ }
}
/**
@@ -155,7 +163,15 @@
protected void assertEquals(String context, Object[] expected, Object[] actual)
{
if (Arrays.equals(expected, actual) == false)
- throw new AssertionFailedError(context + " expected: " + Arrays.asList(expected) + " actual: " + Arrays.asList(actual));
+ {
+ String expectedString = null;
+ if (expected != null)
+ expectedString = Arrays.asList(expected).toString();
+ String actualString = null;
+ if (actual != null)
+ actualString = Arrays.asList(actual).toString();
+ throw new AssertionFailedError(context + " expected: " + expectedString + " actual: " + actualString);
+ }
}
/**
@@ -184,6 +200,17 @@
}
/**
+ * Assert an array is empty or null
+ *
+ * @param array the array
+ */
+ protected static void assertEmpty(Object[] array)
+ {
+ if (array != null)
+ assertEquals(Arrays.asList(array).toString(), 0, array.length);
+ }
+
+ /**
* Check we have the expected exception
*
* @param expected the excepted class of the exception
More information about the jboss-cvs-commits
mailing list