public abstract class JbpmJUnitBaseTestCase
extends org.junit.Assert
EntityManagerFactory
, cleans up Singleton's session idEntityManagerFactory
and data source, disposes RuntimeEngine
's and RuntimeManager
RuntimeManager
for gives set of assets and selected strategy
RuntimeManager
currently active in the scope of test
RuntimeEngine
for given contextEntityManagerFactory
Modifier and Type | Class and Description |
---|---|
static class |
JbpmJUnitBaseTestCase.Strategy
Currently supported RuntimeEngine strategies
|
protected static class |
JbpmJUnitBaseTestCase.TestWorkItemHandler |
Modifier and Type | Field and Description |
---|---|
protected Set<org.kie.api.runtime.manager.RuntimeEngine> |
activeEngines |
protected List<org.kie.api.event.rule.AgendaEventListener> |
customAgendaListeners |
protected Map<String,Object> |
customEnvironmentEntries |
protected Map<String,org.kie.api.runtime.process.WorkItemHandler> |
customHandlers |
protected List<org.kie.api.event.process.ProcessEventListener> |
customProcessListeners |
protected List<org.kie.api.task.TaskLifeCycleEventListener> |
customTaskListeners |
protected org.kie.api.runtime.manager.RuntimeManager |
manager |
protected boolean |
sessionPersistence |
protected boolean |
setupDataSource |
protected org.kie.api.task.UserGroupCallback |
userGroupCallback |
Constructor and Description |
---|
JbpmJUnitBaseTestCase()
The most simple test case configuration:
does NOT initialize data source
does NOT configure session persistence
This is usually used for in memory process management, without human task interaction.
|
JbpmJUnitBaseTestCase(boolean setupDataSource,
boolean sessionPersistence)
Allows to explicitly configure persistence and data source.
|
JbpmJUnitBaseTestCase(boolean setupDataSource,
boolean sessionPersistence,
String persistenceUnitName)
Same as
JbpmJUnitBaseTestCase(boolean, boolean) but allows to use another persistence unit name. |
Modifier and Type | Method and Description |
---|---|
void |
addAgendaEventListener(org.kie.api.event.rule.AgendaEventListener listener) |
void |
addEnvironmentEntry(String name,
Object value) |
void |
addProcessEventListener(org.kie.api.event.process.ProcessEventListener listener) |
void |
addTaskEventListener(org.kie.api.task.TaskLifeCycleEventListener listener) |
void |
addWorkItemHandler(String name,
org.kie.api.runtime.process.WorkItemHandler handler) |
void |
assertNodeActive(long processInstanceId,
org.kie.api.runtime.KieSession ksession,
String... name) |
void |
assertNodeExists(org.kie.api.runtime.process.ProcessInstance process,
String... nodeNames) |
void |
assertNodeTriggered(long processInstanceId,
String... nodeNames) |
void |
assertNumOfIncommingConnections(org.kie.api.runtime.process.ProcessInstance process,
String nodeName,
int num) |
void |
assertNumOfOutgoingConnections(org.kie.api.runtime.process.ProcessInstance process,
String nodeName,
int num) |
void |
assertPackageNameEquals(org.kie.api.runtime.process.ProcessInstance process,
String packageName) |
void |
assertProcessInstanceAborted(long processInstanceId)
Asserts that process instance is aborted.
|
void |
assertProcessInstanceAborted(long processInstanceId,
org.kie.api.runtime.KieSession ksession)
Deprecated.
This method does not check the actual state of process instance. Use either
assertProcessInstanceAborted(long) if session persistence is enabled or
assertProcessInstanceNotActive(long, KieSession) otherwise. |
void |
assertProcessInstanceActive(long processInstanceId)
Asserts that process instance is active.
|
void |
assertProcessInstanceActive(long processInstanceId,
org.kie.api.runtime.KieSession ksession)
Asserts that process instance is active.
|
void |
assertProcessInstanceCompleted(long processInstanceId)
Asserts that process instance is completed.
|
void |
assertProcessInstanceCompleted(long processInstanceId,
org.kie.api.runtime.KieSession ksession)
Deprecated.
This method does not check the actual state of process instance. Use either
assertProcessInstanceCompleted(long) if session persistence is enabled or
assertProcessInstanceNotActive(long, KieSession) otherwise. |
void |
assertProcessInstanceNotActive(long processInstanceId,
org.kie.api.runtime.KieSession ksession)
Asserts that process instance is not active.
|
void |
assertProcessNameEquals(org.kie.api.runtime.process.ProcessInstance process,
String name) |
void |
assertProcessVarExists(org.kie.api.runtime.process.ProcessInstance process,
String... processVarNames) |
void |
assertVersionEquals(org.kie.api.runtime.process.ProcessInstance process,
String version) |
protected static void |
cleanupSingletonSessionId() |
protected void |
clearCustomRegistry() |
protected void |
clearHistory() |
protected org.kie.api.runtime.manager.RuntimeManager |
createRuntimeManager(JbpmJUnitBaseTestCase.Strategy strategy,
Map<String,org.kie.api.io.ResourceType> resources)
Creates default configuration of
RuntimeManager with given strategy and all
resources being added to knowledge base. |
protected org.kie.api.runtime.manager.RuntimeManager |
createRuntimeManager(JbpmJUnitBaseTestCase.Strategy strategy,
Map<String,org.kie.api.io.ResourceType> resources,
org.kie.api.runtime.manager.RuntimeEnvironment environment,
String identifier)
The lowest level of creation of
RuntimeManager that expects to get RuntimeEnvironment
to be given as argument. |
protected org.kie.api.runtime.manager.RuntimeManager |
createRuntimeManager(JbpmJUnitBaseTestCase.Strategy strategy,
Map<String,org.kie.api.io.ResourceType> resources,
String identifier)
Creates default configuration of
RuntimeManager with given strategy and all
resources being added to knowledge base. |
protected org.kie.api.runtime.manager.RuntimeManager |
createRuntimeManager(JbpmJUnitBaseTestCase.Strategy strategy,
String identifier,
String... process)
Creates default configuration of
RuntimeManager with given strategy and all
processes being added to knowledge base. |
protected org.kie.api.runtime.manager.RuntimeManager |
createRuntimeManager(Map<String,org.kie.api.io.ResourceType> resources)
Creates default configuration of
RuntimeManager with SINGLETON strategy and all
resources being added to knowledge base. |
protected org.kie.api.runtime.manager.RuntimeManager |
createRuntimeManager(Map<String,org.kie.api.io.ResourceType> resources,
String identifier)
Creates default configuration of
RuntimeManager with SINGLETON strategy and all
resources being added to knowledge base. |
protected org.kie.api.runtime.manager.RuntimeManager |
createRuntimeManager(String... process)
Creates default configuration of
RuntimeManager with SINGLETON strategy and all
processes being added to knowledge base. |
protected void |
disposeRuntimeManager()
Disposes currently active (in scope of a test)
RuntimeManager together with all
active RuntimeEngine 's that were created (in scope of a test). |
protected DataSource |
getDs() |
protected javax.persistence.EntityManagerFactory |
getEmf() |
protected org.drools.core.audit.WorkingMemoryInMemoryLogger |
getInMemoryLogger() |
protected org.kie.api.runtime.manager.audit.AuditService |
getLogService() |
protected org.kie.api.runtime.manager.RuntimeEngine |
getRuntimeEngine()
Returns new
RuntimeEngine built from the manager of this test case. |
protected org.kie.api.runtime.manager.RuntimeEngine |
getRuntimeEngine(org.kie.api.runtime.manager.Context<?> context)
Returns new
RuntimeEngine built from the manager of this test case. |
protected JbpmJUnitBaseTestCase.TestWorkItemHandler |
getTestWorkItemHandler() |
Object |
getVariableValue(String name,
long processInstanceId,
org.kie.api.runtime.KieSession ksession)
Retrieves value of the variable given by
name from process instance given by processInstanceId
using given session. |
void |
setPersistenceProperty(String name,
Object value) |
void |
setUp() |
protected bitronix.tm.resource.jdbc.PoolingDataSource |
setupPoolingDataSource() |
void |
tearDown() |
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
protected boolean setupDataSource
protected boolean sessionPersistence
protected org.kie.api.runtime.manager.RuntimeManager manager
protected org.kie.api.task.UserGroupCallback userGroupCallback
protected Set<org.kie.api.runtime.manager.RuntimeEngine> activeEngines
protected List<org.kie.api.event.process.ProcessEventListener> customProcessListeners
protected List<org.kie.api.event.rule.AgendaEventListener> customAgendaListeners
protected List<org.kie.api.task.TaskLifeCycleEventListener> customTaskListeners
public JbpmJUnitBaseTestCase()
public JbpmJUnitBaseTestCase(boolean setupDataSource, boolean sessionPersistence)
super(true, false);
super(true, true);
org.jbpm.persistence.jpa
setupDataSource
- - true to configure data source under JNDI name: jdbc/jbpm-dssessionPersistence
- - configures RuntimeEngine to be with JPA persistence enabledpublic JbpmJUnitBaseTestCase(boolean setupDataSource, boolean sessionPersistence, String persistenceUnitName)
JbpmJUnitBaseTestCase(boolean, boolean)
but allows to use another persistence unit name.setupDataSource
- - true to configure data source under JNDI name: jdbc/jbpm-dssessionPersistence
- - configures RuntimeEngine to be with JPA persistence enabledpersistenceUnitName
- - custom persistence unit nameprotected org.kie.api.runtime.manager.RuntimeManager createRuntimeManager(String... process)
RuntimeManager
with SINGLETON strategy and all
processes
being added to knowledge base.
RuntimeManager
created during single test.process
- - processes that shall be added to knowledge baseprotected org.kie.api.runtime.manager.RuntimeManager createRuntimeManager(JbpmJUnitBaseTestCase.Strategy strategy, String identifier, String... process)
RuntimeManager
with given strategy
and all
processes
being added to knowledge base.
RuntimeManager
created during single test.strategy
- - selected strategy of those that are supportedidentifier
- - identifies the runtime managerprocess
- - processes that shall be added to knowledge baseprotected org.kie.api.runtime.manager.RuntimeManager createRuntimeManager(Map<String,org.kie.api.io.ResourceType> resources)
RuntimeManager
with SINGLETON strategy and all
resources
being added to knowledge base.
RuntimeManager
created during single test.resources
- - resources (processes, rules, etc) that shall be added to knowledge baseprotected org.kie.api.runtime.manager.RuntimeManager createRuntimeManager(Map<String,org.kie.api.io.ResourceType> resources, String identifier)
RuntimeManager
with SINGLETON strategy and all
resources
being added to knowledge base.
RuntimeManager
created during single test.resources
- - resources (processes, rules, etc) that shall be added to knowledge baseidentifier
- - identifies the runtime managerprotected org.kie.api.runtime.manager.RuntimeManager createRuntimeManager(JbpmJUnitBaseTestCase.Strategy strategy, Map<String,org.kie.api.io.ResourceType> resources)
RuntimeManager
with given strategy
and all
resources
being added to knowledge base.
RuntimeManager
created during single test.strategy
- - selected strategy of those that are supportedresources
- - resources that shall be added to knowledge baseprotected org.kie.api.runtime.manager.RuntimeManager createRuntimeManager(JbpmJUnitBaseTestCase.Strategy strategy, Map<String,org.kie.api.io.ResourceType> resources, String identifier)
RuntimeManager
with given strategy
and all
resources
being added to knowledge base.
RuntimeManager
created during single test.strategy
- - selected strategy of those that are supportedresources
- - resources that shall be added to knowledge baseidentifier
- - identifies the runtime managerprotected org.kie.api.runtime.manager.RuntimeManager createRuntimeManager(JbpmJUnitBaseTestCase.Strategy strategy, Map<String,org.kie.api.io.ResourceType> resources, org.kie.api.runtime.manager.RuntimeEnvironment environment, String identifier)
RuntimeManager
that expects to get RuntimeEnvironment
to be given as argument. It does not assume any particular configuration as it's considered manual creation
that allows to configure every single piece of RuntimeManager
. strategy
- - selected strategy of those that are supportedresources
- - resources that shall be added to knowledge baseenvironment
- - runtime environment used for RuntimeManager
creationidentifier
- - identifies the runtime managerprotected void disposeRuntimeManager()
RuntimeManager
together with all
active RuntimeEngine
's that were created (in scope of a test). Usual use case is
to simulate system shutdown.protected org.kie.api.runtime.manager.RuntimeEngine getRuntimeEngine()
RuntimeEngine
built from the manager of this test case.
It uses EmptyContext
that is suitable for following strategies:
getRuntimeEngine(Context)
protected org.kie.api.runtime.manager.RuntimeEngine getRuntimeEngine(org.kie.api.runtime.manager.Context<?> context)
RuntimeEngine
built from the manager of this test case. Common use case is to maintain
same session for process instance and thus ProcessInstanceIdContext
shall be used.context
- - instance of the context that shall be used to create RuntimeManager
public Object getVariableValue(String name, long processInstanceId, org.kie.api.runtime.KieSession ksession)
name
from process instance given by processInstanceId
using given session.name
- - name of the variableprocessInstanceId
- - id of process instanceksession
- - ksession used to retrieve the value@Deprecated public void assertProcessInstanceCompleted(long processInstanceId, org.kie.api.runtime.KieSession ksession)
assertProcessInstanceCompleted(long)
if session persistence is enabled or
assertProcessInstanceNotActive(long, KieSession)
otherwise.@Deprecated public void assertProcessInstanceAborted(long processInstanceId, org.kie.api.runtime.KieSession ksession)
assertProcessInstanceAborted(long)
if session persistence is enabled or
assertProcessInstanceNotActive(long, KieSession)
otherwise.public void assertProcessInstanceActive(long processInstanceId, org.kie.api.runtime.KieSession ksession)
processInstanceId
- id of process instanceksession
- public void assertProcessInstanceNotActive(long processInstanceId, org.kie.api.runtime.KieSession ksession)
processInstanceId
- id of process instanceksession
- public void assertProcessInstanceActive(long processInstanceId)
processInstanceId
- id of process instancepublic void assertProcessInstanceCompleted(long processInstanceId)
processInstanceId
- id of process instancepublic void assertProcessInstanceAborted(long processInstanceId)
processInstanceId
- id of process instancepublic void assertNodeActive(long processInstanceId, org.kie.api.runtime.KieSession ksession, String... name)
public void assertNodeTriggered(long processInstanceId, String... nodeNames)
public void assertProcessVarExists(org.kie.api.runtime.process.ProcessInstance process, String... processVarNames)
public void assertNodeExists(org.kie.api.runtime.process.ProcessInstance process, String... nodeNames)
public void assertNumOfIncommingConnections(org.kie.api.runtime.process.ProcessInstance process, String nodeName, int num)
public void assertNumOfOutgoingConnections(org.kie.api.runtime.process.ProcessInstance process, String nodeName, int num)
public void assertVersionEquals(org.kie.api.runtime.process.ProcessInstance process, String version)
public void assertProcessNameEquals(org.kie.api.runtime.process.ProcessInstance process, String name)
public void assertPackageNameEquals(org.kie.api.runtime.process.ProcessInstance process, String packageName)
protected javax.persistence.EntityManagerFactory getEmf()
protected DataSource getDs()
protected bitronix.tm.resource.jdbc.PoolingDataSource setupPoolingDataSource()
protected void clearHistory()
protected void clearCustomRegistry()
protected JbpmJUnitBaseTestCase.TestWorkItemHandler getTestWorkItemHandler()
protected org.kie.api.runtime.manager.audit.AuditService getLogService()
protected org.drools.core.audit.WorkingMemoryInMemoryLogger getInMemoryLogger()
public void addProcessEventListener(org.kie.api.event.process.ProcessEventListener listener)
public void addAgendaEventListener(org.kie.api.event.rule.AgendaEventListener listener)
public void addTaskEventListener(org.kie.api.task.TaskLifeCycleEventListener listener)
public void addWorkItemHandler(String name, org.kie.api.runtime.process.WorkItemHandler handler)
protected static void cleanupSingletonSessionId()
Copyright © 2001–2016 JBoss by Red Hat. All rights reserved.