Class Rule_MatsGeneric<Z>

java.lang.Object
io.mats3.test.abstractunit.AbstractMatsTest<Z>
io.mats3.test.junit.Rule_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.rules.TestRule

public class Rule_MatsGeneric<Z> extends AbstractMatsTest<Z> implements org.junit.rules.TestRule
Similar to Rule_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 Rule is open to the usage of more customized MatsSerializers.

Rule_MatsGeneric shall be considered a ClassRule and thus annotated as such, being a ClassRule also means that the instance field shall be static. Therefore to utilize Rule_MatsGeneric one should add it to a test class in this fashion:

     public class YourTestClass {
         @ClassRule
         public static Rule_MatsGeneric<Z> mats = new Rule_MatsGeneric(new YourSerializer())
     }
 
This will ensure that Rule_MatsGeneric sets up the test harness correctly. However the factory needs to be cleaned in between tests to ensure that there are no endpoint collisions (One can only register a given endpointId once per MatsFactory), thus one should also implement a method within the test class which is annotated with After and executes a call to AbstractMatsTest.cleanMatsFactories() as such:
 @After
 public void cleanFactory() {
     mats.removeAllEndpoints();
 }
 
See Also: