use of joynr.Reply in project joynr by bmwcarit.
the class DispatcherImplTest method testPropagateCompressFlagFromRequestToRepliesImpl.
private void testPropagateCompressFlagFromRequestToRepliesImpl(final boolean compress) throws Exception {
MessagingQos messagingQos = new MessagingQos(1000L);
messagingQos.setCompress(compress);
String requestReplyId = UUID.randomUUID().toString();
Request request = new Request("methodName", new Object[] {}, new String[] {}, requestReplyId);
final String providerParticipantId = "toParticipantId";
MutableMessage joynrMessage = messageFactory.createRequest("fromParticipantId", providerParticipantId, request, messagingQos);
ImmutableMessage outgoingMessage = joynrMessage.getImmutableMessage();
fixture.messageArrived(outgoingMessage);
verify(requestReplyManagerMock).handleRequest(providerCallbackReply.capture(), eq(providerParticipantId), eq(request), eq(joynrMessage.getTtlMs()));
providerCallbackReply.getValue().onSuccess(new Reply(requestReplyId));
verify(messageSenderMock).sendMessage(argThat(new MessageIsCompressedMatcher(compress)));
}
use of joynr.Reply in project joynr by bmwcarit.
the class MutableMessageFactoryTest method setUp.
@Before
public void setUp() throws NoSuchMethodException, SecurityException {
fromParticipantId = "sender";
toParticipantId = "receiver";
Injector injector = Guice.createInjector(new JoynrPropertiesModule(new Properties()), new JsonMessageSerializerModule(), new AbstractModule() {
@Override
protected void configure() {
bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_TTL_UPLIFT_MS)).toInstance(NO_TTL_UPLIFT);
requestStaticInjection(Request.class);
Multibinder<JoynrMessageProcessor> joynrMessageProcessorMultibinder = Multibinder.newSetBinder(binder(), new TypeLiteral<JoynrMessageProcessor>() {
});
joynrMessageProcessorMultibinder.addBinding().toInstance(new JoynrMessageProcessor() {
@Override
public MutableMessage processOutgoing(MutableMessage joynrMessage) {
joynrMessage.getCustomHeaders().put("test", "test");
return joynrMessage;
}
@Override
public ImmutableMessage processIncoming(ImmutableMessage joynrMessage) {
return joynrMessage;
}
});
}
});
objectMapper = injector.getInstance(ObjectMapper.class);
payload = "payload";
Method method = TestProvider.class.getMethod("methodWithStrings", new Class[] { String.class });
request = new Request(method.getName(), new String[] { payload }, method.getParameterTypes());
String requestReplyId = request.getRequestReplyId();
reply = new Reply(requestReplyId, objectMapper.<JsonNode>valueToTree(payload));
messagingQos = new MessagingQos(TTL);
expiryDate = DispatcherUtils.convertTtlToExpirationDate(messagingQos.getRoundTripTtl_ms());
String subscriptionId = "subscription";
String attributeName = "attribute";
PeriodicSubscriptionQos subscriptionqos = new PeriodicSubscriptionQos();
subscriptionqos.setPeriodMs(1000).setValidityMs(10).setAlertAfterIntervalMs(1500).setPublicationTtlMs(1000);
subscriptionRequest = new SubscriptionRequest(subscriptionId, attributeName, subscriptionqos);
String response = "response";
publication = new SubscriptionPublication(Arrays.asList(response), subscriptionId);
mutableMessageFactory = injector.getInstance(MutableMessageFactory.class);
}
use of joynr.Reply in project joynr by bmwcarit.
the class RequestReplyManagerTest method replyCallerInvokedForIncomingReply.
@Test
public void replyCallerInvokedForIncomingReply() throws Exception {
ReplyCaller replyCaller = mock(ReplyCaller.class);
replyCallerDirectory.addReplyCaller(request1.getRequestReplyId(), replyCaller, ExpiryDate.fromRelativeTtl(TIME_TO_LIVE * 2));
Reply reply = new Reply(request1.getRequestReplyId(), payload1);
requestReplyManager.handleReply(reply);
verify(replyCaller).messageCallBack(reply);
}
Aggregations