Fix(jbpm-workitems-bpmn2): make test in JaxWSServiceTaskTest deterministic #2479
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
This PR fixes the flaky tests:
org.jbpm.process.workitem.bpmn2.JaxWSServiceTaskTest.testServiceInvocationWithMultipleIntParamsorg.jbpm.process.workitem.bpmn2.JaxWSServiceTaskTest.testServiceInvocationWithMultipleIntIntParamsThese tests may pass or fail nondeterministically due to the non-deterministic iteration order of multi-value parameters within the WebService handler, which affects the concatenation order in the returned greeting string.
Why the tests fail (root cause)
Both tests validate the output of a web service invocation that concatenates multiple input parameters (e.g., ["john", "doe"] or [2, 3]) into a greeting message such as "Hello doe, john".
However, the internal parameter iteration (e.g., through a HashMap or array conversion in the WebServiceWorkItemHandler) does not guarantee a consistent order of iteration across JVM executions.
For example:
These are semantically equivalent, but because the test compares the raw string output, the equality check is order-sensitive, causing intermittent failures, especially under randomized iteration (e.g., NonDex).
How to reproduce the test failure
Using NonDex, which randomizes collection iteration order:
For example, for the test
testServiceInvocationWithMultipleParams,# Run with NonDex (flakiness appears after a few runs) mvn -pl jbpm-workitems/jbpm-workitems-bpmn2 -am \ edu.illinois:nondex-maven-plugin:2.1.7:nondex \ -Dtest=org.jbpm.process.workitem.bpmn2.JaxWSServiceTaskTest#testServiceInvocationWithMultipleParams \ -DnondexRuns=10 \ -DfailIfNoTests=falseActual Results
Example flaky output:
These greetings are equivalent but differ in key order, resulting in a false test failure.
Description of the fix
The fix makes the assertions order-insensitive by parsing and normalizing the returned greeting before comparison.
Instead of asserting raw string equality, the test now:
This approach ensures:
Verification of the fix
Using the same test commands:
Key points