public void validateCollectedErrors() throws MultipleFailureException { if (errorCollectionEnabled){ if (!throwables.isEmpty()){ throw new MultipleFailureException(throwables); } } } }
public static void throwAll(List<? extends Throwable> exceptions) throws Throwable { if (exceptions.isEmpty()) return; if (exceptions.size() == 1) throw exceptions.get(0); List<Throwable> unrolled = new ArrayList<>(); for (Throwable exception : exceptions) { if (exception instanceof MultipleFailureException) unrolled.addAll(((MultipleFailureException) exception).getFailures()); else unrolled.add(exception); } throw new MultipleFailureException(unrolled); } }
private Exception createTimeoutException(Thread thread) { StackTraceElement[] stackTrace = thread.getStackTrace(); final Thread stuckThread = lookForStuckThread ? getStuckThread(thread) : null; Exception currThreadException = new TestTimedOutException(timeout, timeUnit); if (stackTrace != null) { currThreadException.setStackTrace(stackTrace); thread.interrupt(); } if (stuckThread != null) { Exception stuckThreadException = new Exception("Appears to be stuck in thread " + stuckThread.getName()); stuckThreadException.setStackTrace(getStackTrace(stuckThread)); return new MultipleFailureException( Arrays.<Throwable>asList(currThreadException, stuckThreadException)); } else { return currThreadException; } }
@Override public void intercept(IMethodInvocation invocation) throws Throwable { List<Throwable> throwableList = new ArrayList<>(); for (int i = 0; i <= retry.count(); i++) { Queue<Throwable> throwables = new ConcurrentLinkedQueue<>(); invocation.getFeature().getFeatureMethod().addInterceptor(new InnerRetryInterceptor(retry, condition, throwables)); invocation.proceed(); if (throwables.isEmpty()) { throwableList.clear(); break; } else { throwableList.addAll(throwables); if (retry.delay() > 0) Thread.sleep(retry.delay()); } } if (!throwableList.isEmpty()) { throw new MultipleFailureException(throwableList); } }
protected void handleInvocation(IMethodInvocation invocation) throws Throwable { List<Throwable> throwables = new ArrayList<>(retry.count() + 1); for (int i = 0; i <= retry.count(); i++) { try { invocation.proceed(); return; } catch (Throwable e) { if (isExpected(invocation, e)) { throwables.add(e); if (retry.delay() > 0) { Thread.sleep(retry.delay()); } continue; } else { throw e; } } } throw new MultipleFailureException(throwables); } }
private Exception createTimeoutException(Thread thread) { StackTraceElement[] stackTrace = thread.getStackTrace(); Exception currThreadException = new TestTimedOutException(timeout, timeUnit); if (stackTrace != null) { currThreadException.setStackTrace(stackTrace); thread.interrupt(); } Exception stuckThreadException = getStuckThreadException(thread); Exception deadlockException = getDeadlockedThreadsException(); if (stuckThreadException != null || deadlockException != null) { List<Throwable> exceptions = Stream .of(currThreadException, stuckThreadException, deadlockException) .filter(Objects::nonNull) .collect(Collectors.toList()); return new MultipleFailureException(exceptions); } else { return currThreadException; } }
@Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<Throwable>(); try { next.evaluate(); } catch (Throwable e) { errors.add(e); } try { app.stop(); } catch (Exception ex) { errors.add(ex); } if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw errors.get(0); } throw new MultipleFailureException(errors); } };
throw new MultipleFailureException( failures );
public void getContextTest(boolean persistent) throws InterruptedException, MultipleFailureException { final ContextCheckJob addedJob = new ContextCheckJob(new Params(1).setPersistent(persistent)); final JobManager jobManager = createJobManager(); waitUntilAJobIsDone(jobManager, new WaitUntilCallback() { @Override public void run() { jobManager.addJob(addedJob); } @Override public void assertJob(Job job) { } }); if (!errors.isEmpty()) { throw new MultipleFailureException(errors); } }
@Override protected Exception newMultipleFailureException(final List<Throwable> errors) { return new MultipleFailureException(errors); }
/** * Asserts no Errors are on a {@link Response} from lightblue. * * @param response - {@link Response} to check. * @throws MultipleFailureException */ public static void assertNoErrors(Response response) throws MultipleFailureException { List<Throwable> errors = new ArrayList<Throwable>(response.getErrors()); if (!errors.isEmpty()) { throw new MultipleFailureException(errors); } }
/** * Asserts no DataErrors are on a {@link Response} from lightblue. * * @param response - {@link Response} to check. * @throws MultipleFailureException */ public static void assertNoDataErrors(Response response) throws MultipleFailureException { List<Throwable> errors = new ArrayList<>(); for (DataError error : response.getDataErrors()) { errors.add(new Exception("DataError: " + error.toJson().toString())); } if (!errors.isEmpty()) { throw new MultipleFailureException(errors); } }
private void finishExecutors() throws InterruptedException, MultipleFailureException { mTaskExecutor.shutdown(10); final List<Throwable> errors = mTaskExecutor.getErrors(); if (!errors.isEmpty()) { throw new MultipleFailureException(errors); } } }
private void finishExecutors() throws InterruptedException, MultipleFailureException { mTaskExecutor.shutdown(10); final List<Throwable> errors = mTaskExecutor.getErrors(); if (!errors.isEmpty()) { throw new MultipleFailureException(errors); } } }
@Override public void evaluate() throws Throwable { List<Throwable> cumulative = new ArrayList<Throwable>(); try { beforeAfters.evaluate(); } catch (Throwable t) { cumulative.add(t); } // All @Afters must be called. for (Method m : afters) { try { invoke(m, instance); } catch (Throwable t) { cumulative.add(t); } } // At end, throw the exception or propagete. if (cumulative.size() == 1) { throw cumulative.get(0); } else if (cumulative.size() > 1) { throw new MultipleFailureException(cumulative); } } };
/** * Clients may override this method to add additional behavior when a {@link InitializationError} is raised. * The call of this method is guaranteed. * * @param notifier the notifier * @param e the error */ protected void whenInitializationErrorIsRaised(final EachTestNotifier notifier, final InitializationError e) { notifier.addFailure(new MultipleFailureException(e.getCauses())); }
private Exception createTimeoutException(Thread thread) { StackTraceElement[] stackTrace = thread.getStackTrace(); final Thread stuckThread = lookForStuckThread ? getStuckThread(thread) : null; Exception currThreadException = new TestTimedOutException(timeout, timeUnit); if (stackTrace != null) { currThreadException.setStackTrace(stackTrace); thread.interrupt(); } if (stuckThread != null) { Exception stuckThreadException = new Exception ("Appears to be stuck in thread " + stuckThread.getName()); stuckThreadException.setStackTrace(getStackTrace(stuckThread)); return new MultipleFailureException( Arrays.<Throwable>asList(currThreadException, stuckThreadException)); } else { return currThreadException; } }
private Exception createTimeoutException(Thread thread) { StackTraceElement[] stackTrace = thread.getStackTrace(); final Thread stuckThread = lookForStuckThread ? getStuckThread(thread) : null; Exception currThreadException = new TestTimedOutException(timeout, timeUnit); if (stackTrace != null) { currThreadException.setStackTrace(stackTrace); thread.interrupt(); } if (stuckThread != null) { Exception stuckThreadException = new Exception ("Appears to be stuck in thread " + stuckThread.getName()); stuckThreadException.setStackTrace(getStackTrace(stuckThread)); return new MultipleFailureException( Arrays.<Throwable>asList(currThreadException, stuckThreadException)); } else { return currThreadException; } }
private Exception createTimeoutException(Thread thread) { StackTraceElement[] stackTrace = thread.getStackTrace(); final Thread stuckThread = lookForStuckThread ? getStuckThread(thread) : null; Exception currThreadException = new TestTimedOutException(timeout, timeUnit); if (stackTrace != null) { currThreadException.setStackTrace(stackTrace); thread.interrupt(); } if (stuckThread != null) { Exception stuckThreadException = new Exception ("Appears to be stuck in thread " + stuckThread.getName()); stuckThreadException.setStackTrace(getStackTrace(stuckThread)); return new MultipleFailureException( Arrays.<Throwable>asList(currThreadException, stuckThreadException)); } else { return currThreadException; } }
protected void failed( Throwable e ) throws Throwable { if( scenario.getExecutor().hasFailed() ) { Throwable failedException = scenario.getExecutor().getFailedException(); List<Throwable> errors = Lists.newArrayList( failedException, e ); scenario.getExecutor().setFailedException( new MultipleFailureException( errors ) ); } else { scenario.getExecutor().failed( e ); } scenario.finished(); }