public class ActivitiRule extends Object implements org.junit.rules.TestRule
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 Deployment
annotation. This
base class will make sure that this deployment gets deployed before the setUp
and cascade
deleted
after 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.
Modifier and Type | Field and Description |
---|---|
protected String |
configurationResource |
protected String |
deploymentId |
protected FormService |
formService |
protected HistoryService |
historyService |
protected IdentityService |
identityService |
protected ManagementService |
managementService |
protected ActivitiMockSupport |
mockSupport |
protected ProcessEngine |
processEngine |
protected ProcessEngineConfiguration |
processEngineConfiguration |
protected RepositoryService |
repositoryService |
protected RuntimeService |
runtimeService |
protected TaskService |
taskService |
Constructor and Description |
---|
ActivitiRule() |
ActivitiRule(ProcessEngine processEngine) |
ActivitiRule(String configurationResource) |
Modifier and Type | Method and Description |
---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
Implementation based on
TestWatcher . |
protected void |
configureProcessEngine() |
protected void |
failed(Throwable e,
org.junit.runner.Description description)
Invoked when a test fails
|
protected void |
finished(org.junit.runner.Description description) |
String |
getConfigurationResource() |
FormService |
getFormService() |
HistoryService |
getHistoryService() |
IdentityService |
getIdentityService() |
ManagementService |
getManagementService() |
ActivitiMockSupport |
getMockSupport() |
ProcessEngine |
getProcessEngine() |
RepositoryService |
getRepositoryService() |
RuntimeService |
getRuntimeService() |
TaskService |
getTaskService() |
protected void |
initializeMockSupport() |
protected void |
initializeProcessEngine() |
protected void |
initializeServices() |
ActivitiMockSupport |
mockSupport() |
void |
setConfigurationResource(String configurationResource) |
void |
setCurrentTime(Date currentTime) |
void |
setHistoricDataService(HistoryService historicDataService) |
void |
setIdentityService(IdentityService identityService) |
void |
setManagementService(ManagementService managementService) |
void |
setProcessEngine(ProcessEngine processEngine) |
void |
setProcessEngineConfiguration(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration) |
void |
setRepositoryService(RepositoryService repositoryService) |
void |
setRuntimeService(RuntimeService runtimeService) |
void |
setTaskService(TaskService taskService) |
protected void |
skipped(org.junit.internal.AssumptionViolatedException e,
org.junit.runner.Description description)
Invoked when a test is skipped due to a failed assumption.
|
protected void |
starting(org.junit.runner.Description description) |
protected void |
succeeded(org.junit.runner.Description description)
Invoked when a test succeeds
|
protected String configurationResource
protected String deploymentId
protected ProcessEngineConfiguration processEngineConfiguration
protected ProcessEngine processEngine
protected RepositoryService repositoryService
protected RuntimeService runtimeService
protected TaskService taskService
protected HistoryService historyService
protected IdentityService identityService
protected ManagementService managementService
protected FormService formService
protected ActivitiMockSupport mockSupport
public ActivitiRule()
public ActivitiRule(String configurationResource)
public ActivitiRule(ProcessEngine processEngine)
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
TestWatcher
.apply
in interface org.junit.rules.TestRule
protected void succeeded(org.junit.runner.Description description)
protected void failed(Throwable e, org.junit.runner.Description description)
protected void skipped(org.junit.internal.AssumptionViolatedException e, org.junit.runner.Description description)
protected void starting(org.junit.runner.Description description)
protected void initializeProcessEngine()
protected void initializeServices()
protected void initializeMockSupport()
protected void configureProcessEngine()
protected void finished(org.junit.runner.Description description)
public void setCurrentTime(Date currentTime)
public String getConfigurationResource()
public void setConfigurationResource(String configurationResource)
public ProcessEngine getProcessEngine()
public void setProcessEngine(ProcessEngine processEngine)
public RepositoryService getRepositoryService()
public void setRepositoryService(RepositoryService repositoryService)
public RuntimeService getRuntimeService()
public void setRuntimeService(RuntimeService runtimeService)
public TaskService getTaskService()
public void setTaskService(TaskService taskService)
public HistoryService getHistoryService()
public void setHistoricDataService(HistoryService historicDataService)
public IdentityService getIdentityService()
public void setIdentityService(IdentityService identityService)
public ManagementService getManagementService()
public FormService getFormService()
public void setManagementService(ManagementService managementService)
public void setProcessEngineConfiguration(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration)
public ActivitiMockSupport getMockSupport()
public ActivitiMockSupport mockSupport()
Copyright © 2016 Alfresco. All rights reserved.