/** * Instruct Awaitility to ignore caught exceptions matching the given <code>predicate</code> during condition evaluation. * Exceptions will be treated as evaluating to <code>false</code>. Your test will not fail * upon an exception matching the supplied predicate, unless it times out. */ public static void ignoreExceptionsByDefaultMatching(Predicate<? super Throwable> predicate) { defaultExceptionIgnorer = new PredicateExceptionIgnorer(predicate); }
/** * Instruct Awaitility to ignore caught or uncaught exceptions during condition evaluation. * Exceptions will be treated as evaluating to <code>false</code>. Your test will not fail * upon an exception, unless it times out. */ public static void ignoreExceptionsByDefault() { defaultExceptionIgnorer = new PredicateExceptionIgnorer(new Predicate<Throwable>() { public boolean matches(Throwable e) { return true; } }); }
/** * Instruct Awaitility to ignore caught exception of the given type during condition evaluation. * Exceptions will be treated as evaluating to <code>false</code>. Your test will not fail * upon an exception matching the supplied exception type, unless it times out. */ public static void ignoreExceptionByDefault(final Class<? extends Throwable> exceptionType) { defaultExceptionIgnorer = new PredicateExceptionIgnorer(new Predicate<Throwable>() { public boolean matches(Throwable e) { return e.getClass().equals(exceptionType); } }); }
/** * Instruct Awaitility to ignore exceptions that occur during evaluation and matches the supplied <code>predicate</code>. * Exceptions will be treated as evaluating to * <code>false</code>. This is useful in situations where the evaluated conditions may temporarily throw exceptions. * * @return the condition factory. */ public ConditionFactory ignoreExceptionsMatching(Predicate<? super Throwable> predicate) { return new ConditionFactory(alias, timeoutConstraint, pollInterval, pollDelay, catchUncaughtExceptions, new PredicateExceptionIgnorer(predicate), conditionEvaluationListener, executorLifecycle); }
/** * Reset the timeout, poll interval, poll delay, uncaught exception handling * to their default values: * <p> </p> * <ul> * <li>timeout - 10 seconds</li> * <li>poll interval - 100 milliseconds</li> * <li>poll delay - 100 milliseconds</li> * <li>Catch all uncaught exceptions - true</li> * <li>Do not ignore caught exceptions</li> * <li>Don't handle condition evaluation results</li> * </ul> */ public static void reset() { defaultPollInterval = DEFAULT_POLL_INTERVAL; defaultPollDelay = DEFAULT_POLL_DELAY; defaultWaitConstraint = AtMostWaitConstraint.TEN_SECONDS; defaultCatchUncaughtExceptions = true; defaultConditionEvaluationListener = null; defaultExecutorLifecycle = null; defaultExceptionIgnorer = new PredicateExceptionIgnorer(new Predicate<Throwable>() { public boolean matches(Throwable e) { return false; } }); Thread.setDefaultUncaughtExceptionHandler(null); }
/** * Instruct Awaitility to ignore a specific exception and <i>no</i> subclasses of this exception. * Exceptions will be treated as evaluating to <code>false</code>. * This is useful in situations where the evaluated conditions may temporarily throw exceptions. * <p>If you want to ignore a subtypes of this exception then use {@link #ignoreExceptionsInstanceOf(Class)}} </p> * * @param exceptionType The exception type to ignore * @return the condition factory */ public ConditionFactory ignoreException(final Class<? extends Throwable> exceptionType) { if (exceptionType == null) { throw new IllegalArgumentException("exception cannot be null"); } return new ConditionFactory(alias, timeoutConstraint, pollInterval, pollDelay, catchUncaughtExceptions, new PredicateExceptionIgnorer(new Predicate<Throwable>() { public boolean matches(Throwable e) { return e.getClass().equals(exceptionType); } }), conditionEvaluationListener, executorLifecycle); }
/** * Instruct Awaitility to ignore exceptions instance of the supplied exceptionType type. * Exceptions will be treated as evaluating to <code>false</code>. * This is useful in situations where the evaluated conditions may temporarily throw exceptions. * <p/> * <p>If you want to ignore a specific exceptionType then use {@link #ignoreException(Class)}</p> * * @param exceptionType The exception type (hierarchy) to ignore * @return the condition factory */ public ConditionFactory ignoreExceptionsInstanceOf(final Class<? extends Throwable> exceptionType) { if (exceptionType == null) { throw new IllegalArgumentException("exceptionType cannot be null"); } return new ConditionFactory(alias, timeoutConstraint, pollInterval, pollDelay, catchUncaughtExceptions, new PredicateExceptionIgnorer(new Predicate<Throwable>() { public boolean matches(Throwable e) { return exceptionType.isAssignableFrom(e.getClass()); } }), conditionEvaluationListener, executorLifecycle); }
/** * Instruct Awaitility to ignore caught exceptions matching the given <code>predicate</code> during condition evaluation. * Exceptions will be treated as evaluating to <code>false</code>. Your test will not fail * upon an exception matching the supplied predicate, unless it times out. */ public static void ignoreExceptionsByDefaultMatching(Predicate<? super Throwable> predicate) { defaultExceptionIgnorer = new PredicateExceptionIgnorer(predicate); }
/** * Instruct Awaitility to ignore caught or uncaught exceptions during condition evaluation. * Exceptions will be treated as evaluating to <code>false</code>. Your test will not fail * upon an exception, unless it times out. */ public static void ignoreExceptionsByDefault() { defaultExceptionIgnorer = new PredicateExceptionIgnorer(new Predicate<Throwable>() { public boolean matches(Throwable e) { return true; } }); }
/** * Instruct Awaitility to ignore caught exception of the given type during condition evaluation. * Exceptions will be treated as evaluating to <code>false</code>. Your test will not fail * upon an exception matching the supplied exception type, unless it times out. */ public static void ignoreExceptionByDefault(final Class<? extends Throwable> exceptionType) { defaultExceptionIgnorer = new PredicateExceptionIgnorer(new Predicate<Throwable>() { public boolean matches(Throwable e) { return e.getClass().equals(exceptionType); } }); }
/** * Instruct Awaitility to ignore exceptions that occur during evaluation and matches the supplied <code>predicate</code>. * Exceptions will be treated as evaluating to * <code>false</code>. This is useful in situations where the evaluated conditions may temporarily throw exceptions. * * @return the condition factory. */ public ConditionFactory ignoreExceptionsMatching(Predicate<? super Throwable> predicate) { return new ConditionFactory(alias, timeoutConstraint, pollInterval, pollDelay, catchUncaughtExceptions, new PredicateExceptionIgnorer(predicate), conditionEvaluationListener, executorLifecycle); }
/** * Reset the timeout, poll interval, poll delay, uncaught exception handling * to their default values: * <p> </p> * <ul> * <li>timeout - 10 seconds</li> * <li>poll interval - 100 milliseconds</li> * <li>poll delay - 100 milliseconds</li> * <li>Catch all uncaught exceptions - true</li> * <li>Do not ignore caught exceptions</li> * <li>Don't handle condition evaluation results</li> * </ul> */ public static void reset() { defaultPollInterval = DEFAULT_POLL_INTERVAL; defaultPollDelay = DEFAULT_POLL_DELAY; defaultWaitConstraint = AtMostWaitConstraint.TEN_SECONDS; defaultCatchUncaughtExceptions = true; defaultConditionEvaluationListener = null; defaultExecutorLifecycle = null; defaultExceptionIgnorer = new PredicateExceptionIgnorer(new Predicate<Throwable>() { public boolean matches(Throwable e) { return false; } }); Thread.setDefaultUncaughtExceptionHandler(null); }
/** * Instruct Awaitility to ignore a specific exception and <i>no</i> subclasses of this exception. * Exceptions will be treated as evaluating to <code>false</code>. * This is useful in situations where the evaluated conditions may temporarily throw exceptions. * <p>If you want to ignore a subtypes of this exception then use {@link #ignoreExceptionsInstanceOf(Class)}} </p> * * @param exceptionType The exception type to ignore * @return the condition factory */ public ConditionFactory ignoreException(final Class<? extends Throwable> exceptionType) { if (exceptionType == null) { throw new IllegalArgumentException("exception cannot be null"); } return new ConditionFactory(alias, timeoutConstraint, pollInterval, pollDelay, catchUncaughtExceptions, new PredicateExceptionIgnorer(new Predicate<Throwable>() { public boolean matches(Throwable e) { return e.getClass().equals(exceptionType); } }), conditionEvaluationListener, executorLifecycle); }
/** * Instruct Awaitility to ignore exceptions instance of the supplied exceptionType type. * Exceptions will be treated as evaluating to <code>false</code>. * This is useful in situations where the evaluated conditions may temporarily throw exceptions. * <p/> * <p>If you want to ignore a specific exceptionType then use {@link #ignoreException(Class)}</p> * * @param exceptionType The exception type (hierarchy) to ignore * @return the condition factory */ public ConditionFactory ignoreExceptionsInstanceOf(final Class<? extends Throwable> exceptionType) { if (exceptionType == null) { throw new IllegalArgumentException("exceptionType cannot be null"); } return new ConditionFactory(alias, timeoutConstraint, pollInterval, pollDelay, catchUncaughtExceptions, new PredicateExceptionIgnorer(new Predicate<Throwable>() { public boolean matches(Throwable e) { return exceptionType.isAssignableFrom(e.getClass()); } }), conditionEvaluationListener, executorLifecycle); }