Class OutboxTestAutoConfiguration
Wired automatically by the AutoConfigureOutbox annotation; not
intended for direct activation via application.properties. The
@ConditionalOnProperty check matches the
im2be.outbox.test.captor-enabled property that
AutoConfigureOutbox sets via @PropertyMapping.
Exposes two beans:
TestOutboxRecordCaptor— the assertion API consumers inject to verify whichOutboxRecordentries the production code persisted.OutboxRecordRepository— an in-memory implementation that preempts the JPA-backed repository viaPrimaryso production code that callsrepository.save(...)writes to the captor rather than a real database.
AutoConfigureBefore on the production
com.aim2be.platform.outbox.OutboxAutoConfiguration class name
ensures the in-memory bean is registered before the production autoconfig
fires, so its @ConditionalOnMissingBean(OutboxRecordRepository.class)
checks (when present in downstream wiring) skip the JPA path. The
Primary marker is the belt-and-braces guarantee for cases where the
downstream test pulls in both beans.
Registered via
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
so @AutoConfigureOutbox activates it without an explicit
@Import.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIn-memoryOutboxRecordRepositorythat preempts the JPA-backed repository for tests.TestOutboxRecordCaptorbean exposed to test classes.
-
Constructor Details
-
OutboxTestAutoConfiguration
public OutboxTestAutoConfiguration()
-
-
Method Details
-
testOutboxRecordCaptor
TestOutboxRecordCaptorbean exposed to test classes.- Returns:
- a fresh captor per Spring context
-
testInMemoryOutboxRecordRepository
@Bean @Primary public OutboxRecordRepository testInMemoryOutboxRecordRepository(TestOutboxRecordCaptor captor) In-memoryOutboxRecordRepositorythat preempts the JPA-backed repository for tests. MarkedPrimaryso any consumer auto-wired collection or single-bean injection point resolves to this bean even when the production JPA repository is also in context.- Parameters:
captor- the captor bean wired in the same context- Returns:
- a
ProxyFactory-style dynamic proxy over the in-memory store
-