Ejemplo n.º 1
0
TEST_F(MessageQueueTest, queueDequeueMultipleMessagesForOneParticipant) {
    // add messages to the queue
    JoynrMessage msg;
    msg.setHeaderTo("TEST");
    msg.setHeaderExpiryDate(expiryDate);
    messageQueue.queueMessage(msg);
    messageQueue.queueMessage(msg);
    EXPECT_EQ(messageQueue.getQueueLength(), 2);

    // get messages from queue
    MessageQueueItem* item = messageQueue.getNextMessageForParticipant("TEST");
    EXPECT_EQ(item->getContent(), msg);
    EXPECT_EQ(messageQueue.getQueueLength(), 1);

    item = messageQueue.getNextMessageForParticipant("TEST");
    EXPECT_EQ(item->getContent(), msg);
    EXPECT_EQ(messageQueue.getQueueLength(), 0);
}
Ejemplo n.º 2
0
void JoynrMessageFactory::initMsg(JoynrMessage& msg,
                                  const std::string& senderParticipantId,
                                  const std::string& receiverParticipantId,
                                  const std::int64_t ttl,
                                  const std::string& payload) const
{
    msg.setHeaderCreatorUserId(securityManager->getCurrentProcessUserId());
    msg.setHeaderFrom(senderParticipantId);
    msg.setHeaderTo(receiverParticipantId);

    // calculate expiry date
    JoynrTimePoint expiryDate = DispatcherUtils::convertTtlToAbsoluteTime(ttl);
    msg.setHeaderExpiryDate(expiryDate);

    // add content type and class
    msg.setHeaderContentType(JoynrMessage::VALUE_CONTENT_TYPE_APPLICATION_JSON);

    // set payload
    msg.setPayload(payload);
}