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
An test template extension that helps to branch out a single test into sync and async invocation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Executes sync or async branch depending on the context.static <T> T
Executes sync or async branch depending on the context.Stream<org.junit.jupiter.api.extension.TestTemplateInvocationContext>
provideTestTemplateInvocationContexts
(org.junit.jupiter.api.extension.ExtensionContext extensionContext) boolean
supportsTestTemplate
(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
-
Constructor Details
-
SyncAsyncExtension
public SyncAsyncExtension()
-
-
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:
supportsTestTemplate
in 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:
provideTestTemplateInvocationContexts
in interfaceorg.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
-