Java 类org.junit.runners.model.MultipleFailureException 实例源码

项目:GitHub    文件:RunInLooperThread.java   
private Throwable cleanUp(Throwable testfailure) {
    try {
        after();
        return testfailure;
    } catch (Throwable afterFailure) {
        if (testfailure == null) {
            // Only after() threw an exception
            return afterFailure;
        }

        // Both TestHelper.awaitOrFail() and after() threw exceptions
        return new MultipleFailureException(Arrays.asList(testfailure, afterFailure)) {
            @Override
            public void printStackTrace(PrintStream out) {
                int i = 0;
                for (Throwable t : getFailures()) {
                    out.println("Error " + i + ": " + t.getMessage());
                    t.printStackTrace(out);
                    out.println();
                    i++;
                }
            }
        };
    }
}
项目:smart-testing    文件:TestBed.java   
private Statement statement(final Statement base, final Description description) {

        return new Statement() {
            public void evaluate() throws Throwable {
                before(description);
                try {
                    List<Throwable> errors = new ArrayList<>();

                    try {
                        base.evaluate();
                        succeededQuietly(description, errors);
                    } catch (Throwable e) {
                        errors.add(e);
                        failedQuietly(e, description, errors);
                    }
                    MultipleFailureException.assertEmpty(errors);
                } finally {
                    after();
                }
            }
        };
    }
