public class Extension_Mats extends AbstractMatsTest<java.lang.String> implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback
MatsFactory
utilizing an in-vm
Active MQ broker, and optionally a TestH2DataSource
for database tests.
Notice: If you are in a Spring-context, this is probably not what you are looking for, as the MatsFactory then
should reside as a bean in the Spring context. Look in the 'mats-spring-test' package for testing tools for Spring.
By default the extension
will create a MatsSerializerJson
which will be the serializer
utilized by the created MatsFactory
. Should one want to use a different serializer which
serializes to the type of String
then this can be specified using the method create(MatsSerializer)
.
However should one want to specify a serializer which serializes into anything other than String
, then
Extension_MatsGeneric
offers this possibility.
Extension_Mats
shall be annotated with
@RegisterExtension
and the instance field shall be static
for the Jupiter life cycle to pick up the extension at the correct time. Extension_Mats
can be viewed in the
same manner as one would view a ClassRule in JUnit4.
Example:
public class YourTestClass { @RegisterExtension public static final Extension_Mats MATS = Extension_Mats.createRule() }To get a variant that has a
TestH2DataSource
contained, and the MatsFactory set up with transactional
handling of that, use the createWithDb()
methods. In this case, you might want to clean the database before
each test method, which can be accomplished as such:
public class YourTestClass { @RegisterExtension public static final Extension_Mats MATS = Extension_Mats.createRule() @Before // Will clean the database before each test - if this is what you want. public void cleanDatabase() { MATS.getDataSource().cleanDatabase() } }
Extension_MatsGeneric
_createdMatsFactories, _dataSource, _matsFactory, _matsFuturizer, _matsInitiator, _matsSerializer, _matsTestBroker, _matsTestBrokerInterface, _matsTestLatch, log
Modifier | Constructor and Description |
---|---|
protected |
Extension_Mats(MatsSerializer<java.lang.String> matsSerializer) |
protected |
Extension_Mats(MatsSerializer<java.lang.String> matsSerializer,
javax.sql.DataSource dataSource) |
Modifier and Type | Method and Description |
---|---|
void |
afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
Executed by Jupiter after all test methods have been executed.
|
void |
beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
Executed by Jupiter before any test method is executed.
|
static Extension_Mats |
create()
Creates an
Extension_Mats utilizing the MATS default serializer |
static Extension_Mats |
create(MatsSerializer<java.lang.String> matsSerializer)
Creates an
Extension_Mats utilizing the user provided MatsSerializer which serializes to the type
of String. |
static Extension_Mats |
createWithDb() |
static Extension_Mats |
createWithDb(MatsSerializer<java.lang.String> matsSerializer) |
afterAll, beforeAll, cleanMatsFactories, cleanMatsFactory, createMatsFactory, getDataSource, getJmsConnectionFactory, getMatsFactory, getMatsFuturizer, getMatsInitiator, getMatsInterceptableMatsFactory, getMatsTestBrokerInterface, getMatsTestLatch, id
protected Extension_Mats(MatsSerializer<java.lang.String> matsSerializer)
protected Extension_Mats(MatsSerializer<java.lang.String> matsSerializer, javax.sql.DataSource dataSource)
public static Extension_Mats create()
Extension_Mats
utilizing the MATS default serializer
public static Extension_Mats create(MatsSerializer<java.lang.String> matsSerializer)
Extension_Mats
utilizing the user provided MatsSerializer
which serializes to the type
of String.public static Extension_Mats createWithDb()
public static Extension_Mats createWithDb(MatsSerializer<java.lang.String> matsSerializer)
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
beforeAll
in interface org.junit.jupiter.api.extension.BeforeAllCallback
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
afterAll
in interface org.junit.jupiter.api.extension.AfterAllCallback