Class OutboxTestAutoConfiguration

java.lang.Object
com.aim2be.platform.test.OutboxTestAutoConfiguration

@AutoConfiguration @AutoConfigureBefore(name="com.aim2be.platform.outbox.OutboxAutoConfiguration") @ConditionalOnProperty(prefix="im2be.outbox.test", name="captor-enabled", havingValue="true") public class OutboxTestAutoConfiguration extends Object
Spring Boot test auto-configuration for the outbox-test-fixtures module.

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:

  1. TestOutboxRecordCaptor — the assertion API consumers inject to verify which OutboxRecord entries the production code persisted.
  2. OutboxRecordRepository — an in-memory implementation that preempts the JPA-backed repository via Primary so production code that calls repository.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 Details

    • OutboxTestAutoConfiguration

      public OutboxTestAutoConfiguration()
  • Method Details

    • testOutboxRecordCaptor

      @Bean public TestOutboxRecordCaptor testOutboxRecordCaptor()
      TestOutboxRecordCaptor bean exposed to test classes.
      Returns:
      a fresh captor per Spring context
    • testInMemoryOutboxRecordRepository

      @Bean @Primary public OutboxRecordRepository testInMemoryOutboxRecordRepository(TestOutboxRecordCaptor captor)
      In-memory OutboxRecordRepository that preempts the JPA-backed repository for tests. Marked Primary so 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