Class Extension_MatsGeneric<Z>

  • Type Parameters:
    Z - The type definition for the MatsSerializer employed. This defines the type which STOs and DTOs are serialized into. When employing JSON for the "outer" serialization of MatsTrace, it does not make that much sense to use a binary (Z=byte[]) "inner" representation of the DTOs and STOs, because JSON is terrible at serializing byte arrays.
    All Implemented Interfaces:
    org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.Extension

    public class Extension_MatsGeneric<Z>
    extends io.mats3.test.abstractunit.AbstractMatsTest<Z>
    implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback
    Similar to Extension_Mats, provides a full MATS harness for unit testing by creating MatsFactory utilizing an in-vm Active MQ broker. The difference between the two is that this Extension is open to the usage of more customized MatsSerializers.

    Extension_MatsGeneric 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_MatsGeneric can be viewed in the same manner as one would view a ClassRule in JUnit4.

         public class YourTestClass {
             @RegisterExtension
             public static Extension_MatsGeneric<Z> mats = new Extension_MatsGeneric(new YourSerializer())
         }
     
    This will ensure that Extension_MatsGeneric sets up the test harness correctly.
    See Also:
    AbstractMatsTest
    • Field Summary

      • Fields inherited from class io.mats3.test.abstractunit.AbstractMatsTest

        _createdMatsFactories, _dataSource, _matsFactory, _matsFuturizer, _matsInitiator, _matsSerializer, _matsTestBroker, _matsTestBrokerInterface, _matsTestLatch, log
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Extension_MatsGeneric​(io.mats3.serial.MatsSerializer<Z> matsSerializer)  
      protected Extension_MatsGeneric​(io.mats3.serial.MatsSerializer<Z> matsSerializer, javax.sql.DataSource dataSource)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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 <Z> Extension_MatsGeneric<Z> create​(io.mats3.serial.MatsSerializer<Z> matsSerializer)
      Creates an Extension_MatsGeneric utilizing the user provided MatsSerializer.
      static <Z> Extension_MatsGeneric<Z> createWithDb​(io.mats3.serial.MatsSerializer<Z> matsSerializer)  
      io.mats3.test.TestH2DataSource getDataSource()  
      • Methods inherited from class io.mats3.test.abstractunit.AbstractMatsTest

        afterAll, beforeAll, cleanMatsFactories, createMatsFactory, getJmsConnectionFactory, getMatsFactory, getMatsFuturizer, getMatsInitiator, getMatsTestBrokerInterface, getMatsTestLatch, id
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Extension_MatsGeneric

        protected Extension_MatsGeneric​(io.mats3.serial.MatsSerializer<Z> matsSerializer)
      • Extension_MatsGeneric

        protected Extension_MatsGeneric​(io.mats3.serial.MatsSerializer<Z> matsSerializer,
                                        javax.sql.DataSource dataSource)
    • Method Detail

      • createWithDb

        public static <Z> Extension_MatsGeneric<Z> createWithDb​(io.mats3.serial.MatsSerializer<Z> matsSerializer)
      • getDataSource

        public io.mats3.test.TestH2DataSource getDataSource()
        Overrides:
        getDataSource in class io.mats3.test.abstractunit.AbstractMatsTest<Z>
      • beforeAll

        public void beforeAll​(org.junit.jupiter.api.extension.ExtensionContext context)
        Executed by Jupiter before any test method is executed. (Once at the start of the class.)
        Specified by:
        beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
      • afterAll

        public void afterAll​(org.junit.jupiter.api.extension.ExtensionContext context)
        Executed by Jupiter after all test methods have been executed. (Once at the end of the class.)
        Specified by:
        afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback