I am trying to use @sql and @sqlgroup on my unit test but I want this annotation to use datasource with different name other than default datasource.
How can you achieve this?
From the Transaction management for @Sql section of the Spring Reference Manual:
If the algorithms used by
SqlScriptsTestExecutionListener
to detect aDataSource
andPlatformTransactionManager
and infer the transaction semantics do not suit your needs, you may specify explicit names via thedataSource
andtransactionManager
attributes of@SqlConfig
.
For example:
@SqlGroup({
@Sql(scripts = "script1.sql", config = @SqlConfig(dataSource = "dataSource1", transactionManager = "txMgr1")),
@Sql(scripts = "script2.sql", config = @SqlConfig(dataSource = "dataSource2", transactionManager = "txMgr2"))
})
Regards,
Sam (author of the Spring TestContext Framework)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With