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 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 {
         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:
  • Constructor Details

    • Extension_MatsGeneric

      protected Extension_MatsGeneric(MatsSerializer<Z> matsSerializer)
    • Extension_MatsGeneric

      protected Extension_MatsGeneric(MatsSerializer<Z> matsSerializer, DataSource dataSource)
  • Method Details

    • create

      public static <Z> Extension_MatsGeneric<Z> create(MatsSerializer<Z> matsSerializer)
      Creates an Extension_MatsGeneric utilizing the user provided MatsSerializer.
    • createWithDb

      public static <Z> Extension_MatsGeneric<Z> createWithDb(MatsSerializer<Z> matsSerializer)
    • getDataSource

      public TestH2DataSource getDataSource()
      getDataSource in class AbstractMatsTest<Z>
      the DataSource if this Rule/Extension was created with one, throws IllegalStateException otherwise.
    • 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