Refine search
private Throwable evaluateSafely(Statement base) { try { base.evaluate(); return null; } catch (Throwable throwable) { return throwable; } } };
private Statement methodCompletesWithParameters( final FrameworkMethod method, final Assignments complete, final Object freshInstance) { return new Statement() { @Override public void evaluate() throws Throwable { final Object[] values = complete.getMethodArguments(); if (!nullsOk()) { Assume.assumeNotNull(values); } method.invokeExplosively(freshInstance, values); } }; }
@Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<Throwable>(); startingQuietly(description, errors); try { base.evaluate(); succeededQuietly(description, errors); } catch (org.junit.internal.AssumptionViolatedException e) { errors.add(e); skippedQuietly(e, description, errors); } catch (Throwable e) { errors.add(e); failedQuietly(e, description, errors); } finally { finishedQuietly(description, errors); } MultipleFailureException.assertEmpty(errors); } };
private void run(CloserRule closer, final Runnable runnable) throws Throwable { closer.apply( new Statement() { @Override public void evaluate() { runnable.run(); } }, Description.createTestDescription( CloserRuleTest.class.getCanonicalName(), "baseRunner", UUID.randomUUID() ) ).evaluate(); } }
@Override public void evaluate() throws Throwable { // If this is used as class rule then getMethodName() returns null, so use // getClassName() instead. String name = description.getMethodName() != null ? description.getMethodName() : description.getClassName(); workingDirectory = testDirectory.directory( name ); ensureDatabase( settings -> {} ); try { statement.evaluate(); } finally { shutdownDatabase(); } } };
protected void evaluate(final Statement statement, final Description description) throws Throwable { if (isTest(description)) { Repeat repeat = description.getAnnotation(Repeat.class); for (int count = 0, repetitions = getRepetitions(repeat); count < repetitions; count++) { statement.evaluate(); } } }
@Override public void evaluate() throws Throwable { Long prevNotificationId = getCurrentNotificationId(); statement.evaluate(); Long currNotificationId = getCurrentNotificationId(); if(!testsToSkip.contains(description.getMethodName())){ doBackwardCompatibilityCheck(prevNotificationId,currNotificationId); } else { LOG.info("Skipping backward compatibility check, as requested, for test :" + description); } } };
@Override public void evaluate() throws Throwable { Throwable caughtThrowable = null; for (int i = 0; i < retryCount; i++) { try { base.evaluate(); return; } catch (Throwable t) { caughtThrowable = t; System.err.println(description.getDisplayName() + ": run " + (i + 1) + " failed"); int n = sleep; if (backoff && i != 0) { n = n * (2 << i); } Thread.sleep(n); } } System.err.println(description.getDisplayName() + ": giving up after " + retryCount + " failures"); throw caughtThrowable; } }
/** * Evaluate the next {@link Statement} in the execution chain (typically an instance of * {@link org.junit.internal.runners.statements.RunAfters RunAfters}), catching any * exceptions thrown, and then invoke {@link TestContextManager#afterTestClass()}. * <p>If the invocation of {@code afterTestClass()} throws an exception, it will also * be tracked. Multiple exceptions will be combined into a {@link MultipleFailureException}. */ @Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<>(); try { this.next.evaluate(); } catch (Throwable ex) { errors.add(ex); } try { this.testContextManager.afterTestClass(); } catch (Throwable ex) { errors.add(ex); } MultipleFailureException.assertEmpty(errors); }
private void runTest(final LoggerContextRule rule, final Statement statement) { try { rule.apply(statement, Description .createTestDescription(getClass(), Thread.currentThread().getStackTrace()[1].getMethodName())) .evaluate(); } catch (final Throwable e) { Throwables.rethrow(e); } } }
@Override public void evaluate() throws Throwable { MaxConnections maxConnections1 = description.getAnnotation(MaxConnections.class); ClientEventListener listener = new ClientEventListener(); final MockEventPublisher<ClientEventListener> publisher = MockEventPublisher.disabled(); int maxConnections = null == maxConnections1? DEFAULT_MAX_CONNECTIONS : maxConnections1.value(); init(maxConnections, publisher, publisher, listener); base.evaluate(); } };
@Override public void evaluate() throws Throwable { try { this.next.evaluate(); } finally { testContextManagerCache.remove(this.testClass); } } }
/** * Evaluate the next {@link Statement} in the execution chain (typically an * instance of {@link RunBeforeTestExecutionCallbacks}), catching any exceptions * thrown, and then invoke {@link TestContextManager#afterTestExecution} supplying * the first caught exception (if any). * <p>If the invocation of {@code afterTestExecution()} throws an exception, that * exception will also be tracked. Multiple exceptions will be combined into a * {@link MultipleFailureException}. */ @Override public void evaluate() throws Throwable { Throwable testException = null; List<Throwable> errors = new ArrayList<>(); try { this.next.evaluate(); } catch (Throwable ex) { testException = ex; errors.add(ex); } try { this.testContextManager.afterTestExecution(this.testInstance, this.testMethod, testException); } catch (Throwable ex) { errors.add(ex); } MultipleFailureException.assertEmpty(errors); }
private static URI getHttpsUriFromNeo4jRule( URI configuredHttpsUri ) throws Throwable { ServerControls serverControls = mock( ServerControls.class ); when( serverControls.httpsURI() ).thenReturn( Optional.ofNullable( configuredHttpsUri ) ); TestServerBuilder serverBuilder = mock( TestServerBuilder.class ); when( serverBuilder.newServer() ).thenReturn( serverControls ); Neo4jRule rule = new Neo4jRule( serverBuilder ); AtomicReference<URI> uriRef = new AtomicReference<>(); Statement statement = rule.apply( new Statement() { @Override public void evaluate() throws Throwable { uriRef.set( rule.httpsURI() ); } }, createTestDescription( Neo4jRuleTest.class, "test" ) ); statement.evaluate(); return uriRef.get(); } }
private Statement methodCompletesWithParameters( final FrameworkMethod method, final Assignments complete, final Object freshInstance) { return new Statement() { @Override public void evaluate() throws Throwable { try { final Object[] values = complete.getMethodArguments( nullsOk()); method.invokeExplosively(freshInstance, values); } catch (CouldNotGenerateValueException e) { // ignore } } }; }
@Override public void evaluate() throws Throwable { statement.evaluate(); }
@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); } };
@Override public void run() { try { fStatement.evaluate(); fFinished = true; } catch (InterruptedException e) { // don't log the InterruptedException } catch (Throwable e) { fExceptionThrownByOriginalStatement = e; } } }
/** * Evaluate the next {@link Statement} in the execution chain (typically an instance of * {@link org.junit.internal.runners.statements.RunAfters RunAfters}), catching any * exceptions thrown, and then invoke * {@link TestContextManager#afterTestMethod(Object, Method, Throwable)} supplying the * first caught exception (if any). * <p>If the invocation of {@code afterTestMethod()} throws an exception, that * exception will also be tracked. Multiple exceptions will be combined into a * {@link MultipleFailureException}. */ @Override public void evaluate() throws Throwable { Throwable testException = null; List<Throwable> errors = new ArrayList<>(); try { this.next.evaluate(); } catch (Throwable ex) { testException = ex; errors.add(ex); } try { this.testContextManager.afterTestMethod(this.testInstance, this.testMethod, testException); } catch (Throwable ex) { errors.add(ex); } MultipleFailureException.assertEmpty(errors); }