Class ProcessEngineRule
- java.lang.Object
-
- org.junit.rules.TestWatcher
-
- org.camunda.bpm.engine.test.ProcessEngineRule
-
- All Implemented Interfaces:
ProcessEngineServices,org.junit.rules.TestRule
- Direct Known Subclasses:
UpgradeTestRule
public class ProcessEngineRule extends org.junit.rules.TestWatcher implements ProcessEngineServices
Convenience for ProcessEngine and services initialization in the form of a JUnit rule.Usage:
public class YourTest { @Rule public ProcessEngineRule processEngineRule = new ProcessEngineRule(); ... }The ProcessEngine and the services will be made available to the test class through the getters of the processEngineRule. The processEngine will be initialized by default with the camunda.cfg.xml resource on the classpath. To specify a different configuration file, pass the resource location in
the appropriate constructor. Process engines will be cached statically. Right before the first time the setUp is called for a given configuration resource, the process engine will be constructed.You can declare a deployment with the
Deploymentannotation. This base class will make sure that this deployment gets deployed before the setUp andcascade deletedafter the tearDown. If you add a deployment programmatically in your test, you have to make it known to the processEngineRule by callingmanageDeployment(org.camunda.bpm.engine.repository.Deployment)to have it cleaned up automatically.The processEngineRule also lets you
set the current time used by the process engine. This can be handy to control the exact time that is used by the engine in order to verify e.g., due dates of timers. Or start, end and duration times in the history service. In the tearDown, the internal clock will automatically be reset to use the current system time rather then the time that was set during a test method. In other words, you don't have to clean up your own time messing mess ;-)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
RequiredHistoryLevelannotation. If the current history level of the process engine is lower than the specified one then the test is skipped.- Author:
- Tom Baeyens
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>additionalDeploymentsprotected AuthorizationServiceauthorizationServiceprotected CaseServicecaseServiceprotected java.lang.StringconfigurationResourceprotected java.lang.StringconfigurationResourceCompatprotected DecisionServicedecisionServiceprotected java.lang.StringdeploymentIdprotected booleanensureCleanAfterTestprotected ExternalTaskServiceexternalTaskServiceprotected FilterServicefilterServiceprotected FormServiceformServiceprotected HistoryServicehistoryServiceprotected IdentityServiceidentityServiceprotected ManagementServicemanagementServiceprotected ProcessEngineprocessEngineprotected ProcessEngineConfigurationImplprocessEngineConfigurationprotected RepositoryServicerepositoryServiceprotected RuntimeServiceruntimeServiceprotected TaskServicetaskService
-
Constructor Summary
Constructors Constructor Description ProcessEngineRule()ProcessEngineRule(boolean ensureCleanAfterTest)ProcessEngineRule(java.lang.String configurationResource)ProcessEngineRule(java.lang.String configurationResource, boolean ensureCleanAfterTest)ProcessEngineRule(ProcessEngine processEngine)ProcessEngineRule(ProcessEngine processEngine, boolean ensureCleanAfterTest)
-
Method Summary
-
-
-
Field Detail
-
configurationResource
protected java.lang.String configurationResource
-
configurationResourceCompat
protected java.lang.String configurationResourceCompat
-
deploymentId
protected java.lang.String deploymentId
-
additionalDeployments
protected java.util.List<java.lang.String> additionalDeployments
-
ensureCleanAfterTest
protected boolean ensureCleanAfterTest
-
processEngine
protected ProcessEngine processEngine
-
processEngineConfiguration
protected ProcessEngineConfigurationImpl processEngineConfiguration
-
repositoryService
protected RepositoryService repositoryService
-
runtimeService
protected RuntimeService runtimeService
-
taskService
protected TaskService taskService
-
historyService
protected HistoryService historyService
-
identityService
protected IdentityService identityService
-
managementService
protected ManagementService managementService
-
formService
protected FormService formService
-
filterService
protected FilterService filterService
-
authorizationService
protected AuthorizationService authorizationService
-
caseService
protected CaseService caseService
-
externalTaskService
protected ExternalTaskService externalTaskService
-
decisionService
protected DecisionService decisionService
-
-
Constructor Detail
-
ProcessEngineRule
public ProcessEngineRule()
-
ProcessEngineRule
public ProcessEngineRule(boolean ensureCleanAfterTest)
-
ProcessEngineRule
public ProcessEngineRule(java.lang.String configurationResource)
-
ProcessEngineRule
public ProcessEngineRule(java.lang.String configurationResource, boolean ensureCleanAfterTest)
-
ProcessEngineRule
public ProcessEngineRule(ProcessEngine processEngine)
-
ProcessEngineRule
public ProcessEngineRule(ProcessEngine processEngine, boolean ensureCleanAfterTest)
-
-
Method Detail
-
starting
public void starting(org.junit.runner.Description description)
- Overrides:
startingin classorg.junit.rules.TestWatcher
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)- Specified by:
applyin interfaceorg.junit.rules.TestRule- Overrides:
applyin classorg.junit.rules.TestWatcher
-
initializeProcessEngine
protected void initializeProcessEngine()
-
initializeServices
protected void initializeServices()
-
clearServiceReferences
protected void clearServiceReferences()
-
finished
public void finished(org.junit.runner.Description description)
- Overrides:
finishedin classorg.junit.rules.TestWatcher
-
setCurrentTime
public void setCurrentTime(java.util.Date currentTime)
-
getConfigurationResource
public java.lang.String getConfigurationResource()
-
setConfigurationResource
public void setConfigurationResource(java.lang.String configurationResource)
-
getProcessEngine
public ProcessEngine getProcessEngine()
-
setProcessEngine
public void setProcessEngine(ProcessEngine processEngine)
-
getProcessEngineConfiguration
public ProcessEngineConfigurationImpl getProcessEngineConfiguration()
-
setProcessEngineConfiguration
public void setProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration)
-
getRepositoryService
public RepositoryService getRepositoryService()
Description copied from interface:ProcessEngineServicesReturns the process engine'sRepositoryService.- Specified by:
getRepositoryServicein interfaceProcessEngineServices- Returns:
- the
RepositoryServiceobject.
-
setRepositoryService
public void setRepositoryService(RepositoryService repositoryService)
-
getRuntimeService
public RuntimeService getRuntimeService()
Description copied from interface:ProcessEngineServicesReturns the process engine'sRuntimeService.- Specified by:
getRuntimeServicein interfaceProcessEngineServices- Returns:
- the
RuntimeServiceobject.
-
setRuntimeService
public void setRuntimeService(RuntimeService runtimeService)
-
getTaskService
public TaskService getTaskService()
Description copied from interface:ProcessEngineServicesReturns the process engine'sTaskService.- Specified by:
getTaskServicein interfaceProcessEngineServices- Returns:
- the
TaskServiceobject.
-
setTaskService
public void setTaskService(TaskService taskService)
-
getHistoryService
public HistoryService getHistoryService()
Description copied from interface:ProcessEngineServicesReturns the process engine'sHistoryService.- Specified by:
getHistoryServicein interfaceProcessEngineServices- Returns:
- the
HistoryServiceobject.
-
setHistoryService
public void setHistoryService(HistoryService historyService)
-
setHistoricDataService
public void setHistoricDataService(HistoryService historicService)
- Parameters:
historicService- the historiy service instance- See Also:
setHistoryService(HistoryService)
-
getIdentityService
public IdentityService getIdentityService()
Description copied from interface:ProcessEngineServicesReturns the process engine'sIdentityService.- Specified by:
getIdentityServicein interfaceProcessEngineServices- Returns:
- the
IdentityServiceobject.
-
setIdentityService
public void setIdentityService(IdentityService identityService)
-
getManagementService
public ManagementService getManagementService()
Description copied from interface:ProcessEngineServicesReturns the process engine'sManagementService.- Specified by:
getManagementServicein interfaceProcessEngineServices- Returns:
- the
ManagementServiceobject.
-
getAuthorizationService
public AuthorizationService getAuthorizationService()
Description copied from interface:ProcessEngineServicesReturns the process engine'sAuthorizationService.- Specified by:
getAuthorizationServicein interfaceProcessEngineServices- Returns:
- the
AuthorizationServiceobject.
-
setAuthorizationService
public void setAuthorizationService(AuthorizationService authorizationService)
-
getCaseService
public CaseService getCaseService()
Description copied from interface:ProcessEngineServicesReturns the engine'sCaseService.- Specified by:
getCaseServicein interfaceProcessEngineServices- Returns:
- the
CaseServiceobject.
-
setCaseService
public void setCaseService(CaseService caseService)
-
getFormService
public FormService getFormService()
Description copied from interface:ProcessEngineServicesReturns the process engine'sFormService.- Specified by:
getFormServicein interfaceProcessEngineServices- Returns:
- the
FormServiceobject.
-
setFormService
public void setFormService(FormService formService)
-
setManagementService
public void setManagementService(ManagementService managementService)
-
getFilterService
public FilterService getFilterService()
Description copied from interface:ProcessEngineServicesReturns the engine'sFilterService.- Specified by:
getFilterServicein interfaceProcessEngineServices- Returns:
- the
FilterServiceobject.
-
setFilterService
public void setFilterService(FilterService filterService)
-
getExternalTaskService
public ExternalTaskService getExternalTaskService()
Description copied from interface:ProcessEngineServicesReturns the engine'sExternalTaskService.- Specified by:
getExternalTaskServicein interfaceProcessEngineServices- Returns:
- the
ExternalTaskServiceobject.
-
setExternalTaskService
public void setExternalTaskService(ExternalTaskService externalTaskService)
-
getDecisionService
public DecisionService getDecisionService()
Description copied from interface:ProcessEngineServicesReturns the engine'sDecisionService.- Specified by:
getDecisionServicein interfaceProcessEngineServices- Returns:
- the
DecisionServiceobject.
-
setDecisionService
public void setDecisionService(DecisionService decisionService)
-
manageDeployment
public void manageDeployment(Deployment deployment)
-
-