Skip to content

Commit

Permalink
Migrated JUnit tests to 4.7 idioms
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Jun 21, 2010
1 parent 5f8ac4d commit 8438eda
Show file tree
Hide file tree
Showing 103 changed files with 1,555 additions and 971 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
bin

9 changes: 9 additions & 0 deletions .settings/org.maven.ide.eclipse.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Mon Jun 21 12:02:08 BST 2010
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
skipCompilerPlugin=true
version=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Mon Jun 21 12:06:16 BST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Mon Jun 21 12:02:09 BST 2010
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
skipCompilerPlugin=true
version=1
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,37 @@
*/
package org.activiti.examples.bpmn.event.timer;

import static org.junit.Assert.*;

import java.util.Date;

import org.activiti.ProcessInstance;
import org.activiti.Task;
import org.activiti.impl.time.Clock;
import org.activiti.test.ActivitiTestCase;
import org.activiti.test.ProcessDeclared;
import org.junit.Test;

/**
* @author Joram Barrez
*/
public class BoundaryTimerEventTest extends ActivitiTestCase {


@Test
@ProcessDeclared
public void testInterruptingTimerDuration() {

// Start process instance
deployProcessForThisTestMethod();
ProcessInstance pi = processService.startProcessInstanceByKey("interruptingBoundaryTimer");

// There should be one task, with a timer : first line support
Task task = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
assertEquals("First line support", task.getName());

// Set clock to the future such that the timer can fire
Clock.setCurrentTime(new Date(System.currentTimeMillis() + (5 * 60 * 60 * 1000)));
waitForJobExecutorToProcessAllJobs(10000L, 250);

// The timer has fired, and the second task (secondlinesupport) now exists
task = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
assertEquals("Second line support", task.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,56 +12,54 @@
*/
package org.activiti.examples.bpmn.gateway;

import static org.junit.Assert.*;

import java.util.HashMap;
import java.util.Map;

import org.activiti.ActivitiException;
import org.activiti.ProcessInstance;
import org.activiti.Task;
import org.activiti.test.ActivitiTestCase;

import org.activiti.test.ProcessDeclared;
import org.junit.Test;

/**
* Example of using the exclusive gateway.
*
* @author Joram Barrez
*/
public class ExclusiveGatewayTest extends ActivitiTestCase {

/**
* The test process has an XOR gateway where, the 'input' variable
* is used to select one of the outgoing sequence flow.
* Every one of those sequence flow goes to another task,
* allowing us to test the decision very easily.
* The test process has an XOR gateway where, the 'input' variable is used to
* select one of the outgoing sequence flow. Every one of those sequence flow
* goes to another task, allowing us to test the decision very easily.
*/
@Test
@ProcessDeclared
public void testDecisionFunctionality() {
deployProcessForThisTestMethod();

Map<String, Object> variables = new HashMap<String, Object>();

// Test with input == 1
variables.put("input", 1);
ProcessInstance pi = processService.startProcessInstanceByKey("exclusiveGateway", variables);
Task task = taskService.createTaskQuery()
.processInstance(pi.getId())
.singleResult();
Task task = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
assertEquals("Send e-mail for more information", task.getName());

// Test with input == 2
variables.put("input", 2);
pi = processService.startProcessInstanceByKey("exclusiveGateway", variables);
task = taskService.createTaskQuery()
.processInstance(pi.getId())
.singleResult();
task = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
assertEquals("Check account balance", task.getName());

// Test with input == 3
variables.put("input", 3);
pi = processService.startProcessInstanceByKey("exclusiveGateway", variables);
task = taskService.createTaskQuery()
.processInstance(pi.getId())
.singleResult();
task = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
assertEquals("Call customer", task.getName());

// Test with input == 4
variables.put("input", 4);
try {
Expand All @@ -70,7 +68,7 @@ public void testDecisionFunctionality() {
} catch (ActivitiException e) {
// Exception is expected since no outgoing sequence flow matches
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,35 @@
*/
package org.activiti.examples.bpmn.scripttask;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import org.activiti.ProcessInstance;
import org.activiti.test.ActivitiTestCase;
import org.activiti.test.ProcessDeclared;
import org.activiti.util.CollectionUtil;

import org.junit.Test;

/**
* @author Joram Barrez
*/
public class ScriptTaskTest extends ActivitiTestCase {

public void testScriptExecution() {
deployProcessForThisTestMethod();

int[] inputArray = new int[] {1, 2, 3, 4, 5};
ProcessInstance pi = processService.startProcessInstanceByKey("scriptExecution",
CollectionUtil.singletonMap("inputArray", inputArray));
@Test
@ProcessDeclared
public void testScriptExecution() {
int[] inputArray = new int[] { 1, 2, 3, 4, 5 };
ProcessInstance pi = processService.startProcessInstanceByKey("scriptExecution", CollectionUtil.singletonMap("inputArray", inputArray));

Integer result = (Integer) processService.getVariable(pi.getId(), "sum");
assertEquals(15, result.intValue());
}


@Test
@ProcessDeclared
public void testSetVariableThroughExecutionInScript() {
deployProcessForThisTestMethod();
ProcessInstance pi = processService.startProcessInstanceByKey("setScriptVariableThroughExecution");

// Since 'def' is used, the 'scriptVar' will be script local
// and not automatically stored as a process variable.
assertNull(processService.getVariable(pi.getId(), "scriptVar"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package org.activiti.examples.bpmn.usertask;

import static org.junit.Assert.assertEquals;

import java.util.Collections;
import java.util.List;

import org.activiti.Deployment;
import org.activiti.ProcessInstance;
import org.activiti.Task;
import org.activiti.test.ActivitiTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;


public class FinancialReportProcessTest extends ActivitiTestCase {

@Override
protected void setUp() throws Exception {
super.setUp();

@Before
public void setUp() throws Exception {
identityService.saveUser(identityService.newUser("fozzie"));
identityService.saveUser(identityService.newUser("kermit"));

Expand All @@ -25,15 +28,15 @@ protected void setUp() throws Exception {
identityService.createMembership("kermit", "management");
}

@Override
protected void tearDown() throws Exception {
@After
public void tearDown() throws Exception {
identityService.deleteUser("fozzie");
identityService.deleteUser("kermit");
identityService.deleteGroup("accountancy");
identityService.deleteGroup("management");
super.tearDown();
}

@Test
public void testProcess() {
Deployment deployment = processService.createDeployment()
.addClasspathResource("org/activiti/examples/bpmn/usertask/FinancialReportProcess.bpmn20.xml")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
*/
package org.activiti.examples.bpmn.usertask.taskassignee;

import static org.junit.Assert.assertEquals;

import java.util.List;

import org.activiti.ProcessInstance;
import org.activiti.Task;
import org.activiti.test.ActivitiTestCase;
import org.activiti.test.ProcessDeclared;
import org.junit.Test;


/**
Expand All @@ -26,9 +30,9 @@
*/
public class TaskAssigneeTest extends ActivitiTestCase {

@Test
@ProcessDeclared
public void testTaskAssignee() {
// Deploy test process
deployProcessForThisTestMethod();

// Start process instance
ProcessInstance processInstance = processService.startProcessInstanceByKey("taskAssigneeProcess");
Expand Down
Loading

0 comments on commit 8438eda

Please sign in to comment.