[
https://issues.apache.org/jira/browse/WICKET-7088?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Martin Tzvetanov Grigorov updated WICKET-7088:
----------------------------------------------
Priority: Major (was: Critical)
> Improve test reliability by resolving nondeterministic order of Set and Map
> ---------------------------------------------------------------------------
>
> Key: WICKET-7088
> URL: https://issues.apache.org/jira/browse/WICKET-7088
> Project: Wicket
> Issue Type: Improvement
> Components: wicket-core
> Affects Versions: 10.0.0-M2, 9.16.0
> Environment: Reproduce
> This error can be reproduced with the NondexTool with the following command
> (you can try that without modifying the pom, but feel free to use the plugin
> to protect your project and make it safer 😊 ), and this kind problem is
> widely documented in International Dataset of Flaky Tests (IDoFT)
> mvn edu.illinois:nondex-maven-plugin:2.1.7-SNAPSHOT:nondex -pl
> ./wicket-core-tests -DnondexRuns=10
> -Dtest=org.apache.wicket.markup.html.form.CollectionFormComponentTest#getSetUnmodifiableSet
> Most similar Similar issues
> FasterXML/jackson-jaxrs-providers#154
> https://github.com/FasterXML/jackson-annotations/pull/194/files
> Reporter: huiyang chi
> Priority: Major
> Labels: pull-request-available
>
> The related PR had been approved  :
> [https://github.com/apache/wicket/pull/707] :):):)
> h1. Problem
> In the test getSetUnmodifiableSet and getSetNullList, we use a set to
> intitialize our choice, and assume it will have the order with
> getDefaultModelObjectAsString to be [A, B], but this is not necessary true
> according to [Oracle's official
> document|https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html#:~:text=It%20makes%20no%20guarantees%20as%20to%20the%20iteration%20order%20of%20the%20set%3B%20in%20particular]
> Â
> For the test renderAjaxAttributes, we create the Json string from the
> AjaxRequestAttributes and assume the order of the fields in tests which is
> not true because it serialize from extraParameters which was a HashMap, which
> did not guarantee any order and will cause non-deterministic when we change
> the environments like JDK version. Also the LinkedHashMap is designed with
> specification to guarantee the order to resolve this kind of problem
> h1. Solution
> Use LinkedHashMap
> This problem had encountered and solved in wicket the same way before :
> [wicket/wicket-core/src/main/java/org/apache/wicket/ajax/json/README|https://github.com/apache/wicket/blob/b243eca31ab4a0ab78159fd2ccf7337a38b94840/wicket-core/src/main/java/org/apache/wicket/ajax/json/README#L4-L6]
> Lines 4 to 6 inÂ
> [b243eca|https://github.com/apache/wicket/commit/b243eca31ab4a0ab78159fd2ccf7337a38b94840]
> ||IMPORTANT: JSONObject#map field is manually changed to LinkedHashMap (from
> HashMap) to keep||
> ||the order of the ajax attributes consistent for WicketTester based unit
> tests||
> Â
> Â
> h1. Affected Tests
> Â
> [INFO]
> org.apache.wicket.markup.html.form.CollectionFormComponentTest#getSetUnmodifiableSet
> [INFO]
> org.apache.wicket.markup.html.form.CollectionFormComponentTest#getSetNullSet
> [INFO]
> org.apache.wicket.ajax.AbstractDefaultAjaxBehaviorTest#renderAjaxAttributes
> [INFO]
> org.apache.wicket.ajax.AjaxCallbackFunctionTest#testCallbackFunctionWithConverted
> [INFO]
> org.apache.wicket.ajax.AjaxCallbackFunctionTest#testCallbackFunctionWithExplicit
> [INFO]
> org.apache.wicket.ajax.AjaxCallbackFunctionTest#testCallbackFunctionWithAll
> [INFO]
> org.apache.wicket.ajax.AjaxCallbackFunctionTest#testCallbackFunctionWithContext
> [INFO] org.apache.wicket.ajax.AjaxCallbackFunctionTest#testJQueryUIEvent
> [INFO]
> org.apache.wicket.ajax.AjaxCallbackFunctionTest#testCallbackFunctionWithResolved
> [INFO]
> org.apache.wicket.ajax.AjaxCallbackFunctionTest#testDefaultCallbackFunction
--
This message was sent by Atlassian Jira
(v8.20.10#820010)