Skip to content

Commit

Permalink
Merge pull request #210 from AxonFramework/bugfix/multitenancyconfigu…
Browse files Browse the repository at this point in the history
…ration

Incorrect Spring Boot Auto-configuration ordering
  • Loading branch information
smcvb authored Jul 31, 2024
2 parents d86ded7 + 5596b5e commit caa002c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
@AutoConfiguration
@ConditionalOnClass(AxonServerConfiguration.class)
@ConditionalOnProperty(value = {"axon.axonserver.enabled", "axon.multi-tenancy.enabled"}, matchIfMissing = true)
@AutoConfigureAfter(AxonServerAutoConfiguration.class)
@AutoConfigureBefore(AxonServerAutoConfiguration.class)
@ComponentScan(excludeFilters = {
@ComponentScan.Filter(
type = FilterType.REGEX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.axonframework.extensions.multitenancy.autoconfig;

import org.axonframework.axonserver.connector.event.axon.PersistentStreamMessageSource;
import org.axonframework.axonserver.connector.event.axon.PersistentStreamMessageSourceFactory;
import org.axonframework.extensions.multitenancy.components.TargetTenantResolver;
import org.axonframework.extensions.multitenancy.components.TenantConnectPredicate;
Expand All @@ -39,6 +40,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;

/**
* Test class validating the multi-tenancy auto-configuration.
Expand Down Expand Up @@ -121,6 +123,22 @@ void multiTenancyDisabled() {
});
}

@Test
void multiTenancyAutoConfigurationMultiTenantPersistentStreamMessageSource() {
contextRunner
.withConfiguration(AutoConfigurations.of(AxonServerAutoConfiguration.class))

.withConfiguration(AutoConfigurations.of(MultiTenancyAxonServerAutoConfiguration.class))
.withConfiguration(AutoConfigurations.of(MultiTenantPersistentStreamAutoConfiguration.class))
.withPropertyValues("axon.axonserver.contexts=tenant-1,tenant-2")
.run(context -> {
PersistentStreamMessageSourceFactory persistentStreamMessageSourceFactory =
context.getBean("persistentStreamMessageSourceFactory", PersistentStreamMessageSourceFactory.class);
PersistentStreamMessageSource persistentStreamMessageSource = persistentStreamMessageSourceFactory.build("testName", mock(), mock(), 100, "testContext", mock());
assertThat(persistentStreamMessageSource).isInstanceOf(MultiTenantPersistentStreamMessageSource.class);
});
}

@Test
void multiTenancyMetaDataHelperDisabled() {
TargetTenantResolver<Message<?>> userResolver = (message, tenants) ->
Expand Down

0 comments on commit caa002c

Please sign in to comment.