Class ProcessEngineExtension

java.lang.Object
org.camunda.bpm.engine.test.junit5.ProcessEngineExtension
All Implemented Interfaces:
org.camunda.bpm.engine.ProcessEngineServices, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.AfterTestExecutionCallback, org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.ParameterResolver, org.junit.jupiter.api.extension.TestInstancePostProcessor, org.junit.jupiter.api.extension.TestWatcher

public class ProcessEngineExtension extends Object implements org.junit.jupiter.api.extension.TestWatcher, org.junit.jupiter.api.extension.TestInstancePostProcessor, org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.AfterTestExecutionCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.ParameterResolver, org.camunda.bpm.engine.ProcessEngineServices
Junit 5 Extension to create and inject a ProcessEngine into the test class.

If you provide a camunda.cfg.xml file on the classpath. This file is used to configure the process engine.
Usage:

 @ExtendWith(ProcessEngineExtension.class)
 public class YourTest {

   // provide a property where the extension can inject the process engine
   public ProcessEngine processEngine;

   ...
 }
 

If you want to choose the camunda.cfg.xml file that is used in the test programmatically, you can register the extension directly and use the builder pattern to configure it.
Usage with configuration:

Usage:

 @RegisterExtension
 ProcessEngineExtension extension = ProcessEngineExtension.builder()
    .configurationResource("myConfigurationFile.xml")
    .build();}
 

You can declare a deployment with the Deployment annotation. This base class will make sure that this deployment gets deployed before the setUp and cascade deleted after the tearDown.

