Skip to content

Conversation

@yonghanlin
Copy link

@yonghanlin yonghanlin commented Dec 7, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

This pull request updates three tests that were failing under NonDex due to relying on ordering that is not guaranteed:

  1. KinesisMessageDrivenChannelAdapterTests.resharding: The test previously assumed a specific shard key, which depended on the order in which shards were processed. Under NonDex, this ordering can change. The assertion is updated to accept either of the two expected shard keys (closedEmptyShard5, closedShard4).
  2. SnsBodyBuilderTests.snsBodyBuilder: The test previously asserted equality against a concrete JSON string. When the JSON object fields are emitted in a different order (e.g., "sms" before "default"), the string changes. The assertion is updated to check structure and required fields without enforcing key order.
  3. SnsMessageHandlerTests.snsMessageHandler: Similar to SnsBodyBuilderTests.snsBodyBuilder, this test previously asserted exact string equality on the JSON body. The assertion is updated to verify content while allowing either key order.

💡 Motivation and Context

These three tests were relying on ordering that is not guaranteed by the underlying platform, which NonDex exposes as non-deterministic behavior.

  • In KinesisMessageDrivenChannelAdapterTests.resharding, the test assumed a single shard key, even though the resharding logic can legitimately end with either of two closed shards depending on iteration order. This caused intermittent failures under NonDex despite both outcomes being correct.

  • In SnsBodyBuilderTests.snsBodyBuilder and SnsMessageHandlerTests.snsMessageHandler, the assertions compared JSON payloads using exact string equality. Since JSON object key order is not guaranteed, the tests failed when "sms" appeared before "default", even though the message content was identical.

By:

  • Accepting either valid shard key in the Kinesis test, and
  • Asserting that the SNS JSON payloads are well-formed and contain the expected "default" and "sms" fields (without enforcing key order),

this PR removes hidden ordering assumptions and makes the tests deterministic while still validating the intended behavior.

💚 How did you test it?

Run NonDex on <ModulePath> using the following commands:

mvn -pl <ModulePath> edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=packageName.ClassName#methodName

Replace <ModulePath> with the corresponding packageName.ClassName#methodName:

ModulePath: spring-cloud-aws-kinesis
io.awspring.cloud.kinesis.integration.KinesisMessageDrivenChannelAdapterTests#resharding
ModulePath: spring-cloud-aws-sns
io.awspring.cloud.sns.integration.SnsBodyBuilderTests#snsBodyBuilder
io.awspring.cloud.sns.integration.SnsMessageHandlerTests#snsMessageHandler 

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated reference documentation to reflect the change
  • All tests passing
  • No breaking changes

🔮 Next steps

@github-actions github-actions bot added the component: sns SNS integration related issue label Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: sns SNS integration related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant