error.addSuppressed( recentFree );
boolean onSignal(Signal<T> actualSignal) { SignalEvent<T> signalEvent = (SignalEvent<T>) this.script.poll(); Optional<AssertionError> error = signalEvent.test(actualSignal); if (error.isPresent()) { Exceptions.addThrowable(ERRORS, this, error.get()); // #55 ensure the onError is added as a suppressed to the AssertionError if(actualSignal.isOnError()) { error.get().addSuppressed(actualSignal.getThrowable()); } maybeCancel(actualSignal); this.completeLatch.countDown(); return true; } if (actualSignal.isOnNext()) { unasserted--; } return false; }
final boolean onSignalCount(Signal<T> actualSignal, SignalCountEvent<T> event) { if (unasserted >= event.count) { this.script.poll(); unasserted -= event.count; } else { if (event.count != 0) { Optional<AssertionError> error = this.checkCountMismatch(event, actualSignal); if (error.isPresent()) { Exceptions.addThrowable(ERRORS, this, error.get()); if(actualSignal.isOnError()) { // #55 ensure the onError is added as a suppressed to the AssertionError error.get().addSuppressed(actualSignal.getThrowable()); } maybeCancel(actualSignal); this.completeLatch.countDown(); } } return true; } return false; }
/** * Prepares and throws an AssertionError exception based on the message, cause, the * active state and the potential errors so far. * * @param message the message * @param cause the optional Throwable cause * * @throws AssertionError as expected */ protected final void assertionError(String message, Throwable cause) { StringBuilder b = new StringBuilder(); if (cdl.getCount() != 0) { b.append("(active) "); } b.append(message); List<Throwable> err = errors; if (!err.isEmpty()) { b.append(" (+ ") .append(err.size()) .append(" errors)"); } AssertionError e = new AssertionError(b.toString(), cause); for (Throwable t : err) { e.addSuppressed(t); } throw e; }
if(actualSignal.isOnError()) { error.get().addSuppressed(actualSignal.getThrowable());
.getName(), msg).get(); wrapFailure.addSuppressed(e); Exceptions.addThrowable(ERRORS, this, wrapFailure);
error.addSuppressed( throwable );
/** * Prepares and throws an AssertionError exception based on the message, cause, the active state and the potential * errors so far. * * @param message the message * @param cause the optional Throwable cause * @throws AssertionError as expected */ final void assertionError(String message) { StringBuilder b = new StringBuilder(); if (cdl.getCount() != 0) { b.append("(active) "); } b.append(message); List<Throwable> err = errors; if (!err.isEmpty()) { b.append(" (+ ") .append(err.size()) .append(" errors)"); } b.append("; values = ").append(volatileSize); AssertionError e = new AssertionError(b.toString()); for (Throwable t : err) { e.addSuppressed(t); } throw e; }
@Override public synchronized void close() throws IOException { if (openSearchers.isEmpty() == false) { AssertionError error = new AssertionError("Unreleased searchers found"); for (RuntimeException ex : openSearchers.values()) { error.addSuppressed(ex); } throw error; } }
protected void apply(Iterable<Holder> holders, Callable callable) { AssertionError errors = new AssertionError("invoke on features error " + holders); for (Holder each : holders) { try { callable.call(each); } catch (AssumptionViolatedException cause) { throw cause; } catch (Throwable cause) { errors.addSuppressed(cause); if (cause instanceof InterruptedException) { Thread.currentThread().interrupt(); throw new AssertionError("Interrupted on invoke features", errors); } } } if (errors.getSuppressed().length > 0) { throw errors; } }
@Override public void testRunFinished(final Result result) { List<UncaughtExceptionDetail> exceptions = uncaughtExceptionHandler.getUncaughtExceptions(); if (!exceptions.isEmpty()) { AssertionError assertionError = new AssertionError("Uncaught exceptions encountered " + exceptions); for (UncaughtExceptionDetail ex : exceptions) { Throwable throwable = ex.getThrowable(); assertionError.addSuppressed(throwable); LOG.info("Uncaught exceptions, failures = {} in thread {}", result.getFailures(), ex.getThread(), throwable); } throw assertionError; } }
final boolean onSignalCount(Signal<T> actualSignal, SignalCountEvent<T> event) { if (unasserted >= event.count) { this.script.poll(); unasserted -= event.count; } else { if (event.count != 0) { Optional<AssertionError> error = this.checkCountMismatch(event, actualSignal); if (error.isPresent()) { Exceptions.addThrowable(ERRORS, this, error.get()); if(actualSignal.isOnError()) { // #55 ensure the onError is added as a suppressed to the AssertionError error.get().addSuppressed(actualSignal.getThrowable()); } maybeCancel(actualSignal); this.completeLatch.countDown(); } } return true; } return false; }
boolean onSignal(Signal<T> actualSignal) { SignalEvent<T> signalEvent = (SignalEvent<T>) this.script.poll(); Optional<AssertionError> error = signalEvent.test(actualSignal); if (error.isPresent()) { Exceptions.addThrowable(ERRORS, this, error.get()); // #55 ensure the onError is added as a suppressed to the AssertionError if(actualSignal.isOnError()) { error.get().addSuppressed(actualSignal.getThrowable()); } maybeCancel(actualSignal); this.completeLatch.countDown(); return true; } if (actualSignal.isOnNext()) { unasserted--; } return false; }
private void handleUncaughtExceptions(final Description description, @WillNotClose final Collection<TestLogRecord> logs) { List<UncaughtExceptionDetail> exceptions = uncaughtExceptionHandler.getUncaughtExceptions(); if (!exceptions.isEmpty()) { AssertionError assertionError = new AssertionError("Uncaught exceptions encountered " + exceptions); for (UncaughtExceptionDetail ex : exceptions) { Throwable throwable = ex.getThrowable(); LOG.info("Uncaught exceptions during {} in thread {}", description, ex.getThread(), ex.getThrowable()); assertionError.addSuppressed(throwable); } dumpDebugInfo(logs, description); throw assertionError; } }
@Override public void afterRun(FeaturesRunner runner) { waitForAsyncCompletion(); // fulltext and various workers if (granularity != Granularity.METHOD) { cleanupSession(runner); } if (session != null) { releaseCoreSession(); } List<CoreSessionRegistrationInfo> leakedInfos = Framework.getService(CoreSessionService.class) .getCoreSessionRegistrationInfos(); if (leakedInfos.size() == 0) { return; } AssertionError leakedErrors = new AssertionError(String.format("leaked %d sessions", leakedInfos.size())); for (CoreSessionRegistrationInfo info : leakedInfos) { try { ((CloseableCoreSession) info.getCoreSession()).close(); leakedErrors.addSuppressed(info); } catch (RuntimeException cause) { leakedErrors.addSuppressed(cause); } } throw leakedErrors; }
private static void handleException(String message, Class<? extends Exception> expected, String containedInMessage, Exception actual) { try { Assert.assertEquals(message, expected, actual.getClass()); Assert.assertTrue( "Expected exception message (" + containedInMessage + ") missing: " + actual.getMessage(), actual.getMessage().contains(containedInMessage) ); } catch (AssertionError e) { e.addSuppressed(actual); throw e; } }
private static void handleException(String message, Class<? extends Exception> expected, String containedInMessage, Exception actual) { try { Assert.assertEquals(message, expected, actual.getClass()); Assert.assertTrue( "Expected exception message (" + containedInMessage + ") missing: " + actual.getMessage(), actual.getMessage().contains(containedInMessage) ); } catch (AssertionError e) { e.addSuppressed(actual); throw e; } } }
private static void handleException(String message, Class<? extends Exception> expected, String containedInMessage, Exception actual) { try { Assert.assertEquals(message, expected, actual.getClass()); Assert.assertTrue( "Expected exception message (" + containedInMessage + ") missing: " + actual.getMessage(), actual.getMessage().contains(containedInMessage) ); } catch (AssertionError e) { e.addSuppressed(actual); throw e; } } }
public static void assertEventuallyTrue(final String message, final Block runnable, final long timeoutInMs) { final long endTime = System.currentTimeMillis() + timeoutInMs; Throwable lastThrowable; do { try { runnable.run(); return; } catch (final Throwable ex) { lastThrowable = ex; } Thread.yield(); } while (System.currentTimeMillis() < endTime); final AssertionError error = new AssertionError(message); error.addSuppressed(lastThrowable); throw error; }
/** * Utility method which tests given query produces a {@link UserException} and the exception message contains * the given message. * @param testSqlQuery Test query * @param expectedErrorMsg Expected error message. */ protected static void errorMsgTestHelper(final String testSqlQuery, final String expectedErrorMsg) throws Exception { try { test(testSqlQuery); fail("Expected a UserException when running " + testSqlQuery); } catch (final Exception actualException) { try { Assert.assertThat(actualException.getMessage(), CoreMatchers.containsString(expectedErrorMsg)); } catch (AssertionError e) { e.addSuppressed(actualException); throw e; } } }