summaryrefslogtreecommitdiff
path: root/src/test/DBusManagedTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/DBusManagedTest.cpp')
-rw-r--r--src/test/DBusManagedTest.cpp1339
1 files changed, 1077 insertions, 262 deletions
diff --git a/src/test/DBusManagedTest.cpp b/src/test/DBusManagedTest.cpp
index 421b645..5c0fa12 100644
--- a/src/test/DBusManagedTest.cpp
+++ b/src/test/DBusManagedTest.cpp
@@ -21,11 +21,14 @@
#include "v1_0/commonapi/tests/managed/RootInterfaceStubDefault.hpp"
#include "v1_0/commonapi/tests/managed/LeafInterfaceStubDefault.hpp"
#include "v1_0/commonapi/tests/managed/BranchInterfaceStubDefault.hpp"
+#include "v1_0/commonapi/tests/managed/SecondRootStubDefault.hpp"
#include "v1_0/commonapi/tests/managed/RootInterfaceProxy.hpp"
#include "v1_0/commonapi/tests/managed/RootInterfaceDBusProxy.hpp"
#include "v1_0/commonapi/tests/managed/LeafInterfaceProxy.hpp"
-#include "v1_0/commonapi/tests/managed/SecondRootStubDefault.hpp"
+
+#include "v1_0/commonapi/tests/managed/RootInterfaceDBusStubAdapter.hpp"
+#include "v1_0/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.hpp"
#include <gtest/gtest.h>
#include <algorithm>
@@ -34,37 +37,83 @@
#define VERSION v1_0
+static const std::string connectionId = "managed-test";
+
static const std::string domain = "local";
-static const std::string rootAddress = "commonapi.tests.managed.RootInterface";
-static const std::string leafInstance = "commonapi.tests.managed.RootInterface.LeafInterface";
-static const std::string branchInstance = "commonapi.tests.managed.RootInterface.BranchInterface";
-static const std::string secondLeafInstance = "commonapi.tests.managed.RootInterface.LeafInterface2";
-static const std::string leafAddress = "local:commonapi.tests.managed.LeafInterface:" + leafInstance;
-static const std::string branchAddress = "local:commonapi.tests.managed.BranchInterface:" + branchInstance;
-static const std::string dbusServiceName = "CommonAPI.DBus.DBusObjectManagerStubTest";
+static const std::string instanceNameBase = "commonapi.tests.managed";
+static const std::string objectPathBase = "/commonapi/tests/managed";
+
+//Root
+static const std::string rootInterfaceName = VERSION::commonapi::tests::managed::RootInterfaceStubDefault::StubInterface::getInterface();
+static const std::string rootInstanceName = instanceNameBase + ".RootInterface";
+static const std::string rootDbusServiceName = rootInterfaceName + "_" + rootInstanceName;
+static const std::string rootDbusObjectPath = objectPathBase + "/RootInterface";
+
+//SecondRoot
+static const std::string secondRootInterfaceName = VERSION::commonapi::tests::managed::SecondRootStubDefault::StubInterface::getInterface();
+static const std::string secondRootInstanceName = instanceNameBase + ".SecondRoot";
+static const std::string secondRootDbusServiceName = secondRootInterfaceName + "_" + secondRootInstanceName;
+static const std::string secondRootDbusObjectPath = objectPathBase + "/SecondRoot";
+
+//Leaf
+static const std::string leafInterfaceName = VERSION::commonapi::tests::managed::LeafInterfaceStubDefault::StubInterface::getInterface();
+
+//Leaf based on Root
+static const std::string leafInstanceNameRoot = rootInstanceName + ".LeafInterface";
+static const std::string leafDbusServiceNameRoot = leafInterfaceName + "_" + leafInstanceNameRoot;
+static const std::string leafDbusObjectPathRoot = rootDbusObjectPath + "/LeafInterface";
-static const std::string rootInterfaceName = "/commonapi/tests/managed/RootInterface";
-static const std::string rootObjectPath = "/commonapi/tests/managed/RootInterface";
+//Leaf based on SecondRoot
+static const std::string leafInstanceNameSecondRoot = secondRootInstanceName + ".LeafInterface";
+static const std::string leafDbusObjectPathSecondRoot = secondRootDbusObjectPath + "/LeafInterface";
+//Branch
+static const std::string branchInterfaceName = VERSION::commonapi::tests::managed::BranchInterfaceStubDefault::StubInterface::getInterface();
+static const std::string branchInstanceNameRoot = rootInstanceName + ".BranchInterface";
+static const std::string branchDbusServiceNameRoot = branchInterfaceName + "_" + branchInstanceNameRoot;
+static const std::string branchDbusObjectPathRoot = rootDbusObjectPath + "/BranchInterface";
-const CommonAPI::DBus::DBusObjectManagerStub::DBusObjectPathAndInterfacesDict getManagedObjects(const std::string& dbusObjectPath,
- std::shared_ptr<CommonAPI::DBus::DBusConnection> connection) {
+
+const CommonAPI::DBus::DBusObjectManagerStub::DBusObjectPathAndInterfacesDict getManagedObjects(const std::string& _dbusServiceName, const std::string& _dbusObjectPath,
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> _connection) {
auto dbusMessageCall = CommonAPI::DBus::DBusMessage::createMethodCall(
- CommonAPI::DBus::DBusAddress(dbusServiceName, dbusObjectPath, CommonAPI::DBus::DBusObjectManagerStub::getInterfaceName()),
+ CommonAPI::DBus::DBusAddress(_dbusServiceName, _dbusObjectPath, CommonAPI::DBus::DBusObjectManagerStub::getInterfaceName()),
"GetManagedObjects");
CommonAPI::DBus::DBusError dbusError;
- auto dbusMessageReply = connection->sendDBusMessageWithReplyAndBlock(dbusMessageCall, dbusError);
+ CommonAPI::CallInfo info(1000);
+ auto dbusMessageReply = _connection->sendDBusMessageWithReplyAndBlock(dbusMessageCall, dbusError, &info);
+
+ CommonAPI::DBus::DBusObjectManagerStub::DBusObjectPathAndInterfacesDict dbusObjectPathAndInterfacesDict;
+ if(!dbusMessageReply)
+ return dbusObjectPathAndInterfacesDict;
CommonAPI::DBus::DBusInputStream dbusInputStream(dbusMessageReply);
- CommonAPI::DBus::DBusObjectManagerStub::DBusObjectPathAndInterfacesDict dbusObjectPathAndInterfacesDict;
dbusInputStream >> dbusObjectPathAndInterfacesDict;
return dbusObjectPathAndInterfacesDict;
}
+bool isManaged(const std::string& _objectPath, const std::string& _interfaceName,
+ CommonAPI::DBus::DBusObjectManagerStub::DBusObjectPathAndInterfacesDict& dbusObjectPathAndInterfacesDict)
+{
+ for(auto objectPathDict : dbusObjectPathAndInterfacesDict)
+ {
+ std::string objectPath = objectPathDict.first;
+ if(objectPath != _objectPath)
+ continue;
+ CommonAPI::DBus::DBusObjectManagerStub::DBusInterfacesAndPropertiesDict interfacesAndPropertiesDict = objectPathDict.second;
+ for(auto interfaceDict : interfacesAndPropertiesDict)
+ {
+ std::string interfaceName = interfaceDict.first;
+ if(interfaceName == _interfaceName)
+ return true;
+ }
+ }
+ return false;
+}
class DBusManagedTest: public ::testing::Test {
protected:
@@ -72,28 +121,18 @@ protected:
leafStatus_ = CommonAPI::AvailabilityStatus::UNKNOWN;
runtime_ = CommonAPI::Runtime::get();
- proxyDBusConnection_ = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
- ASSERT_TRUE(proxyDBusConnection_->connect());
- stubDBusConnection_ = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
- ASSERT_TRUE(stubDBusConnection_->connect());
- ASSERT_TRUE(bool(stubDBusConnection_->getDBusObjectManager()));
- ASSERT_TRUE(stubDBusConnection_->requestServiceNameAndBlock(dbusServiceName));
+ manualDBusConnection_ = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ ASSERT_TRUE(manualDBusConnection_->connect(false));
}
virtual void TearDown() {
- //runtime_->unregisterService(rootAddress);
-
- stubDBusConnection_->disconnect();
- stubDBusConnection_.reset();
-
- proxyDBusConnection_->disconnect();
- proxyDBusConnection_.reset();
+ manualDBusConnection_->disconnect();
+ manualDBusConnection_.reset();
}
std::shared_ptr<CommonAPI::Runtime> runtime_;
- std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyDBusConnection_;
- std::shared_ptr<CommonAPI::DBus::DBusConnection> stubDBusConnection_;
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> manualDBusConnection_;
CommonAPI::AvailabilityStatus leafStatus_;
@@ -105,37 +144,58 @@ public:
TEST_F(DBusManagedTest, RegisterRoot) {
auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
- runtime_->registerService(domain, rootAddress, rootStub);
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub));
- auto dbusObjectPathAndInterfacesDict = getManagedObjects("/", proxyDBusConnection_);
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, "/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
- EXPECT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
- //runtime_->unregisterService(rootAddress);
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
}
TEST_F(DBusManagedTest, RegisterLeafUnmanaged) {
- auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
- runtime_->registerService(domain, leafAddress, leafStub);
+ auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, leafInstanceNameRoot, leafStub));
- auto dbusObjectPathAndInterfacesDict = getManagedObjects("/", proxyDBusConnection_);
+ //check that leaf is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(leafDbusServiceNameRoot,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPathRoot, leafInterfaceName, dbusObjectPathAndInterfacesDict));
- EXPECT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ runtime_->unregisterService(domain, leafInterfaceName, leafInstanceNameRoot);
- //runtime_->unregisterService(leafAddress);
+ //check that leaf is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(leafDbusServiceNameRoot,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
}
TEST_F(DBusManagedTest, RegisterLeafManaged) {
- auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
- runtime_->registerService(domain, rootAddress, rootStub);
-
- std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
- VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
- rootAddress,
- rootInterfaceName,
- dbusServiceName,
- rootObjectPath,
- proxyDBusConnection_
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, "/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ CommonAPI::DBus::DBusAddress rootDBusAddress;
+ CommonAPI::Address rootCommonAPIAddress(domain, rootInstanceName, rootInterfaceName);
+ CommonAPI::DBus::DBusAddressTranslator::get()->translate(rootCommonAPIAddress, rootDBusAddress);
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ proxyConnection->connect();
+
+ std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
+ VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
+ rootDBusAddress,
+ proxyConnection
);
rootProxy->init();
@@ -148,55 +208,69 @@ TEST_F(DBusManagedTest, RegisterLeafManaged) {
CommonAPI::ProxyManager& proxyManagerLeafInterface = rootProxy->getProxyManagerLeafInterface();
proxyManagerLeafInterface.getInstanceAvailabilityStatusChangedEvent().subscribe(
std::bind(&DBusManagedTest::managedObjectSignalled,
- this,
- std::placeholders::_1,
- std::placeholders::_2));
+ this,
+ std::placeholders::_1,
+ std::placeholders::_2));
- auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
- bool reg = rootStub->registerManagedStubLeafInterface(leafStub, leafInstance);
- ASSERT_TRUE(reg);
+ ASSERT_TRUE(rootStub->registerManagedStubLeafInterface(leafStub, leafInstanceNameRoot));
- for (uint32_t i = 0; leafStatus_ != CommonAPI::AvailabilityStatus::AVAILABLE && i < 50; ++i) {
+ for (uint32_t i = 0; leafStatus_ != CommonAPI::AvailabilityStatus::AVAILABLE && i < 200; ++i) {
usleep(10 * 1000);
}
ASSERT_TRUE(leafStatus_ == CommonAPI::AvailabilityStatus::AVAILABLE);
- auto dbusObjectPathAndInterfacesDict = getManagedObjects("/", proxyDBusConnection_);
- ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ //check that root manages leaf
dbusObjectPathAndInterfacesDict.clear();
- dbusObjectPathAndInterfacesDict = getManagedObjects(rootInterfaceName, proxyDBusConnection_);
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPathRoot, leafInterfaceName, dbusObjectPathAndInterfacesDict));
- bool deregistered = rootStub->deregisterManagedStubLeafInterface(leafInstance);
- EXPECT_TRUE(deregistered);
+ ASSERT_TRUE(rootStub->deregisterManagedStubLeafInterface(leafInstanceNameRoot));
for (uint32_t i = 0; leafStatus_ != CommonAPI::AvailabilityStatus::NOT_AVAILABLE && i < 200; ++i) {
usleep(10 * 1000);
}
- EXPECT_TRUE(leafStatus_ == CommonAPI::AvailabilityStatus::NOT_AVAILABLE);
+ ASSERT_TRUE(leafStatus_ == CommonAPI::AvailabilityStatus::NOT_AVAILABLE);
+
+ //check that root no longer manages leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
- dbusObjectPathAndInterfacesDict = getManagedObjects(rootInterfaceName, proxyDBusConnection_);
- EXPECT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
- //runtime_->unregisterService(rootAddress);
- dbusObjectPathAndInterfacesDict = getManagedObjects("/", proxyDBusConnection_);
- EXPECT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+ proxyConnection->disconnect();
}
TEST_F(DBusManagedTest, RegisterLeafManagedAndCreateProxyForLeaf) {
- auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
- bool success = runtime_->registerService(domain, rootAddress, rootStub);
- ASSERT_TRUE(success);
-
- std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
- VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
- rootAddress,
- rootInterfaceName,
- dbusServiceName,
- rootObjectPath,
- proxyDBusConnection_
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName , rootStub, connectionId));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, "/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ CommonAPI::DBus::DBusAddress rootDBusAddress;
+ CommonAPI::Address rootCommonAPIAddress(domain, rootInstanceName, rootInterfaceName);
+ CommonAPI::DBus::DBusAddressTranslator::get()->translate(rootCommonAPIAddress, rootDBusAddress);
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ proxyConnection->connect();
+
+ std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
+ VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
+ rootDBusAddress,
+ proxyConnection
);
+
rootProxy->init();
for (uint32_t i = 0; !rootProxy->isAvailable() && i < 200; ++i) {
@@ -206,60 +280,82 @@ TEST_F(DBusManagedTest, RegisterLeafManagedAndCreateProxyForLeaf) {
CommonAPI::ProxyManager& proxyManagerLeafInterface = rootProxy->getProxyManagerLeafInterface();
proxyManagerLeafInterface.getInstanceAvailabilityStatusChangedEvent().subscribe(
- std::bind(
- &DBusManagedTest::managedObjectSignalled,
- this,
- std::placeholders::_1,
- std::placeholders::_2));
+ std::bind(&DBusManagedTest::managedObjectSignalled,
+ this,
+ std::placeholders::_1,
+ std::placeholders::_2));
- auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
- success = rootStub->registerManagedStubLeafInterface(leafStub, leafInstance);
- ASSERT_TRUE(success);
+ auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ ASSERT_TRUE(rootStub->registerManagedStubLeafInterface(leafStub, leafInstanceNameRoot));
- usleep(2000000);
+ for (uint32_t i = 0; leafStatus_ != CommonAPI::AvailabilityStatus::AVAILABLE && i < 200; ++i) {
+ usleep(10 * 1000);
+ }
+ ASSERT_TRUE(leafStatus_ == CommonAPI::AvailabilityStatus::AVAILABLE);
- auto leafProxy = proxyManagerLeafInterface.buildProxy<VERSION::commonapi::tests::managed::LeafInterfaceProxy>(leafInstance);
- for (uint32_t i = 0; !leafProxy->isAvailable() && i < 500; ++i) {
+ //check that root manages leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPathRoot, leafInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ auto leafProxy = proxyManagerLeafInterface.buildProxy<VERSION::commonapi::tests::managed::LeafInterfaceProxy>(leafInstanceNameRoot);
+ for (uint32_t i = 0; !leafProxy->isAvailable() && i < 200; ++i) {
usleep(10 * 1000);
}
ASSERT_TRUE(leafProxy->isAvailable());
CommonAPI::CallStatus callStatus;
- VERSION::commonapi::tests::managed::LeafInterface::testLeafMethodError error;
+ VERSION::commonapi::tests::managed::LeafInterface::testLeafMethodError error;
int outInt;
std::string outString;
leafProxy->testLeafMethod(42, "Test", callStatus, error, outInt, outString);
- EXPECT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+
+ ASSERT_TRUE(rootStub->deregisterManagedStubLeafInterface(leafInstanceNameRoot));
+
+ for (uint32_t i = 0; leafStatus_ != CommonAPI::AvailabilityStatus::NOT_AVAILABLE && i < 200; ++i) {
+ usleep(10 * 1000);
+ }
+ ASSERT_TRUE(leafStatus_ == CommonAPI::AvailabilityStatus::NOT_AVAILABLE);
- success = rootStub->deregisterManagedStubLeafInterface(leafInstance);
- EXPECT_TRUE(success);
+ //check that root no longer manages leaf
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
- auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootInterfaceName, proxyDBusConnection_);
- EXPECT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName));
- //success = runtime_->unregisterService(rootAddress);
- //EXPECT_TRUE(success);
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, "/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
- dbusObjectPathAndInterfacesDict = getManagedObjects("/", proxyDBusConnection_);
- EXPECT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+ proxyConnection->disconnect();
}
TEST_F(DBusManagedTest, PropagateTeardown) {
- auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
- bool success = runtime_->registerService(domain, rootAddress, rootStub);
-
- ASSERT_TRUE(success);
-
- std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
- VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
- rootAddress,
- rootInterfaceName,
- dbusServiceName,
- rootObjectPath,
- proxyDBusConnection_
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub, connectionId));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, "/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ CommonAPI::DBus::DBusAddress rootDBusAddress;
+ CommonAPI::Address rootCommonAPIAddress(domain, rootInstanceName, rootInterfaceName);
+ CommonAPI::DBus::DBusAddressTranslator::get()->translate(rootCommonAPIAddress, rootDBusAddress);
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ proxyConnection->connect();
+
+ std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
+ VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
+ rootDBusAddress,
+ proxyConnection
);
+
rootProxy->init();
for (uint32_t i = 0; !rootProxy->isAvailable() && i < 200; ++i) {
@@ -269,93 +365,129 @@ TEST_F(DBusManagedTest, PropagateTeardown) {
CommonAPI::ProxyManager& proxyManagerLeafInterface = rootProxy->getProxyManagerLeafInterface();
proxyManagerLeafInterface.getInstanceAvailabilityStatusChangedEvent().subscribe(
- std::bind(
- &DBusManagedTest::managedObjectSignalled,
- this,
- std::placeholders::_1,
- std::placeholders::_2));
+ std::bind(&DBusManagedTest::managedObjectSignalled,
+ this,
+ std::placeholders::_1,
+ std::placeholders::_2));
- auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
- bool reg = rootStub->registerManagedStubLeafInterface(leafStub, leafInstance);
- ASSERT_TRUE(reg);
+ auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ ASSERT_TRUE(rootStub->registerManagedStubLeafInterface(leafStub, leafInstanceNameRoot));
- usleep(2000000);
+ for (uint32_t i = 0; leafStatus_ != CommonAPI::AvailabilityStatus::AVAILABLE && i < 200; ++i) {
+ usleep(10 * 1000);
+ }
+ ASSERT_TRUE(leafStatus_ == CommonAPI::AvailabilityStatus::AVAILABLE);
+
+ //check that root manages leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPathRoot, leafInterfaceName, dbusObjectPathAndInterfacesDict));
- auto leafProxy = proxyManagerLeafInterface.buildProxy<VERSION::commonapi::tests::managed::LeafInterfaceProxy>(leafInstance);
+ auto leafProxy = proxyManagerLeafInterface.buildProxy<VERSION::commonapi::tests::managed::LeafInterfaceProxy>(leafInstanceNameRoot);
- for (uint32_t i = 0; !leafProxy->isAvailable() && i < 500; ++i) {
+ for (uint32_t i = 0; !leafProxy->isAvailable() && i < 200; ++i) {
usleep(10 * 1000);
}
ASSERT_TRUE(leafProxy->isAvailable());
CommonAPI::CallStatus callStatus;
- VERSION::commonapi::tests::managed::LeafInterface::testLeafMethodError error;
+ VERSION::commonapi::tests::managed::LeafInterface::testLeafMethodError error;
int outInt;
std::string outString;
leafProxy->testLeafMethod(42, "Test", callStatus, error, outInt, outString);
ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
- //bool dereg = runtime_->unregisterService(rootAddress);
- //ASSERT_TRUE(dereg);
+ rootStub->getStubAdapter()->deactivateManagedInstances();
- for (uint32_t i = 0; leafStatus_ != CommonAPI::AvailabilityStatus::NOT_AVAILABLE && i < 100; ++i) {
+ for (uint32_t i = 0; leafStatus_ != CommonAPI::AvailabilityStatus::NOT_AVAILABLE && i < 200; ++i) {
usleep(10 * 1000);
}
ASSERT_TRUE(leafStatus_ == CommonAPI::AvailabilityStatus::NOT_AVAILABLE);
- auto dbusObjectPathAndInterfacesDict = getManagedObjects("/", proxyDBusConnection_);
+ //check that root no longer manages leaf
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that root is still registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, "/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, "/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ proxyConnection->disconnect();
}
class DBusManagedTestExtended: public ::testing::Test {
protected:
virtual void SetUp() {
runtime_ = CommonAPI::Runtime::get();
+
leafInstanceAvailability = CommonAPI::AvailabilityStatus::UNKNOWN;
branchInstanceAvailability = CommonAPI::AvailabilityStatus::UNKNOWN;
- manualTestDBusConnection_ = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
- ASSERT_TRUE(manualTestDBusConnection_->connect());
-
- auto stubDBusConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
- ASSERT_TRUE(stubDBusConnection->connect());
- ASSERT_TRUE(stubDBusConnection->requestServiceNameAndBlock(dbusServiceName));
+ manualDBusConnection_ = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ ASSERT_TRUE(manualDBusConnection_->connect(false));
}
virtual void TearDown() {
- for (auto it: rootStubs_) {
- //runtime_->unregisterService(it.first);
- }
+ manualDBusConnection_->disconnect();
+ manualDBusConnection_.reset();
+ }
+
+ inline const std::string getSuffixedRootInstanceName(const std::string& suffix) {
+ return rootInstanceName + suffix;
+ }
- rootStubs_.clear();
- rootProxies_.clear();
+ inline bool registerRootStubForSuffix(const std::string& suffix) {
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ const std::string instanceName = getSuffixedRootInstanceName(suffix);
+ bool registered = runtime_->registerService(domain, instanceName, rootStub);
- auto stubDBusConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
- ASSERT_TRUE(stubDBusConnection->releaseServiceName(dbusServiceName));
+ if(registered)
+ rootStubs_.insert( { instanceName, rootStub });
- usleep(50000);
+ return registered;
}
- inline const std::string getSuffixedRootAddress(const std::string& suffix) {
- return "local:commonapi.tests.managed.RootInterface" + suffix + ":commonapi.tests.managed.RootInterface";
- }
+ inline bool unregisterRootForSuffix(const std::string& suffix) {
+ const std::string instanceName = getSuffixedRootInstanceName(suffix);
- inline const std::string getSuffixedSecondRootAddress(const std::string& suffix) {
- return "local:commonapi.tests.managed.SecondRoot" + suffix + ":commonapi.tests.managed.SecondRoot";
- }
+ std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceStubDefault> rootStub = rootStubs_.find(instanceName)->second;
+ rootStub->getStubAdapter()->deactivateManagedInstances();
+
+ bool unregistered = runtime_->unregisterService(domain, rootInterfaceName, instanceName);
- inline const bool registerRootStubForSuffix(const std::string& suffix) {
- std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceStubDefault> rootStub = std::make_shared<
- VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
- const std::string rootAddress = getSuffixedRootAddress(suffix);
- rootStubs_.insert( {rootAddress, rootStub} );
- return runtime_->registerService(domain, rootAddress, rootStub);
+ if(unregistered)
+ rootStubs_.erase(instanceName);
+
+ return unregistered;
}
inline void createRootProxyForSuffix(const std::string& suffix) {
- rootProxies_.push_back(runtime_->buildProxy<VERSION::commonapi::tests::managed::RootInterfaceProxy>(domain, getSuffixedRootAddress(suffix)));
+ CommonAPI::DBus::DBusAddress rootDBusAddress;
+ CommonAPI::Address rootCommonAPIAddress(domain, getSuffixedRootInstanceName(suffix), rootInterfaceName);
+ CommonAPI::DBus::DBusAddressTranslator::get()->translate(rootCommonAPIAddress, rootDBusAddress);
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ proxyConnection->connect();
+
+ std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
+ VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
+ rootDBusAddress,
+ proxyConnection
+ );
+ rootProxy->init();
+ rootProxies_.push_back(rootProxy);
}
template<typename _ProxyType>
@@ -372,18 +504,13 @@ protected:
return allAreAvailable;
}
- bool registerXLeafStubsForAllRoots(uint32_t x, bool doSubscriptionsForLeafNotifications) {
+ bool registerXLeafStubsForAllRoots(uint32_t x) {
bool success = true;
bool expectedValueForRegistration = true;
for (auto rootStubIterator: rootStubs_) {
- if (doSubscriptionsForLeafNotifications) {
- // CommonAPI::ProxyManager& proxyManagerForLeafInterface = rootManagerProxyArray[i]->getProxyManagerLeafInterface();
- // auto subscription = subscribeWithAvailabilityFlag(proxyManagerForLeafInterface, stati[i]);
- // subscriptions.push_back(subscription);
- }
for (uint32_t i = 0; i < x; i++) {
- std::shared_ptr<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault> leafStub = std::make_shared<
- VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ std::shared_ptr<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault> leafStub = std::make_shared<
+ VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
success &= (rootStubIterator.second->registerManagedStubLeafInterfaceAutoInstance(leafStub) == expectedValueForRegistration);
}
//As all root interfaces are registered on the same object path, the leaf interfaces also will be registered with
@@ -398,7 +525,7 @@ protected:
void createXLeafProxiesForAllExistingLeafs() {
for (auto rootProxyIterator : rootProxies_) {
- std::vector<std::shared_ptr<VERSION::commonapi::tests::managed::LeafInterfaceProxyDefault>> leafProxiesForRootX;
+ std::vector<std::shared_ptr<VERSION::commonapi::tests::managed::LeafInterfaceProxyDefault>> leafProxiesForRootX;
CommonAPI::ProxyManager& leafProxyManager = rootProxyIterator->getProxyManagerLeafInterface();
std::vector<std::string> availableInstances;
@@ -406,20 +533,20 @@ protected:
leafProxyManager.getAvailableInstances(status, availableInstances);
for (const std::string& availableInstance : availableInstances) {
- auto newLeafProxy = leafProxyManager.buildProxy<VERSION::commonapi::tests::managed::LeafInterfaceProxy>(availableInstance);
+ auto newLeafProxy = leafProxyManager.buildProxy<VERSION::commonapi::tests::managed::LeafInterfaceProxy>(availableInstance);
leafProxiesForRootX.push_back(newLeafProxy);
}
leafProxies_.push_back(std::move(leafProxiesForRootX));
- }
+ }
}
std::shared_ptr<CommonAPI::Runtime> runtime_;
- std::shared_ptr<CommonAPI::DBus::DBusConnection> manualTestDBusConnection_;
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> manualDBusConnection_;
- std::unordered_map<std::string, std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>> rootStubs_;
- std::vector<std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceProxyDefault>> rootProxies_;
- std::vector<std::vector<std::shared_ptr<VERSION::commonapi::tests::managed::LeafInterfaceProxyDefault>>>leafProxies_;
+ std::unordered_map<std::string, std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>> rootStubs_;
+ std::vector<std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>> rootProxies_;
+ std::vector<std::vector<std::shared_ptr<VERSION::commonapi::tests::managed::LeafInterfaceProxyDefault>>> leafProxies_;
CommonAPI::AvailabilityStatus leafInstanceAvailability;
CommonAPI::AvailabilityStatus branchInstanceAvailability;
@@ -433,22 +560,94 @@ public:
}
};
-TEST_F(DBusManagedTestExtended, RegisterSeveralRootsOnSameObjectPath) {
+/*
+ * Test fails. Registering several roots on same object path is not possible.
+ */
+TEST_F(DBusManagedTestExtended, DISABLED_RegisterSeveralRootsOnSameObjectPath) {
+
+ /* set environment variable (default config: commonapi-dbus.ini) to
+ * to register the roots on the same object path
+ */
+ const char *defaultConfigSet = getenv("COMMONAPI_DBUS_DEFAULT_CONFIG");
+ ASSERT_TRUE(defaultConfigSet);
+
ASSERT_TRUE(registerRootStubForSuffix("One"));
ASSERT_TRUE(registerRootStubForSuffix("Two"));
ASSERT_TRUE(registerRootStubForSuffix("Three"));
- auto dbusObjectPathAndInterfacesDict = getManagedObjects("/", manualTestDBusConnection_);
- EXPECT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ const std::string dbusServiceNameBase = "commonapi.tests.managed.roots.on.same.object.path";
+
+ //check that root one is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".One","/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ //check that root two is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Two","/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ //check that root three is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Three","/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ ASSERT_TRUE(unregisterRootForSuffix("One"));
+ ASSERT_TRUE(unregisterRootForSuffix("Two"));
+ ASSERT_TRUE(unregisterRootForSuffix("Three"));
+
+ //check that root one is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".One","/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that root two is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Two","/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that root three is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Three","/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
}
-TEST_F(DBusManagedTestExtended, RegisterSeveralRootsOnSameObjectPathAndCommunicate) {
+/*
+ * Test fails. Registering several roots on same object path is not possible.
+ */
+TEST_F(DBusManagedTestExtended, DISABLED_RegisterSeveralRootsOnSameObjectPathAndCommunicate) {
+
+ /* set environment variable (default config: commonapi-dbus.ini) to
+ * to register the roots on the same object path
+ */
+ const char *defaultConfigSet = getenv("COMMONAPI_DBUS_DEFAULT_CONFIG");
+ ASSERT_TRUE(defaultConfigSet);
+
ASSERT_TRUE(registerRootStubForSuffix("One"));
ASSERT_TRUE(registerRootStubForSuffix("Two"));
ASSERT_TRUE(registerRootStubForSuffix("Three"));
- auto dbusObjectPathAndInterfacesDict = getManagedObjects("/", manualTestDBusConnection_);
- EXPECT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ const std::string dbusServiceNameBase = "commonapi.tests.managed.roots.on.same.object.path";
+
+ //check that root one is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".One","/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ //check that root two is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Two","/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ //check that root three is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Three","/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
createRootProxyForSuffix("One");
createRootProxyForSuffix("Two");
@@ -458,7 +657,8 @@ TEST_F(DBusManagedTestExtended, RegisterSeveralRootsOnSameObjectPathAndCommunica
ASSERT_TRUE(allRootProxiesAreAvailable);
CommonAPI::CallStatus callStatus;
- VERSION::commonapi::tests::managed::RootInterface::testRootMethodError applicationError;
+ CommonAPI::CallInfo *info;
+ VERSION::commonapi::tests::managed::RootInterface::testRootMethodError applicationError;
int32_t outInt;
std::string outString;
@@ -468,48 +668,141 @@ TEST_F(DBusManagedTestExtended, RegisterSeveralRootsOnSameObjectPathAndCommunica
callStatus,
applicationError,
outInt,
- outString);
- EXPECT_EQ(CommonAPI::CallStatus::SUCCESS, callStatus);
+ outString,
+ info);
+ ASSERT_EQ(CommonAPI::CallStatus::SUCCESS, callStatus);
}
+
+ ASSERT_TRUE(unregisterRootForSuffix("One"));
+ ASSERT_TRUE(unregisterRootForSuffix("Two"));
+ ASSERT_TRUE(unregisterRootForSuffix("Three"));
+
+ //check that root one is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".One","/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that root two is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Two","/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that root three is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Three","/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ rootProxies_.clear();
}
-TEST_F(DBusManagedTestExtended, RegisterSeveralRootsAndSeveralLeafsForEachOnSameObjectPath) {
+/*
+ * Test fails. Registering several roots on same object path is not possible.
+ */
+TEST_F(DBusManagedTestExtended, DISABLED_RegisterSeveralRootsAndSeveralLeafsForEachOnSameObjectPath) {
+
+ /* set environment variable (default config: commonapi-dbus.ini) to
+ * to register the roots on the same object path
+ */
+ const char *defaultConfigSet = getenv("COMMONAPI_DBUS_DEFAULT_CONFIG");
+ ASSERT_TRUE(defaultConfigSet);
+
ASSERT_TRUE(registerRootStubForSuffix("One"));
ASSERT_TRUE(registerRootStubForSuffix("Two"));
ASSERT_TRUE(registerRootStubForSuffix("Three"));
- bool allLeafStubsWereRegistered = registerXLeafStubsForAllRoots(5, false);
+ const std::string dbusServiceNameBase = "commonapi.tests.managed.roots.on.same.object.path";
+
+ //check that root one is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".One","/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ //check that root two is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Two","/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ //check that root three is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Three","/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ bool allLeafStubsWereRegistered = registerXLeafStubsForAllRoots(5);
ASSERT_TRUE(allLeafStubsWereRegistered);
- auto dbusObjectPathAndInterfacesDict = getManagedObjects("/", manualTestDBusConnection_);
- EXPECT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ //TODO check if leafs were registered
+
+ ASSERT_TRUE(unregisterRootForSuffix("One"));
+ ASSERT_TRUE(unregisterRootForSuffix("Two"));
+ ASSERT_TRUE(unregisterRootForSuffix("Three"));
+
+ //check that root one is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".One","/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that root two is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Two","/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that root three is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Three","/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
}
-TEST_F(DBusManagedTestExtended, RegisterSeveralRootsAndSeveralLeafsForEachOnSameObjectPathAndCommunicate) {
+/*
+ * Test fails. Registering several roots on same object path is not possible.
+ */
+TEST_F(DBusManagedTestExtended, DISABLED_RegisterSeveralRootsAndSeveralLeafsForEachOnSameObjectPathAndCommunicate) {
+
+ /* set environment variable (default config: commonapi-dbus.ini) to
+ * to register the roots on the same object path
+ */
+ const char *defaultConfigSet = getenv("COMMONAPI_DBUS_DEFAULT_CONFIG");
+ ASSERT_TRUE(defaultConfigSet);
+
ASSERT_TRUE(registerRootStubForSuffix("One"));
ASSERT_TRUE(registerRootStubForSuffix("Two"));
ASSERT_TRUE(registerRootStubForSuffix("Three"));
- bool allLeafStubsWereRegistered = registerXLeafStubsForAllRoots(5, false);
- ASSERT_TRUE(allLeafStubsWereRegistered);
+ const std::string dbusServiceNameBase = "commonapi.tests.managed.roots.on.same.object.path";
- auto dbusObjectPathAndInterfacesDict = getManagedObjects("/", manualTestDBusConnection_);
- EXPECT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ //check that root one is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".One", "/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName,dbusObjectPathAndInterfacesDict));
+
+ //check that root two is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Two", "/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName,dbusObjectPathAndInterfacesDict));
+
+ //check that root three is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Three", "/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName,dbusObjectPathAndInterfacesDict));
createRootProxyForSuffix("One");
createRootProxyForSuffix("Two");
createRootProxyForSuffix("Three");
- //Check on existence of leaf-stubs
-
bool allRootProxiesAreAvailable = waitForAllProxiesToBeAvailable(rootProxies_);
ASSERT_TRUE(allRootProxiesAreAvailable);
- usleep(500 * 1000);
+ bool allLeafStubsWereRegistered = registerXLeafStubsForAllRoots(5);
+ ASSERT_TRUE(allLeafStubsWereRegistered);
+
+ //TODO check if leafs were registered
createXLeafProxiesForAllExistingLeafs();
- usleep(500 * 1000);
+ usleep(50000);
ASSERT_EQ(3, leafProxies_.size());
@@ -518,76 +811,126 @@ TEST_F(DBusManagedTestExtended, RegisterSeveralRootsAndSeveralLeafsForEachOnSame
ASSERT_EQ(5, leafProxiesForCurrentRoot.size())<< "in run #" << runNr++;
bool allLeafProxiesForCurrentRootAreAvailable = waitForAllProxiesToBeAvailable(leafProxiesForCurrentRoot);
- EXPECT_TRUE(allLeafProxiesForCurrentRootAreAvailable);
+ ASSERT_TRUE(allLeafProxiesForCurrentRootAreAvailable);
++runNr;
}
-// CommonAPI::AvailabilityStatus stati[3];
-// std::vector<CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent::Subscription> subscriptions;
-
- // auto leafStub = std::make_shared<commonapi::tests::managed::LeafInterfaceStubDefault>();
- // bool success = rootStub->registerManagedStubLeafInterface(leafStub, leafInstance);
- // ASSERT_TRUE(success);
- //
- // sleep(2);
- //
- // auto leafProxy = proxyManagerLeafInterface.buildProxy<commonapi::tests::managed::LeafInterfaceProxy>(leafInstance);
- // for (uint32_t i = 0; !leafProxy->isAvailable() && i < 500; ++i) {
- // usleep(10 * 1000);
- // }
- //
- // ASSERT_TRUE(leafProxy->isAvailable());
- //
- // CommonAPI::CallStatus callStatus;
- // commonapi::tests::managed::LeafInterface::testLeafMethodError error;
- // int outInt;
- // std::string outString;
- // leafProxy->testLeafMethod(42, "Test", callStatus, error, outInt, outString);
- //
- // EXPECT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
- //
- // success = rootStub->deregisterManagedStubLeafInterface(leafInstance);
- // EXPECT_TRUE(success);
- //
- // CommonAPI::DBus::DBusObjectManagerStub::DBusObjectPathAndInterfacesDict dbusObjectPathAndInterfacesDict;
- // dbusObjectPathAndInterfacesDict.clear();
- // getManagedObjects(rootInterfaceName, dbusObjectPathAndInterfacesDict);
- // EXPECT_TRUE(dbusObjectPathAndInterfacesDict.empty());
- //
- // success = runtime->getServicePublisher()->unregisterService(rootAddress);
- // EXPECT_TRUE(success);
- //
- // dbusObjectPathAndInterfacesDict.clear();
- // getManagedObjects("/", dbusObjectPathAndInterfacesDict);
- // EXPECT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(unregisterRootForSuffix("One"));
+ ASSERT_TRUE(unregisterRootForSuffix("Two"));
+ ASSERT_TRUE(unregisterRootForSuffix("Three"));
+
+ //check that root one is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".One", "/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that root two is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Two", "/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that root three is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(dbusServiceNameBase + ".Three", "/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ rootProxies_.clear();
+ leafProxies_.clear();
}
TEST_F(DBusManagedTestExtended, RegisterTwoRootsForSameLeafInterface) {
- ASSERT_TRUE(registerRootStubForSuffix("One"));
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ auto secondRootStub = std::make_shared<VERSION::commonapi::tests::managed::SecondRootStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, secondRootInstanceName, secondRootStub));
- std::shared_ptr<VERSION::commonapi::tests::managed::SecondRootStubDefault> secondRootStub = std::make_shared<
- VERSION::commonapi::tests::managed::SecondRootStubDefault>();
- const std::string rootAddressLocal = getSuffixedRootAddress("Two");
- runtime_->registerService(secondRootStub, rootAddressLocal, serviceFactory_);
+ //check that second root is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(secondRootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(secondRootDbusObjectPath, secondRootInterfaceName, dbusObjectPathAndInterfacesDict));
- auto leafStub1 = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
- auto leafStub2 = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ auto leafStub1 = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ auto leafStub2 = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
- bool leafStub1Registered = rootStubs_.begin()->second->registerManagedStubLeafInterface(leafStub1, leafInstance);
- ASSERT_TRUE(leafStub1Registered);
+ ASSERT_TRUE(rootStub->registerManagedStubLeafInterface(leafStub1, leafInstanceNameRoot));
+ ASSERT_TRUE(secondRootStub->registerManagedStubLeafInterface(leafStub2, leafInstanceNameSecondRoot));
- bool leafStub2Registered = secondRootStub->registerManagedStubLeafInterface(leafStub2, secondLeafInstance);
- ASSERT_TRUE(leafStub2Registered);
+ //check that root manages leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPathRoot, leafInterfaceName, dbusObjectPathAndInterfacesDict));
- runtime_->unregisterService(rootAddressLocal);
+ //check that second root manages leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(secondRootDbusServiceName, secondRootDbusObjectPath, manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPathSecondRoot, leafInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ rootStub->getStubAdapter()->deactivateManagedInstances();
+ secondRootStub->getStubAdapter()->deactivateManagedInstances();
+
+ //check that root no longer manages leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that second root no longer manages leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(secondRootDbusServiceName, secondRootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+ runtime_->unregisterService(domain, secondRootInterfaceName, secondRootInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that second root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(secondRootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
}
TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootManaged) {
- ASSERT_TRUE(registerRootStubForSuffix("One"));
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ CommonAPI::DBus::DBusAddress rootDBusAddress;
+ CommonAPI::Address rootCommonAPIAddress(domain, rootInstanceName, rootInterfaceName);
+ CommonAPI::DBus::DBusAddressTranslator::get()->translate(rootCommonAPIAddress, rootDBusAddress);
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ proxyConnection->connect();
+
+ std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
+ VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
+ rootDBusAddress,
+ proxyConnection
+ );
+
+ rootProxy->init();
+
+ for (uint32_t i = 0; !rootProxy->isAvailable() && i < 200; ++i) {
+ usleep(10 * 1000);
+ }
+ ASSERT_TRUE(rootProxy->isAvailable());
- createRootProxyForSuffix("One");
- auto rootProxy = *(rootProxies_.begin());
CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& leafInstanceAvailabilityStatusEvent =
rootProxy->getProxyManagerLeafInterface().getInstanceAvailabilityStatusChangedEvent();
CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& branchInstanceAvailabilityStatusEvent =
@@ -604,11 +947,11 @@ TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootMan
std::placeholders::_1,
std::placeholders::_2));
- auto leafStub1 = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
- auto leafStub2 = std::make_shared<VERSION::commonapi::tests::managed::BranchInterfaceStubDefault>();
+ auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ auto branchStub = std::make_shared<VERSION::commonapi::tests::managed::BranchInterfaceStubDefault>();
+
+ ASSERT_TRUE(rootStub->registerManagedStubLeafInterface(leafStub, leafInstanceNameRoot));
- bool leafStub1Registered = rootStubs_.begin()->second->registerManagedStubLeafInterface(leafStub1, leafInstance);
- ASSERT_TRUE(leafStub1Registered);
usleep(50000);
ASSERT_EQ(CommonAPI::AvailabilityStatus::AVAILABLE, leafInstanceAvailability);
@@ -616,20 +959,70 @@ TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootMan
// check that event for branch instances is not triggered by leaf instances
ASSERT_NE(CommonAPI::AvailabilityStatus::AVAILABLE, branchInstanceAvailability);
- bool leafStub2Registered = rootStubs_.begin()->second->registerManagedStubBranchInterface(
- leafStub2,
- branchInstance);
- ASSERT_TRUE(leafStub2Registered);
+ ASSERT_TRUE(rootStub->registerManagedStubBranchInterface(branchStub, branchInstanceNameRoot));
+
usleep(50000);
ASSERT_EQ(CommonAPI::AvailabilityStatus::AVAILABLE, branchInstanceAvailability);
+
+ //check that root manages leaf and branch
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPathRoot, leafInterfaceName, dbusObjectPathAndInterfacesDict));
+ ASSERT_TRUE(isManaged(branchDbusObjectPathRoot, branchInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ rootStub->getStubAdapter()->deactivateManagedInstances();
+
+ usleep(50000);
+
+ ASSERT_TRUE(leafInstanceAvailability == CommonAPI::AvailabilityStatus::NOT_AVAILABLE);
+ ASSERT_TRUE(branchInstanceAvailability == CommonAPI::AvailabilityStatus::NOT_AVAILABLE);
+
+ //check that root no longer manages leaf and branch
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ proxyConnection->disconnect();
}
TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootUnmanaged) {
- ASSERT_TRUE(registerRootStubForSuffix("One"));
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ CommonAPI::DBus::DBusAddress rootDBusAddress;
+ CommonAPI::Address rootCommonAPIAddress(domain, rootInstanceName, rootInterfaceName);
+ CommonAPI::DBus::DBusAddressTranslator::get()->translate(rootCommonAPIAddress, rootDBusAddress);
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ proxyConnection->connect();
+
+ std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
+ VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
+ rootDBusAddress,
+ proxyConnection
+ );
+
+ rootProxy->init();
+
+ for (uint32_t i = 0; !rootProxy->isAvailable() && i < 200; ++i) {
+ usleep(10 * 1000);
+ }
+ ASSERT_TRUE(rootProxy->isAvailable());
- createRootProxyForSuffix("One");
- auto rootProxy = *(rootProxies_.begin());
CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& leafInstanceAvailabilityStatusEvent =
rootProxy->getProxyManagerLeafInterface().getInstanceAvailabilityStatusChangedEvent();
CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& branchInstanceAvailabilityStatusEvent =
@@ -646,11 +1039,11 @@ TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootUnm
std::placeholders::_1,
std::placeholders::_2));
- auto leafStub1 = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
- runtime_->getServicePublisher()->registerService(leafStub1, leafAddress, serviceFactory_);
+ auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ runtime_->registerService(domain, leafInstanceNameRoot, leafStub);
- auto leafStub2 = std::make_shared<VERSION::commonapi::tests::managed::BranchInterfaceStubDefault>();
- runtime_->getServicePublisher()->registerService(leafStub2, branchAddress, serviceFactory_);
+ auto branchStub = std::make_shared<VERSION::commonapi::tests::managed::BranchInterfaceStubDefault>();
+ runtime_->registerService(domain, branchInstanceNameRoot, branchStub);
usleep(50000);
@@ -658,8 +1051,430 @@ TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootUnm
ASSERT_EQ(CommonAPI::AvailabilityStatus::UNKNOWN, leafInstanceAvailability);
ASSERT_EQ(CommonAPI::AvailabilityStatus::UNKNOWN, branchInstanceAvailability);
- runtime_->unregisterService(leafAddress);
- runtime_->unregisterService(branchAddress);
+ //check that root don't manages leaf and branch
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that leaf is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(leafDbusServiceNameRoot, "/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPathRoot, leafInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ //check that branch is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(branchDbusServiceNameRoot, "/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(branchDbusObjectPathRoot, branchInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ runtime_->unregisterService(domain, leafInterfaceName, leafInstanceNameRoot);
+ runtime_->unregisterService(domain, branchInterfaceName, branchInstanceNameRoot);
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that leaf is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(leafDbusServiceNameRoot,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that branch is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(branchDbusServiceNameRoot,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ proxyConnection->disconnect();
+}
+
+TEST_F(DBusManagedTestExtended, RegisterInvalidChildInstance)
+{
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ auto invalidLeafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+
+ const std::string invalidLeafInstanceName = instanceNameBase + ".InvalidInterface.LeafInterface";
+ const std::string invalidLeafDbusServiceName = leafInterfaceName + "_" + invalidLeafInstanceName;
+
+ ASSERT_FALSE(rootStub->registerManagedStubLeafInterface(invalidLeafStub, invalidLeafInstanceName));
+
+ //check that root doesn't manage invalid leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that invalid leaf is not registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(invalidLeafDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+}
+
+TEST_F(DBusManagedTestExtended, RegsiterInvalidChildInstanceAndValidChildInstances)
+{
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ CommonAPI::DBus::DBusAddress rootDBusAddress;
+ CommonAPI::Address rootCommonAPIAddress(domain, rootInstanceName, rootInterfaceName);
+ CommonAPI::DBus::DBusAddressTranslator::get()->translate(rootCommonAPIAddress, rootDBusAddress);
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ proxyConnection->connect();
+
+ std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
+ VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
+ rootDBusAddress,
+ proxyConnection
+ );
+
+ rootProxy->init();
+
+ for (uint32_t i = 0; !rootProxy->isAvailable() && i < 200; ++i) {
+ usleep(10 * 1000);
+ }
+ ASSERT_TRUE(rootProxy->isAvailable());
+
+ CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& leafInstanceAvailabilityStatusEvent =
+ rootProxy->getProxyManagerLeafInterface().getInstanceAvailabilityStatusChangedEvent();
+ CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& branchInstanceAvailabilityStatusEvent =
+ rootProxy->getProxyManagerBranchInterface().getInstanceAvailabilityStatusChangedEvent();
+
+ leafInstanceAvailabilityStatusEvent.subscribe(
+ std::bind(&DBusManagedTestExtended::onLeafInstanceAvailabilityStatusChanged,
+ this,
+ std::placeholders::_1,
+ std::placeholders::_2));
+ branchInstanceAvailabilityStatusEvent.subscribe(
+ std::bind(&DBusManagedTestExtended::onBranchInstanceAvailabilityStatusChanged,
+ this,
+ std::placeholders::_1,
+ std::placeholders::_2));
+
+ auto validLeafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ auto invalidLeafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ auto validBranchStub = std::make_shared<VERSION::commonapi::tests::managed::BranchInterfaceStubDefault>();
+
+ const std::string invalidLeafInstanceName = instanceNameBase + ".InvalidInterface.LeafInterface";
+ const std::string invalidLeafDbusServiceName = leafInterfaceName + "_" + invalidLeafInstanceName;
+ const std::string invalidLeafDbusObjectPath = objectPathBase + "/InvalidInterface/LeafInterface";
+
+ ASSERT_TRUE(rootStub->registerManagedStubLeafInterface(validLeafStub, leafInstanceNameRoot));
+
+ usleep(50000);
+
+ ASSERT_EQ(CommonAPI::AvailabilityStatus::AVAILABLE, leafInstanceAvailability);
+
+ ASSERT_FALSE(rootStub->registerManagedStubLeafInterface(invalidLeafStub, invalidLeafInstanceName));
+
+ //check that root doesn't manage invalid leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_FALSE(isManaged(invalidLeafDbusObjectPath, leafInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ //check that invalid leaf is not registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(invalidLeafDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ ASSERT_TRUE(rootStub->registerManagedStubBranchInterface(validBranchStub, branchInstanceNameRoot));
+
+ usleep(50000);
+
+ ASSERT_EQ(CommonAPI::AvailabilityStatus::AVAILABLE, branchInstanceAvailability);
+
+ //check that root manages valid leaf and valid branch
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPathRoot, leafInterfaceName, dbusObjectPathAndInterfacesDict));
+ ASSERT_TRUE(isManaged(branchDbusObjectPathRoot, branchInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ rootStub->getStubAdapter()->deactivateManagedInstances();
+
+ usleep(50000);
+
+ ASSERT_TRUE(leafInstanceAvailability == CommonAPI::AvailabilityStatus::NOT_AVAILABLE);
+ ASSERT_TRUE(branchInstanceAvailability == CommonAPI::AvailabilityStatus::NOT_AVAILABLE);
+
+ //check that root no longer manages leaf and branch
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ proxyConnection->disconnect();
+}
+
+TEST_F(DBusManagedTestExtended, ReegisterLeafsWithAutoGeneratedInstanceIds)
+{
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ int numberOfAutoGeneratedInstances = 5;
+ for(int i=0; i<numberOfAutoGeneratedInstances; i++)
+ {
+ ASSERT_TRUE(rootStub->registerManagedStubLeafInterfaceAutoInstance(leafStub));
+ }
+
+ //check that root manages the auto generated leafs
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE((int)dbusObjectPathAndInterfacesDict.size() == numberOfAutoGeneratedInstances);
+
+ rootStub->getStubAdapter()->deactivateManagedInstances();
+
+ //check that root doesn't manage the auto generated leafs anymore
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+}
+
+TEST_F(DBusManagedTestExtended, RegisterLeafsWithAutoGeneratedInstanceIdsAndCommunicate)
+{
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub, connectionId));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ CommonAPI::DBus::DBusAddress rootDBusAddress;
+ CommonAPI::Address rootCommonAPIAddress(domain, rootInstanceName, rootInterfaceName);
+ CommonAPI::DBus::DBusAddressTranslator::get()->translate(rootCommonAPIAddress, rootDBusAddress);
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ proxyConnection->connect();
+
+ std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
+ VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
+ rootDBusAddress,
+ proxyConnection
+ );
+
+ rootProxy->init();
+
+ for (uint32_t i = 0; !rootProxy->isAvailable() && i < 200; ++i) {
+ usleep(10 * 1000);
+ }
+ ASSERT_TRUE(rootProxy->isAvailable());
+
+ auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+ int numberOfAutoGeneratedInstances = 5;
+ for(int i=0; i<numberOfAutoGeneratedInstances; i++)
+ {
+ ASSERT_TRUE(rootStub->registerManagedStubLeafInterfaceAutoInstance(leafStub));
+ }
+
+ //check that root manages the auto generated leafs
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE((int)dbusObjectPathAndInterfacesDict.size() == numberOfAutoGeneratedInstances);
+
+ for(int i=0; i<numberOfAutoGeneratedInstances; i++)
+ {
+ const std::string autoGeneratedInstanceName = rootInstanceName + ".i" + std::to_string(i + 1);
+ auto leafProxy = rootProxy->getProxyManagerLeafInterface().buildProxy<VERSION::commonapi::tests::managed::LeafInterfaceProxy>(autoGeneratedInstanceName);
+
+ for (uint32_t i = 0; !leafProxy->isAvailable() && i < 200; ++i) {
+ usleep(10 * 1000);
+ }
+
+ ASSERT_TRUE(leafProxy->isAvailable());
+
+ CommonAPI::CallStatus callStatus;
+ VERSION::commonapi::tests::managed::LeafInterface::testLeafMethodError error;
+ int outInt;
+ std::string outString;
+ leafProxy->testLeafMethod(42, "Test", callStatus, error, outInt, outString);
+
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ }
+
+ rootStub->getStubAdapter()->deactivateManagedInstances();
+
+ //check that root doesn't manage the auto generated leafs anymore
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ proxyConnection->disconnect();
+}
+
+TEST_F(DBusManagedTestExtended, ConfigurationFileAffectsInterfaceUnmanaged) {
+
+ //set environment variable (default config: commonapi-dbus.ini)
+ const char *defaultConfigSet = getenv("COMMONAPI_DBUS_DEFAULT_CONFIG");
+ ASSERT_TRUE(defaultConfigSet);
+
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+
+ //match with declared addresses in commonapi-dbus.ini
+ const std::string leafInstanceName = "commonapi.tests.managed.config.affects.LeafInterface.Unmanaged";
+ const std::string leafDbusServiceName = "commonapi.tests.managed.config.affects.interface.unmanaged";
+ const std::string leafDbusObjectPath = "/commonapi/tests/managed/RootInterface/LeafInterface/Unmanaged";
+
+ ASSERT_TRUE(runtime_->registerService(domain, leafInstanceName, leafStub));
+
+ //check that leaf is registered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(leafDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPath, leafInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+ runtime_->unregisterService(domain, leafInterfaceName, leafInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ //check that leaf is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(leafDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+}
+
+TEST_F(DBusManagedTestExtended, ConfigurationFileAffectsInterfaceManaged) {
+
+ //set environment variable (default config: commonapi-dbus.ini)
+ const char *defaultConfigSet = getenv("COMMONAPI_DBUS_DEFAULT_CONFIG");
+ ASSERT_TRUE(defaultConfigSet);
+
+ auto rootStub = std::make_shared<VERSION::commonapi::tests::managed::RootInterfaceStubDefault>();
+ ASSERT_TRUE(runtime_->registerService(domain, rootInstanceName, rootStub));
+
+ //check that root is registered
+ auto dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(rootDbusObjectPath, rootInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ CommonAPI::DBus::DBusAddress rootDBusAddress;
+ CommonAPI::Address rootCommonAPIAddress(domain, rootInstanceName, rootInterfaceName);
+ CommonAPI::DBus::DBusAddressTranslator::get()->translate(rootCommonAPIAddress, rootDBusAddress);
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyConnection = CommonAPI::DBus::DBusConnection::getBus(CommonAPI::DBus::DBusType_t::SESSION);
+ proxyConnection->connect();
+
+ std::shared_ptr<VERSION::commonapi::tests::managed::RootInterfaceDBusProxy> rootProxy = std::make_shared<
+ VERSION::commonapi::tests::managed::RootInterfaceDBusProxy>(
+ rootDBusAddress,
+ proxyConnection
+ );
+
+ rootProxy->init();
+
+ for (uint32_t i = 0; !rootProxy->isAvailable() && i < 200; ++i) {
+ usleep(10 * 1000);
+ }
+ ASSERT_TRUE(rootProxy->isAvailable());
+
+ CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& leafInstanceAvailabilityStatusEvent =
+ rootProxy->getProxyManagerLeafInterface().getInstanceAvailabilityStatusChangedEvent();
+
+ leafInstanceAvailabilityStatusEvent.subscribe(
+ std::bind(&DBusManagedTestExtended::onLeafInstanceAvailabilityStatusChanged,
+ this,
+ std::placeholders::_1,
+ std::placeholders::_2));
+
+ auto leafStub = std::make_shared<VERSION::commonapi::tests::managed::LeafInterfaceStubDefault>();
+
+ //match with declared addresses in commonapi-dbus.ini
+ const std::string leafInstanceName = "commonapi.tests.managed.config.affects.LeafInterface.Managed";
+ const std::string leafDbusServiceName = "commonapi.tests.managed.config.affects.interface.managed";
+ const std::string leafDbusObjectPath = "/commonapi/tests/managed/RootInterface/LeafInterface/Managed";
+
+ ASSERT_TRUE(rootStub->registerManagedStubLeafInterface(leafStub, leafInstanceName));
+
+ usleep(50000);
+
+ ASSERT_EQ(CommonAPI::AvailabilityStatus::AVAILABLE, leafInstanceAvailability);
+
+ //check that root manages leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_FALSE(dbusObjectPathAndInterfacesDict.empty());
+ ASSERT_TRUE(isManaged(leafDbusObjectPath, leafInterfaceName, dbusObjectPathAndInterfacesDict));
+
+ rootStub->getStubAdapter()->deactivateManagedInstances();
+
+ usleep(50000);
+
+ ASSERT_TRUE(leafInstanceAvailability == CommonAPI::AvailabilityStatus::NOT_AVAILABLE);
+
+ //check that root no longer manages leaf
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName, rootDbusObjectPath, manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ runtime_->unregisterService(domain, rootInterfaceName, rootInstanceName);
+
+ //check that root is unregistered
+ dbusObjectPathAndInterfacesDict.clear();
+ dbusObjectPathAndInterfacesDict = getManagedObjects(rootDbusServiceName,"/", manualDBusConnection_);
+ ASSERT_TRUE(dbusObjectPathAndInterfacesDict.empty());
+
+ proxyConnection->disconnect();
}
#ifndef __NO_MAIN__