org.camunda.bpm.engine.test
Class ProcessEngineRule

java.lang.Object
  extended by org.junit.rules.TestWatchman
      extended by org.camunda.bpm.engine.test.ProcessEngineRule
All Implemented Interfaces:
org.junit.rules.MethodRule

public class ProcessEngineRule
extends org.junit.rules.TestWatchman

Convenience for ProcessEngine and services initialization in the form of a JUnit rule.

Usage:

public class YourTest {
 
   @Rule
   public ProcessEngineRule activitiRule = new ProcessEngineRule();
   
   ...
 }
 

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 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.

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. In other words, you don't have to clean up your own time messing mess ;-)

Author:
Tom Baeyens

Field Summary
protected  String configurationResource
           
protected  String configurationResourceCompat
           
protected  String deploymentId
           
protected  FormService formService
           
protected  HistoryService historyService
           
protected  IdentityService identityService
           
protected  ManagementService managementService
           
protected  ProcessEngine processEngine
           
protected  RepositoryService repositoryService
           
protected  RuntimeService runtimeService
           
protected  TaskService taskService
           
 
Constructor Summary
ProcessEngineRule()
           
ProcessEngineRule(ProcessEngine processEngine)
           
ProcessEngineRule(String configurationResource)
           
 
Method Summary
 void finished(org.junit.runners.model.FrameworkMethod method)
           
 String getConfigurationResource()
           
 FormService getFormService()
           
 HistoryService getHistoryService()
           
 IdentityService getIdentityService()
           
 ManagementService getManagementService()
           
 ProcessEngine getProcessEngine()
           
 RepositoryService getRepositoryService()
           
 RuntimeService getRuntimeService()
           
 TaskService getTaskService()
           
protected  void initializeProcessEngine()
           
protected  void initializeServices()
           
 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 setRepositoryService(RepositoryService repositoryService)
           
 void setRuntimeService(RuntimeService runtimeService)
           
 void setTaskService(TaskService taskService)
           
 void starting(org.junit.runners.model.FrameworkMethod method)
           
 
Methods inherited from class org.junit.rules.TestWatchman
apply, failed, succeeded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configurationResource

protected String configurationResource

configurationResourceCompat

protected String configurationResourceCompat

deploymentId

protected String deploymentId

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
Constructor Detail

ProcessEngineRule

public ProcessEngineRule()

ProcessEngineRule

public ProcessEngineRule(String configurationResource)

ProcessEngineRule

public ProcessEngineRule(ProcessEngine processEngine)
Method Detail

starting

public void starting(org.junit.runners.model.FrameworkMethod method)
Overrides:
starting in class org.junit.rules.TestWatchman

initializeProcessEngine

protected void initializeProcessEngine()

initializeServices

protected void initializeServices()

finished

public void finished(org.junit.runners.model.FrameworkMethod method)
Overrides:
finished in class org.junit.rules.TestWatchman

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)


Copyright © 2014 camunda services GmbH. All Rights Reserved.