Skip to content

Commit bcc268a

Browse files
committed
Deprecate for removal JUnit 3 and 4 support
1 parent 1925349 commit bcc268a

23 files changed

Lines changed: 87 additions & 396 deletions

File tree

docs/docusaurus/docs/bpmn/ch04-API.md

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,13 @@ Additionally, it’s possible to register custom functions that can be used in e
342342

343343
Business processes are an integral part of software projects and they should be tested in the same way normal application logic is tested: with unit tests. Since Flowable is an embeddable Java engine, writing unit tests for business processes is as simple as writing regular unit tests.
344344

345-
Flowable supports JUnit versions 3, 4 and 5 styles of unit testing.
345+
Flowable supports JUnit Jupiter styles of unit testing.
346346

347-
In the JUnit 5 style one needs to use the org.flowable.engine.test.FlowableTest annotation or register the org.flowable.engine.test.FlowableExtension manually.
348-
The FlowableTest annotation is just a meta annotation and the does the registration of the FlowableExtension (i.e. it does @ExtendWith(FlowableExtension.class)).
347+
In the JUnit Jupiter style one needs to use the org.flowable.engine.test.FlowableTest annotation or register the org.flowable.engine.test.FlowableExtension manually.
348+
The FlowableTest annotation is just a meta-annotation and does the registration of the FlowableExtension (i.e., it does @ExtendWith(FlowableExtension.class)).
349349
This will make the ProcessEngine and the services available as parameters into the test and lifecycle methods (@BeforeAll, @BeforeEach, @AfterEach, @AfterAll).
350350
Before each test the processEngine will be initialized by default with the flowable.cfg.xml resource on the classpath.
351-
In order to specify a different configuration file the org.flowable.engine.test.ConfigurationResource annotation needs to be used (see second example).
351+
To specify a different configuration file, the org.flowable.engine.test.ConfigurationResource annotation needs to be used (see second example).
352352
Process engines are cached statically over multiple unit tests when the configuration resource is the same.
353353

354354
By using FlowableExtension, you can annotate test methods with org.flowable.engine.test.Deployment.
@@ -357,9 +357,9 @@ In case there are no resources defined, a resource file of the form testClassNam
357357
At the end of the test, the deployment will be deleted, including all related process instances, tasks, and so on.
358358
See the Deployment class for more information.
359359

360-
Taking all that in account, a JUnit 5 test looks as follows:
360+
Taking all that into account, a JUnit Jupiter test looks as follows:
361361

362-
**JUnit 5 test with default resource.**
362+
**JUnit Jupiter test with default resource.**
363363

364364
@FlowableTest
365365
class MyBusinessProcessTest {
@@ -388,9 +388,9 @@ Taking all that in account, a JUnit 5 test looks as follows:
388388
}
389389
}
390390

391-
With JUnit 5 you can also inject the id of the deployment (with +org.flowable.engine.test.DeploymentId+_) into your test and lifecycle methods.
391+
With JUnit Jupiter you can also inject the id of the deployment (with +org.flowable.engine.test.DeploymentId+_) into your test and lifecycle methods.
392392

393-
**JUnit 5 test with a custom resource file.**
393+
**JUnit Jupiter test with a custom resource file.**
394394

395395
@FlowableTest
396396
@ConfigurationResource("flowable.custom.cfg.xml")
@@ -420,55 +420,6 @@ Taking all that in account, a JUnit 5 test looks as follows:
420420
}
421421
}
422422

