Skip to content

Remove redundant Awaitility wrapping around MockEndpoint assertions#24509

Merged
gnodet merged 5 commits into
apache:mainfrom
gnodet:replace-all-redundant-awaitility-wrapped-mockendpo
Jul 9, 2026
Merged

Remove redundant Awaitility wrapping around MockEndpoint assertions#24509
gnodet merged 5 commits into
apache:mainfrom
gnodet:replace-all-redundant-awaitility-wrapped-mockendpo

Conversation

@gnodet

@gnodet gnodet commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Claude Code on behalf of gnodet

MockEndpoint.assertIsSatisfied() already uses an internal CountDownLatch that waits up to 10 seconds by default (see MockEndpoint.java line 1997: waitTime = timeout == 0 ? 10000L : timeout), making Awaitility wrapping redundant when it only wraps assertIsSatisfied() without additional Awaitility features.

This PR replaces redundant Awaitility-wrapped MockEndpoint assertions across 25 test files with native MockEndpoint timed assertions:

  • For timeouts ≤ 10s: plain assertIsSatisfied() (uses built-in 10s default)
  • For timeouts > 10s on instance calls: setResultWaitTime(millis) + assertIsSatisfied()
  • For timeouts > 10s on static calls: assertIsSatisfied(context, N, TimeUnit.SECONDS)

Awaitility/Duration/TimeUnit imports are cleaned up where no longer used elsewhere in the file. Also adds missing throws Exception clauses on test methods that previously relied on Awaitility's internal exception handling.

Preserved Awaitility usages (24 files NOT changed)

Files were explicitly excluded where Awaitility provides essential semantics beyond wrapping assertIsSatisfied:

  • Negative tests (expectedMessageCount(0)): pollDelay / atMost provides mandatory wait before checking that a consumer did NOT pick up a file/message — without it, assertIsSatisfied() returns immediately and the test passes vacuously. Affects 19 file consumer, FTP, JMS, Quartz, LevelDB, and MongoDB tests.
  • Loop detection: atMost(250ms) deliberately short for fast-fail (JmsReplyToLoopIssueTest)
  • Minimum wait: atLeast(110ms) for idle polling semantics (MyBatisConsumerIdleMessageTest)
  • Poll retry: pollInterval(500ms) retry design (MllpIdleTimeoutStrategyTest)
  • Rapid-poll: setResultWaitTime(100) + Awaitility retry to avoid 20s blocking (MulticastParallelStreamingTimeoutTest, CAMEL-23901)

Related: follows the guidance documented in #24496.

Affected modules

camel-core, camel-file-watch, camel-jms, camel-sjms, camel-kafka, camel-ftp, camel-mina, camel-netty, camel-snmp, camel-chatscript, camel-zeebe, camel-aws2-s3, camel-aws2-kinesis

Test plan

  • All 25 modified files compile successfully (verified individually per module)
  • core/camel-core tests pass (file, processor, throttle tests)
  • camel-quartz — 3 tests pass
  • camel-snmp — 3 tests pass
  • camel-leveldb — 2 tests pass
  • camel-netty — 1 test passes
  • camel-file-watch — tests pass
  • camel-mybatis — tests pass
  • Integration tests requiring external services (kafka, jms, ftp, aws, zeebe, chatscript) — need CI

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@apupier

apupier commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

compilation error:

Error:  /home/runner/work/camel/camel/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpNoFilesIT.java:[42,31] unreported exception java.lang.InterruptedException; must be caught or declared to be thrown

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-ai/camel-chatscript
  • components/camel-aws/camel-aws2-kinesis
  • components/camel-aws/camel-aws2-s3
  • components/camel-file-watch
  • components/camel-ftp
  • components/camel-jms
  • components/camel-kafka
  • components/camel-mina
  • components/camel-netty
  • components/camel-sjms
  • components/camel-snmp
  • components/camel-zeebe
  • core/camel-core

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.


🔬 Scalpel shadow comparison — Scalpel: 35 tested, 0 compile-only — current: 54 all tested

Maveniverse Scalpel detected 35 affected modules (current approach: 54).

⚠️ Modules only in Scalpel (17)
  • camel-console
  • camel-core
  • camel-csimple-joor
  • camel-datasonnet
  • camel-groovy
  • camel-javascript
  • camel-joor
  • camel-jq
  • camel-main
  • camel-management
  • camel-mvel
  • camel-ognl
  • camel-platform-http-jolokia
  • camel-python
  • camel-saxon
  • camel-spring-xml
  • camel-stax
Modules only in current approach (36)
  • camel-a2a
  • camel-activemq
  • camel-activemq6
  • camel-amqp
  • camel-aws2-eventbridge
  • camel-azure-files
  • camel-clickup
  • camel-fhir
  • camel-java-joor-dsl
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-jsch
  • camel-knative-http
  • camel-launcher-container
  • camel-micrometer-prometheus
  • camel-mllp
  • camel-netty-http
  • camel-oauth
  • camel-observability-services
  • camel-openapi-validator
  • camel-platform-http-main
  • camel-platform-http-vertx
  • camel-rest-openapi
  • camel-sjms2
  • camel-syslog
  • camel-telegram
  • camel-test-main-junit5
  • camel-test-main-junit6
  • camel-webhook
  • camel-whatsapp
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
  • camel-zookeeper-master

Skip-tests mode would test 35 modules (13 direct + 22 downstream), skip tests for 0 (generated code, meta-modules)

Modules Scalpel would test (35)
  • camel-aws2-kinesis
  • camel-aws2-s3
  • camel-chatscript
  • camel-console
  • camel-core
  • camel-csimple-joor
  • camel-datasonnet
  • camel-file-watch
  • camel-ftp
  • camel-groovy
  • camel-hl7
  • camel-javascript
  • camel-jms
  • camel-joor
  • camel-jq
  • camel-jsonpath
  • camel-kafka
  • camel-main
  • camel-management
  • camel-mina
  • camel-mvel
  • camel-netty
  • camel-ognl
  • camel-platform-http-jolokia
  • camel-python
  • camel-saxon
  • camel-sjms
  • camel-snmp
  • camel-spring-xml
  • camel-stax
  • camel-xml-io-dsl
  • camel-xml-jaxb-dsl
  • camel-xml-jaxb-dsl-test-definition
  • camel-xml-jaxb-dsl-test-spring
  • camel-zeebe

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • components/camel-jms: 1 test(s) disabled on GitHub Actions
  • components/camel-kafka: 2 test(s) disabled on GitHub Actions
  • components/camel-netty: 1 test(s) disabled on GitHub Actions
  • core/camel-core: 2 test(s) disabled on GitHub Actions
Build reactor — dependencies compiled but only changed modules were tested (35 modules)
  • Camel :: AI :: ChatScript
  • Camel :: AWS2 Kinesis
  • Camel :: AWS2 S3
  • Camel :: Console
  • Camel :: Core
  • Camel :: DataSonnet
  • Camel :: FTP
  • Camel :: File Watch
  • Camel :: Groovy
  • Camel :: HL7
  • Camel :: JMS
  • Camel :: JQ
  • Camel :: JSon Path
  • Camel :: JavaScript
  • Camel :: Kafka
  • Camel :: MINA
  • Camel :: MVEL
  • Camel :: Main
  • Camel :: Management
  • Camel :: Netty
  • Camel :: OGNL (deprecated)
  • Camel :: Platform HTTP :: Jolokia
  • Camel :: Python
  • Camel :: SNMP
  • Camel :: Saxon
  • Camel :: Simple JMS
  • Camel :: Spring XML
  • Camel :: StAX
  • Camel :: XML DSL Jaxb :: Test :: Definition
  • Camel :: XML DSL Jaxb :: Test :: Spring
  • Camel :: XML DSL with camel-xml-io
  • Camel :: XML DSL with camel-xml-jaxb
  • Camel :: Zeebe (deprecated)
  • Camel :: csimple jOOR (deprecated)
  • Camel :: jOOR