If you need the history service for your tests then you can specify the required history level of the test method or class, using the RequiredHistoryLevel annotation. If the current history level of the process engine is lower than the specified one then the test is skipped.

  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
    • processEngine

      protected org.camunda.bpm.engine.ProcessEngine processEngine
    • processEngineConfiguration

      protected org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration
    • repositoryService

      protected org.camunda.bpm.engine.RepositoryService repositoryService
    • runtimeService

      protected org.camunda.bpm.engine.RuntimeService runtimeService
    • taskService

      protected org.camunda.bpm.engine.TaskService taskService
    • historyService

      protected org.camunda.bpm.engine.HistoryService historyService
    • identityService

      protected org.camunda.bpm.engine.IdentityService identityService
    • managementService

      protected org.camunda.bpm.engine.ManagementService managementService
    • formService

      protected org.camunda.bpm.engine.FormService formService
    • filterService

      protected org.camunda.bpm.engine.FilterService filterService
    • authorizationService

      protected org.camunda.bpm.engine.AuthorizationService authorizationService
    • caseService

      protected org.camunda.bpm.engine.CaseService caseService
    • externalTaskService

      protected org.camunda.bpm.engine.ExternalTaskService externalTaskService
    • decisionService

      protected org.camunda.bpm.engine.DecisionService decisionService
    • configurationResource

      protected String configurationResource
    • deploymentId

      protected String deploymentId
    • ensureCleanAfterTest

      protected boolean ensureCleanAfterTest
    • additionalDeployments

      protected List<String> additionalDeployments
  • Constructor Details

    • ProcessEngineExtension

      public ProcessEngineExtension()
  • Method Details

    • initializeProcessEngine

      protected void initializeProcessEngine()
    • initializeServices

      protected void initializeServices()
    • clearServiceReferences

      protected void clearServiceReferences()
    • supportsParameter

      public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException
      Specified by:
      supportsParameter in interface org.junit.jupiter.api.extension.ParameterResolver
      Throws:
      org.junit.jupiter.api.extension.ParameterResolutionException
    • resolveParameter

      public Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException
      Specified by:
      resolveParameter in interface org.junit.jupiter.api.extension.ParameterResolver
      Throws:
      org.junit.jupiter.api.extension.ParameterResolutionException
    • beforeTestExecution

      public void beforeTestExecution(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      beforeTestExecution in interface org.junit.jupiter.api.extension.BeforeTestExecutionCallback
    • afterTestExecution

      public void afterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      afterTestExecution in interface org.junit.jupiter.api.extension.AfterTestExecutionCallback
    • afterAll

      public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Specified by:
      afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
      Throws:
      Exception
    • postProcessTestInstance

      public void postProcessTestInstance(Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      postProcessTestInstance in interface org.junit.jupiter.api.extension.TestInstancePostProcessor
    • builder

      public static ProcessEngineExtension builder()
    • configurationResource

      public ProcessEngineExtension configurationResource(String configurationResource)
    • useProcessEngine

      public ProcessEngineExtension useProcessEngine(org.camunda.bpm.engine.ProcessEngine engine)
    • ensureCleanAfterTest

      public ProcessEngineExtension ensureCleanAfterTest(boolean ensureCleanAfterTest)
    • manageDeployment

      public ProcessEngineExtension manageDeployment(org.camunda.bpm.engine.repository.Deployment deployment)
    • build

      public ProcessEngineExtension build()
    • illegalStateException

      protected Supplier<IllegalStateException> illegalStateException(String msg)
    • inject

      protected void inject(Object instance, Field field)
    • setCurrentTime

      public void setCurrentTime(Date currentTime)
    • getProcessEngine

      public org.camunda.bpm.engine.ProcessEngine getProcessEngine()
    • setProcessEngine

      public void setProcessEngine(org.camunda.bpm.engine.ProcessEngine processEngine)
    • getConfigurationResource

      public String getConfigurationResource()
    • getProcessEngineConfiguration

      public org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl getProcessEngineConfiguration()
    • getRepositoryService

      public org.camunda.bpm.engine.RepositoryService getRepositoryService()
      Specified by:
      getRepositoryService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setRepositoryService

      public void setRepositoryService(org.camunda.bpm.engine.RepositoryService repositoryService)
    • getRuntimeService

      public org.camunda.bpm.engine.RuntimeService getRuntimeService()
      Specified by:
      getRuntimeService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setRuntimeService

      public void setRuntimeService(org.camunda.bpm.engine.RuntimeService runtimeService)
    • getTaskService

      public org.camunda.bpm.engine.TaskService getTaskService()
      Specified by:
      getTaskService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setTaskService

      public void setTaskService(org.camunda.bpm.engine.TaskService taskService)
    • getHistoryService

      public org.camunda.bpm.engine.HistoryService getHistoryService()
      Specified by:
      getHistoryService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setHistoryService

      public void setHistoryService(org.camunda.bpm.engine.HistoryService historyService)
    • getIdentityService

      public org.camunda.bpm.engine.IdentityService getIdentityService()
      Specified by:
      getIdentityService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setIdentityService

      public void setIdentityService(org.camunda.bpm.engine.IdentityService identityService)
    • getManagementService

      public org.camunda.bpm.engine.ManagementService getManagementService()
      Specified by:
      getManagementService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setManagementService

      public void setManagementService(org.camunda.bpm.engine.ManagementService managementService)
    • getFormService

      public org.camunda.bpm.engine.FormService getFormService()
      Specified by:
      getFormService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setFormService

      public void setFormService(org.camunda.bpm.engine.FormService formService)
    • getFilterService

      public org.camunda.bpm.engine.FilterService getFilterService()
      Specified by:
      getFilterService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setFilterService

      public void setFilterService(org.camunda.bpm.engine.FilterService filterService)
    • getAuthorizationService

      public org.camunda.bpm.engine.AuthorizationService getAuthorizationService()
      Specified by:
      getAuthorizationService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setAuthorizationService

      public void setAuthorizationService(org.camunda.bpm.engine.AuthorizationService authorizationService)
    • getCaseService

      public org.camunda.bpm.engine.CaseService getCaseService()
      Specified by:
      getCaseService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setCaseService

      public void setCaseService(org.camunda.bpm.engine.CaseService caseService)
    • getExternalTaskService

      public org.camunda.bpm.engine.ExternalTaskService getExternalTaskService()
      Specified by:
      getExternalTaskService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setExternalTaskService

      public void setExternalTaskService(org.camunda.bpm.engine.ExternalTaskService externalTaskService)
    • getDecisionService

      public org.camunda.bpm.engine.DecisionService getDecisionService()
      Specified by:
      getDecisionService in interface org.camunda.bpm.engine.ProcessEngineServices
    • setDecisionService

      public void setDecisionService(org.camunda.bpm.engine.DecisionService decisionService)
    • setProcessEngineConfiguration

      public void setProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration)
    • setConfigurationResource

      public void setConfigurationResource(String configurationResource)
    • getDeploymentId

      public String getDeploymentId()
    • isEnsureCleanAfterTest

      public boolean isEnsureCleanAfterTest()
    • setEnsureCleanAfterTest

      public void setEnsureCleanAfterTest(boolean ensureCleanAfterTest)