Package com.azure.core.test
Class SyncAsyncExtension
java.lang.Object
com.azure.core.test.SyncAsyncExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
public final class SyncAsyncExtension
extends Object
implements org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
A test template extension that helps to branch out a single test into sync and async invocation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidExecutes sync or async branch depending on the context.static <T> TExecutes sync or async branch depending on the context.Stream<org.junit.jupiter.api.extension.TestTemplateInvocationContext>provideTestTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext extensionContext) booleansupportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
-
Constructor Details
-
SyncAsyncExtension
public SyncAsyncExtension()Creates a new instance ofSyncAsyncExtension.
-
-
Method Details
-
execute
Executes sync or async branch depending on the context.- Type Parameters:
T- type of result of either sync or async invocation.- Parameters:
sync- sync callable.async- async callable. It should block at some point to return result.- Returns:
- result of either sync or async invocation.
- Throws:
IllegalStateException- if extension doesn't work as expected.RuntimeException- a runtime exception wrapping error from callable.
-
execute
Executes sync or async branch depending on the context.- Parameters:
sync- sync callable.async- async callable. It should block at some point to return result.- Throws:
IllegalStateException- if extension doesn't work as expected.RuntimeException- a runtime exception wrapping error from callable.
-
supportsTestTemplate
public boolean supportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext extensionContext) - Specified by:
supportsTestTemplatein interfaceorg.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
-
provideTestTemplateInvocationContexts
public Stream<org.junit.jupiter.api.extension.TestTemplateInvocationContext> provideTestTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext extensionContext) - Specified by:
provideTestTemplateInvocationContextsin interfaceorg.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
-