public abstract class AbstractMatsTest<Z>
extends java.lang.Object
MatsTestBroker
which is again utilized to
create the MatsFactory
which can be utilized to create unit tests which rely on testing functionality
utilizing MATS.
The setup and creation of these objects are located in the beforeAll()
method, this method should be called
through the use JUnit and Jupiters life
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.CopyOnWriteArrayList<MatsFactory> |
_createdMatsFactories |
protected javax.sql.DataSource |
_dataSource |
protected MatsInterceptableMatsFactory |
_matsFactory |
protected MatsFuturizer |
_matsFuturizer |
protected MatsInitiator |
_matsInitiator |
protected MatsSerializer<Z> |
_matsSerializer |
protected MatsTestBroker |
_matsTestBroker |
protected MatsTestBrokerInterface |
_matsTestBrokerInterface |
protected MatsTestLatch |
_matsTestLatch |
protected static org.slf4j.Logger |
log |
Modifier | Constructor and Description |
---|---|
protected |
AbstractMatsTest(MatsSerializer<Z> matsSerializer) |
protected |
AbstractMatsTest(MatsSerializer<Z> matsSerializer,
javax.sql.DataSource dataSource) |
Modifier and Type | Method and Description |
---|---|
void |
afterAll()
Tear down method, stopping all
MatsFactory created during a test setup and close the AMQ broker. |
void |
beforeAll()
Creates an in-vm ActiveMQ Broker which again is utilized to create a
JmsMatsFactory . |
void |
cleanMatsFactories()
Loops through all the
MatsFactory 's contained in this Rule (default + any specifically created), and
removes all endpoints from each of them, this ensures that all factories are "clean". |
void |
cleanMatsFactory()
Deprecated.
use
cleanMatsFactories() . |
MatsInterceptableMatsFactory |
createMatsFactory()
You should probably NOT use this method, but instead the
getMatsFactory() !. |
javax.sql.DataSource |
getDataSource() |
javax.jms.ConnectionFactory |
getJmsConnectionFactory() |
MatsFactory |
getMatsFactory() |
MatsFuturizer |
getMatsFuturizer() |
MatsInitiator |
getMatsInitiator() |
MatsInterceptableMatsFactory |
getMatsInterceptableMatsFactory() |
MatsTestBrokerInterface |
getMatsTestBrokerInterface() |
MatsTestLatch |
getMatsTestLatch() |
protected java.lang.String |
id(java.lang.Class<?> clazz) |
protected static final org.slf4j.Logger log
protected MatsSerializer<Z> _matsSerializer
protected javax.sql.DataSource _dataSource
protected MatsTestBroker _matsTestBroker
protected MatsInterceptableMatsFactory _matsFactory
protected java.util.concurrent.CopyOnWriteArrayList<MatsFactory> _createdMatsFactories
protected MatsInitiator _matsInitiator
protected MatsTestLatch _matsTestLatch
protected MatsFuturizer _matsFuturizer
protected MatsTestBrokerInterface _matsTestBrokerInterface
protected AbstractMatsTest(MatsSerializer<Z> matsSerializer)
protected AbstractMatsTest(MatsSerializer<Z> matsSerializer, javax.sql.DataSource dataSource)
public void beforeAll()
JmsMatsFactory
.
This method should be called as a result of the following life cycle events for either JUnit or Jupiter:
public void afterAll()
MatsFactory
created during a test setup and close the AMQ broker.
This method should be called as a result of the following life cycle events for either JUnit or Jupiter:
public MatsInitiator getMatsInitiator()
MatsInitiator
from this rule's MatsFactory
.public MatsTestLatch getMatsTestLatch()
MatsTestLatch
public MatsFuturizer getMatsFuturizer()
MatsFuturizer
created with this rule's MatsFactory
.public MatsTestBrokerInterface getMatsTestBrokerInterface()
MatsTestBrokerInterface
instance for getting DLQs (and hopefully other snacks at a later time).public javax.jms.ConnectionFactory getJmsConnectionFactory()
public MatsFactory getMatsFactory()
MatsFactory
that this JUnit Rule sets up.public MatsInterceptableMatsFactory getMatsInterceptableMatsFactory()
MatsInterceptableMatsFactory
that this JUnit Rule sets up - This should not be used unless
testing the Interceptor API!public MatsInterceptableMatsFactory createMatsFactory()
getMatsFactory()
!.
This method is public for a single reason: If you need a new, separate MatsFactory
using the same
JMS ConnectionFactory as the one provided by getMatsFactory()
. The only currently known reason for this
is if you want to register two endpoints with the same endpointId, and the only reason for this again is to test
subscriptionTerminators
.MatsFactory
in addition to the one provided by getMatsFactory()
.public javax.sql.DataSource getDataSource()
IllegalStateException
otherwise.java.lang.IllegalStateException
- if this Rule/Extension wasn't created with a DataSource.@Deprecated public void cleanMatsFactory()
cleanMatsFactories()
.public void cleanMatsFactories()
MatsFactory
's contained in this Rule (default + any specifically created), and
removes all endpoints from each of them, this ensures that all factories are "clean".
You may want to utilize this if you have multiple tests in a class, and set up the Endpoints using a @Before type
annotation in the test, as opposed to @BeforeClass. This because otherwise you will on the second test try to
create the endpoints one more time, and they will already exist, thus you'll get an Exception from the
MatsFactory. Another scenario is that you have a bunch of @Test methods, which inside the test sets up an
endpoint in the "Arrange" section. If you employ the same endpointId for each of those setups (that is, inside
the @Test method itself), you will get "duplicate endpoint" (which is good, as your test would probably randomly
fail anyhow). Thus, as the first statement of each test, before creating the endpoint, invoke this method.protected java.lang.String id(java.lang.Class<?> clazz)