summaryrefslogtreecommitdiff
path: root/src/test/DBusServicePublisherTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/DBusServicePublisherTest.cpp')
-rw-r--r--src/test/DBusServicePublisherTest.cpp82
1 files changed, 35 insertions, 47 deletions
diff --git a/src/test/DBusServicePublisherTest.cpp b/src/test/DBusServicePublisherTest.cpp
index b265e71..c35fcf4 100644
--- a/src/test/DBusServicePublisherTest.cpp
+++ b/src/test/DBusServicePublisherTest.cpp
@@ -1,9 +1,7 @@
-/* Copyright (C) 2013 BMW Group
- * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de)
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+// Copyright (C) 2013-2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <gtest/gtest.h>
@@ -18,30 +16,29 @@
#include <tuple>
#include <type_traits>
-#include <CommonAPI/CommonAPI.h>
+#include <CommonAPI/CommonAPI.hpp>
+#ifndef COMMONAPI_INTERNAL_COMPILATION
#define COMMONAPI_INTERNAL_COMPILATION
+#endif
-#include <CommonAPI/AttributeExtension.h>
-#include <CommonAPI/types.h>
+#include <CommonAPI/DBus/DBusConnection.hpp>
+#include <CommonAPI/DBus/DBusProxy.hpp>
-#include <CommonAPI/DBus/DBusConnection.h>
-#include <CommonAPI/DBus/DBusProxy.h>
-#include <CommonAPI/DBus/DBusRuntime.h>
+#include "commonapi/tests/PredefinedTypeCollection.hpp"
+#include "commonapi/tests/DerivedTypeCollection.hpp"
+#include "v1_0/commonapi/tests/TestInterfaceProxy.hpp"
+#include "v1_0/commonapi/tests/TestInterfaceStubDefault.hpp"
+#include "v1_0/commonapi/tests/TestInterfaceDBusStubAdapter.hpp"
-#include "commonapi/tests/PredefinedTypeCollection.h"
-#include "commonapi/tests/DerivedTypeCollection.h"
-#include "commonapi/tests/TestInterfaceProxy.h"
-#include "commonapi/tests/TestInterfaceStubDefault.h"
-#include "commonapi/tests/TestInterfaceDBusStubAdapter.h"
-
-#include "commonapi/tests/TestInterfaceDBusProxy.h"
+#include "v1_0/commonapi/tests/TestInterfaceDBusProxy.hpp"
+#define VERSION v1_0
class DBusServicePublisherTest: public ::testing::Test {
protected:
virtual void SetUp() {
- runtime_ = CommonAPI::Runtime::load();
+ runtime_ = CommonAPI::Runtime::get();
ASSERT_TRUE((bool)runtime_);
}
@@ -52,66 +49,57 @@ class DBusServicePublisherTest: public ::testing::Test {
std::shared_ptr<CommonAPI::Runtime> runtime_;
};
+/** TODO: CHECK IF STILL USEFUL **/
+/*
TEST_F(DBusServicePublisherTest, HandlesManagementOfServices) {
- std::shared_ptr<CommonAPI::Factory> serviceFactory = runtime_->createFactory();
- ASSERT_TRUE((bool)serviceFactory);
- std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime_->getServicePublisher();
- ASSERT_TRUE((bool)servicePublisher);
-
+ const std::string domain = "local";
const std::string serviceAddress = "local:commonapi.tests.TestInterface:commonapi.tests.TestInterface";
const std::string serviceAddress2 = "local:commonapi.tests.TestInterfaceTwo:commonapi.tests.TestInterface";
auto myStub = std::make_shared<commonapi::tests::TestInterfaceStubDefault>();
- bool success = servicePublisher->registerService(myStub, serviceAddress, serviceFactory);
+ bool success = runtime_->registerService(domain, serviceAddress, myStub);
EXPECT_TRUE(success);
auto myStub2 = std::make_shared<commonapi::tests::TestInterfaceStubDefault>();
- success = servicePublisher->registerService(myStub2, serviceAddress2, serviceFactory);
+ success = runtime_->registerService(domain, serviceAddress2, myStub2);
EXPECT_TRUE(success);
- std::shared_ptr<CommonAPI::Factory> clientFactory = runtime_->createFactory();
-
usleep(10000);
- bool instanceIsAvailable = clientFactory->isServiceInstanceAlive(serviceAddress);
+ bool instanceIsAvailable = runtime_->isServiceInstanceAlive(serviceAddress);
EXPECT_TRUE(instanceIsAvailable);
- instanceIsAvailable = clientFactory->isServiceInstanceAlive(serviceAddress2);
+ instanceIsAvailable = runtime_->isServiceInstanceAlive(serviceAddress2);
EXPECT_TRUE(instanceIsAvailable);
- success = servicePublisher->unregisterService("SomeOther:Unknown:Service");
+ success = runtime_->unregisterService("SomeOther:Unknown:Service");
EXPECT_FALSE(success);
- success = servicePublisher->unregisterService(serviceAddress);
+ success = runtime_->unregisterService(serviceAddress);
EXPECT_TRUE(success);
- success = servicePublisher->unregisterService(serviceAddress2);
+ success = runtime_->unregisterService(serviceAddress2);
EXPECT_TRUE(success);
usleep(10000);
- instanceIsAvailable = clientFactory->isServiceInstanceAlive(serviceAddress);
+ instanceIsAvailable = runtime_->isServiceInstanceAlive(serviceAddress);
EXPECT_FALSE(instanceIsAvailable);
- instanceIsAvailable = clientFactory->isServiceInstanceAlive(serviceAddress2);
+ instanceIsAvailable = runtime_->isServiceInstanceAlive(serviceAddress2);
EXPECT_FALSE(instanceIsAvailable);
}
-
+*/
TEST_F(DBusServicePublisherTest, GracefullyHandlesWrongAddresses) {
- std::shared_ptr<CommonAPI::Factory> proxyFactory = runtime_->createFactory();
- ASSERT_TRUE((bool)proxyFactory);
- std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime_->getServicePublisher();
- ASSERT_TRUE((bool)servicePublisher);
-
- auto myStub = std::make_shared<commonapi::tests::TestInterfaceStubDefault>();
+ auto myStub = std::make_shared<VERSION::commonapi::tests::TestInterfaceStubDefault>();
- EXPECT_FALSE(servicePublisher->registerService(myStub, "", proxyFactory));
- EXPECT_FALSE(servicePublisher->registerService(myStub, "too:much:stuff:here", proxyFactory));
+ EXPECT_FALSE(runtime_->registerService("local", "", myStub, "connection"));
+ EXPECT_FALSE(runtime_->registerService("local", "too:much:stuff:here", myStub, "connection"));
}
-#ifndef WIN32
+#ifndef __NO_MAIN__
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
-#endif \ No newline at end of file
+#endif