TEST_F(LibJoynrDbusCommunicationTests, transmit_message) {
    QString ccMessagingAddress("local:joynr.messaging:cc.message6");

    // register skeletons
    MockMessaging* msgMock = new MockMessaging();
    EXPECT_CALL(*msgMock, transmit(A<JoynrMessage&>())).Times(1);
    auto msgSkeleton = new IDbusSkeletonWrapper<DbusMessagingSkeleton, IMessaging>(*msgMock, ccMessagingAddress);

    // get stub
    DbusMessagingStubAdapter* msgStub = new DbusMessagingStubAdapter(ccMessagingAddress);
    ASSERT_TRUE(msgStub->isProxyAvailable());

    // create message
    JoynrMessage msg;
    msg.setType(JoynrMessage::VALUE_MESSAGE_TYPE_ONE_WAY);
    msg.setHeaderTo(QString("local"));
    msg.setPayload("This is a test");

    // create messaging qos
    msgStub->transmit(msg);

    // delete skeleton
    delete msgSkeleton;

    // error on transmission
    msgStub->transmit(msg);

    // stub not availabe
    ASSERT_FALSE(msgStub->isProxyAvailable());

    delete msgStub;
    delete msgMock;
}
示例#2
0
JoynrMessage JoynrMessageFactory::createOneWay(const std::string& senderId,
                                               const std::string& receiverId,
                                               const MessagingQos& qos,
                                               const Reply& payload) const
{
    JoynrMessage msg;
    msg.setType(JoynrMessage::VALUE_MESSAGE_TYPE_ONE_WAY);
    initMsg(msg, senderId, receiverId, qos.getTtl(), JsonSerializer::serialize<Reply>(payload));
    return msg;
}
示例#3
0
JoynrMessage JoynrMessageFactory::createRequest(const std::string& senderId,
                                                const std::string& receiverId,
                                                const MessagingQos& qos,
                                                const Request& payload) const
{
    // create message and set type
    JoynrMessage msg;
    msg.setType(JoynrMessage::VALUE_MESSAGE_TYPE_REQUEST);
    initMsg(msg, senderId, receiverId, qos.getTtl(), JsonSerializer::serialize<Request>(payload));
    return msg;
}
示例#4
0
JoynrMessage JoynrMessageFactory::createSubscriptionStop(const std::string& senderId,
                                                         const std::string& receiverId,
                                                         const MessagingQos& qos,
                                                         const SubscriptionStop& payload) const
{
    JoynrMessage msg;
    msg.setType(JoynrMessage::VALUE_MESSAGE_TYPE_SUBSCRIPTION_STOP);
    initMsg(msg,
            senderId,
            receiverId,
            qos.getTtl(),
            JsonSerializer::serialize<SubscriptionStop>(payload));
    return msg;
}
示例#5
0
JoynrMessage JoynrMessageFactory::createSubscriptionPublication(
        const std::string& senderId,
        const std::string& receiverId,
        const MessagingQos& qos,
        const SubscriptionPublication& payload) const
{
    JoynrMessage msg;
    msg.setType(JoynrMessage::VALUE_MESSAGE_TYPE_PUBLICATION);
    initMsg(msg,
            senderId,
            receiverId,
            qos.getTtl(),
            JsonSerializer::serialize<SubscriptionPublication>(payload));
    return msg;
}
示例#6
0
JoynrMessage JoynrMessageFactory::createBroadcastSubscriptionRequest(
        const std::string& senderId,
        const std::string& receiverId,
        const MessagingQos& qos,
        const BroadcastSubscriptionRequest& payload) const
{
    JoynrMessage msg;
    msg.setType(JoynrMessage::VALUE_MESSAGE_TYPE_BROADCAST_SUBSCRIPTION_REQUEST);
    initMsg(msg,
            senderId,
            receiverId,
            qos.getTtl(),
            JsonSerializer::serialize<BroadcastSubscriptionRequest>(payload));
    return msg;
}
TEST_F(LibJoynrDbusCommunicationTests, dbus_skeletonwrapper_register_unregister) {
    QString ccMessagingAddress("local:cc.messaging:cc.messaging8");

    // craete mock and expect 2 calls
    MockMessaging* msgMock = new MockMessaging();
    EXPECT_CALL(*msgMock, transmit(A<JoynrMessage&>())).Times(2);

    // create the skeleton
    LOG_INFO(logger, "Register skeleton");
    auto msgSkeleton = new IDbusSkeletonWrapper<DbusMessagingSkeleton, IMessaging>(*msgMock, ccMessagingAddress);

    // create message
    JoynrMessage msg;
    msg.setType(JoynrMessage::VALUE_MESSAGE_TYPE_ONE_WAY);
    msg.setHeaderTo(QString("local"));
    msg.setPayload("This is a test");

    // get stub
    DbusMessagingStubAdapter* msgStub = new DbusMessagingStubAdapter(ccMessagingAddress);
    ASSERT_TRUE(msgStub->isProxyAvailable());

    // call method
    LOG_INFO(logger, "Transmit message: should work");
    msgStub->transmit(msg);

    // delete skeleton
    LOG_INFO(logger, "Delete skeleton");
    delete msgSkeleton;

    // call method
    LOG_INFO(logger, "Transmit message: should fail");
    msgStub->transmit(msg);

    // register skeleton
    LOG_INFO(logger, "Register skeleton");
    msgSkeleton = new IDbusSkeletonWrapper<DbusMessagingSkeleton, IMessaging>(*msgMock, ccMessagingAddress);

    // call method
    LOG_INFO(logger, "Transmit message: should work");
    msgStub->transmit(msg);

    delete msgSkeleton;

    delete msgMock;
}