Class ActivitiRule
- java.lang.Object
-
- org.activiti.engine.test.ActivitiRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class ActivitiRule extends java.lang.Object implements org.junit.rules.TestRuleConvenience for ProcessEngine and services initialization in the form of a JUnit rule.Usage:
public class YourTest { @Rule public ActivitiRule activitiRule = new ActivitiRule(); ... }The ProcessEngine and the services will be made available to the test class through the getters of the activitiRule. The processEngine will be initialized by default with the activiti.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.The activitiRule 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. 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.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringconfigurationResourceprotected java.lang.StringdeploymentIdprotected HistoryServicehistoryServiceprotected ManagementServicemanagementServiceprotected ActivitiMockSupportmockSupportprotected ProcessEngineprocessEngineprotected ProcessEngineConfigurationprocessEngineConfigurationprotected RepositoryServicerepositoryServiceprotected RuntimeServiceruntimeServiceprotected TaskServicetaskService
-
Constructor Summary
Constructors Constructor Description ActivitiRule()ActivitiRule(java.lang.String configurationResource)ActivitiRule(ProcessEngine processEngine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description)Implementation based onTestWatcher.protected voidconfigureProcessEngine()protected voidfailed(java.lang.Throwable e, org.junit.runner.Description description)Invoked when a test failsprotected voidfinished(org.junit.runner.Description description)java.lang.StringgetConfigurationResource()HistoryServicegetHistoryService()ManagementServicegetManagementService()ActivitiMockSupportgetMockSupport()ProcessEnginegetProcessEngine()RepositoryServicegetRepositoryService()RuntimeServicegetRuntimeService()TaskServicegetTaskService()protected voidinitializeMockSupport()protected voidinitializeProcessEngine()protected voidinitializeServices()ActivitiMockSupportmockSupport()voidsetConfigurationResource(java.lang.String configurationResource)voidsetCurrentTime(java.util.Date currentTime)voidsetHistoricDataService(HistoryService historicDataService)voidsetManagementService(ManagementService managementService)voidsetProcessEngine(ProcessEngine processEngine)voidsetProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration)voidsetRepositoryService(RepositoryService repositoryService)voidsetRuntimeService(RuntimeService runtimeService)voidsetTaskService(TaskService taskService)protected voidskipped(org.junit.internal.AssumptionViolatedException e, org.junit.runner.Description description)Invoked when a test is skipped due to a failed assumption.protected voidstarting(org.junit.runner.Description description)protected voidsucceeded(org.junit.runner.Description description)Invoked when a test succeeds
-
-
-
Field Detail
-
configurationResource
protected java.lang.String configurationResource
-
deploymentId
protected java.lang.String deploymentId
-
processEngineConfiguration
protected ProcessEngineConfiguration processEngineConfiguration
-
processEngine
protected ProcessEngine processEngine
-
repositoryService
protected RepositoryService repositoryService
-
runtimeService
protected RuntimeService runtimeService
-
taskService
protected TaskService taskService
-
historyService
protected HistoryService historyService
-
managementService
protected ManagementService managementService
-
mockSupport
protected ActivitiMockSupport mockSupport
-
-
Constructor Detail
-
ActivitiRule
public ActivitiRule()
-
ActivitiRule
public ActivitiRule(java.lang.String configurationResource)
-
ActivitiRule
public ActivitiRule(ProcessEngine processEngine)
-
-
Method Detail
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)Implementation based onTestWatcher.- Specified by:
applyin interfaceorg.junit.rules.TestRule
-
succeeded
protected void succeeded(org.junit.runner.Description description)
Invoked when a test succeeds
-
failed
protected void failed(java.lang.Throwable e, org.junit.runner.Description description)Invoked when a test fails
-
skipped
protected void skipped(org.junit.internal.AssumptionViolatedException e, org.junit.runner.Description description)Invoked when a test is skipped due to a failed assumption.
-
starting
protected void starting(org.junit.runner.Description description)
-
initializeProcessEngine
protected void initializeProcessEngine()
-
initializeServices
protected void initializeServices()
-
initializeMockSupport
protected void initializeMockSupport()
-
configureProcessEngine
protected void configureProcessEngine()
-
finished
protected void finished(org.junit.runner.Description description)
-
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)
-
getRepositoryService
public RepositoryService getRepositoryService()
-
setRepositoryService
public void setRepositoryService(RepositoryService repositoryService)
-
getRuntimeService
public RuntimeService getRuntimeService()
-
setRuntimeService
public void setRuntimeService(RuntimeService runtimeService)
-
getTaskService
public TaskService getTaskService()
-
setTaskService
public void setTaskService(TaskService taskService)
-
getHistoryService
public HistoryService getHistoryService()
-
setHistoricDataService
public void setHistoricDataService(HistoryService historicDataService)
-
getManagementService
public ManagementService getManagementService()
-
setManagementService
public void setManagementService(ManagementService managementService)
-
setProcessEngineConfiguration
public void setProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration)
-
getMockSupport
public ActivitiMockSupport getMockSupport()
-
mockSupport
public ActivitiMockSupport mockSupport()
-
-