Class FlowableRule
- java.lang.Object
-
- org.flowable.engine.test.FlowableRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class FlowableRule extends Object implements org.junit.rules.TestRule
Convenience for ProcessEngine and services initialization in the form of a JUnit rule.Usage:
public class YourTest { @Rule public FlowableRule flowableRule = new FlowableRule(); ... }
The ProcessEngine and the services will be made available to the test class through the getters of the FlowableRule. The processEngine will be initialized by default with the flowable.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.The FlowableRule 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.- Author:
- Tom Baeyens
-
-
Field Summary
Fields Modifier and Type Field Description protected String
configurationResource
protected String
deploymentId
protected FormService
formService
protected HistoryService
historyService
protected IdentityService
identityService
protected ManagementService
managementService
protected FlowableMockSupport
mockSupport
protected ProcessEngine
processEngine
protected ProcessEngineConfiguration
processEngineConfiguration
protected RepositoryService
repositoryService
protected RuntimeService
runtimeService
protected TaskService
taskService
-
Constructor Summary
Constructors Constructor Description FlowableRule()
FlowableRule(String configurationResource)
FlowableRule(ProcessEngine processEngine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statement
apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
Implementation based onTestWatcher
.protected void
configureProcessEngine()
protected void
failed(Throwable e, org.junit.runner.Description description)
Invoked when a test failsprotected void
finished(org.junit.runner.Description description)
String
getConfigurationResource()
FormService
getFormService()
HistoryService
getHistoryService()
IdentityService
getIdentityService()
ManagementService
getManagementService()
FlowableMockSupport
getMockSupport()
ProcessEngine
getProcessEngine()
RepositoryService
getRepositoryService()
RuntimeService
getRuntimeService()
TaskService
getTaskService()
protected void
initializeMockSupport()
protected void
initializeProcessEngine()
protected void
initializeServices()
FlowableMockSupport
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.flowable.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
-
-
-
Field Detail
-
configurationResource
protected String configurationResource
-
deploymentId
protected 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
-
identityService
protected IdentityService identityService
-
managementService
protected ManagementService managementService
-
formService
protected FormService formService
-
mockSupport
protected FlowableMockSupport mockSupport
-
-
Constructor Detail
-
FlowableRule
public FlowableRule()
-
FlowableRule
public FlowableRule(String configurationResource)
-
FlowableRule
public FlowableRule(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:
apply
in interfaceorg.junit.rules.TestRule
-
succeeded
protected void succeeded(org.junit.runner.Description description)
Invoked when a test succeeds
-
failed
protected void failed(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(Date currentTime)
-
getConfigurationResource
public String getConfigurationResource()
-
setConfigurationResource
public void setConfigurationResource(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)
-
getIdentityService
public IdentityService getIdentityService()
-
setIdentityService
public void setIdentityService(IdentityService identityService)
-
getManagementService
public ManagementService getManagementService()
-
getFormService
public FormService getFormService()
-
setManagementService
public void setManagementService(ManagementService managementService)
-
setProcessEngineConfiguration
public void setProcessEngineConfiguration(org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration)
-
getMockSupport
public FlowableMockSupport getMockSupport()
-
mockSupport
public FlowableMockSupport mockSupport()
-
-