public class Concurrently extends Object
Deferred values using the style Concurrently.assertThat(...)
try (Concurrent.Assertion assertion = Concurrently.assertThat(invoking(someObject).get(), is(someValue))) {
// ...perform some operations...
assertion.check(); // ensure the assertion still holds
// ...perform some other operations...
assertion.check(); // ensure the assertion still holds
}
Concurrently.assertThat(...) methods are intended be used within
try-with-resources blocks. When not, they should always be closed to ensure correct
clean-up of background resources used for concurrent assertion.
To control "fail-fast" semantics, where by the Concurrent.Assertion may interrupt the
Thread that created the Concurrent.Assertion, the FailFast option
should be specified.
try (Concurrent.Assertion assertion = Concurrently.assertThat(invoking(someObject).get(),
is(someValue),
FailFast.enabled())) {
// ...perform some long running operations... (will be interrupted if the assertion fails)
} catch (InterruptedException e) {
// determine if the InterruptedException was due to AssertionError
Concurrent.Assertion.check(e);
}
To customize assertion behavior, this class allows extensive use of
Options. For example, the following Options may be used
to customize timeout constraints when asserting Deferred values;
Timeout, MaximumRetryDelay, Initial InitialDelay and
RetryFrequency.
Copyright (c) 2016. All Rights Reserved. Oracle Corporation.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Eventually,
Repetitively| Constructor and Description |
|---|
Concurrently() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
assertThat(JavaApplication application,
RemoteCallable<T> callable,
org.hamcrest.Matcher<? super T> matcher)
Creates a background thread to repetitively assert that the specified
RemoteCallable
submitted to the JavaApplication matches the specified Matcher. |
static <T> void |
assertThat(JavaApplication application,
RemoteCallable<T> callable,
org.hamcrest.Matcher<? super T> matcher,
com.oracle.bedrock.Option... options)
Creates a background thread to repetitively assert that the specified
RemoteCallable
submitted to the JavaApplication matches the specified Matcher
using the specified Options. |
static <T> com.oracle.bedrock.deferred.Concurrent.Assertion |
assertThat(String message,
com.oracle.bedrock.deferred.Deferred<T> deferred,
org.hamcrest.Matcher<? super T> matcher,
com.oracle.bedrock.Option... options)
Creates a background thread to repetitively assert that a
Deferred
value, when available, satisfies the specified Matcher using
constraints defined by the provided Options. |
static <T> com.oracle.bedrock.deferred.Concurrent.Assertion |
assertThat(String message,
T value,
org.hamcrest.Matcher<? super T> matcher)
Creates a background thread to repetitively assert that a value will
satisfy the specified
Matcher. |
static <T> com.oracle.bedrock.deferred.Concurrent.Assertion |
assertThat(String message,
T value,
org.hamcrest.Matcher<? super T> matcher,
com.oracle.bedrock.Option... options)
Creates a background thread to repetitively assert that a value satisfies the
specified
Matcher using the provided Options. |
static <T> com.oracle.bedrock.deferred.Concurrent.Assertion |
assertThat(T value,
org.hamcrest.Matcher<? super T> matcher,
com.oracle.bedrock.Option... options)
Creates a background thread to repetitively assert that a value satisfies the
specified
Matcher using the specified Options. |
public static <T> com.oracle.bedrock.deferred.Concurrent.Assertion assertThat(T value,
org.hamcrest.Matcher<? super T> matcher,
com.oracle.bedrock.Option... options)
throws AssertionError
Matcher using the specified Options.
Should the value be the result of a call to DeferredHelper.invoking(Deferred)
the result is unwrapped into a Deferred that is then used for the assert.
T - the type of the valuevalue - the valuematcher - the Matcher for the valueoptions - the Options for the assertionConcurrent.Assertion to be used to determine the current success
of the concurrent assertionAssertionError - if the assertion failspublic static <T> com.oracle.bedrock.deferred.Concurrent.Assertion assertThat(String message, T value, org.hamcrest.Matcher<? super T> matcher) throws AssertionError
Matcher.
Should the value be the result of a call to DeferredHelper.invoking(Deferred)
the result is unwrapped into a Deferred that is then used for the assert.
T - the type of the valuemessage - the message for the AssertionError (null ok)value - the valuematcher - the Matcher for the valueConcurrent.Assertion to be used to determine the current success
of the concurrent assertionAssertionError - if the assertion failspublic static <T> com.oracle.bedrock.deferred.Concurrent.Assertion assertThat(String message, T value, org.hamcrest.Matcher<? super T> matcher, com.oracle.bedrock.Option... options) throws AssertionError
Matcher using the provided Options.
Should the value be the result of a call to DeferredHelper.invoking(Deferred)
the result is unwrapped into a Deferred that is then used for the assert.
T - the type of the valuemessage - the message for the AssertionError (null ok)value - the valuematcher - the Matcher for the valueoptions - the OptionsConcurrent.Assertion to be used to determine the current success
of the concurrent assertionAssertionError - if the assertion failspublic static <T> com.oracle.bedrock.deferred.Concurrent.Assertion assertThat(String message, com.oracle.bedrock.deferred.Deferred<T> deferred, org.hamcrest.Matcher<? super T> matcher, com.oracle.bedrock.Option... options)
Deferred
value, when available, satisfies the specified Matcher using
constraints defined by the provided Options.T - the type of the valuemessage - the message for the AssertionError (null ok)deferred - the Deferred valuematcher - the Matcher for the valueoptions - the OptionsConcurrent.Assertion providing the ability to check the status and
control the evaluation of the concurrent Concurrent.Assertionpublic static <T> void assertThat(JavaApplication application, RemoteCallable<T> callable, org.hamcrest.Matcher<? super T> matcher) throws AssertionError
RemoteCallable
submitted to the JavaApplication matches the specified Matcher.T - the type of the valueapplication - the JavaApplication to which the RemoteCallable will be submittedcallable - the RemoteCallablematcher - the Matcher representing the desire condition to matchAssertionError - if the assertion failspublic static <T> void assertThat(JavaApplication application, RemoteCallable<T> callable, org.hamcrest.Matcher<? super T> matcher, com.oracle.bedrock.Option... options) throws AssertionError
RemoteCallable
submitted to the JavaApplication matches the specified Matcher
using the specified Options.T - the type of the valueapplication - the JavaApplication to which the RemoteCallable will be submittedcallable - the RemoteCallablematcher - the Matcher representing the desire condition to matchoptions - the OptionsAssertionError - if the assertion failsCopyright © 2017. All rights reserved.