Ejemplo n.º 1
0
TEST_F(MessagingTest, routeMsgToHttpCommunicationMgr)
{
    JoynrMessage message = messageFactory.createRequest(
                senderId,
                receiverId,
                qos,
                request);
    message.setHeaderReplyChannelId(senderChannelId);

    // InProcessMessagingSkeleton should not receive the message
    EXPECT_CALL(*inProcessMessagingSkeleton, transmit(Eq(message)))
            .Times(0);

    // HttpCommunicationManager should receive the message
    EXPECT_CALL(*mockMessageSender, sendMessage(Eq(receiverChannelId),Eq(message)))
            .Times(1).WillRepeatedly(ReleaseSemaphore(&semaphore));

    std::shared_ptr<system::RoutingTypes::ChannelAddress> joynrMessagingEndpointAddr =
            std::shared_ptr<system::RoutingTypes::ChannelAddress>(new system::RoutingTypes::ChannelAddress());
    joynrMessagingEndpointAddr->setChannelId(receiverChannelId);

    messageRouter->addNextHop(receiverId, joynrMessagingEndpointAddr);

    messageRouter->route(message);

    WaitXTimes(1);
}
Ejemplo n.º 2
0
TEST_F(MessagingTest, routeMultipleMessages)
{
    JoynrMessage message = messageFactory.createRequest(
                senderId,
                receiverId,
                qos,
                request);
    message.setHeaderReplyChannelId(senderChannelId);

    std::string receiverId2("receiverId2");
    JoynrMessage message2 = messageFactory.createRequest(
                senderId,
                receiverId2,
                qos,
                request);
    message2.setHeaderReplyChannelId(senderChannelId);

    // InProcessMessagingSkeleton should receive the message2 and message3
    EXPECT_CALL(*inProcessMessagingSkeleton, transmit(Eq(message2)))
            .Times(2).WillRepeatedly(ReleaseSemaphore(&semaphore));

    // MessageSender should receive the message
    EXPECT_CALL(*mockMessageSender, sendMessage(Eq(receiverChannelId), Eq(message)))
            .Times(1).WillRepeatedly(ReleaseSemaphore(&semaphore));

    EXPECT_CALL(*mockMessageReceiver, getReceiveChannelId())
//            .WillOnce(ReturnRefOfCopy(senderChannelId));
            .WillRepeatedly(ReturnRefOfCopy(senderChannelId));

    std::shared_ptr<InProcessMessagingAddress> messagingSkeletonEndpointAddr(
                new InProcessMessagingAddress(inProcessMessagingSkeleton)
    );

    messageRouter->addNextHop(receiverId2, messagingSkeletonEndpointAddr);

    std::shared_ptr<system::RoutingTypes::ChannelAddress> joynrMessagingEndpointAddr =
            std::shared_ptr<system::RoutingTypes::ChannelAddress>(new system::RoutingTypes::ChannelAddress());
    joynrMessagingEndpointAddr->setChannelId(receiverChannelId);

    messageRouter->addNextHop(receiverId, joynrMessagingEndpointAddr);

    messageRouter->route(message);
    messageRouter->route(message2);
    messageRouter->route(message2);

    WaitXTimes(3);
}