项目:apiman-cli    文件:WaitForHttp.java   
@Override
public Statement apply(Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            final List<Throwable> errors = new ArrayList<>();

            starting();

            try {
                base.evaluate();
            } catch (Throwable e) {
                errors.add(e);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:flowable-engine    文件:FlowableDmnRule.java   
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:flowable-engine    文件:FlowableIdmRule.java   
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:flowable-engine    文件:ActivitiRule.java   
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:flowable-engine    文件:FlowableCmmnRule.java   
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:flowable-engine    文件:FlowableRule.java   
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:flowable-engine    文件:FlowableFormRule.java   
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:flowable-engine    文件:FlowableContentRule.java   
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:testcontainers-java    文件:FailureDetectingExternalResource.java   
@Override
public Statement apply(Statement base, Description description) {

    return new Statement() {
        @Override
        public void evaluate() throws Throwable {

            List<Throwable> errors = new ArrayList<Throwable>();

            try {
                starting(description);
                base.evaluate();
                succeeded(description);
            } catch (Throwable e) {
                errors.add(e);
                failed(e, description);
            } finally {
                finished(description);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:one-decision    文件:DecisionRule.java   
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:hifive-pitalium    文件:ParameterizedTestWatcher.java   
@Override
public Statement apply(final Statement base, final Description description, final Object[] params) {
    return new Statement() {
        public void evaluate() throws Throwable {
            ArrayList<Throwable> errors = new ArrayList<Throwable>();
            ParameterizedTestWatcher.this.startingQuietly(description, errors, params);

            try {
                base.evaluate();
                ParameterizedTestWatcher.this.succeededQuietly(description, errors, params);
            } catch (AssumptionViolatedException var7) {
                errors.add(var7);
                ParameterizedTestWatcher.this.skippedQuietly(var7, description, errors, params);
            } catch (Throwable var8) {
                errors.add(var8);
                ParameterizedTestWatcher.this.failedQuietly(var8, description, errors, params);
            } finally {
                ParameterizedTestWatcher.this.finishedQuietly(description, errors, params);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:sosiefier    文件:FailOnTimeout.java   
private Exception createTimeoutException(Thread thread) {
    StackTraceElement[] stackTrace = thread.getStackTrace();
    final Thread stuckThread = fLookForStuckThread ? getStuckThread(thread) : null;
    Exception currThreadException = new TestTimedOutException(fTimeout, fTimeUnit);
    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;
    }
}
项目:sosiefier    文件:MultipleFailureExceptionTest.java   
@Test
public void assertEmptyThrowsMutipleFailureExceptionForManyThrowables() throws Exception {
    List<Throwable> errors = new ArrayList<Throwable>();
    errors.add(new ExpectedException("basil"));
    errors.add(new RuntimeException("garlic"));

    try {
        MultipleFailureException.assertEmpty(errors);
        fail();
    } catch (MultipleFailureException expected) {
        assertThat(expected.getFailures(), equalTo(errors));
        assertTrue(expected.getMessage().startsWith("There were 2 errors:\n"));
        assertTrue(expected.getMessage().contains("ExpectedException(basil)\n"));
        assertTrue(expected.getMessage().contains("RuntimeException(garlic)"));
    }
}
项目:lcm    文件:TestWatcher.java   
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:es6draft    文件:MozillaJSTest.java   
@Before
public void setUp() throws Throwable {
    assumeTrue("Test disabled", test.isEnabled());

    realm.initialize(new NullConsole(), test);
    realm.get().createGlobalProperties(new Print(), Print.class);
    exceptionHandler.setExecutionContext(realm.get().defaultContext());

    // Apply scripted conditions
    scriptConditions();

    // Filter disabled tests (may have changed after applying scripted conditions)
    assumeTrue("Test disabled", test.isEnabled());

    if (test.negative) {
        expected.expect(
                Matchers.either(StandardErrorHandler.defaultMatcher()).or(ScriptExceptionHandler.defaultMatcher())
                        .or(Matchers.instanceOf(MultipleFailureException.class)));
    } else {
        errorHandler.match(StandardErrorHandler.defaultMatcher());
        exceptionHandler.match(ScriptExceptionHandler.defaultMatcher());
    }
}
项目:es6draft    文件:WebKitTest.java   
@Before
public void setUp() throws Throwable {
    assumeTrue("Test disabled", test.isEnabled());

    realm.initialize(new NullConsole(), test);
    realm.get().createGlobalProperties(new Print(), Print.class);
    exceptionHandler.setExecutionContext(realm.get().defaultContext());

    if (test.negative) {
        expected.expect(
                Matchers.either(StandardErrorHandler.defaultMatcher()).or(ScriptExceptionHandler.defaultMatcher())
                        .or(Matchers.instanceOf(MultipleFailureException.class)));
    } else {
        errorHandler.match(StandardErrorHandler.defaultMatcher());
        exceptionHandler.match(ScriptExceptionHandler.defaultMatcher());
    }
}
项目:assertj-core    文件:JUnitSoftAssertionsFailureTest.java   
@Test
public void should_report_all_errors() throws Throwable {
  try {
    softly.assertThat(1).isEqualTo(1);
    softly.assertThat(1).isEqualTo(2);
    softly.assertThat(Lists.newArrayList(1, 2)).containsOnly(1, 3);
    MultipleFailureException.assertEmpty(softly.errorsCollected());
    fail("Should not reach here");
  } catch (MultipleFailureException e) {
    List<Throwable> failures = e.getFailures();

    assertThat(failures).hasSize(2);
    assertThat(failures.get(0).getMessage()).startsWith("expected:<[2]> but was:<[1]>");
    assertThat(failures.get(1).getMessage()).startsWith(format("%n" +
                                                               "Expecting:%n" +
                                                               "  <[1, 2]>%n" +
                                                               "to contain only:%n" +
                                                               "  <[1, 3]>%n" +
                                                               "elements not found:%n" +
                                                               "  <[3]>%n" +
                                                               "and elements not expected:%n" +
                                                               "  <[2]>%n"));
  }
}
项目:assertj-core    文件:JUnitBDDSoftAssertionsFailureTest.java   
@Test
public void should_report_all_errors() throws Throwable {
  try {
    softly.then(1).isEqualTo(1);
    softly.then(1).isEqualTo(2);
    softly.then(Lists.newArrayList(1, 2)).containsOnly(1, 3);
    MultipleFailureException.assertEmpty(softly.getErrors());
    fail("Should not reach here");
  } catch (MultipleFailureException e) {
    List<Throwable> failures = e.getFailures();
    assertThat(failures).hasSize(2)
                        .extracting("message")
                        .contains("expected:<[2]> but was:<[1]>",
                                  format("%n" +
                                         "Expecting:%n" +
                                         "  <[1, 2]>%n" +
                                         "to contain only:%n" +
                                         "  <[1, 3]>%n" +
                                         "elements not found:%n" +
                                         "  <[3]>%n" +
                                         "and elements not expected:%n" +
                                         "  <[2]>%n"));
  }
}
项目:assertj-core    文件:Java6JUnitSoftAssertionsFailureTest.java   
@Test
public void should_report_all_errors() throws Throwable {
  try {
    softly.assertThat(1).isEqualTo(1);
    softly.assertThat(1).isEqualTo(2);
    softly.assertThat(Lists.newArrayList(1, 2)).containsOnly(1, 3);
    MultipleFailureException.assertEmpty(softly.errorsCollected());
    fail("Should not reach here");
  } catch (MultipleFailureException e) {
    List<Throwable> failures = e.getFailures();

    assertThat(failures).hasSize(2);
    assertThat(failures.get(0)).hasMessageContaining("expected:<[2]> but was:<[1]>");
    assertThat(failures.get(1)).hasMessageContaining(format("%n" +
                                                            "Expecting:%n" +
                                                            "  <[1, 2]>%n" +
                                                            "to contain only:%n" +
                                                            "  <[1, 3]>%n" +
                                                            "elements not found:%n" +
                                                            "  <[3]>%n" +
                                                            "and elements not expected:%n" +
                                                            "  <[2]>%n"));
  }
}
项目:spliceengine    文件:TableRule.java   
@Override
public org.junit.runners.model.Statement apply(final org.junit.runners.model.Statement base,
                                               Description description){

    return new org.junit.runners.model.Statement(){
        @Override
        public void evaluate() throws Throwable{
            try{
                setup();
            }catch(SQLException e){
                throw new SetupFailureException(e);
            }
            List<Throwable> errors = new LinkedList<>();
            try{
                base.evaluate();
            }catch(Throwable t){
                errors.add(t);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:spliceengine    文件:SpliceWatcher.java   
private void closeResultSets() {
    List<Throwable> t = Lists.newArrayListWithExpectedSize(0);
    for (ResultSet r : resultSets) {
        try {
            if (!r.isClosed()) {
                r.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            t.add(e);
        }
    }
    try {
        MultipleFailureException.assertEmpty(t);
    } catch (Throwable throwable) {
        throw new RuntimeException(throwable);
    }
}
项目:junit    文件:TestWatcher.java   
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:junit    文件:MultipleFailureExceptionTest.java   
@Test
public void assertEmptyThrowsMutipleFailureExceptionForManyThrowables() throws Throwable {
    List<Throwable> errors = new ArrayList<Throwable>();
    errors.add(new ExpectedException("basil"));
    errors.add(new RuntimeException("garlic"));

    try {
        MultipleFailureException.assertEmpty(errors);
        fail();
    } catch (MultipleFailureException expected) {
        assertThat(expected.getFailures(), equalTo(errors));
        assertTrue(expected.getMessage().startsWith("There were 2 errors:\n"));
        assertTrue(expected.getMessage().contains("ExpectedException(basil)\n"));
        assertTrue(expected.getMessage().contains("RuntimeException(garlic)"));
    }
}
项目:org.openntf.domino    文件:TestWatcher.java   
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:health-and-care-developer-network    文件:MultipleFailureExceptionTest.java   
@Test
public void assertEmptyThrowsMutipleFailureExceptionForManyThrowables() throws Throwable {
    List<Throwable> errors = new ArrayList<Throwable>();
    errors.add(new ExpectedException("basil"));
    errors.add(new RuntimeException("garlic"));

    try {
        MultipleFailureException.assertEmpty(errors);
        fail();
    } catch (MultipleFailureException expected) {
        assertThat(expected.getFailures(), equalTo(errors));
        assertTrue(expected.getMessage().startsWith("There were 2 errors:\n"));
        assertTrue(expected.getMessage().contains("ExpectedException(basil)\n"));
        assertTrue(expected.getMessage().contains("RuntimeException(garlic)"));
    }
}
项目:testcontainers-junit    文件:GenericContainerRule.java   
/** {@inheritDoc} */
@Override
public Statement apply(Statement base, Description description) {
    container = containerSupplier.get();
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();
            try {
                beforeStart(container);
                container.start();
                afterStart(container);
                beforeTest(container);
                base.evaluate();
                afterTest(container);
            } catch (Exception e) {
                errors.add(e);
                error(e);
            } finally {
                beforeStop(container);
                container.stop();
                afterStop(container);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
项目:dsl-devkit    文件:MultipleTestProblems.java   
/**
 * Adds a new problem.
 *
 * @param problem
 *          the {@link Throwable} to be added, must not be {@code null}
 */
public final void addProblem(final Throwable problem) {
  if (problem instanceof MultipleTestProblems) {
    addProblems((MultipleTestProblems) problem);
  } else if (problem instanceof MultipleFailureException) {
    addProblems(((MultipleFailureException) problem).getFailures());
  } else {
    problems.add(problem);
  }
}
项目:putput    文件:JUnitSoftAssertions.java   
/**
 * TestRule implementation that verifies that no proxied assertion methods have failed.
 */
public Statement apply(final Statement base, Description description) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      base.evaluate();
      MultipleFailureException.assertEmpty(collector.errors());
    }
  };
}
项目:nexus-public    文件:PurgeUnusedFacetImplTest.java   
@Test
public void testCancellable() throws Exception {
  // infinite item loops
  when(componentDocsIterator.hasNext()).thenReturn(true);
  when(componentDocsIterator.next()).thenReturn(mock(ODocument.class));
  when(assetIterator.hasNext()).thenReturn(true);
  when(assetIterator.next()).thenReturn(mock(Asset.class));

  List<Runnable> cancelables = Arrays.asList(
      () -> underTest.deleteUnusedComponents(new Date()),
      () -> underTest.deleteUnusedAssets(new Date())
  );

  for (Runnable cancelable : cancelables) {
    AtomicBoolean canceled = new AtomicBoolean(false);
    Thread t = createTaskThread(cancelable, canceled);
    t.start();

    sleep((long) (Math.random() * 1000)); // sleep for up to a second (emulate task running)
    canceled.set(true); // cancel the task
    t.join(5000); // ensure task thread ends

    if (t.isAlive()) {
      fail("Task did not cancel");
    }

    if (uncaught.size() > 0) {
      throw new MultipleFailureException(uncaught);
    }
  }
}
项目:mesos-rxjava    文件:AsyncTest.java   
@Test
public void multipleExceptionReportedWhenTheyOccur() {
    final Async async = new Async();
    final IllegalStateException exception1 = new IllegalStateException("exception-1");
    final IllegalStateException exception2 = new IllegalStateException("exception-2");
    final IllegalStateException exception3 = new IllegalStateException("exception-3");
    async.run(() -> {
        throw exception1;
    });
    async.run(() -> {
        throw exception2;
    });
    async.run(() -> {
        throw exception3;
    });

    try {
        async.verify();
        fail("Exception should have been thrown in verify");
    } catch (MultipleFailureException mfe) {
        final Set<String> errorMessages = mfe.getFailures().stream()
            .map(Throwable::getCause)
            .map(Throwable::getMessage)
            .collect(Collectors.toSet());
        assertThat(errorMessages).isEqualTo(Sets.newHashSet("exception-1", "exception-2", "exception-3"));
        assertThat(mfe.getMessage()).contains("Error while running Async: exception-1");
    } catch (Throwable e) {
        fail("Expected MultipleFailureException but got: " + e.getClass().getName());
    }
}
项目:sosiefier    文件:EachTestNotifier.java   
public void addFailure(Throwable targetException) {
    if (targetException instanceof MultipleFailureException) {
        addMultipleFailureException((MultipleFailureException) targetException);
    } else {
        fNotifier
                .fireTestFailure(new Failure(fDescription, targetException));
    }
}
项目:sosiefier    文件:MultipleFailureExceptionTest.java   
@Test
public void assertEmptyRethrowsSingleRuntimeException() throws Exception {
    Throwable exception= new ExpectedException("pesto");
    List<Throwable> errors= Collections.singletonList(exception);
    try {
        MultipleFailureException.assertEmpty(errors);
        fail();
    } catch (ExpectedException e) {
        assertSame(e, exception);
    }
}
项目:sosiefier    文件:MultipleFailureExceptionTest.java   
@Test
public void assertEmptyRethrowsSingleError() throws Exception {
    Throwable exception= new AnnotationFormatError("changeo");
    List<Throwable> errors= Collections.singletonList(exception);
    try {
        MultipleFailureException.assertEmpty(errors);
        fail();
    } catch (AnnotationFormatError e) {
        assertSame(e, exception);
    }
}
项目:c5-replicator    文件:AsyncChannelAsserts.java   
private static <T> void helper(ChannelListener<T> listener,
                               Matcher<? super T> matcher,
                               boolean assertFail) throws Throwable {

  List<T> received = new ArrayList<>();
  while (true) {
    T msg = listener.messages.poll(5, TimeUnit.SECONDS);

    if (msg == null) {
      Description d = new StringDescription();
      matcher.describeTo(d);

      if (!received.isEmpty()) {
        d.appendText("we received messages:");
      }

      for (T m : received) {
        matcher.describeMismatch(m, d);
      }

      if (assertFail) {
        listener.throwables.add(new AssertionError("Failing waiting for " + d.toString()));
        MultipleFailureException.assertEmpty(listener.throwables);
      }

      return;
    }

    if (matcher.matches(msg)) {
      if (!listener.throwables.isEmpty()) {
        MultipleFailureException.assertEmpty(listener.throwables);
      }

      return;
    }

    received.add(msg);
  }
}
项目:c5-replicator    文件:JUnitRuleFiberExceptions.java   
@Override
public Statement apply(final Statement base, Description description) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      try {
        base.evaluate();
      } catch (Throwable t) {
        throwables.add(t);
      }
      MultipleFailureException.assertEmpty(throwables);
    }
  };
}
项目:JGiven    文件:JGivenMethodRule.java   
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();
}
项目:lcm    文件:EachTestNotifier.java   
public void addFailure(Throwable targetException) {
    if (targetException instanceof MultipleFailureException) {
        addMultipleFailureException((MultipleFailureException) targetException);
    } else {
        fNotifier
                .fireTestFailure(new Failure(fDescription, targetException));
    }
}
项目:arquillian-cube    文件:NetworkDslRule.java   
@Override
public Statement apply(Statement base, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();
            network = networkBuilder.build();

            final org.arquillian.cube.docker.impl.client.config.Network dockerNetwork = network.getNetwork();
            String networkId = null;
            try {

                networkId = dockerClientExecutor.createNetwork(network.getId(), dockerNetwork);
                dockerNetwork.addMetadata(IsNetworkContainerObject.class, new IsNetworkContainerObject());

                base.evaluate();

            } catch (Throwable t) {
                errors.add(t);
            } finally {
                if (networkId != null) {
                    dockerClientExecutor.removeNetwork(networkId);
                }
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}