X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Ftest%2FAssertionUtils.java;h=0a3e41719a8121ec52f844d63ebb7c33385b30e9;hb=e4c24db4532ff3473bb40dda0af6c200a317ac50;hp=fc4040721d9aabeffac4017ad0b5f4907caa0529;hpb=49502b42e6885ad05ca88d0e0613d7033b75ced3;p=utils diff --git a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java index fc404072..0a3e4171 100644 --- a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java +++ b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java @@ -37,25 +37,6 @@ public final class AssertionUtils { // Empty } - /** - * Asserts that two collections are equal including equality of the elements. - * @param aExpected - * @param aActual - */ - public static void assertEquals(List aExpected, List aActual) { - assertEquals(aExpected.toArray(), aActual.toArray()); - } - - /** - * Asserts that two collections are equal including equality of the elements. - * @param aMsg - * @param aExpected - * @param aActual - */ - public static void assertEquals(String aMsg, List aExpected, List aActual) { - assertEquals(aMsg, aExpected.toArray(), aActual.toArray()); - } - /** * Asserts that two object arrays are equal. * @@ -137,4 +118,27 @@ public final class AssertionUtils { aExpectedMap.get(key), aActual.get(key)); } } + + public static interface ErroneousCode { + void run() throws Exception; + } + + /** + * Asserts that an exception occurs. + * @param aRunnable Test cases should create a subclass of this which contains the + * code that should throw an exception. + * @param aType Type of exception that is expected. + */ + public static void assertException(ErroneousCode aObject, Class aType) { + try { + aObject.run(); + } catch (Throwable t) { + if ( aType.isInstance(t)) { + return; // ok + } + else { + throw new RuntimeException(t); + } + } + } }