public class TestSpringMatsFactoryProvider
extends java.lang.Object
MatsFactory
-provider which utilizes the MatsTestBroker
for the produced
MatsFactory to connect to - this is for the scenarios where you do NOT have your test load the entire
application's Spring configuration, but instead "piece together" the relevant Spring
@Components
containing test-relevant Mats endpoints and other beans from your application
along with test-specific mocked-out endpoints: You will then probably not have the MatsFactory present in the Spring
context. You can then use this class to get a "quick and dirty" MatsFactory (with an in-vm MQ Broker backing it) on
which your application's endpoints, and mocked-out endpoints in the test, can run.
If your requirements aren't all that exotic, you may get this indirectly invoked by using the
@MatsTestContext
annotation directly on the Test-class. If your requirements are slightly more
involved, check out the MatsTestInfrastructureConfiguration
and MatsTestInfrastructureDbConfiguration
Spring Configuration classes (loaded in a test with @ContextConfiguration
), which employs the
methods in this class.Constructor and Description |
---|
TestSpringMatsFactoryProvider() |
Modifier and Type | Method and Description |
---|---|
static MatsFactory |
createJmsTxOnlyTestMatsFactory(int concurrency,
MatsSerializer<?> matsSerializer)
If you need a
MatsFactory that only handles the JMS transactions, this is your factory method - but if
you DO make any database calls within any Mats endpoint lambda, you will now have no or poor transactional
demarcation, use createSpringDataSourceTxTestMatsFactory(..) instead. |
static MatsFactory |
createJmsTxOnlyTestMatsFactory(MatsSerializer<?> matsSerializer)
Convenience variant of
createJmsTxOnlyTestMatsFactory(int, MatsSerializer) where concurrency is 2, which
should be adequate for most testing - unless you explicitly want to test concurrency. |
static MatsFactory |
createSpringDataSourceTxTestMatsFactory(javax.sql.DataSource sqlDataSource,
MatsSerializer<?> matsSerializer)
Convenience variant of
createSpringDataSourceTxTestMatsFactory(int, DataSource, MatsSerializer) where
concurrency is 1, which should be adequate for most testing - unless you explicitly want to test concurrency. |
static MatsFactory |
createSpringDataSourceTxTestMatsFactory(int concurrency,
javax.sql.DataSource sqlDataSource,
MatsSerializer<?> matsSerializer)
If you need a
MatsFactory employing Spring's DataSourceTransactionManager (which you probably do in a
Spring environment utilizing SQL), this is your factory method. |
static MatsFactory |
createSpringDataSourceTxTestMatsFactory(int concurrency,
org.springframework.transaction.PlatformTransactionManager platformTransactionManager,
MatsSerializer<?> matsSerializer)
If you need a
MatsFactory , but you need to make your own PlatformTransactionManager , this is your
factory method - please note that the contained DataSource should have been wrapped using the static
method JmsMatsTransactionManager_JmsAndSpringManagedSqlTx.wrapLazyConnectionDatasource(DataSource) . |
static MatsFactory |
createSpringDataSourceTxTestMatsFactory(org.springframework.transaction.PlatformTransactionManager platformTransactionManager,
MatsSerializer<?> matsSerializer)
Convenience variant of
createSpringDataSourceTxTestMatsFactory(int, PlatformTransactionManager, MatsSerializer) where
concurrency is 2, which should be adequate for most testing - unless you explicitly want to test concurrency. |
public static MatsFactory createSpringDataSourceTxTestMatsFactory(int concurrency, javax.sql.DataSource sqlDataSource, MatsSerializer<?> matsSerializer)
MatsFactory
employing Spring's DataSourceTransactionManager (which you probably do in a
Spring environment utilizing SQL), this is your factory method. If you need to make y
Usage: In the test, make a @Bean-annotated method which returns the result of this method - or employ the
convenience MatsTestInfrastructureDbConfiguration
.concurrency
- The concurrency of the created MatsFactory
, set with
MatsFactory.FactoryConfig.setConcurrency(int)
.sqlDataSource
- the SQL DataSource which to stash into a Spring DataSourceTransactionManager
, and from which
SQL Connection
s are fetched from, using DataSource.getConnection()
. It is assumed that
if username and password is needed, you have configured that on the DataSource.matsSerializer
- the MatsSerializer to use. If you employ the standard, use MatsSerializerJson.create()
.MatsFactory
public static MatsFactory createSpringDataSourceTxTestMatsFactory(javax.sql.DataSource sqlDataSource, MatsSerializer<?> matsSerializer)
createSpringDataSourceTxTestMatsFactory(int, DataSource, MatsSerializer)
where
concurrency is 1, which should be adequate for most testing - unless you explicitly want to test concurrency.sqlDataSource
- the SQL DataSource which to stash into a Spring DataSourceTransactionManager
, and from which
SQL Connection
s are fetched from, using DataSource.getConnection()
. It is assumed that
if username and password is needed, you have configured that on the DataSource.matsSerializer
- the MatsSerializer to use. If you employ the standard, use MatsSerializerJson.create()
.MatsFactory
public static MatsFactory createSpringDataSourceTxTestMatsFactory(int concurrency, org.springframework.transaction.PlatformTransactionManager platformTransactionManager, MatsSerializer<?> matsSerializer)
MatsFactory
, but you need to make your own PlatformTransactionManager
, this is your
factory method - please note that the contained DataSource
should have been wrapped using the static
method JmsMatsTransactionManager_JmsAndSpringManagedSqlTx.wrapLazyConnectionDatasource(DataSource)
.
Usage: In the test, make a @Bean-annotated method which returns the result of this method - or employ the
convenience MatsTestInfrastructureDbConfiguration
.concurrency
- The concurrency of the created MatsFactory
, set with
MatsFactory.FactoryConfig.setConcurrency(int)
.platformTransactionManager
- the PlatformTransactionManager
that the SpringJmsMats transaction manager should employ. From
this, the DataSource
is gotten using refelction to find a method 'getDataSource()'. please
note that the contained DataSource
should have been wrapped using the static * method
JmsMatsTransactionManager_JmsAndSpringManagedSqlTx.wrapLazyConnectionDatasource(DataSource)
.
It is assumed that if username and password is needed, you have configured that on the DataSource.matsSerializer
- the MatsSerializer to use. If you employ the standard, use MatsSerializerJson.create()
.MatsFactory
public static MatsFactory createSpringDataSourceTxTestMatsFactory(org.springframework.transaction.PlatformTransactionManager platformTransactionManager, MatsSerializer<?> matsSerializer)
createSpringDataSourceTxTestMatsFactory(int, PlatformTransactionManager, MatsSerializer)
where
concurrency is 2, which should be adequate for most testing - unless you explicitly want to test concurrency.platformTransactionManager
- the PlatformTransactionManager
that the SpringJmsMats transaction manager should employ. From
this, the DataSource
is gotten using reflection to find a method 'getDataSource()'. please
note that the contained DataSource
should have been wrapped using the static method
JmsMatsTransactionManager_JmsAndSpringManagedSqlTx.wrapLazyConnectionDatasource(DataSource)
.
It is assumed that if username and password is needed, you have configured that on the DataSource.matsSerializer
- the MatsSerializer to use. If you employ the standard, use MatsSerializerJson.create()
.MatsFactory
public static MatsFactory createJmsTxOnlyTestMatsFactory(int concurrency, MatsSerializer<?> matsSerializer)
MatsFactory
that only handles the JMS transactions, this is your factory method - but if
you DO make any database calls within any Mats endpoint lambda, you will now have no or poor transactional
demarcation, use createSpringDataSourceTxTestMatsFactory(..)
instead.
Usage: In the test, make a @Bean-annotated method which returns the result of this method - or employ the
convenience MatsTestInfrastructureConfiguration
.concurrency
- The concurrency of the created MatsFactory
, set with
MatsFactory.FactoryConfig.setConcurrency(int)
.matsSerializer
- the MatsSerializer to use. If you employ the standard, use MatsSerializerJson.create()
.MatsFactory
public static MatsFactory createJmsTxOnlyTestMatsFactory(MatsSerializer<?> matsSerializer)
createJmsTxOnlyTestMatsFactory(int, MatsSerializer)
where concurrency is 2, which
should be adequate for most testing - unless you explicitly want to test concurrency.matsSerializer
- the MatsSerializer to use. If you employ the standard, use MatsSerializerJson.create()
.MatsFactory