Package io.servicetalk.concurrent.api
Class BlockingTestUtils
- java.lang.Object
-
- io.servicetalk.concurrent.api.BlockingTestUtils
-
public final class BlockingTestUtils extends java.lang.Object
Utilities to await results of an asynchronous computation either by blocking the calling thread.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
await(Completable source, long timeout, java.util.concurrent.TimeUnit timeoutUnit)
Awaits termination of the passedCompletable
by blocking the calling thread.static <T> java.util.List<T>
await(Publisher<T> source, long timeout, java.util.concurrent.TimeUnit timeoutUnit)
Awaits termination of the passedPublisher
by blocking the calling thread.static <T> T
await(Single<T> source, long timeout, java.util.concurrent.TimeUnit timeoutUnit)
Awaits termination of the passedSingle
by blocking the calling thread.static void
awaitIndefinitely(Completable source)
Awaits termination of the passedCompletable
by blocking the calling thread.static <T> java.util.List<T>
awaitIndefinitely(Publisher<T> source)
Awaits termination of the passedPublisher
by blocking the calling thread.static <T> T
awaitIndefinitely(Single<T> source)
Awaits termination of the passedSingle
by blocking the calling thread.static <T> java.util.List<T>
awaitIndefinitelyNonNull(Publisher<T> source)
Awaits termination of the passedPublisher
by blocking the calling thread.static <T> T
awaitIndefinitelyNonNull(Single<T> source)
Awaits termination of the passedSingle
by blocking the calling thread.static void
awaitIndefinitelyUnchecked(Completable source)
Awaits termination of the passedCompletable
by blocking the calling thread.static <T> java.util.List<T>
awaitNonNull(Publisher<T> source, long timeout, java.util.concurrent.TimeUnit timeoutUnit)
Awaits termination of the passedPublisher
by blocking the calling thread.static <T> T
awaitNonNull(Single<T> source, long timeout, java.util.concurrent.TimeUnit timeoutUnit)
Awaits termination of the passedSingle
by blocking the calling thread.
-
-
-
Method Detail
-
awaitIndefinitely
@Nullable public static <T> java.util.List<T> awaitIndefinitely(Publisher<T> source) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
Awaits termination of the passedPublisher
by blocking the calling thread.- Type Parameters:
T
- Type of items produced by thePublisher
.- Parameters:
source
- to await for.- Returns:
List
of all elements emitted by thePublisher
, iff it terminated successfully.- Throws:
java.util.concurrent.ExecutionException
- if the passedPublisher
terminates with a failure.java.lang.InterruptedException
- if the thread was interrupted while waiting for termination.
-
awaitIndefinitelyNonNull
public static <T> java.util.List<T> awaitIndefinitelyNonNull(Publisher<T> source) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
Awaits termination of the passedPublisher
by blocking the calling thread.- Type Parameters:
T
- Type of items produced by thePublisher
.- Parameters:
source
- to await for.- Returns:
List
of all elements emitted by thePublisher
, iff it terminated successfully.- Throws:
java.util.concurrent.ExecutionException
- if the passedPublisher
terminates with a failure, or if the result ofawaitIndefinitely(Publisher)
isnull
.java.lang.InterruptedException
- if the thread was interrupted while waiting for termination.- See Also:
awaitIndefinitely(Publisher)
-
await
@Nullable public static <T> java.util.List<T> await(Publisher<T> source, long timeout, java.util.concurrent.TimeUnit timeoutUnit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Awaits termination of the passedPublisher
by blocking the calling thread.- Type Parameters:
T
- Type of items produced by thePublisher
.- Parameters:
source
- to await for.timeout
- maximum time to wait for termination.timeoutUnit
-TimeUnit
for timeout.- Returns:
List
of all elements emitted by thePublisher
, iff it terminated successfully.- Throws:
java.util.concurrent.ExecutionException
- if the passedPublisher
terminates with a failure.java.lang.InterruptedException
- if the thread was interrupted while waiting for termination.java.util.concurrent.TimeoutException
- If thePublisher
isn't terminated after waiting for the passedtimeout
duration.
-
awaitNonNull
public static <T> java.util.List<T> awaitNonNull(Publisher<T> source, long timeout, java.util.concurrent.TimeUnit timeoutUnit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Awaits termination of the passedPublisher
by blocking the calling thread.- Type Parameters:
T
- Type of items produced by thePublisher
.- Parameters:
source
- to await for.timeout
- maximum time to wait for termination.timeoutUnit
-TimeUnit
for timeout.- Returns:
List
of all elements emitted by thePublisher
, iff it terminated successfully.- Throws:
java.util.concurrent.ExecutionException
- if the passedPublisher
terminates with a failure, or if the result ofawait(Publisher, long, TimeUnit)
isnull
.java.lang.InterruptedException
- if the thread was interrupted while waiting for termination.java.util.concurrent.TimeoutException
- If thePublisher
isn't terminated after waiting for the passedtimeout
duration.- See Also:
await(Publisher, long, TimeUnit)
-
awaitIndefinitely
@Nullable public static <T> T awaitIndefinitely(Single<T> source) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
Awaits termination of the passedSingle
by blocking the calling thread.- Type Parameters:
T
- Type of the result ofSingle
.- Parameters:
source
- to await for.- Returns:
- Result of the
Single
.null
if thesource
is of typeVoid
. - Throws:
java.util.concurrent.ExecutionException
- if the passedPublisher
terminates with a failure.java.lang.InterruptedException
- if the thread was interrupted while waiting for termination.
-
awaitIndefinitelyNonNull
public static <T> T awaitIndefinitelyNonNull(Single<T> source) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
Awaits termination of the passedSingle
by blocking the calling thread.- Type Parameters:
T
- Type of the result ofSingle
.- Parameters:
source
- to await for.- Returns:
- Result of the
Single
.null
if thesource
is of typeVoid
. - Throws:
java.util.concurrent.ExecutionException
- if the passedPublisher
terminates with a failure, or if the result ofawaitIndefinitely(Single)
isnull
.java.lang.InterruptedException
- if the thread was interrupted while waiting for termination.- See Also:
awaitIndefinitely(Single)
-
await
@Nullable public static <T> T await(Single<T> source, long timeout, java.util.concurrent.TimeUnit timeoutUnit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Awaits termination of the passedSingle
by blocking the calling thread.- Type Parameters:
T
- Type of the result ofSingle
.- Parameters:
source
- to await for.timeout
- maximum time to wait for termination.timeoutUnit
-TimeUnit
for timeout.- Returns:
- Result of the
Single
.null
if thesource
is of typeVoid
. - Throws:
java.util.concurrent.ExecutionException
- if the passedPublisher
terminates with a failure.java.lang.InterruptedException
- if the thread was interrupted while waiting for termination.java.util.concurrent.TimeoutException
- If the result isn't available after waiting for the passedtimeout
duration.
-
awaitNonNull
public static <T> T awaitNonNull(Single<T> source, long timeout, java.util.concurrent.TimeUnit timeoutUnit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Awaits termination of the passedSingle
by blocking the calling thread.- Type Parameters:
T
- Type of the result ofSingle
.- Parameters:
source
- to await for.timeout
- maximum time to wait for termination.timeoutUnit
-TimeUnit
for timeout.- Returns:
- Result of the
Single
.null
if thesource
is of typeVoid
. - Throws:
java.util.concurrent.ExecutionException
- if the passedPublisher
terminates with a failure, or if the result ofawait(Single, long, TimeUnit)
isnull
.java.lang.InterruptedException
- if the thread was interrupted while waiting for termination.java.util.concurrent.TimeoutException
- If the result isn't available after waiting for the passedtimeout
duration.- See Also:
await(Single, long, TimeUnit)
-
awaitIndefinitely
public static void awaitIndefinitely(Completable source) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
Awaits termination of the passedCompletable
by blocking the calling thread.- Parameters:
source
- to await for.- Throws:
java.util.concurrent.ExecutionException
- if the passedPublisher
terminates with a failure.java.lang.InterruptedException
- if the thread was interrupted while waiting for termination.
-
awaitIndefinitelyUnchecked
public static void awaitIndefinitelyUnchecked(Completable source)
Awaits termination of the passedCompletable
by blocking the calling thread.This method will re-throw exceptions from
awaitIndefinitely(Completable)
.- Parameters:
source
- to await for.
-
await
public static void await(Completable source, long timeout, java.util.concurrent.TimeUnit timeoutUnit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Awaits termination of the passedCompletable
by blocking the calling thread.- Parameters:
source
- to await for.timeout
- maximum time to wait for termination.timeoutUnit
-TimeUnit
for timeout.- Throws:
java.util.concurrent.ExecutionException
- if the passedPublisher
terminates with a failure.java.lang.InterruptedException
- if the thread was interrupted while waiting for termination.java.util.concurrent.TimeoutException
- If theCompletable
isn't terminated after waiting for the passedtimeout
duration.
-
-