Class ProcessEngineRule
- All Implemented Interfaces:
ProcessEngineServices
,org.junit.rules.TestRule
- Direct Known Subclasses:
UpgradeTestRule
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
and cascade
deleted
after the tearDown. If you add a deployment programmatically in your
test, you have to make it known to the processEngineRule by calling
manageDeployment(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
Modifier and TypeFieldDescriptionprotected AuthorizationService
protected CaseService
protected String
protected String
protected DecisionService
protected String
protected boolean
protected ExternalTaskService
protected FilterService
protected FormService
protected HistoryService
protected IdentityService
protected ManagementService
protected ProcessEngine
protected ProcessEngineConfigurationImpl
protected RepositoryService
protected RuntimeService
protected TaskService
-
Constructor Summary
ConstructorDescriptionProcessEngineRule
(boolean ensureCleanAfterTest) ProcessEngineRule
(String configurationResource) ProcessEngineRule
(String configurationResource, boolean ensureCleanAfterTest) ProcessEngineRule
(ProcessEngine processEngine) ProcessEngineRule
(ProcessEngine processEngine, boolean ensureCleanAfterTest) -
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runner.Description description) protected void
void
finished
(org.junit.runner.Description description) Returns the process engine'sAuthorizationService
.Returns the engine'sCaseService
.Returns the engine'sDecisionService
.Returns the engine'sExternalTaskService
.Returns the engine'sFilterService
.Returns the process engine'sFormService
.Returns the process engine'sHistoryService
.Returns the process engine'sIdentityService
.Returns the process engine'sManagementService
.Returns the process engine'sRepositoryService
.Returns the process engine'sRuntimeService
.Returns the process engine'sTaskService
.protected void
protected void
void
manageDeployment
(Deployment deployment) void
setAuthorizationService
(AuthorizationService authorizationService) void
setCaseService
(CaseService caseService) void
setConfigurationResource
(String configurationResource) void
setCurrentTime
(Date currentTime) void
setDecisionService
(DecisionService decisionService) void
setExternalTaskService
(ExternalTaskService externalTaskService) void
setFilterService
(FilterService filterService) void
setFormService
(FormService formService) void
setHistoricDataService
(HistoryService historicService) void
setHistoryService
(HistoryService historyService) void
setIdentityService
(IdentityService identityService) void
setManagementService
(ManagementService managementService) void
setProcessEngine
(ProcessEngine processEngine) void
setProcessEngineConfiguration
(ProcessEngineConfigurationImpl processEngineConfiguration) void
setRepositoryService
(RepositoryService repositoryService) void
setRuntimeService
(RuntimeService runtimeService) void
setTaskService
(TaskService taskService) void
starting
(org.junit.runner.Description description) Methods inherited from class org.junit.rules.TestWatcher
failed, skipped, skipped, succeeded
-
Field Details
-
configurationResource
-
configurationResourceCompat
-
deploymentId
-
additionalDeployments
-
ensureCleanAfterTest
protected boolean ensureCleanAfterTest -
processEngine
-
processEngineConfiguration
-
repositoryService
-
runtimeService
-
taskService
-
historyService
-
identityService
-
managementService
-
formService
-
filterService
-
authorizationService
-
caseService
-
externalTaskService
-
decisionService
-
-
Constructor Details
-
ProcessEngineRule
public ProcessEngineRule() -
ProcessEngineRule
public ProcessEngineRule(boolean ensureCleanAfterTest) -
ProcessEngineRule
-
ProcessEngineRule
-
ProcessEngineRule
-
ProcessEngineRule
-
-
Method Details
-
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
-
getConfigurationResource
-
setConfigurationResource
-
getProcessEngine
-
setProcessEngine
-
getProcessEngineConfiguration
-
setProcessEngineConfiguration
public void setProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration) -
getRepositoryService
Description copied from interface:ProcessEngineServices
Returns the process engine'sRepositoryService
.- Specified by:
getRepositoryService
in interfaceProcessEngineServices
- Returns:
- the
RepositoryService
object.
-
setRepositoryService
-
getRuntimeService
Description copied from interface:ProcessEngineServices
Returns the process engine'sRuntimeService
.- Specified by:
getRuntimeService
in interfaceProcessEngineServices
- Returns:
- the
RuntimeService
object.
-
setRuntimeService
-
getTaskService
Description copied from interface:ProcessEngineServices
Returns the process engine'sTaskService
.- Specified by:
getTaskService
in interfaceProcessEngineServices
- Returns:
- the
TaskService
object.
-
setTaskService
-
getHistoryService
Description copied from interface:ProcessEngineServices
Returns the process engine'sHistoryService
.- Specified by:
getHistoryService
in interfaceProcessEngineServices
- Returns:
- the
HistoryService
object.
-
setHistoryService
-
setHistoricDataService
- Parameters:
historicService
- the historiy service instance- See Also:
-
getIdentityService
Description copied from interface:ProcessEngineServices
Returns the process engine'sIdentityService
.- Specified by:
getIdentityService
in interfaceProcessEngineServices
- Returns:
- the
IdentityService
object.
-
setIdentityService
-
getManagementService
Description copied from interface:ProcessEngineServices
Returns the process engine'sManagementService
.- Specified by:
getManagementService
in interfaceProcessEngineServices
- Returns:
- the
ManagementService
object.
-
getAuthorizationService
Description copied from interface:ProcessEngineServices
Returns the process engine'sAuthorizationService
.- Specified by:
getAuthorizationService
in interfaceProcessEngineServices
- Returns:
- the
AuthorizationService
object.
-
setAuthorizationService
-
getCaseService
Description copied from interface:ProcessEngineServices
Returns the engine'sCaseService
.- Specified by:
getCaseService
in interfaceProcessEngineServices
- Returns:
- the
CaseService
object.
-
setCaseService
-
getFormService
Description copied from interface:ProcessEngineServices
Returns the process engine'sFormService
.- Specified by:
getFormService
in interfaceProcessEngineServices
- Returns:
- the
FormService
object.
-
setFormService
-
setManagementService
-
getFilterService
Description copied from interface:ProcessEngineServices
Returns the engine'sFilterService
.- Specified by:
getFilterService
in interfaceProcessEngineServices
- Returns:
- the
FilterService
object.
-
setFilterService
-
getExternalTaskService
Description copied from interface:ProcessEngineServices
Returns the engine'sExternalTaskService
.- Specified by:
getExternalTaskService
in interfaceProcessEngineServices
- Returns:
- the
ExternalTaskService
object.
-
setExternalTaskService
-
getDecisionService
Description copied from interface:ProcessEngineServices
Returns the engine'sDecisionService
.- Specified by:
getDecisionService
in interfaceProcessEngineServices
- Returns:
- the
DecisionService
object.
-
setDecisionService
-
manageDeployment
-