Skip to content

Commit

Permalink
Polish "Configure jOOQ with TransactionProvider bean when available"
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Feb 1, 2023
1 parent b2a8c8b commit 56a1551
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ void transactionProviderBacksOffOnExistingTransactionProvider() {
.run((context) -> {
TransactionProvider transactionProvider = context.getBean(TransactionProvider.class);
assertThat(transactionProvider).isInstanceOf(CustomTransactionProvider.class);
DSLContext dsl = context.getBean(DSLContext.class);
assertThat(dsl.configuration().transactionProvider()).isSameAs(transactionProvider);
});
}

@Test
void transactionProviderFromConfigurationCustomizerOverridesTransactionProviderBean() {
this.contextRunner.withUserConfiguration(JooqDataSourceConfiguration.class, TxManagerConfiguration.class,
CustomTransactionProviderFromCustomizerConfiguration.class).run((context) -> {
TransactionProvider transactionProvider = context.getBean(TransactionProvider.class);
assertThat(transactionProvider).isInstanceOf(SpringTransactionProvider.class);
DSLContext dsl = context.getBean(DSLContext.class);
assertThat(dsl.configuration().transactionProvider()).isInstanceOf(CustomTransactionProvider.class);
});
}

Expand Down Expand Up @@ -239,6 +252,16 @@ TransactionProvider transactionProvider() {

}

@Configuration(proxyBeanMethods = false)
static class CustomTransactionProviderFromCustomizerConfiguration {

@Bean
DefaultConfigurationCustomizer transactionProviderCustomizer() {
return (configuration) -> configuration.setTransactionProvider(new CustomTransactionProvider());
}

}

@Configuration(proxyBeanMethods = false)
static class TxManagerConfiguration {

Expand Down

0 comments on commit 56a1551

Please # to comment.