Package io.servicetalk.concurrent.api
Class BlockingTestUtils
- java.lang.Object
-
- io.servicetalk.concurrent.api.BlockingTestUtils
-
public final class BlockingTestUtils extends java.lang.ObjectUtilities 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 voidawait(Completable source, long timeout, java.util.concurrent.TimeUnit timeoutUnit)Awaits termination of the passedCompletableby 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 passedPublisherby blocking the calling thread.static <T> Tawait(Single<T> source, long timeout, java.util.concurrent.TimeUnit timeoutUnit)Awaits termination of the passedSingleby blocking the calling thread.static voidawaitIndefinitely(Completable source)Awaits termination of the passedCompletableby blocking the calling thread.static <T> java.util.List<T>awaitIndefinitely(Publisher<T> source)Awaits termination of the passedPublisherby blocking the calling thread.static <T> TawaitIndefinitely(Single<T> source)Awaits termination of the passedSingleby blocking the calling thread.static <T> java.util.List<T>awaitIndefinitelyNonNull(Publisher<T> source)Awaits termination of the passedPublisherby blocking the calling thread.static <T> TawaitIndefinitelyNonNull(Single<T> source)Awaits termination of the passedSingleby blocking the calling thread.static voidawaitIndefinitelyUnchecked(Completable source)Awaits termination of the passedCompletableby 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 passedPublisherby blocking the calling thread.static <T> TawaitNonNull(Single<T> source, long timeout, java.util.concurrent.TimeUnit timeoutUnit)Awaits termination of the passedSingleby 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 passedPublisherby blocking the calling thread.- Type Parameters:
T- Type of items produced by thePublisher.- Parameters:
source- to await for.- Returns:
Listof all elements emitted by thePublisher, iff it terminated successfully.- Throws:
java.util.concurrent.ExecutionException- if the passedPublisherterminates 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 passedPublisherby blocking the calling thread.- Type Parameters:
T- Type of items produced by thePublisher.- Parameters:
source- to await for.- Returns:
Listof all elements emitted by thePublisher, iff it terminated successfully.- Throws:
java.util.concurrent.ExecutionException- if the passedPublisherterminates 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 passedPublisherby 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-TimeUnitfor timeout.- Returns:
Listof all elements emitted by thePublisher, iff it terminated successfully.- Throws:
java.util.concurrent.ExecutionException- if the passedPublisherterminates with a failure.java.lang.InterruptedException- if the thread was interrupted while waiting for termination.java.util.concurrent.TimeoutException- If thePublisherisn't terminated after waiting for the passedtimeoutduration.
-
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 passedPublisherby 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-TimeUnitfor timeout.- Returns:
Listof all elements emitted by thePublisher, iff it terminated successfully.- Throws:
java.util.concurrent.ExecutionException- if the passedPublisherterminates 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 thePublisherisn't terminated after waiting for the passedtimeoutduration.- 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 passedSingleby blocking the calling thread.- Type Parameters:
T- Type of the result ofSingle.- Parameters:
source- to await for.- Returns:
- Result of the
Single.nullif thesourceis of typeVoid. - Throws:
java.util.concurrent.ExecutionException- if the passedPublisherterminates 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 passedSingleby blocking the calling thread.- Type Parameters:
T- Type of the result ofSingle.- Parameters:
source- to await for.- Returns:
- Result of the
Single.nullif thesourceis of typeVoid. - Throws:
java.util.concurrent.ExecutionException- if the passedPublisherterminates 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 passedSingleby 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-TimeUnitfor timeout.- Returns:
- Result of the
Single.nullif thesourceis of typeVoid. - Throws:
java.util.concurrent.ExecutionException- if the passedPublisherterminates 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 passedtimeoutduration.
-
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 passedSingleby 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-TimeUnitfor timeout.- Returns:
- Result of the
Single.nullif thesourceis of typeVoid. - Throws:
java.util.concurrent.ExecutionException- if the passedPublisherterminates 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 passedtimeoutduration.- 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 passedCompletableby blocking the calling thread.- Parameters:
source- to await for.- Throws:
java.util.concurrent.ExecutionException- if the passedPublisherterminates 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 passedCompletableby 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 passedCompletableby blocking the calling thread.- Parameters:
source- to await for.timeout- maximum time to wait for termination.timeoutUnit-TimeUnitfor timeout.- Throws:
java.util.concurrent.ExecutionException- if the passedPublisherterminates with a failure.java.lang.InterruptedException- if the thread was interrupted while waiting for termination.java.util.concurrent.TimeoutException- If theCompletableisn't terminated after waiting for the passedtimeoutduration.
-
-