summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Laner <Stefan.Laner@partner.bmw.de>2014-03-03 10:39:22 +0100
committerGerrit Code Review <qqmthk1@lpmodthk02.bmwgroup.net>2014-03-03 10:39:22 +0100
commit1f195652b8bc7171fecb642154c18ec540c2d29f (patch)
treea9817bc156b1cdb0fe06efebbc90a58462ce3085
parentd6d48f30254dcefca310e4eb626fcc4c5b193cd7 (diff)
parentafcc6ec1efabd6f050ef1d74b019ad19f073104f (diff)
downloadgenivi-common-api-runtime-1f195652b8bc7171fecb642154c18ec540c2d29f.tar.gz
Merge "GLIPCI-207 Adapted Test "DBusCommunicationTest > RemoteMethodCallSucceeds" to verification test."
-rw-r--r--org.genivi.commonapi.core.verification/CommunicationVerification.conf.in5
-rw-r--r--org.genivi.commonapi.core.verification/Makefile.am14
-rw-r--r--org.genivi.commonapi.core.verification/configure.ac2
-rw-r--r--org.genivi.commonapi.core.verification/src/CommunicationVerification.cpp.in114
4 files changed, 133 insertions, 2 deletions
diff --git a/org.genivi.commonapi.core.verification/CommunicationVerification.conf.in b/org.genivi.commonapi.core.verification/CommunicationVerification.conf.in
new file mode 100644
index 0000000..4916c37
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/CommunicationVerification.conf.in
@@ -0,0 +1,5 @@
+{binding:@BINDING_NAME@}
+libpath=@BINDING_SO@
+alias=TestAlias
+genpath=@GLUECODE_SO@
+default
diff --git a/org.genivi.commonapi.core.verification/Makefile.am b/org.genivi.commonapi.core.verification/Makefile.am
index e466962..db8aa4e 100644
--- a/org.genivi.commonapi.core.verification/Makefile.am
+++ b/org.genivi.commonapi.core.verification/Makefile.am
@@ -12,11 +12,13 @@ AM_CPPFLAGS = \
check_PROGRAMS = \
DynamicLoadingVerification \
- MainLoopVerification
+ MainLoopVerification \
+ CommunicationVerification
generated = \
src-gen/commonapi/tests/DerivedTypeCollection.cpp \
- src-gen/commonapi/tests/TestInterfaceStubDefault.cpp
+ src-gen/commonapi/tests/TestInterfaceStubDefault.cpp \
+ src-gen/commonapi/tests/CommunicationVerification.cpp
TESTS = ${check_PROGRAMS}
@@ -28,6 +30,10 @@ MainLoopVerification_SOURCES = \
src/utils/VerificationTestStub.cpp \
src/MainLoopVerification.cpp
+CommunicationVerification_SOURCES = \
+ src/utils/VerificationTestStub.cpp \
+ src/CommunicationVerification.cpp
+
DynamicLoadingVerification_CPPFLAGS = ${AM_CPPFLAGS}
DynamicLoadingVerification_LDADD = ${COMMONAPI_LIBS} ${GTEST_LIBS}
DynamicLoadingVerification_LDFLAGS = ${GLUE_LDFLAGS_FOR_SO}
@@ -35,3 +41,7 @@ DynamicLoadingVerification_LDFLAGS = ${GLUE_LDFLAGS_FOR_SO}
MainLoopVerification_CPPFLAGS = ${AM_CPPFLAGS}
MainLoopVerification_LDADD = ${COMMONAPI_LIBS} ${BINDING_A} ${GTEST_LIBS}
MainLoopVerification_LDFLAGS = ${GLUE_LDFLAGS_FOR_A}
+
+CommunicationVerification_CPPFLAGS = ${AM_CPPFLAGS}
+CommunicationVerification_LDADD = ${COMMONAPI_LIBS} ${BINDING_A} ${GTEST_LIBS}
+CommunicationVerification_LDFLAGS = ${GLUE_LDFLAGS_FOR_A}
diff --git a/org.genivi.commonapi.core.verification/configure.ac b/org.genivi.commonapi.core.verification/configure.ac
index 2758998..fa6863f 100644
--- a/org.genivi.commonapi.core.verification/configure.ac
+++ b/org.genivi.commonapi.core.verification/configure.ac
@@ -9,6 +9,8 @@ AC_CONFIG_FILES([
Makefile
DynamicLoadingVerification.conf
src/DynamicLoadingVerification.cpp
+ CommunicationVerification.conf
+ src/CommunicationVerification.cpp
])
AC_CANONICAL_SYSTEM
diff --git a/org.genivi.commonapi.core.verification/src/CommunicationVerification.cpp.in b/org.genivi.commonapi.core.verification/src/CommunicationVerification.cpp.in
new file mode 100644
index 0000000..5c548be
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/CommunicationVerification.cpp.in
@@ -0,0 +1,114 @@
+/* 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/. */
+
+#include <functional>
+#include <fstream>
+#include <gtest/gtest.h>
+#include "CommonAPI/CommonAPI.h"
+#include "utils/VerificationMainLoop.h"
+#include "commonapi/tests/TestInterfaceProxy.h"
+#include "utils/VerificationTestStub.h"
+
+const std::string testAddress = "local:my.test:commonapi.address";
+
+const std::string configString =
+ "{binding:@BINDING_NAME@}\n"
+ "libpath=@BINDING_SO@\n"
+ "alias=TestAlias\n"
+ "genpath=@GLUECODE_SO@\n"
+ "default"
+;
+
+const std::string COMMONAPI_CONFIG_SUFFIX = ".conf";
+
+
+
+class Environment: public ::testing::Environment {
+public:
+ virtual ~Environment() {
+ }
+
+ virtual void SetUp() {
+ configFileName_ = CommonAPI::getCurrentBinaryFileFQN();
+ configFileName_ += COMMONAPI_CONFIG_SUFFIX;
+ std::ofstream configFile(configFileName_);
+ ASSERT_TRUE(configFile.is_open());
+ configFile << configString;
+ configFile.close();
+ }
+
+ virtual void TearDown() {
+ std::remove(configFileName_.c_str());
+ }
+
+ std::string configFileName_;
+};
+
+
+
+
+class CommunicationTest: public ::testing::Test {
+
+protected:
+ void SetUp() {
+ runtime_ = CommonAPI::Runtime::load();
+ ASSERT_TRUE((bool)runtime_);
+
+ proxyFactory_ = runtime_->createFactory();
+ ASSERT_TRUE((bool)proxyFactory_);
+ stubFactory_ = runtime_->createFactory();
+ ASSERT_TRUE((bool)stubFactory_);
+
+ servicePublisher_ = runtime_->getServicePublisher();
+ ASSERT_TRUE((bool)servicePublisher_);
+ }
+
+ void TearDown() {
+ usleep(30000);
+ }
+
+ std::string configFileName_;
+ std::shared_ptr<CommonAPI::Runtime> runtime_;
+ std::shared_ptr<CommonAPI::Factory> proxyFactory_;
+ std::shared_ptr<CommonAPI::Factory> stubFactory_;
+ std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher_;
+};
+
+
+TEST_F(CommunicationTest, RemoteMethodCallSucceeds) {
+ auto defaultTestProxy = proxyFactory_->buildProxy<commonapi::tests::TestInterfaceProxy>(testAddress);
+ ASSERT_TRUE((bool)defaultTestProxy);
+
+ auto stub = std::make_shared<commonapi::tests::TestInterfaceStubDefault>();
+
+ bool serviceRegistered = servicePublisher_->registerService(stub, testAddress, stubFactory_);
+ for(unsigned int i = 0; !serviceRegistered && i < 100; ++i) {
+ serviceRegistered = servicePublisher_->registerService(stub, testAddress, stubFactory_);
+ usleep(10000);
+ }
+ ASSERT_TRUE(serviceRegistered);
+
+ for(unsigned int i = 0; !defaultTestProxy->isAvailable() && i < 100; ++i) {
+ usleep(10000);
+ }
+ ASSERT_TRUE(defaultTestProxy->isAvailable());
+
+ uint32_t v1 = 5;
+ std::string v2 = "Ciao ;)";
+ CommonAPI::CallStatus stat;
+ defaultTestProxy->testVoidPredefinedTypeMethod(v1, v2, stat);
+
+ EXPECT_EQ(stat, CommonAPI::CallStatus::SUCCESS);
+
+ servicePublisher_->unregisterService(testAddress);
+}
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(new Environment());
+ return RUN_ALL_TESTS();
+}