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
FieldsModifier and TypeFieldDescriptionprotected AuthorizationServiceprotected CaseServiceprotected Stringprotected Stringprotected DecisionServiceprotected Stringprotected booleanprotected ExternalTaskServiceprotected FilterServiceprotected FormServiceprotected HistoryServiceprotected IdentityServiceprotected ManagementServiceprotected ProcessEngineprotected ProcessEngineConfigurationImplprotected RepositoryServiceprotected RuntimeServiceprotected TaskService -
Constructor Summary
ConstructorsConstructorDescriptionProcessEngineRule(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.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description) protected voidvoidfinished(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 voidprotected voidvoidmanageDeployment(Deployment deployment) voidsetAuthorizationService(AuthorizationService authorizationService) voidsetCaseService(CaseService caseService) voidsetConfigurationResource(String configurationResource) voidsetCurrentTime(Date currentTime) voidsetDecisionService(DecisionService decisionService) voidsetExternalTaskService(ExternalTaskService externalTaskService) voidsetFilterService(FilterService filterService) voidsetFormService(FormService formService) voidsetHistoricDataService(HistoryService historicService) voidsetHistoryService(HistoryService historyService) voidsetIdentityService(IdentityService identityService) voidsetManagementService(ManagementService managementService) voidsetProcessEngine(ProcessEngine processEngine) voidsetProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration) voidsetRepositoryService(RepositoryService repositoryService) voidsetRuntimeService(RuntimeService runtimeService) voidsetTaskService(TaskService taskService) voidstarting(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:
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
-
getConfigurationResource
-
setConfigurationResource
-
getProcessEngine
-
setProcessEngine
-
getProcessEngineConfiguration
-
setProcessEngineConfiguration
public void setProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration) -
getRepositoryService
Description copied from interface:ProcessEngineServicesReturns the process engine'sRepositoryService.- Specified by:
getRepositoryServicein interfaceProcessEngineServices- Returns:
- the
RepositoryServiceobject.
-
setRepositoryService
-
getRuntimeService
Description copied from interface:ProcessEngineServicesReturns the process engine'sRuntimeService.- Specified by:
getRuntimeServicein interfaceProcessEngineServices- Returns:
- the
RuntimeServiceobject.
-
setRuntimeService
-
getTaskService
Description copied from interface:ProcessEngineServicesReturns the process engine'sTaskService.- Specified by:
getTaskServicein interfaceProcessEngineServices- Returns:
- the
TaskServiceobject.
-
setTaskService
-
getHistoryService
Description copied from interface:ProcessEngineServicesReturns the process engine'sHistoryService.- Specified by:
getHistoryServicein interfaceProcessEngineServices- Returns:
- the
HistoryServiceobject.
-
setHistoryService
-
setHistoricDataService
- Parameters:
historicService- the historiy service instance- See Also:
-
getIdentityService
Description copied from interface:ProcessEngineServicesReturns the process engine'sIdentityService.- Specified by:
getIdentityServicein interfaceProcessEngineServices- Returns:
- the
IdentityServiceobject.
-
setIdentityService
-
getManagementService
Description copied from interface:ProcessEngineServicesReturns the process engine'sManagementService.- Specified by:
getManagementServicein interfaceProcessEngineServices- Returns:
- the
ManagementServiceobject.
-
getAuthorizationService
Description copied from interface:ProcessEngineServicesReturns the process engine'sAuthorizationService.- Specified by:
getAuthorizationServicein interfaceProcessEngineServices- Returns:
- the
AuthorizationServiceobject.
-
setAuthorizationService
-
getCaseService
Description copied from interface:ProcessEngineServicesReturns the engine'sCaseService.- Specified by:
getCaseServicein interfaceProcessEngineServices- Returns:
- the
CaseServiceobject.
-
setCaseService
-
getFormService
Description copied from interface:ProcessEngineServicesReturns the process engine'sFormService.- Specified by:
getFormServicein interfaceProcessEngineServices- Returns:
- the
FormServiceobject.
-
setFormService
-
setManagementService
-
getFilterService
Description copied from interface:ProcessEngineServicesReturns the engine'sFilterService.- Specified by:
getFilterServicein interfaceProcessEngineServices- Returns:
- the
FilterServiceobject.
-
setFilterService
-
getExternalTaskService
Description copied from interface:ProcessEngineServicesReturns the engine'sExternalTaskService.- Specified by:
getExternalTaskServicein interfaceProcessEngineServices- Returns:
- the
ExternalTaskServiceobject.
-
setExternalTaskService
-
getDecisionService
Description copied from interface:ProcessEngineServicesReturns the engine'sDecisionService.- Specified by:
getDecisionServicein interfaceProcessEngineServices- Returns:
- the
DecisionServiceobject.
-
setDecisionService
-
manageDeployment
-