use of joynr.MutableMessage in project joynr by bmwcarit.
the class MutableMessageFactoryTest method testCompressedFlagIsSet.
@Test
public void testCompressedFlagIsSet() {
MutableMessage message;
MessagingQos messagingQos = new MessagingQos();
messagingQos.setCompress(true);
message = mutableMessageFactory.createRequest("from", "to", request, messagingQos);
assertEquals(true, message.getCompressed());
messagingQos.setCompress(false);
message = mutableMessageFactory.createRequest("from", "to", request, messagingQos);
assertEquals(false, message.getCompressed());
}
use of joynr.MutableMessage 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.MutableMessage in project joynr by bmwcarit.
the class MutableMessageFactoryTest method testCreateOneWayRequestWithCustomHeader.
@Test
public void testCreateOneWayRequestWithCustomHeader() throws Exception {
final Map<String, String> myCustomHeaders = new HashMap<>();
final String headerName = "header";
final String headerValue = "value";
myCustomHeaders.put(headerName, headerValue);
messagingQos.getCustomMessageHeaders().putAll(myCustomHeaders);
MutableMessage message = mutableMessageFactory.createOneWayRequest(fromParticipantId, toParticipantId, request, messagingQos);
assertNotNull(message);
assertEquals(Message.VALUE_MESSAGE_TYPE_ONE_WAY, message.getType());
assertExpiryDateEquals(expiryDate.getValue(), message);
final String expectedCustomHeaderName = Message.CUSTOM_HEADER_PREFIX + headerName;
assertTrue(message.getImmutableMessage().getHeaders().containsKey(expectedCustomHeaderName));
Map<String, String> customHeaders = message.getCustomHeaders();
assertTrue(customHeaders.size() == 2);
assertTrue(customHeaders.containsKey(headerName));
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class MutableMessageFactoryTest method testCreateMulticastSubscriptionRequest.
@Test
public void testCreateMulticastSubscriptionRequest() {
String multicastId = "multicastId";
String subscriptionId = "subscriptionId";
String multicastName = "multicastName";
SubscriptionQos subscriptionQos = mock(SubscriptionQos.class);
MulticastSubscriptionRequest multicastSubscriptionRequest = new MulticastSubscriptionRequest(multicastId, subscriptionId, multicastName, subscriptionQos);
MutableMessage result = mutableMessageFactory.createSubscriptionRequest(fromParticipantId, toParticipantId, multicastSubscriptionRequest, messagingQos);
assertNotNull(result);
assertEquals(Message.VALUE_MESSAGE_TYPE_MULTICAST_SUBSCRIPTION_REQUEST, result.getType());
assertExpiryDateEquals(expiryDate.getValue(), result);
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class MutableMessageFactoryTest method testCreateOneWayRequest.
@Test
public void testCreateOneWayRequest() {
MutableMessage message = mutableMessageFactory.createOneWayRequest(fromParticipantId, toParticipantId, request, messagingQos);
assertNotNull(message);
assertEquals(Message.VALUE_MESSAGE_TYPE_ONE_WAY, message.getType());
assertEquals(fromParticipantId, message.getSender());
assertEquals(toParticipantId, message.getRecipient());
assertExpiryDateEquals(expiryDate.getValue(), message);
assertNotNull(message.getPayload());
}
Aggregations