Skip to content

Fix MqttClientActorTest failures by replacing static mocking with constructor injection#2345

Merged
thjaeckle merged 1 commit into
eclipse-ditto:masterfrom
beyonnex-io:bugfix/fix-mqtt-client-actor-test-static-mocking
Feb 17, 2026
Merged

Fix MqttClientActorTest failures by replacing static mocking with constructor injection#2345
thjaeckle merged 1 commit into
eclipse-ditto:masterfrom
beyonnex-io:bugfix/fix-mqtt-client-actor-test-static-mocking

Conversation

@thjaeckle
Copy link
Copy Markdown
Member

The Mockito 5 upgrade broke the MockedStatic<GenericMqttClientFactory> pattern, causing all 8 MqttClientActorTest tests to fail on CI with ConnectionFailedException("Connection attempt timed out"). The static mock no longer intercepted GenericMqttClientFactory.newInstance(), so real HiveMQ clients were created instead of mocks.

Follow the established RabbitMQClientActor pattern: add a second constructor accepting GenericMqttClientFactory and a package-private propsForTests() method. This eliminates MockedStatic entirely, avoiding all thread-locality and Mockito version issues.

…structor injection

The Mockito 5 upgrade broke the `MockedStatic<GenericMqttClientFactory>`
pattern, causing all 8 MqttClientActorTest tests to fail on CI with
`ConnectionFailedException("Connection attempt timed out")`. The static
mock no longer intercepted `GenericMqttClientFactory.newInstance()`, so
real HiveMQ clients were created instead of mocks.

Follow the established `RabbitMQClientActor` pattern: add a second
constructor accepting `GenericMqttClientFactory` and a package-private
`propsForTests()` method. This eliminates `MockedStatic` entirely,
avoiding all thread-locality and Mockito version issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@thjaeckle thjaeckle added this to the 3.9.0 milestone Feb 17, 2026
@thjaeckle thjaeckle self-assigned this Feb 17, 2026
@thjaeckle thjaeckle merged commit f608961 into eclipse-ditto:master Feb 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant