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 SummaryFields 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 SummaryConstructors 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- 
configurationResourceprotected java.lang.String configurationResource 
 - 
configurationResourceCompatprotected java.lang.String configurationResourceCompat 
 - 
deploymentIdprotected java.lang.String deploymentId 
 - 
additionalDeploymentsprotected java.util.List<java.lang.String> additionalDeployments 
 - 
ensureCleanAfterTestprotected boolean ensureCleanAfterTest 
 - 
processEngineprotected ProcessEngine processEngine 
 - 
processEngineConfigurationprotected ProcessEngineConfigurationImpl processEngineConfiguration 
 - 
repositoryServiceprotected RepositoryService repositoryService 
 - 
runtimeServiceprotected RuntimeService runtimeService 
 - 
taskServiceprotected TaskService taskService 
 - 
historyServiceprotected HistoryService historyService 
 - 
identityServiceprotected IdentityService identityService 
 - 
managementServiceprotected ManagementService managementService 
 - 
formServiceprotected FormService formService 
 - 
filterServiceprotected FilterService filterService 
 - 
authorizationServiceprotected AuthorizationService authorizationService 
 - 
caseServiceprotected CaseService caseService 
 - 
externalTaskServiceprotected ExternalTaskService externalTaskService 
 - 
decisionServiceprotected DecisionService decisionService 
 
- 
 - 
Constructor Detail- 
ProcessEngineRulepublic ProcessEngineRule() 
 - 
ProcessEngineRulepublic ProcessEngineRule(boolean ensureCleanAfterTest) 
 - 
ProcessEngineRulepublic ProcessEngineRule(java.lang.String configurationResource) 
 - 
ProcessEngineRulepublic ProcessEngineRule(java.lang.String configurationResource, boolean ensureCleanAfterTest)
 - 
ProcessEngineRulepublic ProcessEngineRule(ProcessEngine processEngine) 
 - 
ProcessEngineRulepublic ProcessEngineRule(ProcessEngine processEngine, boolean ensureCleanAfterTest) 
 
- 
 - 
Method Detail- 
startingpublic void starting(org.junit.runner.Description description) - Overrides:
- startingin class- org.junit.rules.TestWatcher
 
 - 
applypublic org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)- Specified by:
- applyin interface- org.junit.rules.TestRule
- Overrides:
- applyin class- org.junit.rules.TestWatcher
 
 - 
initializeProcessEngineprotected void initializeProcessEngine() 
 - 
initializeServicesprotected void initializeServices() 
 - 
clearServiceReferencesprotected void clearServiceReferences() 
 - 
finishedpublic void finished(org.junit.runner.Description description) - Overrides:
- finishedin class- org.junit.rules.TestWatcher
 
 - 
setCurrentTimepublic void setCurrentTime(java.util.Date currentTime) 
 - 
getConfigurationResourcepublic java.lang.String getConfigurationResource() 
 - 
setConfigurationResourcepublic void setConfigurationResource(java.lang.String configurationResource) 
 - 
getProcessEnginepublic ProcessEngine getProcessEngine() 
 - 
setProcessEnginepublic void setProcessEngine(ProcessEngine processEngine) 
 - 
getProcessEngineConfigurationpublic ProcessEngineConfigurationImpl getProcessEngineConfiguration() 
 - 
setProcessEngineConfigurationpublic void setProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration) 
 - 
getRepositoryServicepublic RepositoryService getRepositoryService() Description copied from interface:ProcessEngineServicesReturns the process engine'sRepositoryService.- Specified by:
- getRepositoryServicein interface- ProcessEngineServices
- Returns:
- the RepositoryServiceobject.
 
 - 
setRepositoryServicepublic void setRepositoryService(RepositoryService repositoryService) 
 - 
getRuntimeServicepublic RuntimeService getRuntimeService() Description copied from interface:ProcessEngineServicesReturns the process engine'sRuntimeService.- Specified by:
- getRuntimeServicein interface- ProcessEngineServices
- Returns:
- the RuntimeServiceobject.
 
 - 
setRuntimeServicepublic void setRuntimeService(RuntimeService runtimeService) 
 - 
getTaskServicepublic TaskService getTaskService() Description copied from interface:ProcessEngineServicesReturns the process engine'sTaskService.- Specified by:
- getTaskServicein interface- ProcessEngineServices
- Returns:
- the TaskServiceobject.
 
 - 
setTaskServicepublic void setTaskService(TaskService taskService) 
 - 
getHistoryServicepublic HistoryService getHistoryService() Description copied from interface:ProcessEngineServicesReturns the process engine'sHistoryService.- Specified by:
- getHistoryServicein interface- ProcessEngineServices
- Returns:
- the HistoryServiceobject.
 
 - 
setHistoryServicepublic void setHistoryService(HistoryService historyService) 
 - 
setHistoricDataServicepublic void setHistoricDataService(HistoryService historicService) - Parameters:
- historicService- the historiy service instance
- See Also:
- setHistoryService(HistoryService)
 
 - 
getIdentityServicepublic IdentityService getIdentityService() Description copied from interface:ProcessEngineServicesReturns the process engine'sIdentityService.- Specified by:
- getIdentityServicein interface- ProcessEngineServices
- Returns:
- the IdentityServiceobject.
 
 - 
setIdentityServicepublic void setIdentityService(IdentityService identityService) 
 - 
getManagementServicepublic ManagementService getManagementService() Description copied from interface:ProcessEngineServicesReturns the process engine'sManagementService.- Specified by:
- getManagementServicein interface- ProcessEngineServices
- Returns:
- the ManagementServiceobject.
 
 - 
getAuthorizationServicepublic AuthorizationService getAuthorizationService() Description copied from interface:ProcessEngineServicesReturns the process engine'sAuthorizationService.- Specified by:
- getAuthorizationServicein interface- ProcessEngineServices
- Returns:
- the AuthorizationServiceobject.
 
 - 
setAuthorizationServicepublic void setAuthorizationService(AuthorizationService authorizationService) 
 - 
getCaseServicepublic CaseService getCaseService() Description copied from interface:ProcessEngineServicesReturns the engine'sCaseService.- Specified by:
- getCaseServicein interface- ProcessEngineServices
- Returns:
- the CaseServiceobject.
 
 - 
setCaseServicepublic void setCaseService(CaseService caseService) 
 - 
getFormServicepublic FormService getFormService() Description copied from interface:ProcessEngineServicesReturns the process engine'sFormService.- Specified by:
- getFormServicein interface- ProcessEngineServices
- Returns:
- the FormServiceobject.
 
 - 
setFormServicepublic void setFormService(FormService formService) 
 - 
setManagementServicepublic void setManagementService(ManagementService managementService) 
 - 
getFilterServicepublic FilterService getFilterService() Description copied from interface:ProcessEngineServicesReturns the engine'sFilterService.- Specified by:
- getFilterServicein interface- ProcessEngineServices
- Returns:
- the FilterServiceobject.
 
 - 
setFilterServicepublic void setFilterService(FilterService filterService) 
 - 
getExternalTaskServicepublic ExternalTaskService getExternalTaskService() Description copied from interface:ProcessEngineServicesReturns the engine'sExternalTaskService.- Specified by:
- getExternalTaskServicein interface- ProcessEngineServices
- Returns:
- the ExternalTaskServiceobject.
 
 - 
setExternalTaskServicepublic void setExternalTaskService(ExternalTaskService externalTaskService) 
 - 
getDecisionServicepublic DecisionService getDecisionService() Description copied from interface:ProcessEngineServicesReturns the engine'sDecisionService.- Specified by:
- getDecisionServicein interface- ProcessEngineServices
- Returns:
- the DecisionServiceobject.
 
 - 
setDecisionServicepublic void setDecisionService(DecisionService decisionService) 
 - 
manageDeploymentpublic void manageDeployment(Deployment deployment) 
 
- 
 
-