use of joynr.MutableMessage in project joynr by bmwcarit.
the class MutableMessageFactoryTest method createRequestWithCustomHeaders.
@Test
public void createRequestWithCustomHeaders() 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.createRequest(fromParticipantId, toParticipantId, request, messagingQos);
assertEquals(Message.VALUE_MESSAGE_TYPE_REQUEST, 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() == 3);
assertTrue(customHeaders.containsKey(headerName));
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class MutableMessageFactoryTest method testCreateMulticastMessage.
@Test
public void testCreateMulticastMessage() {
String multicastId = "multicastId";
MulticastPublication multicastPublication = new MulticastPublication(Collections.emptyList(), multicastId);
MutableMessage joynrMessage = mutableMessageFactory.createMulticast(fromParticipantId, multicastPublication, messagingQos);
assertNotNull(joynrMessage);
assertExpiryDateEquals(expiryDate.getValue(), joynrMessage);
assertEquals(fromParticipantId, joynrMessage.getSender());
assertEquals(multicastId, joynrMessage.getRecipient());
assertEquals(Message.VALUE_MESSAGE_TYPE_MULTICAST, joynrMessage.getType());
assertTrue(new String(joynrMessage.getPayload(), Charsets.UTF_8).contains(MulticastPublication.class.getName()));
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class TtlUpliftTest method testTtlUpliftMs_SubscriptionReply.
@Test
public void testTtlUpliftMs_SubscriptionReply() {
SubscriptionReply subscriptionReply = new SubscriptionReply();
expiryDate = DispatcherUtils.convertTtlToExpirationDate(messagingQos.getRoundTripTtl_ms());
MutableMessage message = messageFactoryWithTtlUplift.createSubscriptionReply(fromParticipantId, toParticipantId, subscriptionReply, messagingQos);
long expiryDateValue = expiryDate.getValue() + TTL_UPLIFT_MS;
MutableMessageFactoryTest.assertExpiryDateEquals(expiryDateValue, message);
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class TtlUpliftTest method testTtlUpliftMs_SubscriptionStop.
@Test
public void testTtlUpliftMs_SubscriptionStop() {
SubscriptionStop subscriptionStop = new SubscriptionStop();
expiryDate = DispatcherUtils.convertTtlToExpirationDate(messagingQos.getRoundTripTtl_ms());
MutableMessage message = messageFactoryWithTtlUplift.createSubscriptionStop(fromParticipantId, toParticipantId, subscriptionStop, messagingQos);
long expiryDateValue = expiryDate.getValue() + TTL_UPLIFT_MS;
MutableMessageFactoryTest.assertExpiryDateEquals(expiryDateValue, message);
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class HttpCommunicationManagerTest method testCreateOpenAndDeleteChannel.
@Test
public void testCreateOpenAndDeleteChannel() throws Exception {
MutableMessage mutableMessage = new MutableMessage();
mutableMessage.setType(Message.VALUE_MESSAGE_TYPE_REQUEST);
mutableMessage.setSender("testSender");
mutableMessage.setRecipient("testRecipient");
mutableMessage.setPayload(new byte[] { 0, 1, 2 });
mutableMessage.setTtlAbsolute(true);
mutableMessage.setTtlMs(ExpiryDate.fromRelativeTtl(30000).getValue());
byte[] serializedMessage = mutableMessage.getImmutableMessage().getSerializedMessage();
final Object waitForChannelCreated = new Object();
longpollingMessageReceiver.start(dispatcher, new ReceiverStatusListener() {
@Override
public void receiverStarted() {
synchronized (waitForChannelCreated) {
waitForChannelCreated.notify();
}
}
@Override
public void receiverException(Throwable e) {
}
});
synchronized (waitForChannelCreated) {
waitForChannelCreated.wait(5000);
}
// post to the channel to see if it exists
onrequest(1000).with().body(serializedMessage).expect().statusCode(201).when().post("channels/" + testChannelId + "/message/");
longpollingMessageReceiver.shutdown(true);
// post again; this time it should be missing (NO_CONTENT)
onrequest(1000).with().body(serializedMessage).expect().statusCode(400).body(containsString("Channel not found")).when().post("channels/" + testChannelId + "/message/");
}
Aggregations