annhchen89 opened a new pull request, #6229:
URL: https://github.com/apache/shenyu/pull/6229

   <!-- Describe your PR here; e.g. Fixes #issueNo -->
   ## **What is the purpose of the change**  
   
   This PR fixes several nondeterministic tests in
   
```org.apache.shenyu.admin.listener.websocket.WebsocketDataChangedListenerTest```,
   specifically the following tests:
   
   - testOnRuleChanged
   - testOnSelectorChanged
   - testOnMetaDataChanged
   - testOnPluginChanged
   - testOnAppAuthChanged
   
   The original tests relied on exact string comparison of JSON payloads when 
verifying calls to WebsocketCollector.send. Since JSON object field order is 
not guaranteed, the serialized output can vary across runs or under NonDex, 
causing the tests to fail unpredictably despite having equivalent data.
   
   
   ## **The Fix**  
   Instead of comparing raw JSON strings, the tests now verify the payload 
using Jackson-based structural comparison.
   This approach validates logical equality while ignoring serialization-order 
differences, ensuring the tests fail only when the actual JSON content is 
incorrect.
   
   ## **Reproduce Test**  
   The nondeterministic failures can be reproduced by running the following 
NonDex commands:
   
   ```bash
   mvn -pl shenyu-admin edu.illinois:nondex-maven-plugin:2.2.1:nondex \
     
-Dtest=org.apache.shenyu.admin.listener.websocket.WebsocketDataChangedListenerTest#testOnRuleChanged
   ```
   Repeat similarly for:
   ```
   #testOnSelectorChanged
   #testOnMetaDataChanged
   #testOnPluginChanged
   #testOnAppAuthChanged
   ```
   <!--
   Thank you for proposing a pull request. This template will guide you through 
the essential steps necessary for a pull request.
   -->
   Make sure that:
   
   - [x] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your 
changes.
   - [x] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to