v3.3.0
no-rewritesDynamic bean overrides — keep your production Kafka beans in tests.
Highlights
- 01
SharedKafkaBeanOverridePostProcessor
A BeanPostProcessor that rewrites bootstrap servers and strips production security on existing ProducerFactory, ConsumerFactory, KafkaTemplate, and listener factory beans at context init.
Read the guide → - 02
Listener group-id isolation
SharedKafkaListenerAnnotationEnhancer suffixes consumer group ids per-context, preventing collisions across parallel test contexts.
- 03
Map-built factories supported
ProducerFactory and ConsumerFactory beans built directly from Map<String, Object> are overridden the same way; custom serialisers and deserialisers are preserved.
- 04
Mock registry for map-built Avro
When bean overrides + mock-schema-registry are both enabled, map-built Avro factories are pointed at the mock registry and registry auth is stripped.
Full notes
Added
- SharedKafkaBeanOverridePostProcessor — rewrites bootstrap servers and removes production security settings (security.protocol, sasl., ssl., basic.auth.*) on existing ProducerFactory, ConsumerFactory, KafkaTemplate, and ConcurrentKafkaListenerContainerFactory beans.
- SharedKafkaListenerAnnotationEnhancer — appends a unique, context-scoped suffix to configured consumer group ids when bean overrides are enabled.
- Property: spring.kafka.test.bean-overrides.enabled — enable the post-processor.
- Property: spring.kafka.test.bean-overrides.consumer.auto-offset-reset — override auto.offset.reset (defaults to earliest); use 'preserve' to keep the application's existing value.
- Property: spring.kafka.test.bean-overrides.consumer.unique-group-ids — toggle group id suffixing (default true).
- Property: spring.kafka.test.bean-overrides.consumer.group-id-suffix — provide a deterministic suffix instead of the random default.
- Map-built Kafka configuration support: factories built directly from Map<String, Object> are overridden in the same way, with custom serialiser/deserialiser classes preserved.
- Mock schema registry integration for map-built Avro clients.
- Integration tests covering property- and map-configured Kafka beans, consumer default opt-out paths, and assertion helpers after override.
- Bean overrides guide in the documentation site covering setup, JSON/Avro support, listener factories, opt-out, and when to keep manual @TestConfiguration overrides.
Changed
- Bumped version to 3.3.0-SNAPSHOT.
- Updated dependency examples in the README and docs to use io.gitlab.guisseppe:spring-kafka-test-utils:3.3.0.
- Migration guide renumbered and updated to include a step for enabling dynamic bean overrides.