423-
In the JUnit 3 style, the org.flowable.engine.test.FlowableTestCase must be extended. This will make the ProcessEngine and the services available through protected member fields. In the setup() of the test, the processEngine will be initialized by default with the flowable.cfg.xml resource on the classpath. To specify a different configuration file, override the *getConfigurationResource()* method. Process engines are cached statically over multiple unit tests when the configuration resource is the same.
424-
425-
As with the FlowableExtension (see above), extending the FlowableTestCase will enable the use of the org.flowable.engine.test.Deployment annotation (see above for an explanation of its use and configuration). Before the test is run, a resource file of the form testClassName.testMethod.bpmn20.xml in the same package as the test class, will be deployed. At the end of the test, the deployment will be deleted, including all related process instances, tasks, and so on. The Deployment annotation also supports setting the resource location explicitly. See the class itself for more information.
426-
427-
Taking all that in account, a JUnit 3 style test looks as follows.
428-
429-
**JUnit 3 test with default resource file.**
430-
431-
public class MyBusinessProcessTest extends FlowableTestCase {
432-
433-
@Deployment
434-
public void testSimpleProcess() {
435-
runtimeService.startProcessInstanceByKey("simpleProcess");
436-
437-
Task task = taskService.createTaskQuery().singleResult();
438-
assertEquals("My Task", task.getName());
439-
440-
taskService.complete(task.getId());
441-
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
442-
}
443-
}
444-
445-
To get the same functionality when using the JUnit 4 style of writing unit tests, the org.flowable.engine.test.FlowableRule Rule must be used. Through this rule, the process engine and services are available through getters.
446-
As with the FlowableExtension (see above), including this Rule will enable the use of the org.flowable.engine.test.Deployment annotation (see above for an explanation of its use and configuration) and it will look for the default configuration file on the classpath. Process engines are statically cached over multiple unit tests when using the same configuration resource.
447-
448-
The following code snippet shows an example of using the JUnit 4 style of testing and the usage of the FlowableRule.
449-
450-
**JUnit 4 test with default resource file.**
451-
452-
public class MyBusinessProcessTest {
453-
454-
@Rule
455-
public FlowableRule flowableRule = new FlowableRule();
456-
457-
@Test
458-
@Deployment
459-
public void ruleUsageExample() {
460-
RuntimeService runtimeService = flowableRule.getRuntimeService();
461-
runtimeService.startProcessInstanceByKey("ruleUsage");
462-
463-
TaskService taskService = flowableRule.getTaskService();
464-
Task task = taskService.createTaskQuery().singleResult();
465-
assertEquals("My Task", task.getName());
466-
467-
taskService.complete(task.getId());
468-
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
469-
}
470-
}
471-
472423
## Debugging unit tests
473424

474425
When using the in-memory H2 database for unit tests, the following instructions allow you to easily inspect the data in the Flowable database during a debugging session. The screenshots here are taken in Eclipse, but the mechanism should be similar for other IDEs.

docs/docusaurus/docs/bpmn/ch05-Spring.md

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,12 @@ In addition to using the values listed above for deploymentMode, you may require
218218
## Unit testing
219219

220220
When integrating with Spring, business processes can be tested very easily using the standard [Flowable testing facilities](bpmn/ch04-API.md#unit-testing).
221-
The following examples show how a business process is tested in typical Spring-based JUnit 4 and 5 test:
221+
The following examples show how a business process is tested in typical Spring-based JUnit Jupiter test:
222222

223223
**JUnit 5 test.**
224224

225225
@ExtendWith(FlowableSpringExtension.class)
226-
@ExtendWith(SpringExtension.class)
227-
@ContextConfiguration(classes = SpringJunitJupiterTest.TestConfiguration.class)
226+
@SpringJUnitConfig(SpringJunitJupiterTest.TestConfiguration.class)
228227
public class MyBusinessProcessTest {
229228

230229
@Autowired
@@ -248,41 +247,6 @@ The following examples show how a business process is tested in typical Spring-b
248247

249248
Using the FlowableSpringExtension allows the usage of the Deployment annotation.
250249

251-
**JUnit 4 test.**
252-
253-
@RunWith(SpringJUnit4ClassRunner.class)
254-
@ContextConfiguration("classpath:org/flowable/spring/test/junit4/springTypicalUsageTest-context.xml")
255-
public class MyBusinessProcessTest {
256-
257-
@Autowired
258-
private RuntimeService runtimeService;
259-
260-
@Autowired
261-
private TaskService taskService;
262-
263-
@Autowired
264-
@Rule
265-
public FlowableRule flowableSpringRule;
266-
267-
@Test
268-
@Deployment
269-
public void simpleProcessTest() {
270-
runtimeService.startProcessInstanceByKey("simpleProcess");
271-
Task task = taskService.createTaskQuery().singleResult();
272-
assertEquals("My Task", task.getName());
273-
274-
taskService.complete(task.getId());
275-
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
276-
277-
}
278-
}
279-
280-
Note that for this to work, you need to define an *org.flowable.engine.test.Flowable* bean in the Spring configuration (which is injected by auto-wiring in the example above).
281-
282-
<bean id="flowableRule" class="org.flowable.engine.test.Flowable">
283-
<property name="processEngine" ref="processEngine" />
284-
</bean>
285-
286250
## JPA with Hibernate 4.2.x
287251

288252
When using Hibernate 4.2.x JPA in service task or listener logic in the Flowable engine, an additional dependency to Spring ORM is needed. This is not needed for Hibernate 4.1.x or earlier. The following dependency should be added:

docs/docusaurus/docs/cmmn/ch03-API.md

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,10 @@ Delete all HistoricCaseInstances and their related data that are older than one
386386
Cases are an integral part of software projects and they should be tested in the same way normal application logic is tested: with unit tests.
387387
Since Flowable is an embeddable Java engine, writing unit tests for business cases is as simple as writing regular unit tests.
388388

389-
Flowable supports JUnit versions 4 and 5 styles of unit testing.
389+
Flowable supports JUnit Jupiter styles of unit testing.
390390

391-
In the JUnit 5 style one needs to use the org.flowable.cmmn.engine.test.FlowableCmmnTest annotation or register the org.flowable.cmmn.engine.test.FlowableCmmnExtension manually.
392-
The FlowableCmmnTest annotation is just a meta annotation and the does the registration of the FlowableCmmnExtension (i.e. it does @ExtendWith(FlowableCmmnExtension.class)).
391+
In the JUnit Jupiter style one needs to use the org.flowable.cmmn.engine.test.FlowableCmmnTest annotation or register the org.flowable.cmmn.engine.test.FlowableCmmnExtension manually.
392+
The FlowableCmmnTest annotation is just a meta-annotation and does the registration of the FlowableCmmnExtension (i.e. it does @ExtendWith(FlowableCmmnExtension.class)).
393393
This will make the CmmnEngine and the services available as parameters into the test and lifecycle methods (@BeforeAll, @BeforeEach, @AfterEach, @AfterAll).
394394
Before each test the cmmnEngine will be initialized by default with the flowable.cmmn.cfg.xml resource on the classpath.
395395
In order to specify a different configuration file the org.flowable.cmmn.engine.test.CmmnConfigurationResource annotation needs to be used (see the second example).
@@ -401,9 +401,9 @@ In case there are no resources defined, a resource file of the form testClassNam
401401
At the end of the test, the deployment will be deleted, including all related case instances, tasks, and so on.
402402
See the CmmnDeployment class for more information.
403403

404-
Taking all that into account, a JUnit 5 test looks as follows:
404+
Taking all that into account, a JUnit Jupiter test looks as follows:
405405

406-
**Junit 5 test with the default resource.**
406+
**Junit Jupiter test with the default resource.**
407407

408408
@FlowableCmmnTest
409409
class MyTest {
@@ -436,9 +436,9 @@ Taking all that into account, a JUnit 5 test looks as follows:
436436
}
437437
}
438438

439-
With JUnit 5 you can also inject the id of the deployment (with +org.flowable.cmmn.engine.test.CmmnDeploymentId+_) into your test and lifecycle methods.
439+
With JUnit Jupiter you can also inject the id of the deployment (with +org.flowable.cmmn.engine.test.CmmnDeploymentId+_) into your test and lifecycle methods.
440440

441-
**Junit 5 test with custom resource.**
441+
**Junit Jupiter test with custom resource.**
442442

443443
@FlowableCmmnTest
444444
@CmmnConfigurationResource("flowable.custom.cmmn.cfg.xml")
@@ -470,40 +470,3 @@ Taking all that into account, a JUnit 5 test looks as follows:
470470
assertEquals(0, cmmnRuntimeService.createCaseInstanceQuery().count());
471471
}
472472
}
473-
474-
In the JUnit 4 style, the *org.flowable.cmmn.engine.test.FlowableCmmnTestCase* is available as parent class. It uses a configuration file *flowable.cmmn.cfg.xml* by default or uses a standard CmmnEngine using an H2 in-memory database if such file is missing.
475-
Behind the scenes, a CmmnTestRunner is used to initialise the CMMN engine. Note in the example below how the *@CmmnDeployment* annotation is used to automatically deploy the case definition (it will look for a .cmmn file in the same folder as the test class and expects the file to be named &lt;Test class name&gt;.&lt;test method name&gt;.cmmn.
476-
477-
public class MyTest extends FlowableCmmnTestCase {
478-
479-
@Test
480-
@CmmnDeployment
481-
public void testSingleHumanTask() {
482-
CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder()
483-
.caseDefinitionKey("myCase")
484-
.start();
485-
assertNotNull(caseInstance);
486-
487-
Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
488-
assertEquals("Task 1", task.getName());
489-
assertEquals("JohnDoe", task.getAssignee());
490-
491-
cmmnTaskService.complete(task.getId());
492-
assertEquals(0, cmmnRuntimeService.createCaseInstanceQuery().count());
493-
}
494-
}
495-
496-
Alternatively, the *FlowableCmmnRule* is available and allows to set a custom configuration:
497-
498-
**JUnit 4 test with a Rule.**
499-
500-
@Rule
501-
public FlowableCmmnRule cmmnRule = new FlowableCmmnRule("org/flowable/custom.cfg.xml")
502-
503-
@Test
504-
@CmmnDeployment
505-
public void testSomething() {
506-
// ...
507-
assertThat((String) cmmnRule.getCmmnRuntimeService().getVariable(caseInstance.getId(), "test"), containsString("John"));
508-
// ...
509-
}

docs/docusaurus/docs/cmmn/ch04-Spring.md

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,12 @@ In addition to using the values listed above for deploymentMode, you may require
173173
## Unit testing
174174

175175
When integrating with Spring, business cases can be tested very easily using the standard standard [Flowable testing facilities](cmmn/ch03-API.md#unit-testing).
176-
The following examples show how a case definition is tested in typical Spring-based JUnit 4 and 5 test:
176+
The following examples show how a case definition is tested in typical Spring-based JUnit Jupiter test:
177177

178-
**JUnit 5 test.**
178+
**JUnit Jupiter test.**
179179

180180
@ExtendWith(FlowableCmmnSpringExtension.class)
181-
@ExtendWith(SpringExtension.class)
182-
@ContextConfiguration(classes = CmmnSpringJunitJupiterTest.TestConfiguration.class)
181+
@SpringJUnitConfig(CmmnSpringJunitJupiterTest.TestConfiguration.class)
183182
class MyBusinessCaseTest {
184183

185184
@Autowired
@@ -200,22 +199,3 @@ The following examples show how a case definition is tested in typical Spring-ba
200199
}
201200
}
202201

203-
**JUnit 4 test.**
204-
205-
public class MyBusinessCaseTest {
206-
207-
@Rule
208-
public FlowableCmmnRule cmmnRule = new FlowableCmmnRule("org/flowable/spring/test/el/SpringBeanTest-context.xml");
209-
210-
@Test
211-
public void simpleCaseTest() {
212-
cmmnRule.getCmmnRepositoryService().createDeployment().addClasspathResource("org/flowable/spring/test/el/springExpression.cmmn").deploy();
213-
CmmnRuntimeService cmmnRuntimeService = cmmnRule.getCmmnRuntimeService();
214-
CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder()
215-
.caseDefinitionKey("myCase")
216-
.variable("var1", "John Doe")
217-
.start();
218-
219-
Assert.assertNotNull(caseInstance);
220-
}
221-
}

docs/docusaurus/docs/dmn/ch03-API.md

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@ Sometimes you need more powerful queries, for example, queries using an OR opera
8686

8787
As Flowable DMN is an embeddable Java engine, writing unit tests for DMN definitions is as simple as writing regular unit tests.
8888

89-
Flowable supports the JUnit version 4 and 5 style of unit testing.
89+
Flowable supports the JUnit Jupiter style of unit testing.
9090

91-
In the JUnit 5 style one needs to use the org.flowable.dmn.engine.test.FlowableDmnTest annotation
91+
In the JUnit Jupiter style one needs to use the org.flowable.dmn.engine.test.FlowableDmnTest annotation
9292
or register the org.flowable.dmn.engine.test.FlowableDmnExtension manually.
93-
The FlowableDmnTest annotation is just a meta annotation and the does the registration of the FlowableDmnExtension
93+
The FlowableDmnTest annotation is just a meta-annotation and does the registration of the FlowableDmnExtension
9494
(i.e. it does @ExtendWith(FlowableDmnExtension.class)).
9595
This will make the DmnEngine and the services available as parameters into the test and lifecycle methods
9696
(@BeforeAll, @BeforeEach, @AfterEach, @AfterAll).
9797
Before each test the dmnEngine will be initialized by default with the flowable.dmn.cfg.xml resource on the classpath.
98-
In order to specify a different configuration file the org.flowable.dmn.engine.test.DmnConfigurationResource
98+
To specify a different configuration file the org.flowable.dmn.engine.test.DmnConfigurationResource
9999
annotation needs to be used (see second example).
100100
Dmn engines are cached statically over multiple unit tests when the configuration resource is the same.
101101

@@ -110,9 +110,9 @@ in the same package as the test class, will be deployed.
110110
At the end of the test, the deployment will be deleted, including all related dmn definitions, executions, and so on.
111111
See the DmnDeployment class for more information.
112112

113-
Taking all that in account, a JUnit 5 test looks as follows:
113+
Taking all that into account, a JUnit Jupiter test looks as follows:
114114

115-
**JUnit 5 test with default resource.**
115+
**JUnit Jupiter test with default resource.**
116116

117117
@FlowableDmnTest
118118
class MyDecisionTableTest {
@@ -132,9 +132,9 @@ Taking all that in account, a JUnit 5 test looks as follows:
132132
}
133133
}
134134

135-
With JUnit 5 you can also inject the id of the deployment (with +org.flowable.dmn.engine.test.DmnDeploymentId+_) into your test and lifecycle methods.
135+
With JUnit Jupiter you can also inject the id of the deployment (with +org.flowable.dmn.engine.test.DmnDeploymentId+_) into your test and lifecycle methods.
136136

137-
**JUnit 5 test with custom resource.**
137+
**JUnit Jupiter test with custom resource.**
138138

139139
@FlowableDmnTest
140140
@DmnConfigurationResource("flowable.custom.dmn.cfg.xml")
@@ -155,34 +155,6 @@ Taking all that in account, a JUnit 5 test looks as follows:
155155
}
156156
}
157157

158-
When writing JUnit 4 unit tests, the org.flowable.dmn.engine.test.FlowableDmnRule Rule can be used. Through this rule, the DMN engine and services are available through getters. Including this Rule will enable the use of the org.flowable.dmn.engine.test.DmnDeploymentAnnotation annotation (see above for an explanation of its use and configuration) and it will look for the default configuration file on the classpath. DMN engines are statically cached over multiple unit tests when using the same configuration resource.
159-
It’s also possible to provide a custom engine configuration to the rule.
160-
161-
The following code snippet shows an example of using the JUnit 4 style of testing and the usage of the FlowableDmnRule (and passing an optional custom configuration):
162-
163-
**JUnit 4 test.**
164-
165-
public class MyDecisionTableTest {
166-
167-
@Rule
168-
public FlowableDmnRule flowableDmnRule = new FlowableDmnRule("custom1.flowable.dmn.cfg.xml");
169-
170-
@Test
171-
@DmnDeploymentAnnotation
172-
public void ruleUsageExample() {
173-
DmnEngine dmnEngine = flowableDmnRule.getDmnEngine();
174-
DmnRuleService dmnRuleService = dmnEngine.getDmnRuleService();
175-
176-
Map<String, Object> executionResult = ruleService.createExecuteDecisionBuilder()
177-
.decisionKey("extensionUsage")
178-
.variable("inputVariable1", 2)
179-
.variable("inputVariable2", "test2")
180-
.executeWithSingleResult();
181-
182-
Assertions.assertThat(executionResult).containsEntry("output1", "test1");
183-
}
184-
}
185-
186158
## The DMN engine in a web application
187159

188160
The DmnEngine is a thread-safe class and can easily be shared among multiple threads. In a web application, this means it is possible to create the DMN engine once when the container boots and shut down the engine when the container goes down.

0 commit comments

Comments
 (0)