Class ManagedExecutorTest
java.lang.Object
org.jboss.arquillian.testng.Arquillian
org.eclipse.microprofile.context.tck.ManagedExecutorTest
- All Implemented Interfaces:
org.testng.IHookable,org.testng.ITestNGListener
public class ManagedExecutorTest
extends org.jboss.arquillian.testng.Arquillian
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jboss.arquillian.testng.Arquillian
org.jboss.arquillian.testng.Arquillian.UpdateResultListener -
Field Summary
Fields inherited from class org.jboss.arquillian.testng.Arquillian
ARQUILLIAN_DATA_PROVIDER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafter()voidafterMethod(Method m, org.testng.ITestResult result) voidbefore()voidvoidvoidVerify that the ManagedExecutor implementation clears context types that are not configured under propagated, or cleared.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages of the completed future that is created by the ManagedExecutor's completedFuture implementation.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages of the completed future that is created by the ManagedExecutor's completedStage implementation.voidVerify the MicroProfile Context Propagation implementation of propagate(), and cleared() for ManagedExecutor.Builder.voidWhen an already-contextualized Callable is specified as the action/task, the action/task runs with its already-captured context rather than capturing and applying context per the configuration of the managed executor.voidWhen an already-contextualized Consumer or BiFunction is specified as the action/task, the action/task runs with its already-captured context rather than capturing and applying context per the configuration of the managed executor.voidWhen an already-contextualized Function is specified as the action/task, the action/task runs with its already-captured context rather than capturing and applying context per the configuration of the managed executor.voidWhen an already-contextualized Runnable is specified as the action/task, the action/task runs with its already-captured context rather than capturing and applying context per the configuration of the managed executor.voidWhen an already-contextualized Supplier or BiFunction is specified as the action/task, the action/task runs with its already-captured context rather than capturing and applying context per the configuration of the managed executor.voidVerify that we can copy a CompletableFuture and get context propagation in the copy's dependent stages.voidVerify that we can copy a CompletionStage and get context propagation in the copy's dependent stages.static org.jboss.shrinkwrap.api.spec.WebArchivevoidVerify that thread context is cleared per the configuration of the ManagedExecutor builder for all tasks that are executed via the execute method.voidVerify that thread context is propagated per the configuration of the ManagedExecutor builder for all tasks that are executed via the execute method.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages of the completed future that is created by the ManagedExecutor's failedFuture implementation.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages of the completed future that is created by the ManagedExecutor's failedStage implementation.voidVerify that the ManagedExecutor implementation starts 2 async tasks/actions, and no more, when maxAsync is configured to 2.voidAttempt to specify invalid values (less than -1 and 0) for maxAsync.voidVerify that 3 tasks/actions, and no more, can be queued when maxQueued is configured to 3.voidAttempt to specify invalid values (less than -1 and 0) for maxQueued.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages of the incomplete future that is created by the ManagedExecutor's newIncompleteFuture implementation.voidVerify that Application context makes the application's thread context class loader available to the task.voidVerify that when JTA transactions are supported and configuration of propagated=TRANSACTION is permitted, it is at least possible to propagate the absence of a transaction, and if context is allowed to be captured while a transaction is active, then the task or action runs with a transaction on the thread.voidVerify that the ManagedExecutor.Builder can be used to create multiple ManagedExecutors with different configured contexts.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages as well as the initial stage created by the ManagedExecutor's runAsync implementation.voidVerify that the ManagedExecutor shutdownNow method prevents additional tasks from being submitted and cancels tasks that are currently in progress or queued.voidVerify that the ManagedExecutor shutdown method prevents additional tasks from being submitted but does not interfere with tasks and actions that are running or queued.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all tasks that are submitted via the submit(Callable), submit(Runnable) and submit(Runnable, result) methods.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages as well as the initial stage created by the ManagedExecutor's supplyAsync implementation.voidVerify that we can obtain a ThreadContext with the same settings as the ManagedExecutorvoidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all tasks that are submitted via the ManagedExecutor's timed invokeAll operation.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for one or more tasks that are submitted via the ManagedExecutor's timed invokeAny operation.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all tasks that are submitted via the ManagedExecutor's untimed invokeAll operation.voidVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for one or more tasks that are submitted via the ManagedExecutor's untimed invokeAny operation.voidVerify that the presence of a default executor service implies async actions run on it.Methods inherited from class org.jboss.arquillian.testng.Arquillian
arquillianAfterClass, arquillianAfterSuite, arquillianAfterTest, arquillianArgumentProvider, arquillianBeforeClass, arquillianBeforeSuite, arquillianBeforeTest, run
-
Constructor Details
-
ManagedExecutorTest
public ManagedExecutorTest()
-
-
Method Details
-
after
@AfterClass public void after() -
afterMethod
-
before
@BeforeClass public void before() -
beforeMethod
-
createDeployment
@Deployment public static org.jboss.shrinkwrap.api.spec.WebArchive createDeployment() -
builderForManagedExecutorIsProvided
public void builderForManagedExecutorIsProvided() -
clearUnspecifiedContexts
public void clearUnspecifiedContexts() throws InterruptedException, ExecutionException, TimeoutExceptionVerify that the ManagedExecutor implementation clears context types that are not configured under propagated, or cleared.- Throws:
TimeoutException- indicates test failureExecutionException- indicates test failureInterruptedException- indicates test failure
-
completedFutureDependentStagesRunWithContext
public void completedFutureDependentStagesRunWithContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages of the completed future that is created by the ManagedExecutor's completedFuture implementation. Thread context is captured at each point where a dependent stage is added, rather than solely upon creation of the initial stage or construction of the builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
completedStageDependentStagesRunWithContext
Verify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages of the completed future that is created by the ManagedExecutor's completedStage implementation. Thread context is captured at each point where a dependent stage is added, rather than solely upon creation of the initial stage or construction of the builder.- Throws:
InterruptedException- indicates test failure
-
contextControlsForManagedExecutorBuilder
public void contextControlsForManagedExecutorBuilder() throws InterruptedException, ExecutionException, TimeoutExceptionVerify the MicroProfile Context Propagation implementation of propagate(), and cleared() for ManagedExecutor.Builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
contextOfContextualCallableOverridesContextOfManagedExecutor
public void contextOfContextualCallableOverridesContextOfManagedExecutor() throws ExecutionException, InterruptedException, TimeoutExceptionWhen an already-contextualized Callable is specified as the action/task, the action/task runs with its already-captured context rather than capturing and applying context per the configuration of the managed executor.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
contextOfContextualConsumerAndBiFunctionOverrideContextOfManagedExecutor
public void contextOfContextualConsumerAndBiFunctionOverrideContextOfManagedExecutor() throws ExecutionException, InterruptedException, TimeoutExceptionWhen an already-contextualized Consumer or BiFunction is specified as the action/task, the action/task runs with its already-captured context rather than capturing and applying context per the configuration of the managed executor.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
contextOfContextualFunctionOverridesContextOfManagedExecutor
public void contextOfContextualFunctionOverridesContextOfManagedExecutor() throws ExecutionException, InterruptedException, TimeoutExceptionWhen an already-contextualized Function is specified as the action/task, the action/task runs with its already-captured context rather than capturing and applying context per the configuration of the managed executor.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
contextOfContextualRunnableOverridesContextOfManagedExecutor
public void contextOfContextualRunnableOverridesContextOfManagedExecutor() throws ExecutionException, InterruptedException, TimeoutExceptionWhen an already-contextualized Runnable is specified as the action/task, the action/task runs with its already-captured context rather than capturing and applying context per the configuration of the managed executor.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
contextOfContextualSuppplierAndBiConsumerOverrideContextOfManagedExecutor
public void contextOfContextualSuppplierAndBiConsumerOverrideContextOfManagedExecutor() throws ExecutionException, InterruptedException, TimeoutExceptionWhen an already-contextualized Supplier or BiFunction is specified as the action/task, the action/task runs with its already-captured context rather than capturing and applying context per the configuration of the managed executor.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
executedTaskRunsWithClearedContext
public void executedTaskRunsWithClearedContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is cleared per the configuration of the ManagedExecutor builder for all tasks that are executed via the execute method. This test supplies the ManagedExecutor to a Java SE CompletableFuture, which invokes the execute method to run tasks asynchronously.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
executedTaskRunsWithContext
public void executedTaskRunsWithContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is propagated per the configuration of the ManagedExecutor builder for all tasks that are executed via the execute method.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
failedFutureDependentStagesRunWithContext
public void failedFutureDependentStagesRunWithContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages of the completed future that is created by the ManagedExecutor's failedFuture implementation. Thread context is captured at each point where a dependent stage is added, rather than solely upon creation of the initial stage or construction of the builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
failedStageDependentStagesRunWithContext
public void failedStageDependentStagesRunWithContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages of the completed future that is created by the ManagedExecutor's failedStage implementation. Thread context is captured at each point where a dependent stage is added, rather than solely upon creation of the initial stage or construction of the builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
maxAsync2
Verify that the ManagedExecutor implementation starts 2 async tasks/actions, and no more, when maxAsync is configured to 2.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
maxAsyncInvalidValues
public void maxAsyncInvalidValues() throws ExecutionException, InterruptedException, TimeoutExceptionAttempt to specify invalid values (less than -1 and 0) for maxAsync. Require this to be rejected upon the maxQueued operation per JavaDoc rather than from the build method.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
maxQueued3
Verify that 3 tasks/actions, and no more, can be queued when maxQueued is configured to 3.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
maxQueuedInvalidValues
public void maxQueuedInvalidValues() throws ExecutionException, InterruptedException, TimeoutExceptionAttempt to specify invalid values (less than -1 and 0) for maxQueued. Require this to be rejected upon the maxQueued operation per JavaDoc rather than from the build method.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
newIncompleteFutureDependentStagesRunWithContext
public void newIncompleteFutureDependentStagesRunWithContext() throws ExecutionException, InterruptedExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages of the incomplete future that is created by the ManagedExecutor's newIncompleteFuture implementation. Thread context is captured at each point where a dependent stage is added, rather than solely upon creation of the initial stage or construction of the builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failure
-
propagateApplicationContext
public void propagateApplicationContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that Application context makes the application's thread context class loader available to the task.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
propagateTransactionContextJTA
Verify that when JTA transactions are supported and configuration of propagated=TRANSACTION is permitted, it is at least possible to propagate the absence of a transaction, and if context is allowed to be captured while a transaction is active, then the task or action runs with a transaction on the thread. It would be nice to test participation in the same transaction, but that isn't possible without the TCK having a dependency on a particular type of transactional resource. The test tries to get hold ofUserTransactionvia JNDI and via CDI. Should neither work, it still doesn't throw exception but instead returns.- Throws:
Exception- indicates test failure
-
shutdownNowPreventsAdditionalSubmitsAndCancelsTasks
public void shutdownNowPreventsAdditionalSubmitsAndCancelsTasks() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that the ManagedExecutor shutdownNow method prevents additional tasks from being submitted and cancels tasks that are currently in progress or queued. Also verify that once the tasks and actions terminate, the ManagedExecutor transitions to terminated state.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
shutdownPreventsAdditionalSubmits
public void shutdownPreventsAdditionalSubmits() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that the ManagedExecutor shutdown method prevents additional tasks from being submitted but does not interfere with tasks and actions that are running or queued. Also verify that once the tasks and actions finish, the ManagedExecutor transitions to terminated state.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
reuseManagedExecutorBuilder
public void reuseManagedExecutorBuilder() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that the ManagedExecutor.Builder can be used to create multiple ManagedExecutors with different configured contexts.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
runAsyncStageAndDependentStagesRunWithContext
public void runAsyncStageAndDependentStagesRunWithContext() throws ExecutionException, InterruptedExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages as well as the initial stage created by the ManagedExecutor's runAsync implementation. Thread context is captured at each point where a dependent stage is added, rather than solely upon creation of the initial stage or construction of the builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failure
-
submittedTasksRunWithContext
public void submittedTasksRunWithContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all tasks that are submitted via the submit(Callable), submit(Runnable) and submit(Runnable, result) methods.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
supplyAsyncStageAndDependentStagesRunWithContext
public void supplyAsyncStageAndDependentStagesRunWithContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all dependent stages as well as the initial stage created by the ManagedExecutor's supplyAsync implementation. Thread context is captured at each point where a dependent stage is added, rather than solely upon creation of the initial stage or construction of the builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
timedInvokeAllRunsTasksWithContext
public void timedInvokeAllRunsTasksWithContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all tasks that are submitted via the ManagedExecutor's timed invokeAll operation. Thread context is captured at the point where invokeAll is invoked, rather than upon creation of the executor or construction of the builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
timedInvokeAnyRunsTaskWithContext
public void timedInvokeAnyRunsTaskWithContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for one or more tasks that are submitted via the ManagedExecutor's timed invokeAny operation. Thread context is captured at the point where invokeAny is invoked, rather than upon creation of the executor or construction of the builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
untimedInvokeAllRunsTasksWithContext
public void untimedInvokeAllRunsTasksWithContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for all tasks that are submitted via the ManagedExecutor's untimed invokeAll operation. Thread context is captured at the point where invokeAll is invoked, rather than upon creation of the executor or construction of the builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
untimedInvokeAnyRunsTasksWithContext
public void untimedInvokeAnyRunsTasksWithContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that thread context is captured and propagated per the configuration of the ManagedExecutor builder for one or more tasks that are submitted via the ManagedExecutor's untimed invokeAny operation. Thread context is captured at the point where invokeAny is invoked, rather than upon creation of the executor or construction of the builder.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-
copyCompletableFuture
public void copyCompletableFuture() throws InterruptedException, ExecutionException, TimeoutExceptionVerify that we can copy a CompletableFuture and get context propagation in the copy's dependent stages.- Throws:
InterruptedException- indicates test failureExecutionException- indicates test failureTimeoutException- indicates test failure
-
copyCompletionStage
Verify that we can copy a CompletionStage and get context propagation in the copy's dependent stages.- Throws:
InterruptedException- indicates test failureExecutionException- indicates test failureTimeoutException- indicates test failure
-
threadContextHasSamePropagationSettings
public void threadContextHasSamePropagationSettings() throws InterruptedException, ExecutionException, TimeoutExceptionVerify that we can obtain a ThreadContext with the same settings as the ManagedExecutor- Throws:
InterruptedException- indicates test failureExecutionException- indicates test failureTimeoutException- indicates test failure
-
withDefaultExecutorServiceIsUsedDirectlyAndViaGetThreadContext
public void withDefaultExecutorServiceIsUsedDirectlyAndViaGetThreadContext() throws ExecutionException, InterruptedException, TimeoutExceptionVerify that the presence of a default executor service implies async actions run on it.- Throws:
ExecutionException- indicates test failureInterruptedException- indicates test failureTimeoutException- indicates test failure
-