/** * Asserts that a list of throwables is empty. If it isn't empty, * will throw {@link MultipleFailureException} (if there are * multiple throwables in the list) or the first element in the list * (if there is only one element). * * @param errors list to check * @throws Throwable if the list is not empty */ @SuppressWarnings("deprecation") public static void assertEmpty(List<Throwable> errors) throws Throwable { if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw errors.get(0); } /* * Many places in the code are documented to throw * org.junit.internal.runners.model.MultipleFailureException. * That class now extends this one, so we throw the internal * exception in case developers have tests that catch * MultipleFailureException. */ throw new org.junit.internal.runners.model.MultipleFailureException(errors); } }
for(final Throwable failure : ((MultipleFailureException)t).getFailures()){ final boolean isMissingCreds = isMissingCredsException( failure );
@Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<Throwable>(); errors.clear(); try { System.out.println("=============++> Entering Test Scope"); scope.enter(); injector.injectMembers(test); inner.evaluate(); } catch (Throwable e) { errors.add(e); } finally { try { System.out.println("=============++> Exiting Test Scope"); scope.exit(); } catch (Throwable e) { errors.add(e); } } MultipleFailureException.assertEmpty(errors); } }
@Override public void evaluate() throws Throwable { System.out.println("ConnectionProvider class: " + connectionProvider); JdbcScheduler.get().forceCleanup(); LOGGER.info("Removing all rows"); removeAllRows(); LOGGER.info("DBUnit: loading " + name + " into the database."); IDataSet data = loadDataSet(); LOGGER.info("DBUnit: loaded " + name + ", table names: " + Arrays.toString(data.getTableNames())); List<Throwable> errors = new ArrayList<Throwable>(); errors.clear(); try { populate(data); next.evaluate(); } catch (Throwable e) { errors.add(e); } MultipleFailureException.assertEmpty(errors); }
/** * Asserts that a list of throwables is empty. If it isn't empty, * will throw {@link MultipleFailureException} (if there are * multiple throwables in the list) or the first element in the list * (if there is only one element). * * @param errors list to check * @throws Exception or Error if the list is not empty */ @SuppressWarnings("deprecation") public static void assertEmpty(List<Throwable> errors) throws Exception { if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw Throwables.rethrowAsException(errors.get(0)); } /* * Many places in the code are documented to throw * org.junit.internal.runners.model.MultipleFailureException. * That class now extends this one, so we throw the internal * exception in case developers have tests that catch * MultipleFailureException. */ throw new org.junit.internal.runners.model.MultipleFailureException(errors); } }
/** * This method was inspired from an internal JUnit class * (EachTestNotifier#addFailure(Throwable)). * * @param notifier * the notifier * @param targetException * the target exception * @param description * the description */ protected final void addFailure(final RunNotifier notifier, final Throwable targetException, final Description description) { if (targetException instanceof MultipleFailureException) { MultipleFailureException mfe = (MultipleFailureException) targetException; for (Throwable each : mfe.getFailures()) { addFailure(notifier, each, description); } return; } notifier.fireTestFailure(new Failure(description, targetException)); }
/** * Asserts that a list of throwables is empty. If it isn't empty, * will throw {@link MultipleFailureException} (if there are * multiple throwables in the list) or the first element in the list * (if there is only one element). * * @param errors list to check * @throws Throwable if the list is not empty */ @SuppressWarnings("deprecation") public static void assertEmpty(List<Throwable> errors) throws Throwable { if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw errors.get(0); } /* * Many places in the code are documented to throw * org.junit.internal.runners.model.MultipleFailureException. * That class now extends this one, so we throw the internal * exception in case developers have tests that catch * MultipleFailureException. */ throw new org.junit.internal.runners.model.MultipleFailureException(errors); } }
} catch (Throwable t) { if (t instanceof MultipleFailureException) { t = ((MultipleFailureException) t).getFailures().get(0);
/** * Asserts that a list of throwables is empty. If it isn't empty, * will throw {@link MultipleFailureException} (if there are * multiple throwables in the list) or the first element in the list * (if there is only one element). * * @param errors list to check * @throws Throwable if the list is not empty */ @SuppressWarnings("deprecation") public static void assertEmpty(List<Throwable> errors) throws Throwable { if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw errors.get(0); } /* * Many places in the code are documented to throw * org.junit.internal.runners.model.MultipleFailureException. * That class now extends this one, so we throw the internal * exception in case developers have tests that catch * MultipleFailureException. */ throw new org.junit.internal.runners.model.MultipleFailureException(errors); } }
for (Throwable throwable : m.getFailures()) { log.warn("Multiple exception element", throwable);
/** * Asserts that a list of throwables is empty. If it isn't empty, * will throw {@link MultipleFailureException} (if there are * multiple throwables in the list) or the first element in the list * (if there is only one element). * * @param errors list to check * @throws Throwable if the list is not empty */ @SuppressWarnings("deprecation") public static void assertEmpty(List<Throwable> errors) throws Throwable { if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw errors.get(0); } /* * Many places in the code are documented to throw * org.junit.internal.runners.model.MultipleFailureException. * That class now extends this one, so we throw the internal * exception in case developers have tests that catch * MultipleFailureException. */ throw new org.junit.internal.runners.model.MultipleFailureException(errors); } }
for (Throwable throwable : m.getFailures()) { log.warn("Multiple exception element", throwable);
/** * A helper to safely execute multiple statements in one.<br/> * <p> * Will execute all statements even if they fail, all exceptions will be kept. If multiple {@link Statement}s * fail, a {@link MultipleFailureException} will be thrown. * * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a> * @version $Revision: $ */ private void multiExecute(Statement... statements) throws Throwable { List<Throwable> exceptions = new ArrayList<Throwable>(); for (Statement command : statements) { try { command.evaluate(); } catch (Throwable e) { exceptions.add(e); } } if (exceptions.isEmpty()) { return; } if (exceptions.size() == 1) { throw exceptions.get(0); } throw new MultipleFailureException(exceptions); }
/** * A helper to safely execute multiple statements in one.<br/> * * Will execute all statements even if they fail, all exceptions will be kept. If multiple {@link Statement}s fail, a * {@link MultipleFailureException} will be thrown. * * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a> * @version $Revision: $ */ private void multiExecute(Statement... statements) throws Throwable { List<Throwable> exceptions = new ArrayList<Throwable>(); for (Statement command : statements) { try { command.evaluate(); } catch (Exception e) { exceptions.add(e); } } if (exceptions.isEmpty()) { return; } if (exceptions.size() == 1) { throw exceptions.get(0); } throw new MultipleFailureException(exceptions); }
/** * Asserts that a list of throwables is empty. If it isn't empty, * will throw {@link MultipleFailureException} (if there are * multiple throwables in the list) or the first element in the list * (if there is only one element). * * @param errors list to check * @throws Exception or Error if the list is not empty */ @SuppressWarnings("deprecation") public static void assertEmpty(List<Throwable> errors) throws Exception { if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw Throwables.rethrowAsException(errors.get(0)); } /* * Many places in the code are documented to throw * org.junit.internal.runners.model.MultipleFailureException. * That class now extends this one, so we throw the internal * exception in case developers have tests that catch * MultipleFailureException. */ throw new org.junit.internal.runners.model.MultipleFailureException(errors); } }
/** * A helper to safely execute multiple statements in one.<br/> * <p> * Will execute all statements even if they fail, all exceptions will be kept. If multiple {@link Statement}s * fail, a {@link MultipleFailureException} will be thrown. * * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a> * @version $Revision: $ */ private void multiExecute(Statement... statements) throws Throwable { List<Throwable> exceptions = new ArrayList<Throwable>(); for (Statement command : statements) { try { command.evaluate(); } catch (Throwable e) { exceptions.add(e); } } if (exceptions.isEmpty()) { return; } if (exceptions.size() == 1) { throw exceptions.get(0); } throw new MultipleFailureException(exceptions); }
@Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<Throwable>(); errors.clear(); try { prev.evaluate(); } catch (Throwable e) { errors.add(e); } finally { for (Statement after : afters) { try { after.evaluate(); } catch (Throwable e) { errors.add(e); } } } if (!errors.isEmpty()) { throw new MultipleFailureException(errors); } } }
/** * Asserts that a list of throwables is empty. If it isn't empty, * will throw {@link MultipleFailureException} (if there are * multiple throwables in the list) or the first element in the list * (if there is only one element). * * @param errors list to check * @throws Exception or Error if the list is not empty */ @SuppressWarnings("deprecation") public static void assertEmpty(List<Throwable> errors) throws Exception { if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw Throwables.rethrowAsException(errors.get(0)); } /* * Many places in the code are documented to throw * org.junit.internal.runners.model.MultipleFailureException. * That class now extends this one, so we throw the internal * exception in case developers have tests that catch * MultipleFailureException. */ throw new org.junit.internal.runners.model.MultipleFailureException(errors); } }
@Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<Throwable>(); errors.clear(); try { prev.evaluate(); } catch (Throwable e) { errors.add(e); } finally { for (Statement after : afters) { try { after.evaluate(); } catch (Throwable e) { errors.add(e); } } } if (!errors.isEmpty()) { throw new MultipleFailureException(errors); } } }
@Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<Throwable>(); try { next.evaluate(); } catch (Throwable e) { errors.add(e); } finally { for (Map.Entry<Object, List<FrameworkMethod>> each : targetsToMethods.entrySet()) { for (FrameworkMethod after : each.getValue()) { try { after.invokeExplosively(each.getKey()); } catch (Throwable e) { errors.add(e); } } } } if (errors.isEmpty()) return; if (errors.size() == 1) throw errors.get(0); throw new MultipleFailureException(errors); }