/** * Specify a thread supplier whose thread will be used to evaluate the poll condition in Awaitility. * The supplier will be called only once and the thread it returns will be reused during all condition evaluations. * This is an advanced feature and it should only be used sparingly. * * @param threadSupplier A supplier of the thread that Awaitility will use when polling * @since 3.0.0 */ public static void pollThread(final Function<Runnable, Thread> threadSupplier) { defaultExecutorLifecycle = ExecutorLifecycle.withNormalCleanupBehavior(new Supplier<ExecutorService>() { @Override public ExecutorService get() { return InternalExecutorServiceFactory.create(threadSupplier); } }); }
/** * Instructs Awaitility to execute the polling of the condition from the same as the test. * This is an advanced feature and you should be careful when combining this with conditions that * wait forever (or a long time) since Awaitility cannot interrupt the thread when using the same * thread as the test. For safety you should always combine tests using this feature with a test framework specific timeout, * for example in JUnit: *<pre> * @Test(timeout = 2000L) * public void myTest() { * Awaitility.pollInSameThread(); * await().forever().until(...); * } *</pre> * * @since 3.0.0 */ public static void pollInSameThread() { defaultExecutorLifecycle = ExecutorLifecycle.withNormalCleanupBehavior(new Supplier<ExecutorService>() { @Override public ExecutorService get() { return InternalExecutorServiceFactory.sameThreadExecutorService(); } }); }
/** * Specify a thread supplier whose thread will be used to evaluate the poll condition in Awaitility. * The supplier will be called only once and the thread it returns will be reused during all condition evaluations. * This is an advanced feature and it should only be used sparingly. * * @param threadSupplier A supplier of the thread that Awaitility will use when polling * @return the condition factory */ public ConditionFactory pollThread(final Function<Runnable, Thread> threadSupplier) { return new ConditionFactory(alias, timeoutConstraint, pollInterval, pollDelay, false, exceptionsIgnorer, conditionEvaluationListener, ExecutorLifecycle.withNormalCleanupBehavior(new Supplier<ExecutorService>() { @Override public ExecutorService get() { return InternalExecutorServiceFactory.create(threadSupplier); } })); }
/** * Instructs Awaitility to execute the polling of the condition from the same as the test. * This is an advanced feature and you should be careful when combining this with conditions that * wait forever (or a long time) since Awaitility cannot interrupt the thread when it's using the same * thread as the test. For safety you should always combine tests using this feature with a test framework specific timeout, * for example in JUnit: *<pre> * @Test(timeout = 2000L) * public void myTest() { * Awaitility.pollInSameThread(); * await().forever().until(...); * } *</pre> * @return the condition factory */ public ConditionFactory pollInSameThread() { return new ConditionFactory(alias, timeoutConstraint, pollInterval, pollDelay, false, exceptionsIgnorer, conditionEvaluationListener, ExecutorLifecycle.withNormalCleanupBehavior(new Supplier<ExecutorService>() { @Override public ExecutorService get() { return InternalExecutorServiceFactory.sameThreadExecutorService(); } })); }
executorLifecycle = ExecutorLifecycle.withNormalCleanupBehavior(new Supplier<ExecutorService>() { @Override public ExecutorService get() {
/** * Specify a thread supplier whose thread will be used to evaluate the poll condition in Awaitility. * The supplier will be called only once and the thread it returns will be reused during all condition evaluations. * This is an advanced feature and it should only be used sparingly. * * @param threadSupplier A supplier of the thread that Awaitility will use when polling * @since 3.0.0 */ public static void pollThread(final Function<Runnable, Thread> threadSupplier) { defaultExecutorLifecycle = ExecutorLifecycle.withNormalCleanupBehavior(new Supplier<ExecutorService>() { @Override public ExecutorService get() { return InternalExecutorServiceFactory.create(threadSupplier); } }); }
/** * Instructs Awaitility to execute the polling of the condition from the same as the test. * This is an advanced feature and you should be careful when combining this with conditions that * wait forever (or a long time) since Awaitility cannot interrupt the thread when using the same * thread as the test. For safety you should always combine tests using this feature with a test framework specific timeout, * for example in JUnit: *<pre> * @Test(timeout = 2000L) * public void myTest() { * Awaitility.pollInSameThread(); * await().forever().until(...); * } *</pre> * * @since 3.0.0 */ public static void pollInSameThread() { defaultExecutorLifecycle = ExecutorLifecycle.withNormalCleanupBehavior(new Supplier<ExecutorService>() { @Override public ExecutorService get() { return InternalExecutorServiceFactory.sameThreadExecutorService(); } }); }
/** * Specify a thread supplier whose thread will be used to evaluate the poll condition in Awaitility. * The supplier will be called only once and the thread it returns will be reused during all condition evaluations. * This is an advanced feature and it should only be used sparingly. * * @param threadSupplier A supplier of the thread that Awaitility will use when polling * @return the condition factory */ public ConditionFactory pollThread(final Function<Runnable, Thread> threadSupplier) { return new ConditionFactory(alias, timeoutConstraint, pollInterval, pollDelay, false, exceptionsIgnorer, conditionEvaluationListener, ExecutorLifecycle.withNormalCleanupBehavior(new Supplier<ExecutorService>() { @Override public ExecutorService get() { return InternalExecutorServiceFactory.create(threadSupplier); } })); }
/** * Instructs Awaitility to execute the polling of the condition from the same as the test. * This is an advanced feature and you should be careful when combining this with conditions that * wait forever (or a long time) since Awaitility cannot interrupt the thread when it's using the same * thread as the test. For safety you should always combine tests using this feature with a test framework specific timeout, * for example in JUnit: *<pre> * @Test(timeout = 2000L) * public void myTest() { * Awaitility.pollInSameThread(); * await().forever().until(...); * } *</pre> * @return the condition factory */ public ConditionFactory pollInSameThread() { return new ConditionFactory(alias, timeoutConstraint, pollInterval, pollDelay, false, exceptionsIgnorer, conditionEvaluationListener, ExecutorLifecycle.withNormalCleanupBehavior(new Supplier<ExecutorService>() { @Override public ExecutorService get() { return InternalExecutorServiceFactory.sameThreadExecutorService(); } })); }
executorLifecycle = ExecutorLifecycle.withNormalCleanupBehavior(new Supplier<ExecutorService>() { @Override public ExecutorService get() {