R - The reply class of the message generated by this endpoint. (Reply Class)I - The incoming message class for this endpoint. (Request Class)public class Extension_MatsEndpoint<R,I>
extends io.mats3.test.abstractunit.AbstractMatsTestEndpoint<R,I>
implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
The endpoint processor can be changed on demand using #setProcessLambda(ProcessSingleLambda)
Must be annotated with @RegisterExtension.
Retrieve the endpoint's received(incoming) message/messages by calling on of the following methods:
AbstractMatsTestEndpoint.waitForRequest() - Wait for a message(singular) using the default timeoutAbstractMatsTestEndpoint.waitForRequest(long) - Wait for a message(singular) with user specified
timeoutAbstractMatsTestEndpoint.waitForRequests(int) - Wait for X messages using the default timeoutAbstractMatsTestEndpoint.waitForRequests(int, long) - Wait for X messages with user specified timeoutAbstractMatsTestEndpoint.verifyNotInvoked() to ensure that the endpoint was not in fact invoked during the
test.
If no process lambda is specified for the endpoint it will act as a terminator, thus it does not generate a reply.
@RegisterExtension
public Extension_MatsEndpoint<String, String> _world = Extension_MatsEndpoint.single(endpointFactory, "World",
String.class, String.class, (context, in) -> in + "World");
Should one want to utilize this test endpoint approach in a test which brings up a Spring context which contains a
MatsFactory one can utilize the @SpringInjectRulesAndExtensions (in 'mats-spring-test') which
will inject/autowire this class automatically by providing the MatsFactory located in said Spring context.| Modifier and Type | Method and Description |
|---|---|
void |
afterEach(org.junit.jupiter.api.extension.ExtensionContext context) |
void |
beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) |
static <R,I> Extension_MatsEndpoint<R,I> |
create(Extension_Mats matsRule,
java.lang.String endpointId,
java.lang.Class<R> replyMsgClass,
java.lang.Class<I> incomingMsgClass)
Convenience variant of
create(endpointId, replyClass, incomingClass) taking
a Extension_Mats as first argument for fetching the MatsFactory, for use in "pure Java"
environments (read as: non-Spring). |
static <R,I> Extension_MatsEndpoint<R,I> |
create(java.lang.String endpointId,
java.lang.Class<R> replyMsgClass,
java.lang.Class<I> incomingMsgClass)
Creates a Jupiter Extension for a single-staged endpoint whose processor is not defined at start.
|
Extension_MatsEndpoint<R,I> |
setMatsFactory(io.mats3.MatsFactory matsFactory)
Sets the internal
MatsFactory to be utilized for the creation of this endpoint. |
Extension_MatsEndpoint<R,I> |
setProcessLambda(io.mats3.MatsEndpoint.ProcessSingleLambda<R,I> processLambda) |
@Inject public Extension_MatsEndpoint<R,I> setMatsFactory(io.mats3.MatsFactory matsFactory)
MatsFactory to be utilized for the creation of this endpoint.
If not utilized explicitly can also be injected/autowired through the use of the test execution listener
SpringInjectRulesAndExtensions> should this Extension be utilized in a test where a Spring context
is in play.
public Extension_MatsEndpoint<R,I> setProcessLambda(io.mats3.MatsEndpoint.ProcessSingleLambda<R,I> processLambda)
public static <R,I> Extension_MatsEndpoint<R,I> create(java.lang.String endpointId, java.lang.Class<R> replyMsgClass, java.lang.Class<I> incomingMsgClass)
MatsFactory must be set
before it is usable! In a Spring environment, you should probably employ the
@SpringInjectRulesAndExtensions to make this happen automagically. In a "pure Java" environment,
consider the convenience overload create(Mats_Rule,
endpointId, replyClass, incomingClass) to easily supply the corresponding
@RegisterExtension Extension_Mats for fetching the MatsFactory.
Do notice that you need to invoke #setProcessLambda(ProcessSingleLambda) - typically inside the
@Test method - before sending messages to it, as there is no default.
endpointId - of the endpoint.replyMsgClass - the class of the reply message generated by this endpoint.incomingMsgClass - the incoming message class for this endpoint.Extension_Mats without a predefined processLambda.public static <R,I> Extension_MatsEndpoint<R,I> create(Extension_Mats matsRule, java.lang.String endpointId, java.lang.Class<R> replyMsgClass, java.lang.Class<I> incomingMsgClass)
create(endpointId, replyClass, incomingClass) taking
a Extension_Mats as first argument for fetching the MatsFactory, for use in "pure Java"
environments (read as: non-Spring).public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallbackpublic void afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback