Permalink
Browse files

refactoring jbpm-test to use runtime manager

  • Loading branch information...
mswiderski committed Mar 26, 2013
1 parent 0d181c3 commit d822d3ab932d421950aab08daefbe9ad3687580b
@@ -5,7 +5,7 @@
import org.jbpm.test.JbpmJUnitTestCase;
import org.junit.Test;
-import org.kie.internal.runtime.StatefulKnowledgeSession;
+import org.kie.api.runtime.KieSession;
/**
* This is a sample file to test a process.
@@ -14,7 +14,7 @@
@Test
public void testProcess() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("quickstarts/ScriptTask.bpmn");
+ KieSession ksession = createKnowledgeSession("quickstarts/ScriptTask.bpmn");
Map<String, Object> params = new HashMap<String, Object>();
params.put("person", new Person("krisv"));
ksession.startProcess("com.sample.script", params);
View
@@ -56,16 +56,16 @@
<artifactId>quartz</artifactId>
</dependency>
<dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <scope>test</scope>
- </dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -7,6 +7,7 @@
import org.jbpm.test.JbpmJUnitTestCase;
import org.junit.Ignore;
import org.junit.Test;
+import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.internal.runtime.StatefulKnowledgeSession;
import org.kie.internal.task.api.TaskService;
@@ -24,8 +25,8 @@ public ProcessHumanTaskTest() {
@Test
public void testProcess() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantask.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("humantask.bpmn");
+ TaskService taskService = getTaskService();
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");
@@ -54,8 +55,8 @@ public void testProcess() {
@Test @Ignore //-> task CreatedBy in summary is not filled ??
public void testProcessWithCreatedBy() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantaskwithcreatedby.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("humantaskwithcreatedby.bpmn");
+ TaskService taskService = getTaskService();
Map<String, Object> params = new HashMap<String, Object>();
params.put("person", "krisv");
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello.createdby", params);
@@ -5,6 +5,7 @@
import org.jbpm.test.JbpmJUnitTestCase;
import org.junit.Test;
+import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.internal.runtime.StatefulKnowledgeSession;
import org.kie.internal.task.api.TaskService;
@@ -27,8 +28,8 @@ public ProcessPersistenceHumanTaskOnLaneTest() {
@Test
public void testProcess() throws Exception {
- StatefulKnowledgeSession ksession = createKnowledgeSession("HumanTaskOnLane.bpmn2");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("HumanTaskOnLane.bpmn2");
+ TaskService taskService = getTaskService();
ProcessInstance processInstance = ksession.startProcess("UserTask");
@@ -37,7 +38,7 @@ public void testProcess() throws Exception {
// simulating a system restart
ksession = restoreSession(ksession, true);
- taskService = getTaskService(ksession);
+ taskService = getTaskService();
// let john execute Task 1
String taskUser = "john";
@@ -54,7 +55,7 @@ public void testProcess() throws Exception {
// simulating a system restart
ksession = restoreSession(ksession, true);
- taskService = getTaskService(ksession);
+ taskService = getTaskService();
List<Status> reservedOnly = new ArrayList<Status>();
reservedOnly.add(Status.Reserved);
@@ -7,6 +7,7 @@
import org.jbpm.test.JbpmJUnitTestCase;
import org.junit.Test;
+import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.internal.runtime.StatefulKnowledgeSession;
import org.kie.internal.task.api.TaskService;
@@ -28,8 +29,8 @@ public ProcessPersistenceHumanTaskTest() {
@Test
public void testProcess() throws Exception {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantask.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("humantask.bpmn");
+ TaskService taskService = getTaskService();
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");
@@ -38,7 +39,7 @@ public void testProcess() throws Exception {
// simulating a system restart
ksession = restoreSession(ksession, true);
- taskService = getTaskService(ksession);
+ taskService = getTaskService();
// let john execute Task 1
String taskGroup = "en-UK";
@@ -52,7 +53,7 @@ public void testProcess() throws Exception {
// simulating a system restart
ksession = restoreSession(ksession, true);
- taskService = getTaskService(ksession);
+ taskService = getTaskService();
// let mary execute Task 2
String taskUser = "mary";
@@ -69,8 +70,8 @@ public void testProcess() throws Exception {
@Test
public void testTransactions() throws Exception {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantask.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("humantask.bpmn");
+ TaskService taskService = getTaskService();
UserTransaction ut = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
ut.begin();
@@ -6,7 +6,7 @@
import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler;
import org.jbpm.test.JbpmJUnitTestCase;
import org.junit.Test;
-import org.kie.internal.runtime.StatefulKnowledgeSession;
+import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
/**
@@ -21,7 +21,7 @@ public ProcessPersistenceTest() {
@Test
public void testProcess() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("hello.bpmn");
+ KieSession ksession = createKnowledgeSession("hello.bpmn");
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");
// check whether the process instance has completed successfully
assertProcessInstanceCompleted(processInstance.getId(), ksession);
@@ -30,7 +30,7 @@ public void testProcess() {
@Test
public void testTransactions() throws Exception {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantask.bpmn");
+ KieSession ksession = createKnowledgeSession("humantask.bpmn");
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
UserTransaction ut = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
@@ -2,7 +2,7 @@
import org.jbpm.test.JbpmJUnitTestCase;
import org.junit.Test;
-import org.kie.internal.runtime.StatefulKnowledgeSession;
+import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
/**
@@ -12,7 +12,7 @@
@Test
public void testProcess() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("hello.bpmn");
+ KieSession ksession = createKnowledgeSession("hello.bpmn");
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");
// check whether the process instance has completed successfully
assertProcessInstanceCompleted(processInstance.getId(), ksession);
@@ -20,6 +20,7 @@
import org.jbpm.test.JbpmJUnitTestCase;
import org.junit.Test;
+import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.internal.KieInternalServices;
import org.kie.internal.process.CorrelationAwareProcessRuntime;
@@ -40,8 +41,8 @@ public AbstractStartProcessWithCorrelationKeyTest(boolean persistence) {
@Test
public void testCreateAndStartProcessWithBusinessKey() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantask.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("humantask.bpmn");
+ TaskService taskService = getTaskService();
ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)ksession).createProcessInstance("com.sample.bpmn.hello", getCorrelationKey(), null);
ksession.startProcessInstance(processInstance.getId());
@@ -75,8 +76,8 @@ public void testCreateAndStartProcessWithBusinessKey() {
@Test
public void testProcessWithBusinessKey() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantask.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("humantask.bpmn");
+ TaskService taskService = getTaskService();
ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)ksession).startProcess("com.sample.bpmn.hello", getCorrelationKey(), null);
@@ -109,8 +110,8 @@ public void testProcessWithBusinessKey() {
@Test
public void testProcessWithBusinessKeyFailOnDuplicatedBusinessKey() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantask.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("humantask.bpmn");
+ TaskService taskService = getTaskService();
ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)ksession)
.startProcess("com.sample.bpmn.hello", getCorrelationKey(), null);
@@ -151,8 +152,8 @@ public void testProcessWithBusinessKeyFailOnDuplicatedBusinessKey() {
@Test
public void testProcessesWithSameBusinessKeyNotInParallel() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantask.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("humantask.bpmn");
+ TaskService taskService = getTaskService();
ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)ksession).
startProcess("com.sample.bpmn.hello", getCorrelationKey(), null);
@@ -215,8 +216,8 @@ public void testProcessesWithSameBusinessKeyNotInParallel() {
@Test
public void testProcessWithMultiValuedBusinessKey() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantask.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("humantask.bpmn");
+ TaskService taskService = getTaskService();
ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)ksession).startProcess("com.sample.bpmn.hello", getMultiValuedCorrelationKey(), null);
@@ -249,8 +250,8 @@ public void testProcessWithMultiValuedBusinessKey() {
@Test
public void testProcessWithInvalidBusinessKey() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("humantask.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("humantask.bpmn");
+ TaskService taskService = getTaskService();
ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)ksession).startProcess("com.sample.bpmn.hello", getMultiValuedCorrelationKey(), null);
@@ -19,9 +19,8 @@
import org.jbpm.test.JbpmJUnitTestCase;
import org.junit.Assert;
import org.junit.Test;
+import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
-import org.kie.internal.KnowledgeBase;
-import org.kie.internal.runtime.StatefulKnowledgeSession;
import org.kie.internal.task.api.TaskService;
import org.kie.internal.task.api.model.Content;
import org.kie.internal.task.api.model.Task;
@@ -42,7 +41,7 @@
protected TaskService taskService ;
- protected StatefulKnowledgeSession ksession;
+ protected KieSession ksession;
public PatientVariablePersistenceStrategyTest() {
super(true);
@@ -64,10 +63,9 @@ public void simplePatientMedicalRecordTest() throws Exception {
em.getTransaction().commit();
- KnowledgeBase kbase = createKnowledgeBase("patient-appointment.bpmn");
- ksession = createKnowledgeSession(kbase);
+ ksession = createKnowledgeSession("patient-appointment.bpmn");
- taskService = getTaskService(ksession);
+ taskService = getTaskService();
logger.info("### Starting process ###");
Map<String, Object> parameters = new HashMap<String, Object>();
@@ -26,6 +26,7 @@
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.internal.builder.KnowledgeBuilder;
import org.kie.internal.builder.KnowledgeBuilderFactory;
@@ -67,10 +68,10 @@ public void testSerizliableTestsWithExternalRollback() {
TransactionManager tm = TransactionManagerServices.getTransactionManager();
- StatefulKnowledgeSession sesion = createKnowledgeSession("HumanTaskWithBoundaryTimer.bpmn");
+ KieSession sesion = createKnowledgeSession("HumanTaskWithBoundaryTimer.bpmn");
System.out.println("Created knowledge session");
- TaskService taskService = getTaskService(sesion);
+ TaskService taskService = getTaskService();
Map<String, User> users = new HashMap<String, User>();
users.put("Administrator", new UserImpl("Administrator"));
users.put("john", new UserImpl("john"));
@@ -129,14 +130,14 @@ public void testSerizliableTestsWithExternalRollback() {
}
@Test
- @Ignore
+// @Ignore
public void testSerizliableTestsWithEngineRollback() {
try {
- StatefulKnowledgeSession sesion = createKnowledgeSession("HumanTaskWithBoundaryTimer.bpmn");
+ KieSession sesion = createKnowledgeSession("HumanTaskWithBoundaryTimer.bpmn");
System.out.println("Created knowledge session");
- TaskService taskService = getTaskService(sesion);
+ TaskService taskService = getTaskService();
System.out.println("Task service created");
Map<String, User> users = new HashMap<String, User>();
users.put("Administrator", new UserImpl("Administrator"));
@@ -159,7 +160,8 @@ public void testSerizliableTestsWithEngineRollback() {
} else {
try {
Map<String, Object> params = new HashMap<String, Object>();
- params.put("test", "test");
+ // set test variable to null so engine will rollback
+ params.put("test", null);
System.out.println("Creating process instance: " + i);
ProcessInstance pi = sesion.startProcess("PROCESS_1", params);
} catch (Exception e) {
@@ -21,8 +21,8 @@
import org.jbpm.test.JbpmJUnitTestCase;
import org.junit.Test;
+import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
-import org.kie.internal.runtime.StatefulKnowledgeSession;
import org.kie.internal.task.api.TaskService;
import org.kie.internal.task.api.model.TaskSummary;
@@ -40,8 +40,8 @@ public SupportProcessTest() {
@Test
public void simpleSupportProcessTest() {
- StatefulKnowledgeSession ksession = createKnowledgeSession("support.bpmn");
- TaskService taskService = getTaskService(ksession);
+ KieSession ksession = createKnowledgeSession("support.bpmn");
+ TaskService taskService = getTaskService();
Map<String, Object> params = new HashMap<String, Object>();
params.put("customer", "salaboy");
Oops, something went wrong.

0 comments on commit d822d3a

Please sign in to comment.