/** * Asserts a collection is empty * * @param c the collection */ protected void assertEmpty(Collection c) { assertNotNull(c); if (c.isEmpty() == false) throw new AssertionFailedError("Expected empty collection " + c); }
/** * Asserts a collection is empty * * @param c the collection */ protected void assertEmpty(Collection c) { assertNotNull(c); if (c.isEmpty() == false) throw new AssertionFailedError("Expected empty collection " + c); }
/** * Asserts a collection is empty * * @param context the context * @param c the collection */ protected void assertEmpty(String context, Collection c) { assertNotNull(c); if (c.isEmpty() == false) throw new AssertionFailedError(context); }
/** * Asserts a collection is empty * * @param context the context * @param c the collection */ protected void assertEmpty(String context, Collection c) { assertNotNull(c); if (c.isEmpty() == false) throw new AssertionFailedError(context); }
/** * Check a throwable and rethrow if it doesn't match * * @param expected the expected throwable * @param throwable the throwable * @throws Exception the thrown exception */ public static void checkThrowableRethrow(Class<? extends Throwable> expected, Throwable throwable) throws Exception { assertNotNull(expected); assertNotNull(throwable); if (expected.equals(throwable.getClass()) == false) { if (throwable instanceof Exception) throw (Exception) throwable; else if (throwable instanceof Error) throw (Error) throwable; else throw new UnexpectedThrowable("UnexpectedThrowable", throwable); } else { staticLog.debug("Got expected " + expected.getName() + "(" + throwable + ")"); } }
/** * Check a throwable and rethrow if it doesn't match * * @param expected the expected throwable * @param throwable the throwable * @throws Exception the thrown exception */ public static void checkThrowableRethrow(Class<? extends Throwable> expected, Throwable throwable) throws Exception { assertNotNull(expected); assertNotNull(throwable); if (expected.equals(throwable.getClass()) == false) { if (throwable instanceof Exception) throw (Exception) throwable; else if (throwable instanceof Error) throw (Error) throwable; else throw new UnexpectedThrowable("UnexpectedThrowable", throwable); } else { staticLog.debug("Got expected " + expected.getName() + "(" + throwable + ")"); } }
assertNotNull(expected); assertNotNull(throwable);
/** * Check we have the expected deep exception * * @param expected the excepted class of the exception * @param throwable the real exception */ public static void checkDeepThrowable(Class<? extends Throwable> expected, Throwable throwable) { assertNotNull(expected); assertNotNull(throwable); while (throwable.getCause() != null) throwable = throwable.getCause(); if (throwable instanceof AssertionFailedError || throwable instanceof AssertionError) throw (Error) throwable; if (expected.equals(throwable.getClass()) == false) { staticLog.error("Unexpected throwable", throwable); fail("Unexpected throwable: " + throwable); } else { staticLog.debug("Got expected " + expected.getName() + "(" + throwable + ")"); } }
/** * Check we have the expected deep exception * * @param expected the excepted class of the exception * @param throwable the real exception */ public static void checkDeepThrowable(Class<? extends Throwable> expected, Throwable throwable) { assertNotNull(expected); assertNotNull(throwable); while (throwable.getCause() != null) throwable = throwable.getCause(); if (throwable instanceof AssertionFailedError || throwable instanceof AssertionError) throw (Error) throwable; if (expected.equals(throwable.getClass()) == false) { staticLog.error("Unexpected throwable", throwable); fail("Unexpected throwable: " + throwable); } else { staticLog.debug("Got expected " + expected.getName() + "(" + throwable + ")"); } }
assertNotNull(expected); assertNotNull(throwable);