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
Deployment
annotation. This base class will make sure that this deployment gets deployed before the setUp andcascade deleted
after 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
RequiredHistoryLevel
annotation. 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>
additionalDeployments
protected AuthorizationService
authorizationService
protected CaseService
caseService
protected java.lang.String
configurationResource
protected java.lang.String
configurationResourceCompat
protected DecisionService
decisionService
protected java.lang.String
deploymentId
protected boolean
ensureCleanAfterTest
protected ExternalTaskService
externalTaskService
protected FilterService
filterService
protected FormService
formService
protected HistoryService
historyService
protected IdentityService
identityService
protected ManagementService
managementService
protected ProcessEngine
processEngine
protected ProcessEngineConfigurationImpl
processEngineConfiguration
protected RepositoryService
repositoryService
protected RuntimeService
runtimeService
protected TaskService
taskService
-
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:
starting
in 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:
apply
in interfaceorg.junit.rules.TestRule
- Overrides:
apply
in 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:
finished
in 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:ProcessEngineServices
Returns the process engine'sRepositoryService
.- Specified by:
getRepositoryService
in interfaceProcessEngineServices
- Returns:
- the
RepositoryService
object.
-
setRepositoryService
public void setRepositoryService(RepositoryService repositoryService)
-
getRuntimeService
public RuntimeService getRuntimeService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sRuntimeService
.- Specified by:
getRuntimeService
in interfaceProcessEngineServices
- Returns:
- the
RuntimeService
object.
-
setRuntimeService
public void setRuntimeService(RuntimeService runtimeService)
-
getTaskService
public TaskService getTaskService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sTaskService
.- Specified by:
getTaskService
in interfaceProcessEngineServices
- Returns:
- the
TaskService
object.
-
setTaskService
public void setTaskService(TaskService taskService)
-
getHistoryService
public HistoryService getHistoryService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sHistoryService
.- Specified by:
getHistoryService
in interfaceProcessEngineServices
- Returns:
- the
HistoryService
object.
-
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:ProcessEngineServices
Returns the process engine'sIdentityService
.- Specified by:
getIdentityService
in interfaceProcessEngineServices
- Returns:
- the
IdentityService
object.
-
setIdentityService
public void setIdentityService(IdentityService identityService)
-
getManagementService
public ManagementService getManagementService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sManagementService
.- Specified by:
getManagementService
in interfaceProcessEngineServices
- Returns:
- the
ManagementService
object.
-
getAuthorizationService
public AuthorizationService getAuthorizationService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sAuthorizationService
.- Specified by:
getAuthorizationService
in interfaceProcessEngineServices
- Returns:
- the
AuthorizationService
object.
-
setAuthorizationService
public void setAuthorizationService(AuthorizationService authorizationService)
-
getCaseService
public CaseService getCaseService()
Description copied from interface:ProcessEngineServices
Returns the engine'sCaseService
.- Specified by:
getCaseService
in interfaceProcessEngineServices
- Returns:
- the
CaseService
object.
-
setCaseService
public void setCaseService(CaseService caseService)
-
getFormService
public FormService getFormService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sFormService
.- Specified by:
getFormService
in interfaceProcessEngineServices
- Returns:
- the
FormService
object.
-
setFormService
public void setFormService(FormService formService)
-
setManagementService
public void setManagementService(ManagementService managementService)
-
getFilterService
public FilterService getFilterService()
Description copied from interface:ProcessEngineServices
Returns the engine'sFilterService
.- Specified by:
getFilterService
in interfaceProcessEngineServices
- Returns:
- the
FilterService
object.
-
setFilterService
public void setFilterService(FilterService filterService)
-
getExternalTaskService
public ExternalTaskService getExternalTaskService()
Description copied from interface:ProcessEngineServices
Returns the engine'sExternalTaskService
.- Specified by:
getExternalTaskService
in interfaceProcessEngineServices
- Returns:
- the
ExternalTaskService
object.
-
setExternalTaskService
public void setExternalTaskService(ExternalTaskService externalTaskService)
-
getDecisionService
public DecisionService getDecisionService()
Description copied from interface:ProcessEngineServices
Returns the engine'sDecisionService
.- Specified by:
getDecisionService
in interfaceProcessEngineServices
- Returns:
- the
DecisionService
object.
-
setDecisionService
public void setDecisionService(DecisionService decisionService)
-
manageDeployment
public void manageDeployment(Deployment deployment)
-
-