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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    afterMethod(Method m, org.testng.ITestResult result)
     
    void
     
    void
     
    void
     
    void
    Verify that the ManagedExecutor implementation clears context types that are not configured under propagated, or cleared.
    void
    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 completedFuture implementation.
    void
    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.
    void
    Verify the MicroProfile Context Propagation implementation of propagate(), and cleared() for ManagedExecutor.Builder.
    void
    When 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.
    void
    When 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.
    void
    When 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.
    void
    When 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.
    void
    When 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.
    void
    Verify that we can copy a CompletableFuture and get context propagation in the copy's dependent stages.
    void
    Verify that we can copy a CompletionStage and get context propagation in the copy's dependent stages.
    static org.jboss.shrinkwrap.api.spec.WebArchive
     
    void
    Verify that thread context is cleared per the configuration of the ManagedExecutor builder for all tasks that are executed via the execute method.
    void
    Verify that thread context is propagated per the configuration of the ManagedExecutor builder for all tasks that are executed via the execute method.
    void
    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 failedFuture implementation.
    void
    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 failedStage implementation.
    void
    Verify that the ManagedExecutor implementation starts 2 async tasks/actions, and no more, when maxAsync is configured to 2.
    void
    Attempt to specify invalid values (less than -1 and 0) for maxAsync.
    void
    Verify that 3 tasks/actions, and no more, can be queued when maxQueued is configured to 3.
    void
    Attempt to specify invalid values (less than -1 and 0) for maxQueued.
    void
    Verify 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.
    void
    Verify that Application context makes the application's thread context class loader available to the task.
    void
    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.
    void
    Verify that the ManagedExecutor.Builder can be used to create multiple ManagedExecutors with different configured contexts.
    void
    Verify 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.
    void
    Verify that the ManagedExecutor shutdownNow method prevents additional tasks from being submitted and cancels tasks that are currently in progress or queued.
    void
    Verify that the ManagedExecutor shutdown method prevents additional tasks from being submitted but does not interfere with tasks and actions that are running or queued.
    void
    Verify 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.
    void
    Verify 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.
    void
    Verify that we can obtain a ThreadContext with the same settings as the ManagedExecutor
    void
    Verify 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.
    void
    Verify 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.
    void
    Verify 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.
    void
    Verify 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.
    void
    Verify 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ManagedExecutorTest

      public ManagedExecutorTest()
  • Method Details

    • after

      @AfterClass public void after()
    • afterMethod

      @AfterMethod public void afterMethod(Method m, org.testng.ITestResult result)
    • before

      @BeforeClass public void before()
    • beforeMethod

      @BeforeMethod public void beforeMethod(Method m)
    • createDeployment

      @Deployment public static org.jboss.shrinkwrap.api.spec.WebArchive createDeployment()
    • builderForManagedExecutorIsProvided

      public void builderForManagedExecutorIsProvided()
    • clearUnspecifiedContexts

      public void clearUnspecifiedContexts() throws InterruptedException, ExecutionException, TimeoutException
      Verify that the ManagedExecutor implementation clears context types that are not configured under propagated, or cleared.
      Throws:
      TimeoutException - indicates test failure
      ExecutionException - indicates test failure
      InterruptedException - indicates test failure
    • completedFutureDependentStagesRunWithContext

      public void completedFutureDependentStagesRunWithContext() throws ExecutionException, InterruptedException, TimeoutException
      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 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • completedStageDependentStagesRunWithContext

      public void completedStageDependentStagesRunWithContext() throws InterruptedException
      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, TimeoutException
      Verify the MicroProfile Context Propagation implementation of propagate(), and cleared() for ManagedExecutor.Builder.
      Throws:
      ExecutionException - indicates test failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • contextOfContextualCallableOverridesContextOfManagedExecutor

      public void contextOfContextualCallableOverridesContextOfManagedExecutor() throws ExecutionException, InterruptedException, TimeoutException
      When 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • contextOfContextualConsumerAndBiFunctionOverrideContextOfManagedExecutor

      public void contextOfContextualConsumerAndBiFunctionOverrideContextOfManagedExecutor() throws ExecutionException, InterruptedException, TimeoutException
      When 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • contextOfContextualFunctionOverridesContextOfManagedExecutor

      public void contextOfContextualFunctionOverridesContextOfManagedExecutor() throws ExecutionException, InterruptedException, TimeoutException
      When 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • contextOfContextualRunnableOverridesContextOfManagedExecutor

      public void contextOfContextualRunnableOverridesContextOfManagedExecutor() throws ExecutionException, InterruptedException, TimeoutException
      When 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • contextOfContextualSuppplierAndBiConsumerOverrideContextOfManagedExecutor

      public void contextOfContextualSuppplierAndBiConsumerOverrideContextOfManagedExecutor() throws ExecutionException, InterruptedException, TimeoutException
      When 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • executedTaskRunsWithClearedContext

      public void executedTaskRunsWithClearedContext() throws ExecutionException, InterruptedException, TimeoutException
      Verify 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • executedTaskRunsWithContext

      public void executedTaskRunsWithContext() throws ExecutionException, InterruptedException, TimeoutException
      Verify 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • failedFutureDependentStagesRunWithContext

      public void failedFutureDependentStagesRunWithContext() throws ExecutionException, InterruptedException, TimeoutException
      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 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • failedStageDependentStagesRunWithContext

      public void failedStageDependentStagesRunWithContext() throws ExecutionException, InterruptedException, TimeoutException
      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 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • maxAsync2

      public void maxAsync2() throws ExecutionException, InterruptedException, TimeoutException
      Verify that the ManagedExecutor implementation starts 2 async tasks/actions, and no more, when maxAsync is configured to 2.
      Throws:
      ExecutionException - indicates test failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • maxAsyncInvalidValues

      public void maxAsyncInvalidValues() throws ExecutionException, InterruptedException, TimeoutException
      Attempt 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • maxQueued3

      public void maxQueued3() throws ExecutionException, InterruptedException, TimeoutException
      Verify that 3 tasks/actions, and no more, can be queued when maxQueued is configured to 3.
      Throws:
      ExecutionException - indicates test failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • maxQueuedInvalidValues

      public void maxQueuedInvalidValues() throws ExecutionException, InterruptedException, TimeoutException
      Attempt 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • newIncompleteFutureDependentStagesRunWithContext

      public void newIncompleteFutureDependentStagesRunWithContext() throws ExecutionException, InterruptedException
      Verify 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 failure
      InterruptedException - indicates test failure
    • propagateApplicationContext

      public void propagateApplicationContext() throws ExecutionException, InterruptedException, TimeoutException
      Verify that Application context makes the application's thread context class loader available to the task.
      Throws:
      ExecutionException - indicates test failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • propagateTransactionContextJTA

      public void propagateTransactionContextJTA() throws Exception
      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 of UserTransaction via 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, TimeoutException
      Verify 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • shutdownPreventsAdditionalSubmits

      public void shutdownPreventsAdditionalSubmits() throws ExecutionException, InterruptedException, TimeoutException
      Verify 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • reuseManagedExecutorBuilder

      public void reuseManagedExecutorBuilder() throws ExecutionException, InterruptedException, TimeoutException
      Verify that the ManagedExecutor.Builder can be used to create multiple ManagedExecutors with different configured contexts.
      Throws:
      ExecutionException - indicates test failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • runAsyncStageAndDependentStagesRunWithContext

      public void runAsyncStageAndDependentStagesRunWithContext() throws ExecutionException, InterruptedException
      Verify 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 failure
      InterruptedException - indicates test failure
    • submittedTasksRunWithContext

      public void submittedTasksRunWithContext() throws ExecutionException, InterruptedException, TimeoutException
      Verify 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • supplyAsyncStageAndDependentStagesRunWithContext

      public void supplyAsyncStageAndDependentStagesRunWithContext() throws ExecutionException, InterruptedException, TimeoutException
      Verify 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • timedInvokeAllRunsTasksWithContext

      public void timedInvokeAllRunsTasksWithContext() throws ExecutionException, InterruptedException, TimeoutException
      Verify 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • timedInvokeAnyRunsTaskWithContext

      public void timedInvokeAnyRunsTaskWithContext() throws ExecutionException, InterruptedException, TimeoutException
      Verify 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • untimedInvokeAllRunsTasksWithContext

      public void untimedInvokeAllRunsTasksWithContext() throws ExecutionException, InterruptedException, TimeoutException
      Verify 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • untimedInvokeAnyRunsTasksWithContext

      public void untimedInvokeAnyRunsTasksWithContext() throws ExecutionException, InterruptedException, TimeoutException
      Verify 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 failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure
    • copyCompletableFuture

      public void copyCompletableFuture() throws InterruptedException, ExecutionException, TimeoutException
      Verify that we can copy a CompletableFuture and get context propagation in the copy's dependent stages.
      Throws:
      InterruptedException - indicates test failure
      ExecutionException - indicates test failure
      TimeoutException - indicates test failure
    • copyCompletionStage

      public void copyCompletionStage() throws InterruptedException, ExecutionException, TimeoutException
      Verify that we can copy a CompletionStage and get context propagation in the copy's dependent stages.
      Throws:
      InterruptedException - indicates test failure
      ExecutionException - indicates test failure
      TimeoutException - indicates test failure
    • threadContextHasSamePropagationSettings

      public void threadContextHasSamePropagationSettings() throws InterruptedException, ExecutionException, TimeoutException
      Verify that we can obtain a ThreadContext with the same settings as the ManagedExecutor
      Throws:
      InterruptedException - indicates test failure
      ExecutionException - indicates test failure
      TimeoutException - indicates test failure
    • withDefaultExecutorServiceIsUsedDirectlyAndViaGetThreadContext

      public void withDefaultExecutorServiceIsUsedDirectlyAndViaGetThreadContext() throws ExecutionException, InterruptedException, TimeoutException
      Verify that the presence of a default executor service implies async actions run on it.
      Throws:
      ExecutionException - indicates test failure
      InterruptedException - indicates test failure
      TimeoutException - indicates test failure