Skip to content

Commit

Permalink
refactoring jbpm-test to use runtime manager
Browse files Browse the repository at this point in the history
  • Loading branch information
mswiderski committed Mar 26, 2013
1 parent 0d181c3 commit d822d3a
Show file tree
Hide file tree
Showing 16 changed files with 257 additions and 252 deletions.
Expand Up @@ -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.
Expand All @@ -14,7 +14,7 @@ public class JavaServiceQuickstartTest extends JbpmJUnitTestCase {

@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);
Expand Down
20 changes: 10 additions & 10 deletions jbpm-test/pom.xml
Expand Up @@ -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>
Expand Down
262 changes: 136 additions & 126 deletions jbpm-test/src/main/java/org/jbpm/test/JbpmJUnitTestCase.java

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions jbpm-test/src/test/java/org/jbpm/ProcessHumanTaskTest.java
Expand Up @@ -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;
Expand All @@ -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");

Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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;
Expand All @@ -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");

Expand All @@ -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";
Expand All @@ -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);

Expand Down
Expand Up @@ -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;
Expand All @@ -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");

Expand All @@ -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";
Expand All @@ -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";
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions jbpm-test/src/test/java/org/jbpm/ProcessPersistenceTest.java
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand All @@ -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" );
Expand Down
4 changes: 2 additions & 2 deletions jbpm-test/src/test/java/org/jbpm/ProcessTest.java
Expand Up @@ -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;

/**
Expand All @@ -12,7 +12,7 @@ public class ProcessTest extends JbpmJUnitTestCase {

@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);
Expand Down
Expand Up @@ -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;
Expand All @@ -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());
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
Expand Up @@ -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;
Expand All @@ -42,7 +41,7 @@ public class PatientVariablePersistenceStrategyTest extends JbpmJUnitTestCase {
protected TaskService taskService ;


protected StatefulKnowledgeSession ksession;
protected KieSession ksession;

public PatientVariablePersistenceStrategyTest() {
super(true);
Expand All @@ -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>();
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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"));
Expand All @@ -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) {
Expand Down
Expand Up @@ -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;

Expand All @@ -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");
Expand Down

0 comments on commit d822d3a

Please sign in to comment.