summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/test/database
diff options
context:
space:
mode:
authorChristian Mueller <christian@lmuc329619u.(none)>2011-12-12 21:43:47 +0100
committerChristian Mueller <christian@lmuc329619u.(none)>2011-12-12 21:43:47 +0100
commit205595e3d3e6a1d55be3c462ef02c9f828a77feb (patch)
tree9c1202619c7b9a66ed874ca1a0c81530ae06e426 /AudioManagerDaemon/test/database
parentd85e69bbf6d8ec6e087c7af579686923c76079cd (diff)
downloadaudiomanager-205595e3d3e6a1d55be3c462ef02c9f828a77feb.tar.gz
some updates, new tests
Diffstat (limited to 'AudioManagerDaemon/test/database')
-rw-r--r--AudioManagerDaemon/test/database/CMakeLists.txt73
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.cpp1369
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.h37
3 files changed, 1479 insertions, 0 deletions
diff --git a/AudioManagerDaemon/test/database/CMakeLists.txt b/AudioManagerDaemon/test/database/CMakeLists.txt
new file mode 100644
index 0000000..33e6f87
--- /dev/null
+++ b/AudioManagerDaemon/test/database/CMakeLists.txt
@@ -0,0 +1,73 @@
+#
+# Copyright (C) 2011, BMW AG
+#
+# GeniviAudioMananger DatbaseTest
+#
+# \file CMakeLists.txt
+#
+# \date 20-Oct-2011 3:42:04 PM
+# \author Christian Mueller (christian.ei.mueller@bmw.de)
+#
+# \section License
+# GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+# Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+#
+# This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+# You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+# Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+# Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+# As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+# Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+#
+
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(datbaseTest)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
+#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1")
+
+set(STD_INCLUDE_DIRS "/usr/include")
+set(DBUS_FOLDER ${CMAKE_SOURCE_DIR}/../../../dbusInterfaces)
+set(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../includes)
+set(DBUS_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../../dbusIncludes)
+set(INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../include)
+set(EXECUTABLE_OUTPUT_PATH ../../../../test/)
+
+FIND_PACKAGE(PkgConfig)
+pkg_check_modules(SQLITE REQUIRED sqlite3)
+pkg_check_modules(DLT REQUIRED automotive-dlt)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${AUDIO_INCLUDES_FOLDER}
+ ${DBUS_ARCH_INCLUDE_DIR}
+ ${DBUS_INCLUDES_FOLDER}
+ ${CMAKE_SOURCE_DIR}
+ ${STD_INCLUDE_DIRS}
+ ${DLT_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIR}
+ ${INCLUDES_FOLDER}
+)
+
+file(GLOB DATABASE_SRCS_CXX
+ "../../src/DatabaseHandler.cpp"
+ "../../src/Observer.cpp"
+ "../../src/CommandSender.cpp"
+ "../../src/RoutingSender.cpp"
+ "../CommonFunctions.cpp"
+ "*.cpp"
+ )
+
+ADD_EXECUTABLE( databasetest ${DATABASE_SRCS_CXX})
+
+TARGET_LINK_LIBRARIES( databasetest
+ ${SQLITE_LIBRARIES}
+ ${DLT_LIBRARIES}
+ ${DBUS_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ gtest
+ gmock
+) \ No newline at end of file
diff --git a/AudioManagerDaemon/test/database/databaseTest.cpp b/AudioManagerDaemon/test/database/databaseTest.cpp
new file mode 100644
index 0000000..75fb389
--- /dev/null
+++ b/AudioManagerDaemon/test/database/databaseTest.cpp
@@ -0,0 +1,1369 @@
+/**
+* Copyright (C) 2011, BMW AG
+*
+* GeniviAudioMananger AudioManagerDaemon
+*
+* \file databasetest.cpp
+*
+* \date 20-Oct-2011 3:42:04 PM
+* \author Christian Mueller (christian.ei.mueller@bmw.de)
+*
+* \section License
+* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+*
+* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+*/
+
+#include "databaseTest.h"
+#include "Observer.h"
+
+using namespace am;
+
+//extern int GetRandomNumber(int nLow, int nHigh);
+//extern bool equalSoundProperty (const am_SoundProperty_s a, const am_SoundProperty_s b);
+extern bool equalMainSoundProperty (const am_MainSoundProperty_s a, const am_MainSoundProperty_s b);
+extern bool equalRoutingElement (const am_RoutingElement_s a,const am_RoutingElement_s b);
+extern bool equalClassProperties (const am_ClassProperty_s a,const am_ClassProperty_s b);
+extern std::string int2string(int i);
+
+void databaseTest::createMainConnectionSetup()
+{
+ //fill the connection database
+ am_Connection_s connection;
+ am_Source_s source;
+ am_Sink_s sink;
+ std::vector<am_Connection_s> connectionList;
+
+ for (uint16_t i=1;i<10;i++)
+ {
+ am_sinkID_t forgetSink;
+ am_sourceID_t forgetSource;
+ am_connectionID_t forgetConnection;
+
+ pCF.createConnection(connection);
+ connection.sinkID=i;
+ connection.sourceID=i;
+ connectionList.push_back(connection);
+
+ pCF.createSink(sink);
+ sink.sinkID=i;
+ sink.name="sink" + int2string(i);
+ sink.domainID=4;
+ pCF.createSource(source);
+ source.sourceID=i;
+ source.name="source" + int2string(i);
+ source.domainID=4;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(forgetConnection));
+ }
+
+ //fill the route
+ std::vector<am_RoutingElement_s> routingList;
+ pCF.connectionList2RoutingList(routingList,connectionList);
+
+ //create the Route
+ am_Route_s route;
+ route.route=routingList;
+ route.sinkID=1;
+ route.sourceID=1;
+
+ //create a mainConnection
+ am_MainConnection_s mainConnection;
+ am_mainConnectionID_t mainConnectionID;
+ std::vector<am_MainConnection_s> mainConnectionList;
+ pCF.createMainConnection(mainConnection,route);
+
+ //enter mainconnection in database
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID))<< "ERROR: database error";
+ ASSERT_NE(0,mainConnectionID)<< "ERROR: connectionID zero";
+
+ //read out the mainconnections and check if they are equal to the data written.
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(mainConnectionList));
+ bool equal=true;
+ std::vector<am_MainConnection_s>::iterator listIterator=mainConnectionList.begin();
+ for(;listIterator<mainConnectionList.end();++listIterator)
+ {
+ if(listIterator->connectionID==mainConnectionID) {
+ equal= equal && (listIterator->connectionState == mainConnection.connectionState)
+ && (listIterator->route.sinkID == mainConnection.route.sinkID)
+ && (listIterator->route.sourceID == mainConnection.route.sourceID)
+ && (listIterator->delay == mainConnection.delay)
+ && (std::equal(listIterator->route.route.begin(),listIterator->route.route.end(),routingList.begin(),equalRoutingElement));
+ }
+ }
+ ASSERT_EQ(true,equal);
+}
+
+void databaseTest::SetUp()
+{
+ DLT_REGISTER_APP("Dtest","AudioManagerDeamon");
+ DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Database Test started "));
+ Observer *observer=NULL;
+ pDatabaseHandler.registerObserver(observer);
+}
+
+void databaseTest::TearDown()
+{
+ DLT_UNREGISTER_CONTEXT(AudioManager);
+}
+
+TEST_F(databaseTest, peekSource)
+{
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID;
+ am_sourceID_t source2ID;
+ am_Source_s source;
+ pCF.createSource(source);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.empty());
+ ASSERT_EQ(sourceID,100);
+ source.name="newsource";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,source2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(sourceID,source2ID);
+ ASSERT_TRUE(listSources[0].sourceID==sourceID);
+}
+
+TEST_F(databaseTest, peekSourceDouble)
+{
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID;
+ am_sourceID_t source2ID;
+ am_sourceID_t source3ID;
+ am_Source_s source;
+ pCF.createSource(source);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource2"),source2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.empty());
+ ASSERT_EQ(sourceID,100);
+ source.name="newsource";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,source3ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(sourceID,source3ID);
+ ASSERT_TRUE(listSources[0].sourceID==sourceID);
+}
+
+TEST_F(databaseTest, peekSourceExists)
+{
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID;
+ am_sourceID_t source2ID;
+ am_Source_s source;
+ pCF.createSource(source);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(source.name,source2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.size()==1);
+ ASSERT_EQ(sourceID,source2ID);
+}
+
+TEST_F(databaseTest, peekSink)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID;
+ am_sinkID_t sink2ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.empty());
+ ASSERT_EQ(sinkID,100);
+ sink.name="newsink";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sink2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(sinkID,sink2ID);
+ ASSERT_TRUE(listSinks[0].sinkID==sinkID);
+}
+
+TEST_F(databaseTest, peekSinkDouble)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID;
+ am_sinkID_t sink2ID;
+ am_sinkID_t sink3ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("nextsink"),sink2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.empty());
+ ASSERT_EQ(sinkID,100);
+ sink.name="newsink";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sink3ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(sinkID,sink3ID);
+ ASSERT_TRUE(listSinks[0].sinkID==sinkID);
+}
+
+TEST_F(databaseTest, peekSinkExists)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID;
+ am_sinkID_t sink2ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(sink.name,sink2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.size()==1);
+ ASSERT_EQ(sinkID,sink2ID);
+}
+
+
+TEST_F(databaseTest,changeConnectionTimingInformationCheckMainConnection)
+{
+ am_Connection_s connection;
+ std::vector<am_Connection_s> connectionList;
+ std::vector<am_MainConnectionType_s> mainList;
+ pCF.createConnection(connection);
+ createMainConnectionSetup();
+ ASSERT_EQ(-E_OK,pDatabaseHandler.getListVisibleMainConnections(mainList));
+ ASSERT_EQ(mainList[0].delay,-1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
+ std::vector<am_Connection_s>::iterator iteratorConnectionList=connectionList.begin();
+ for(;iteratorConnectionList<connectionList.end();++iteratorConnectionList)
+ {
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionTimingInformation(iteratorConnectionList->sinkID,24));
+ }
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(mainList));
+ ASSERT_NE(mainList[0].delay,-1);
+}
+
+TEST_F(databaseTest,changeConnectionTimingInformation)
+{
+ am_Connection_s connection;
+ am_connectionID_t connectionID;
+ std::vector<am_Connection_s> connectionList;
+ pCF.createConnection(connection);
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionTimingInformation(connectionID,24));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(connectionList[0].delay==24);
+}
+
+TEST_F(databaseTest,getSinkClassOfSink)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass, returnClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ classProperty.classProperty=CP_SINK_TYPE;
+ classProperty.value=1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty=CP_SOURCE_TYPE;
+ classProperty.value=4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name="test";
+ sinkClass.sinkClassID=4;
+ sinkClass.listClassProperties=classPropertyList;
+ pCF.createSink(sink);
+ sink.sinkClassID=4;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID,4);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getSinkClassInfoDB(sinkID,returnClass));
+ ASSERT_EQ(sinkClassList[0].name,returnClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID,returnClass.sinkClassID);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),returnClass.listClassProperties.begin(),equalClassProperties));
+}
+
+
+TEST_F(databaseTest,getSourceClassOfSource)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass, sinkSourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ classProperty.classProperty=CP_SINK_TYPE;
+ classProperty.value=1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty=CP_SOURCE_TYPE;
+ classProperty.value=4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name="test";
+ sourceClass.sourceClassID=1;
+ sourceClass.listClassProperties=classPropertyList;
+ pCF.createSource(source);
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID,1);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getSourceClassInfoDB(sourceID,sinkSourceClass));
+ ASSERT_EQ(sourceClassList[0].name,sinkSourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID,sinkSourceClass.sourceClassID);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),sinkSourceClass.listClassProperties.begin(),equalClassProperties));
+}
+
+
+TEST_F(databaseTest,removeSourceClass)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty=CP_SINK_TYPE;
+ classProperty.value=1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty=CP_SOURCE_TYPE;
+ classProperty.value=4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name="test";
+ sourceClass.sourceClassID=3;
+ sourceClass.listClassProperties=classPropertyList;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID,3);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceClassDB(3));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_TRUE(sourceClassList.empty());
+}
+
+TEST_F(databaseTest,updateSourceClass)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList,changedPropertyList;
+ am_SourceClass_s sourceClass, changedClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty=CP_SINK_TYPE;
+ classProperty.value=1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty=CP_SOURCE_TYPE;
+ classProperty.value=4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name="test";
+ sourceClass.sourceClassID=0;
+ sourceClass.listClassProperties=classPropertyList;
+ changedClass=sourceClass;
+ changedClass.listClassProperties[1].value=6;
+ changedPropertyList=changedClass.listClassProperties;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ changedClass.sourceClassID=sourceClassID;
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID,100);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceClassInfoDB(changedClass));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID,100);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(databaseTest,enterSourceClass)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty=CP_SINK_TYPE;
+ classProperty.value=1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty=CP_SOURCE_TYPE;
+ classProperty.value=4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name="test";
+ sourceClass.sourceClassID=0;
+ sourceClass.listClassProperties=classPropertyList;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID,100);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(databaseTest,enterSourceClassStatic)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty=CP_SINK_TYPE;
+ classProperty.value=1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty=CP_SOURCE_TYPE;
+ classProperty.value=4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name="test";
+ sourceClass.sourceClassID=3;
+ sourceClass.listClassProperties=classPropertyList;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID,3);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+
+TEST_F(databaseTest,removeSinkClass)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty=CP_SINK_TYPE;
+ classProperty.value=1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty=CP_SOURCE_TYPE;
+ classProperty.value=4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name="test";
+ sinkClass.sinkClassID=0;
+ sinkClass.listClassProperties=classPropertyList;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID,100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkClassDB(sinkClassID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_TRUE(sinkClassList.empty());
+}
+
+TEST_F(databaseTest,updateSinkClass)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
+ am_SinkClass_s sinkClass, changedClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty=CP_SINK_TYPE;
+ classProperty.value=1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty=CP_SOURCE_TYPE;
+ classProperty.value=4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name="test";
+ sinkClass.sinkClassID=0;
+ sinkClass.listClassProperties=classPropertyList;
+ changedClass=sinkClass;
+ changedClass.listClassProperties[1].value=6;
+ changedPropertyList=changedClass.listClassProperties;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ changedClass.sinkClassID=sinkClassID;
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID,100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkClassInfoDB(changedClass));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID,100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(databaseTest,enterSinkClass)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty=CP_SINK_TYPE;
+ classProperty.value=1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty=CP_SOURCE_TYPE;
+ classProperty.value=4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name="test";
+ sinkClass.sinkClassID=0;
+ sinkClass.listClassProperties=classPropertyList;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID,100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(databaseTest,enterSinkClassStatic)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty=CP_SINK_TYPE;
+ classProperty.value=1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty=CP_SOURCE_TYPE;
+ classProperty.value=4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name="test";
+ sinkClass.sinkClassID=4;
+ sinkClass.listClassProperties=classPropertyList;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID,4);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+
+TEST_F(databaseTest, changeSystemProperty)
+{
+ std::vector<am_SystemProperty_s> listSystemProperties,listReturn;
+ am_SystemProperty_s systemProperty;
+
+ systemProperty.type=SYP_TEST;
+ systemProperty.value=33;
+ listSystemProperties.push_back(systemProperty);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSystemProperties(listSystemProperties));
+ systemProperty.value=444;
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeSystemPropertyDB(systemProperty));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSystemProperties(listReturn));
+ ASSERT_EQ(listReturn[0].type,systemProperty.type);
+ ASSERT_EQ(listReturn[0].value,systemProperty.value);
+}
+
+TEST_F(databaseTest, systemProperties)
+{
+ std::vector<am_SystemProperty_s> listSystemProperties,listReturn;
+ am_SystemProperty_s systemProperty;
+
+ systemProperty.type=SYP_TEST;
+ systemProperty.value=33;
+ listSystemProperties.push_back(systemProperty);
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSystemProperties(listSystemProperties));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSystemProperties(listReturn));
+ ASSERT_EQ(listReturn[0].type,systemProperty.type);
+ ASSERT_EQ(listReturn[0].value,systemProperty.value);
+}
+
+
+TEST_F(databaseTest,enterSourcesCorrect)
+{
+ //fill the connection database
+ am_Source_s staticSource,firstDynamicSource,secondDynamicSource;
+ am_sourceID_t staticSourceID,firstDynamicSourceID,secondDynamicSourceID;
+ std::vector<am_Source_s> sourceList;
+
+ pCF.createSource(staticSource);
+ staticSource.sourceID=4;
+ staticSource.name="Static";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
+ ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
+
+ pCF.createSource(firstDynamicSource);
+ firstDynamicSource.name="firstDynamicSource";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(firstDynamicSource,firstDynamicSourceID))<< "ERROR: database error";
+ ASSERT_EQ(firstDynamicSourceID,DYNAMIC_ID_BOUNDARY)<< "ERROR: ID not the one given in firstDynamicSink";
+
+ pCF.createSource(secondDynamicSource);
+ secondDynamicSource.name="secondDynamicSource";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(secondDynamicSource,secondDynamicSourceID))<< "ERROR: database error";
+ ASSERT_NEAR(secondDynamicSourceID,DYNAMIC_ID_BOUNDARY,10)<< "ERROR: ID not the one given in secondDynamicSink";
+
+ //now read back and check the returns agains the given values
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(sourceList))<< "ERROR: database error";
+ bool equal=true;
+
+ std::vector<am_Source_s>::iterator listIterator=sourceList.begin();
+ for(;listIterator<sourceList.end();++listIterator)
+ {
+ if(listIterator->sourceID==staticSourceID)
+ {
+ equal = equal && pCF.compareSource(listIterator,staticSource);
+ }
+
+ if(listIterator->sourceID==firstDynamicSourceID)
+ {
+ equal = equal && pCF.compareSource(listIterator,firstDynamicSource);
+ }
+
+ if(listIterator->sourceID==secondDynamicSourceID)
+ {
+ equal = equal && pCF.compareSource(listIterator,secondDynamicSource);
+ }
+
+ }
+ ASSERT_EQ(true,equal);
+}
+
+
+TEST_F(databaseTest, changeSourceMainSoundProperty)
+{
+ std::vector<am_Source_s> listSources;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ am_MainSoundProperty_s property;
+ property.type=MSP_NAVIGATION_OFFSET;
+ property.value=33;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSourceSoundPropertyDB(property,sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ std::vector<am_MainSoundProperty_s>::iterator listIterator=listSources[0].listMainSoundProperties.begin();
+ for(;listIterator<listSources[0].listMainSoundProperties.end();++listIterator)
+ {
+ if(listIterator->type==property.type)
+ {
+ ASSERT_EQ(listIterator->value,property.value);
+ }
+ }
+}
+
+TEST_F(databaseTest, changeSinkMuteState)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_MuteState_e muteState=MS_MUTED;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(muteState,listSinks[0].muteState);
+}
+
+TEST_F(databaseTest, changeSinkMainSoundProperty)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_MainSoundProperty_s property;
+ property.type=MSP_NAVIGATION_OFFSET;
+ property.value=33;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ std::vector<am_MainSoundProperty_s>::iterator listIterator=listSinks[0].listMainSoundProperties.begin();
+ for(;listIterator<listSinks[0].listMainSoundProperties.end();++listIterator)
+ {
+ if(listIterator->type==property.type)
+ {
+ ASSERT_EQ(listIterator->value,property.value);
+ }
+ }
+}
+
+TEST_F(databaseTest, peekDomain)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_domainID_t domain2ID;
+ pCF.createDomain(domain);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekDomain(std::string("newdomain"),domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_TRUE(listDomains.empty());
+ ASSERT_EQ(domainID,1);
+ domain.name="newdomain";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domain2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_EQ(domainID,domain2ID);
+ ASSERT_TRUE(listDomains[0].domainID==domainID);
+}
+
+TEST_F(databaseTest, peekDomainFirstEntered)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_domainID_t domain2ID;
+ pCF.createDomain(domain);
+ domain.name="newdomain";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekDomain(std::string("newdomain"),domain2ID));
+ ASSERT_EQ(domainID,domain2ID);
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_TRUE(listDomains.size()==1);
+}
+
+TEST_F(databaseTest, changeDomainState)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ pCF.createDomain(domain);
+ am_DomainState_e newState=DS_INDEPENDENT_STARTUP;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changDomainStateDB(newState,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_EQ(newState,listDomains[0].state);
+}
+
+
+TEST_F(databaseTest, changeMainConnectionState)
+{
+ std::vector<am_MainConnection_s> listMainConnections;
+ createMainConnectionSetup();
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionStateDB(1,CS_DISCONNECTING))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(listMainConnections));
+ ASSERT_EQ(CS_DISCONNECTING,listMainConnections[0].connectionState);
+}
+
+TEST_F(databaseTest, changeSinkAvailability)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_Availability_s availability;
+ availability.availability=A_UNKNOWN;
+ availability.availabilityReason=AR_TEMPERATURE;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkAvailabilityDB(availability,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(availability.availability,listSinks[0].available.availability);
+ ASSERT_EQ(availability.availabilityReason,listSinks[0].available.availabilityReason);
+}
+
+TEST_F(databaseTest, changeSourceAvailability)
+{
+ std::vector<am_Source_s> listSources;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ am_Availability_s availability;
+ availability.availability=A_UNKNOWN;
+ availability.availabilityReason=AR_TEMPERATURE;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceAvailabilityDB(availability,sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(availability.availability,listSources[0].available.availability);
+ ASSERT_EQ(availability.availabilityReason,listSources[0].available.availabilityReason);
+}
+
+
+TEST_F(databaseTest,changeMainConnectionRoute)
+{
+ std::vector<am_MainConnection_s> originalList;
+ std::vector<am_MainConnection_s> newList;
+ createMainConnectionSetup();
+ //fill the connection database
+ am_Connection_s connection;
+ am_Source_s source;
+ am_Sink_s sink;
+ std::vector<am_Connection_s> connectionList;
+
+ for (uint16_t i=1;i<10;i++)
+ {
+ am_sinkID_t forgetSink;
+ am_sourceID_t forgetSource;
+ am_connectionID_t forgetConnection;
+
+ pCF.createConnection(connection);
+ connection.sinkID=i+20;
+ connection.sourceID=i+20;
+ connection.delay=-1;
+ connectionList.push_back(connection);
+
+ pCF.createSink(sink);
+ sink.sinkID=i+20;
+ sink.name="sink" + int2string(i+20);
+ sink.domainID=4;
+ pCF.createSource(source);
+ source.sourceID=i+20;
+ source.name="source" + int2string(i+30);
+ source.domainID=4;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(originalList))<< "ERROR: database error";
+
+ }
+
+ //fill the route
+ std::vector<am_RoutingElement_s> routingList;
+ pCF.connectionList2RoutingList(routingList,connectionList);
+
+ //create the Route
+ am_Route_s route;
+ route.route=routingList;
+ route.sinkID=2;
+ route.sourceID=2;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionRouteDB(1,route));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(newList))<< "ERROR: database error";
+ ASSERT_TRUE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),routingList.begin(),equalRoutingElement));
+ ASSERT_FALSE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),originalList[0].route.route.begin(),equalRoutingElement));
+}
+
+TEST_F(databaseTest,changeMainSinkVolume)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_mainVolume_t newVol=20;
+ std::vector<am_Sink_s> listSinks;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(listSinks[0].mainVolume,newVol);
+}
+
+TEST_F(databaseTest,getMainSourceSoundProperties)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ std::vector<am_MainSoundProperty_s> mainSoundProperties=source.listMainSoundProperties;
+ std::vector<am_MainSoundProperty_s> listMainSoundProperties;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSourceSoundProperties(sourceID,listMainSoundProperties));
+ ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
+}
+
+TEST_F(databaseTest,getMainSinkSoundProperties)
+ {
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ std::vector<am_MainSoundProperty_s> mainSoundProperties=sink.listMainSoundProperties;
+ std::vector<am_MainSoundProperty_s> listMainSoundProperties;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSinkSoundProperties(sinkID,listMainSoundProperties));
+ ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
+ }
+
+TEST_F(databaseTest,getMainSources)
+{
+ am_Source_s source, source1,source2;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ pCF.createSource(source1);
+ pCF.createSource(source2);
+ source1.name="source1";
+ source2.name="source2";
+ bool equal=true;
+ source1.visible=false;
+ std::vector<am_SourceType_s> listMainSources;
+ std::vector<am_Source_s> listSources;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ source.sourceID=sourceID;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source1,sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID));
+ source2.sourceID=sourceID;
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSources(listMainSources));
+ listSources.push_back(source);
+ listSources.push_back(source2);
+ std::vector<am_SourceType_s>::iterator listIterator=listMainSources.begin();
+ for(;listIterator<listMainSources.end();++listIterator)
+ {
+ equal = equal && pCF.compareSinkMainSource(listIterator,listSources);
+ }
+ ASSERT_TRUE(equal);
+}
+
+TEST_F(databaseTest,getMainSinks)
+{
+ am_Sink_s sink, sink1,sink2;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ pCF.createSink(sink1);
+ pCF.createSink(sink2);
+ sink1.name="sink1";
+ sink2.name="sink2";
+ bool equal=true;
+ sink1.visible=false;
+ std::vector<am_SinkType_s> listMainSinks;
+ std::vector<am_Sink_s> listSinks;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ sink.sinkID=sinkID;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink1,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID));
+ sink2.sinkID=sinkID;
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSinks(listMainSinks));
+ listSinks.push_back(sink);
+ listSinks.push_back(sink2);
+ std::vector<am_SinkType_s>::iterator listIterator=listMainSinks.begin();
+ for(;listIterator<listMainSinks.end();++listIterator)
+ {
+ equal = equal && pCF.compareSinkMainSink(listIterator,listSinks);
+ }
+ ASSERT_TRUE(equal);
+}
+
+TEST_F(databaseTest,getVisibleMainConnections)
+{
+ createMainConnectionSetup();
+ am_MainConnection_s mainConnection;
+ am_Route_s route;
+ pCF.createMainConnection(mainConnection,route);
+ std::vector<am_MainConnectionType_s> visibleMainConnection;
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(visibleMainConnection));
+ ASSERT_TRUE(1==visibleMainConnection[0].mainConnectionID);
+ ASSERT_TRUE(mainConnection.connectionState==visibleMainConnection[0].connectionState);
+ ASSERT_TRUE(mainConnection.delay==visibleMainConnection[0].delay);
+ ASSERT_TRUE(1==visibleMainConnection[0].sinkID);
+ ASSERT_TRUE(1==visibleMainConnection[0].sourceID);
+}
+
+TEST_F(databaseTest,getListSourcesOfDomain)
+{
+ am_Source_s source, source2;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_sourceID_t sourceID;
+ std::vector<am_sourceID_t> sourceList,sourceCheckList;
+ pCF.createSource(source);
+ source.sourceID=1;
+ source.name="testSource";
+ source.domainID=1;
+ pCF.createSource(source2);
+ source2.sourceID=0;
+ source2.name="testSource2";
+ source2.domainID=5;
+ pCF.createDomain(domain);
+ sourceCheckList.push_back(1);//sink.sinkID);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID))<< "ERROR: database error";
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSourcesOfDomain(2,sourceList))<< "ERROR: database error";
+ ASSERT_TRUE(sourceList.empty());
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSourcesOfDomain(1,sourceList))<< "ERROR: database error";
+ ASSERT_TRUE(std::equal(sourceList.begin(),sourceList.end(),sourceCheckList.begin()) && !sourceList.empty());
+}
+
+TEST_F(databaseTest,getListSinksOfDomain)
+{
+ am_Sink_s sink, sink2;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_sinkID_t sinkID;
+ std::vector<am_sinkID_t> sinkList,sinkCheckList;
+ pCF.createSink(sink);
+ sink.sinkID=1;
+ sink.domainID=1;
+ pCF.createSink(sink2);
+ sink2.domainID=5;
+ sink2.name="sink2";
+ pCF.createDomain(domain);
+ sinkCheckList.push_back(1);//sink.sinkID);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID))<< "ERROR: database error";
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSinksOfDomain(2,sinkList))<< "ERROR: database error";
+ ASSERT_TRUE(sinkList.empty());
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinksOfDomain(1,sinkList))<< "ERROR: database error";
+ ASSERT_TRUE(std::equal(sinkList.begin(),sinkList.end(),sinkCheckList.begin()) && !sinkList.empty());
+}
+
+TEST_F(databaseTest,getListGatewaysOfDomain)
+{
+ am_Gateway_s gateway, gateway2;
+ am_gatewayID_t gatewayID;
+ am_domainID_t domainID;
+ am_Domain_s domain;
+ std::vector<am_gatewayID_t> gatewayList,gatewayCheckList;
+ pCF.createGateway(gateway);
+ gateway.gatewayID=1;
+ gateway.name="testGateway";
+ gateway.controlDomainID=1;
+ gateway.sourceID=1;
+ gateway.sinkID=1;
+ gateway.domainSinkID=1;
+ gateway.domainSourceID=1;
+ pCF.createGateway(gateway2);
+ gateway2.gatewayID=2;
+ gateway2.name="testGateway2";
+ gateway2.controlDomainID=4;
+ gateway2.sourceID=1;
+ gateway2.sinkID=1;
+ gateway2.domainSinkID=1;
+ gateway2.domainSourceID=1;
+ pCF.createDomain(domain);
+ gatewayCheckList.push_back(gateway.gatewayID);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID))<< "ERROR: database error";
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListGatewaysOfDomain(2,gatewayList))<< "ERROR: database error";
+ ASSERT_TRUE(gatewayList.empty());
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListGatewaysOfDomain(1,gatewayList))<< "ERROR: database error";
+ ASSERT_TRUE(std::equal(gatewayList.begin(),gatewayList.end(),gatewayCheckList.begin()) && !gatewayList.empty());
+}
+
+TEST_F(databaseTest,removeDomain)
+{
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Domain_s> listDomains;
+ pCF.createDomain(domain);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeDomainDB(domainID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains))<< "ERROR: database error";
+ ASSERT_TRUE(listDomains.empty());
+}
+
+TEST_F(databaseTest,removeGateway)
+{
+ am_Gateway_s gateway;
+ am_gatewayID_t gatewayID;
+ std::vector<am_Gateway_s> listGateways;
+ pCF.createGateway(gateway);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeGatewayDB(gatewayID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(listGateways))<< "ERROR: database error";
+ ASSERT_TRUE(listGateways.empty());
+}
+
+TEST_F(databaseTest,removeSink)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ std::vector<am_Sink_s> listSinks;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkDB(sinkID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks))<< "ERROR: database error";
+ ASSERT_TRUE(listSinks.empty());
+}
+
+TEST_F(databaseTest,removeSource)
+{
+ //fill the connection database
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ std::vector<am_Source_s> listSources;
+ pCF.createSource(source);
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources))<< "ERROR: database error";
+ ASSERT_TRUE(listSources.empty());
+}
+
+TEST_F(databaseTest, removeMainConnection)
+{
+ createMainConnectionSetup();
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeMainConnectionDB(1))<< "ERROR: database error";
+}
+
+TEST_F(databaseTest,removeNonexistentMainConnectionFail)
+{
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeMainConnectionDB(34))<< "ERROR: database error";
+}
+
+TEST_F(databaseTest,removeNonexistentSource)
+{
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSourceDB(3))<< "ERROR: database error";
+}
+
+TEST_F(databaseTest,removeNonexistentSink)
+{
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSinkDB(2))<< "ERROR: database error";
+}
+
+TEST_F(databaseTest,removeNonexistentGateway)
+{
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeGatewayDB(12))<< "ERROR: database error";
+}
+
+TEST_F(databaseTest,registerGatewayCorrect)
+{
+ //initialize gateway
+ std::vector<am_Gateway_s> returnList;
+ am_Gateway_s gateway, gateway1, gateway2;
+ am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
+
+ pCF.createGateway(gateway);
+ pCF.createGateway(gateway1);
+ gateway1.gatewayID=20;
+ pCF.createGateway(gateway2);
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
+ ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))<< "ERROR: database error";
+ ASSERT_EQ(gateway1.gatewayID,gatewayID1)<< "ERROR: domainID zero";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))<< "ERROR: database error";
+ ASSERT_EQ(101,gatewayID2)<< "ERROR: domainID zero";
+
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(returnList));
+ bool equal=true;
+ std::vector<am_Gateway_s>::iterator listIterator=returnList.begin();
+
+ for(;listIterator<returnList.end();++listIterator)
+ {
+ if(listIterator->gatewayID==gatewayID)
+ {
+ equal= equal && pCF.compareGateway(listIterator,gateway);
+ }
+
+ if(listIterator->gatewayID==gatewayID1)
+ {
+ equal= equal && pCF.compareGateway(listIterator,gateway1);
+ }
+
+ if(listIterator->gatewayID==gatewayID2)
+ {
+ equal= equal && pCF.compareGateway(listIterator,gateway2);
+ }
+ }
+
+ ASSERT_EQ(true,equal);
+}
+
+TEST_F(databaseTest,getGatewayInfo)
+{
+ //initialize gateway
+ std::vector<am_Gateway_s> returnList;
+ am_Gateway_s gateway, gateway1, gateway2;
+ am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
+
+ pCF.createGateway(gateway);
+ pCF.createGateway(gateway1);
+ gateway1.gatewayID=20;
+ pCF.createGateway(gateway2);
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
+ ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))<< "ERROR: database error";
+ ASSERT_EQ(gateway1.gatewayID,gatewayID1)<< "ERROR: domainID zero";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))<< "ERROR: database error";
+ ASSERT_EQ(101,gatewayID2)<< "ERROR: domainID zero";
+
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(returnList));
+ bool equal=true;
+ std::vector<am_Gateway_s>::iterator listIterator=returnList.begin();
+
+ for(;listIterator<returnList.end();++listIterator)
+ {
+ if(listIterator->gatewayID==gatewayID)
+ {
+ equal= equal && pCF.compareGateway(listIterator,gateway);
+ }
+
+ if(listIterator->gatewayID==gatewayID1)
+ {
+ equal= equal && pCF.compareGateway(listIterator,gateway1);
+ }
+
+ if(listIterator->gatewayID==gatewayID2)
+ {
+ equal= equal && pCF.compareGateway(listIterator,gateway2);
+ }
+ }
+
+ ASSERT_EQ(true,equal);
+
+ am_Gateway_s gatewayInfo;
+ ASSERT_EQ(E_OK,pDatabaseHandler.getGatewayInfoDB(20,gatewayInfo));
+ ASSERT_TRUE(pCF.compareGateway1(gateway1,gatewayInfo));
+
+}
+
+TEST_F(databaseTest,enterSinkThatAlreadyExistFail)
+{
+ //fill the connection database
+ am_Sink_s staticSink,SecondSink;
+ am_sinkID_t staticSinkID,SecondSinkID;
+
+ pCF.createSink(staticSink);
+ staticSink.sinkID=43;
+ staticSink.name="Static";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
+ ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
+
+ pCF.createSink(SecondSink);
+ SecondSink.sinkID=43;
+ SecondSink.name="SecondSink";
+
+ ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSinkDB(SecondSink,SecondSinkID))<< "ERROR: database error";
+}
+
+TEST_F(databaseTest,enterSourcesThatAlreadyExistFail)
+{
+ //fill the connection database
+ am_Source_s staticSource,SecondSource;
+ am_sourceID_t staticSourceID,SecondSourceID;
+ pCF.createSource(staticSource);
+ staticSource.sourceID=4;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
+ ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
+
+ pCF.createSource(SecondSource);
+ SecondSource.sourceID=4;
+
+ ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSourceDB(SecondSource,SecondSourceID))<< "ERROR: database error";
+}
+
+TEST_F(databaseTest,registerDomainCorrect)
+{
+ //initialize domain
+ std::vector<am_Domain_s> returnList;
+ am_Domain_s domain;
+ am_domainID_t domainID=0;
+ pCF.createDomain(domain);
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
+ ASSERT_NE(0,domainID)<< "ERROR: domainID zero";
+
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(returnList));
+ bool equal=true;
+ std::vector<am_Domain_s>::iterator listIterator=returnList.begin();
+ for(;listIterator<returnList.end();++listIterator)
+ {
+ if(listIterator->domainID==domainID) {
+ equal= equal && (listIterator->name.compare(domain.name)==0)
+ && (listIterator->busname.compare(domain.busname)==0)
+ && (listIterator->complete == domain.complete)
+ && (listIterator->early == domain.early)
+ && (listIterator->state == domain.state);
+ }
+ }
+ ASSERT_EQ(true,equal);
+}
+
+TEST_F(databaseTest,registerConnectionCorrect)
+{
+ am_Connection_s connection;
+ am_connectionID_t connectionID;
+ std::vector<am_Connection_s> returnList;
+ pCF.createConnection(connection);
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))<< "ERROR: database error";;
+ ASSERT_NE(0,connectionID)<< "ERROR: connectionID zero";
+
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(returnList));
+ bool equal=false;
+ std::vector<am_Connection_s>::iterator listIterator=returnList.begin();
+ for(;listIterator<returnList.end();++listIterator)
+ {
+ if(listIterator->connectionID==connectionID) {
+ equal= (listIterator->sourceID == connection.sourceID)
+ && (listIterator->sinkID == connection.sinkID)
+ && (listIterator->delay == connection.delay)
+ && (listIterator->connectionFormat = connection.connectionFormat);
+ }
+ }
+ ASSERT_EQ(true,equal);
+}
+
+TEST_F(databaseTest,enterMainConnectionCorrect)
+{
+ createMainConnectionSetup();
+}
+
+TEST_F(databaseTest,enterSinksCorrect)
+{
+ //fill the connection database
+ am_Sink_s staticSink,firstDynamicSink,secondDynamicSink;
+ am_sinkID_t staticSinkID,firstDynamicSinkID,secondDynamicSinkID;
+ std::vector<am_Sink_s> sinkList;
+
+ pCF.createSink(staticSink);
+ staticSink.sinkID=4;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
+ ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
+
+ pCF.createSink(firstDynamicSink);
+ firstDynamicSink.name="firstdynamic";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(firstDynamicSink,firstDynamicSinkID))<< "ERROR: database error";
+ ASSERT_EQ(firstDynamicSinkID,DYNAMIC_ID_BOUNDARY)<< "ERROR: ID not the one given in firstDynamicSink";
+
+ pCF.createSink(secondDynamicSink);
+ secondDynamicSink.name="seconddynamic";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(secondDynamicSink,secondDynamicSinkID))<< "ERROR: database error";
+ ASSERT_NEAR(secondDynamicSinkID,DYNAMIC_ID_BOUNDARY,10)<< "ERROR: ID not the one given in secondDynamicSink";
+
+ //now read back and check the returns agains the given values
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(sinkList))<< "ERROR: database error";
+ bool equal=true;
+
+ std::vector<am_Sink_s>::iterator listIterator=sinkList.begin();
+ for(;listIterator<sinkList.end();++listIterator)
+ {
+ if(listIterator->sinkID==staticSinkID)
+ {
+ equal = equal && pCF.compareSink(listIterator,staticSink);
+ }
+
+ if(listIterator->sinkID==firstDynamicSinkID)
+ {
+ equal = equal && pCF.compareSink(listIterator,firstDynamicSink);
+ }
+
+ if(listIterator->sinkID==secondDynamicSinkID)
+ {
+ equal = equal && pCF.compareSink(listIterator,secondDynamicSink);
+ }
+ }
+ ASSERT_EQ(true,equal);
+}
+
+//Commented out - gives always a warning..
+//TEST_F(databaseTest,registerDomainFailonID0)
+//{
+// am_Domain_s domain;
+// am_domainID_t domainID=5;
+// pCF.createDomain(domain);
+// domain.domainID=1;
+// ASSERT_DEATH(pDatabaseHandler.enterDomainDB(domain,domainID),"Assertion `domainData.domainID==0'");
+//}
+
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+
+
+
+
+
+
+
+
+
diff --git a/AudioManagerDaemon/test/database/databaseTest.h b/AudioManagerDaemon/test/database/databaseTest.h
new file mode 100644
index 0000000..3255b71
--- /dev/null
+++ b/AudioManagerDaemon/test/database/databaseTest.h
@@ -0,0 +1,37 @@
+/*
+ * databasetest.h
+ *
+ * Created on: Dec 6, 2011
+ * Author: christian
+ */
+
+#ifndef DATABASETEST_H_
+#define DATABASETEST_H_
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <dlt/dlt.h>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "DatabaseHandler.h"
+#include "../CommonFunctions.h"
+
+DLT_DECLARE_CONTEXT(AudioManager)
+
+using namespace testing;
+
+class databaseTest : public Test {
+public:
+
+ DatabaseHandler pDatabaseHandler;
+ CommonFunctions pCF;
+
+ void SetUp();
+ void TearDown();
+
+ void createMainConnectionSetup();
+};
+
+#endif /* DATABASETEST_H_ */