private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
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 void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
private int handleMultipleFailures(ErrorInfo error) { MultipleFailureException multiFailure = (MultipleFailureException) error.getException(); int runStatus = OK; for (Throwable failure : multiFailure.getFailures()) runStatus = error(new ErrorInfo(error.getMethod(), failure)); return runStatus; }
if ( err instanceof MultipleFailureException ) failures.addAll( ( (MultipleFailureException) err ).getFailures() );
for ( Throwable failure : multipleFailures.getFailures() )
@Test @Parameters({"EXECUTE_IN_SERIES", "EXECUTE_IN_PARALLEL"}) public void deadlocksGetResolved(Execution execution) { final AtomicBoolean lock1 = new AtomicBoolean(); final AtomicBoolean lock2 = new AtomicBoolean(); concurrencyRule.add(() -> { await().until(() -> lock2.equals(Boolean.TRUE)); lock1.set(true); return null; }); concurrencyRule.add(() -> { await().until(() -> lock1.equals(Boolean.TRUE)); lock2.set(true); return null; }); concurrencyRule.setTimeout(Duration.ofSeconds(1)); Throwable thrown = catchThrowable(() -> execution.execute(concurrencyRule)); Throwable cause = thrown.getCause(); assertThat(thrown).isInstanceOf(RuntimeException.class); assertThat(cause).isInstanceOf(MultipleFailureException.class); assertThat(((MultipleFailureException) cause).getFailures()) .hasSize(2) .hasOnlyElementsOfType(TimeoutException.class); }
@Test @Parameters({"EXECUTE_IN_SERIES", "EXECUTE_IN_PARALLEL"}) public void runManyThreads(Execution execution) { Callable<Void> exceptionCallable = () -> { throw new IOException("foo"); }; Callable<String> valueCallable = () -> { return "successful value"; }; Callable<Void> setInvokedCallable = () -> { invoked.set(true); return null; }; concurrencyRule.add(exceptionCallable).expectException(new NullPointerException("foo")); concurrencyRule.add(exceptionCallable).expectException(new IOException("foo")); concurrencyRule.add(valueCallable).expectValue("successful value"); concurrencyRule.add(valueCallable).expectValue("wrong value"); concurrencyRule.add(setInvokedCallable); concurrencyRule.add(exceptionCallable); Throwable thrown = catchThrowable(() -> execution.execute(concurrencyRule)); List<Throwable> errors = ((MultipleFailureException) thrown.getCause()).getFailures(); assertThat(errors).hasSize(3); assertThat(errors.get(0)).isInstanceOf(AssertionError.class) .hasMessageContaining(IOException.class.getName()); assertThat(errors.get(1)).isInstanceOf(AssertionError.class) .hasMessageContaining("[successful] value") .hasMessageContaining("[wrong] value"); assertThat(errors.get(2)).hasMessageContaining("foo") .isInstanceOf(IOException.class); }
@Test @Parameters({"EXECUTE_IN_SERIES", "EXECUTE_IN_PARALLEL"}) public void timeoutValueIsRespected(Execution execution) { Callable<Void> c1 = () -> { Thread.sleep(5000); return null; }; concurrencyRule.setTimeout(Duration.ofSeconds(1)); concurrencyRule.add(c1); concurrencyRule.add(c1); await("timeout is respected").until(() -> { Throwable thrown = catchThrowable(() -> execution.execute(concurrencyRule)); assertThat(((MultipleFailureException) thrown.getCause()).getFailures()).hasSize(2) .hasOnlyElementsOfType(TimeoutException.class); return true; }); }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
private void addMultipleFailureException(MultipleFailureException mfe) { mfe.getFailures().stream().forEach((each) -> { addFailure(each); }); }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
public void addFailure(Throwable throwable) { if (throwable instanceof MultipleFailureException) { MultipleFailureException exception = (MultipleFailureException) throwable; exception.getFailures().stream() .forEach(this::addFailure); } else { Failure failure = new Failure(testDescription, throwable); fireTestFailure(failure); } } }
private void fireTestFailure(RunNotifier notifier, Description description, Throwable t) { if (t instanceof MultipleFailureException) { for (Throwable nested : ((MultipleFailureException) t).getFailures()) { fireTestFailure(notifier, description, nested); } } else { notifier.fireTestFailure(new Failure(description, t)); } }
private void fireTestFailure(RunNotifier notifier, Description description, Throwable t) { if (t instanceof MultipleFailureException) { for (Throwable nested : ((MultipleFailureException) t).getFailures()) { fireTestFailure(notifier, description, nested); } } else { notifier.fireTestFailure(new Failure(description, t)); } }
@Override public void failed(final Throwable e, final Description desc) { if (e instanceof MultipleFailureException) { MultipleFailureException mfe = (MultipleFailureException) e; log("{} FAILED {} {}", prefix(desc), e, mfe.getFailures()); } else { log("{} FAILED", prefix(desc), e); } }