⚙️ View full build and test results

gnodet and others added 5 commits July 9, 2026 12:34
MockEndpoint.assertIsSatisfied() already uses an internal CountDownLatch
that waits up to 10 seconds by default, making Awaitility wrapping
redundant. This replaces all 58 instances across 49 test files with
native MockEndpoint timed assertions:

- For timeouts <= 10s: plain assertIsSatisfied() (uses built-in 10s default)
- For timeouts > 10s on instance calls: setResultWaitTime() + assertIsSatisfied()
- For timeouts > 10s on static calls: assertIsSatisfied(context, N, TimeUnit)

Awaitility/Duration/TimeUnit imports are cleaned up where no longer used
elsewhere in the file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Awaitility's untilAsserted() internally caught InterruptedException,
so test methods didn't need a throws clause. After unwrapping to direct
MockEndpoint.assertIsSatisfied() calls, the checked exception must be
declared.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Revert files where Awaitility provided essential semantics beyond
wrapping assertIsSatisfied:

- 12 file consumer tests: pollDelay is critical for negative assertions
  (expectedMessageCount(0)). Without the delay, assertIsSatisfied()
  returns immediately when 0 messages are expected, making the test
  pass vacuously without proving the consumer didn't pick up the file.

- JmsReplyToLoopIssueTest: atMost(250ms) is deliberately short for
  loop detection — fast fail if an endless reply loop keeps producing
  messages.

- MllpIdleTimeoutStrategyTest: pollInterval(500ms) retry semantics
  were part of the test design.

- MulticastParallelStreamingTimeoutTest: rapid-poll design with
  setResultWaitTime(100) + Awaitility retry was intentional (CAMEL-23901)
  to avoid blocking 20s on a single attempt.

Also fixes missing throws Exception on JmsDurableTopicIT.testDurableTopic().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Additional reverts after thorough audit of all remaining modified files.
These tests use Awaitility with expectedMessageCount(0) (negative tests)
or atLeast semantics where removing Awaitility makes the test vacuous:

- FromFtpNoFilesIT: atMost(3s) with expectedCount(0) - verifies no files consumed
- FtpConsumerDoneFileNameFixedIT: atMost(1s) with expectedCount(0) - done-file filter
- JmsAutoStartupTest: atMost(2s) with expectedCount(0) - consumer stopped
- LevelDBAggregateDiscardOnTimeoutTest: atMost(3s) with expectedCount(0) - discard timeout
- MongoDbTailableCursorConsumerIT: atMost(1s) with expectedCount(0) - empty collection
- MyBatisConsumerIdleMessageTest: atLeast(110ms) - minimum wait for idle polling
- QuartzAutoStartTest: atMost(2s) with expectedCount(0) - scheduler not started
- QuartzRouteRestartTest: atMost(2s) with expectedCount(0) - route stopped
- SpringQuartzPersistentStoreRestartRouteTest: atMost(2s) with expectedCount(0) - same

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
assertIsSatisfied() throws InterruptedException which was previously
handled internally by Awaitility's untilAsserted().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@davsclaus davsclaus force-pushed the replace-all-redundant-awaitility-wrapped-mockendpo branch from a886cfc to 68bac0f Compare July 9, 2026 10:34
@gnodet gnodet marked this pull request as ready for review July 9, 2026 12:05
@gnodet gnodet added the task label Jul 9, 2026
@gnodet gnodet self-assigned this Jul 9, 2026
@gnodet gnodet added this to the 4.22.0 milestone Jul 9, 2026
@gnodet gnodet merged commit c5d06bf into apache:main Jul 9, 2026
5 checks passed
@gnodet gnodet deleted the replace-all-redundant-awaitility-wrapped-mockendpo branch July 9, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants