Class AbstractMatsTest<Z>

java.lang.Object
io.mats3.test.abstractunit.AbstractMatsTest<Z>
Direct Known Subclasses:
Extension_Mats, Extension_MatsGeneric, Rule_Mats, Rule_MatsGeneric

public abstract class AbstractMatsTest<Z> extends Object
Base class containing common code for Rule_Mats and Extension_Mats located in the following modules:
  • mats-test-junit
  • mats-test-jupiter
This class sets up an in-vm Active MQ broker through the use of 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

  • Field Details

  • Constructor Details

  • Method Details

    • beforeAll

      public void beforeAll()
      Creates an in-vm ActiveMQ Broker which again is utilized to create a JmsMatsFactory.

      This method should be called as a result of the following life cycle events for either JUnit or Jupiter:

      • BeforeClass - JUnit - static ClassRule
      • BeforeAllCallback - Jupiter - static Extension
    • afterAll

      public void afterAll()
      Tear down method, stopping all 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:

      • AfterClass - JUnit - static ClassRule
      • AfterAllCallback - Jupiter - static Extension
    • getMatsInitiator

      public MatsInitiator getMatsInitiator()
      Returns:
      the default MatsInitiator from this rule's MatsFactory.
    • getMatsTestLatch

      public MatsTestLatch getMatsTestLatch()
      Returns:
      a singleton MatsTestLatch
    • getMatsFuturizer

      public MatsFuturizer getMatsFuturizer()
      Returns:
      a convenience singleton MatsFuturizer created with this rule's MatsFactory.
    • getMatsTestBrokerInterface

      public MatsTestBrokerInterface getMatsTestBrokerInterface()
      Returns:
      a MatsTestBrokerInterface instance for getting DLQs (and hopefully other snacks at a later time).
    • getJmsConnectionFactory

      public javax.jms.ConnectionFactory getJmsConnectionFactory()
      Returns:
      the JMS ConnectionFactory that this JUnit Rule sets up.
    • getMatsFactory

      public MatsFactory getMatsFactory()
      Returns:
      the MatsFactory that this JUnit Rule sets up.
    • getMatsInterceptableMatsFactory

      public MatsInterceptableMatsFactory getMatsInterceptableMatsFactory()
      Returns:
      the MatsInterceptableMatsFactory that this JUnit Rule sets up - This should not be used unless testing the Interceptor API!
    • createMatsFactory

      public MatsInterceptableMatsFactory createMatsFactory()
      You should probably NOT use this method, but instead the 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.

      Returns:
      a new, separate MatsFactory in addition to the one provided by getMatsFactory().
    • getDataSource

      public DataSource getDataSource()
      Returns:
      the DataSource if this Rule/Extension was created with one, throws IllegalStateException otherwise.
      Throws:
      IllegalStateException - if this Rule/Extension wasn't created with a DataSource.
    • cleanMatsFactory

      @Deprecated public void cleanMatsFactory()
      Deprecated.
    • cleanMatsFactories

      public 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".

      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.

    • id

      protected String id(Class<?> clazz)