2ed2c9bf1abff19f4630fd288f965649e1de68c9
[profile/ivi/audiomanager.git] / AudioManagerDaemon / test / routing / routingTest.cpp
1 /**
2  * Copyright (C) 2011, BMW AG
3  *
4  * GeniviAudioMananger AudioManagerDaemon
5  *
6  * \file databasetest.cpp
7  *
8  * \date 20-Oct-2011 3:42:04 PM
9  * \author Christian Mueller (christian.ei.mueller@bmw.de)
10  *
11  * \section License
12  * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
13  * Copyright (C) 2011, BMW AG Christian Mueller  Christian.ei.mueller@bmw.de
14  *
15  * 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.
16  * 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.
17  * 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>.
18  * 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.
19  * 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.
20  * 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.
21  * 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.
22  *
23  * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
24  */
25
26 #include "routingTest.h"
27 #include "MockInterfaces.h"
28 #include "DatabaseHandler.h"
29 #include "ControlReceiver.h"
30 #include "ControlSender.h"
31 #include "DatabaseObserver.h"
32 #include "Router.h"
33 #include "../ControlInterfaceBackdoor.h"
34 #include "../CommandInterfaceBackdoor.h"
35 #include "../CommonFunctions.h"
36 #include <string.h>
37
38 using namespace am;
39 using namespace testing;
40
41 DLT_DECLARE_CONTEXT(DLT_CONTEXT)
42
43 routingTest::routingTest() :
44         plistRoutingPluginDirs(), //
45         plistCommandPluginDirs(), //
46         pDatabaseHandler(std::string(":memory:")), //
47         pControlSender(std::string("")), //
48         pRouter(&pDatabaseHandler,&pControlSender), //
49         pRoutingSender(plistRoutingPluginDirs), //
50         pCommandSender(plistCommandPluginDirs), //
51         pMockInterface(), //
52         pMockControlInterface(), //
53         pRoutingInterfaceBackdoor(), //
54         pCommandInterfaceBackdoor(), //
55         pControlInterfaceBackdoor(), //
56         pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pRouter), //
57         pObserver(&pCommandSender, &pRoutingSender)
58 {
59     pDatabaseHandler.registerObserver(&pObserver);
60     pCommandInterfaceBackdoor.injectInterface(&pCommandSender, &pMockInterface);
61     pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
62 }
63
64 routingTest::~routingTest()
65 {
66 }
67
68 void routingTest::SetUp()
69 {
70     DLT_REGISTER_APP("Dtest", "AudioManagerDeamon");
71     DLT_REGISTER_CONTEXT(DLT_CONTEXT, "Main", "Main Context");
72     DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("Database Test started "));
73 }
74
75 void routingTest::TearDown()
76 {
77     DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
78 }
79
80 ACTION(returnConnectionFormat)
81 {
82     arg3=arg2;
83 }
84
85 //test that checks 3 domains, one sink one source but the connectionformat of third domains do not fit.
86 TEST_F(routingTest,simpleRoute3DomainsNoConnection)
87 {
88     EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
89     EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
90     EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(),Return(E_OK)));
91
92     //initialize 2 domains
93     am_Domain_s domain1, domain2, domain3;
94     am_domainID_t domainID1, domainID2, domainID3;
95
96     domain1.domainID = 0;
97     domain1.name = "domain1";
98     domain1.busname = "domain1bus";
99     domain1.state = DS_CONTROLLED;
100     domain2.domainID = 0;
101     domain2.name = "domain2";
102     domain2.busname = "domain2bus";
103     domain2.state = DS_CONTROLLED;
104     domain3.domainID = 0;
105     domain3.name = "domain3";
106     domain3.busname = "domain3bus";
107     domain3.state = DS_CONTROLLED;
108
109     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
110     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
111     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
112
113     am_Source_s source, gwSource, gwSource1;
114     am_sourceID_t sourceID, gwSourceID, gwSourceID1;
115
116     source.domainID = domainID1;
117     source.name = "source1";
118     source.sourceState = SS_ON;
119     source.sourceID = 0;
120     source.sourceClassID = 5;
121     source.listConnectionFormats.push_back(CF_MONO);
122
123     gwSource.domainID = domainID2;
124     gwSource.name = "gwsource1";
125     gwSource.sourceState = SS_ON;
126     gwSource.sourceID = 0;
127     gwSource.sourceClassID = 5;
128     gwSource.listConnectionFormats.push_back(CF_ANALOG);
129
130     gwSource1.domainID = domainID3;
131     gwSource1.name = "gwsource2";
132     gwSource1.sourceState = SS_ON;
133     gwSource1.sourceID = 0;
134     gwSource1.sourceClassID = 5;
135     gwSource1.listConnectionFormats.push_back(CF_MONO);
136
137     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
138     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
139     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
140
141     am_Sink_s sink, gwSink, gwSink1;
142     am_sinkID_t sinkID, gwSinkID, gwSinkID1;
143
144     sink.domainID = domainID3;
145     sink.name = "sink1";
146     sink.sinkID = 0;
147     sink.sinkClassID = 5;
148     sink.muteState = MS_MUTED;
149     sink.listConnectionFormats.push_back(CF_STEREO);
150
151     gwSink.domainID = domainID1;
152     gwSink.name = "gwSink";
153     gwSink.sinkID = 0;
154     gwSink.sinkClassID = 5;
155     gwSink.muteState = MS_MUTED;
156     gwSink.listConnectionFormats.push_back(CF_MONO);
157
158     gwSink1.domainID = domainID2;
159     gwSink1.name = "gwSink1";
160     gwSink1.sinkID = 0;
161     gwSink1.sinkClassID = 5;
162     gwSink1.muteState = MS_MUTED;
163     gwSink1.listConnectionFormats.push_back(CF_ANALOG);
164
165     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
166     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
167     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
168
169     am_Gateway_s gateway, gateway1;
170     am_gatewayID_t gatewayID, gatewayID1;
171
172     gateway.controlDomainID = domainID1;
173     gateway.gatewayID = 0;
174     gateway.sinkID = gwSinkID;
175     gateway.sourceID = gwSourceID;
176     gateway.domainSourceID = domainID2;
177     gateway.domainSinkID = domainID1;
178     gateway.listSinkFormats = gwSink.listConnectionFormats;
179     gateway.listSourceFormats = gwSource.listConnectionFormats;
180     gateway.convertionMatrix.push_back(true);
181     gateway.name = "gateway";
182
183     gateway1.controlDomainID = domainID2;
184     gateway1.gatewayID = 0;
185     gateway1.sinkID = gwSinkID1;
186     gateway1.sourceID = gwSourceID1;
187     gateway1.domainSourceID = domainID3;
188     gateway1.domainSinkID = domainID2;
189     gateway1.listSinkFormats = gwSink1.listConnectionFormats;
190     gateway1.listSourceFormats = gwSource1.listConnectionFormats;
191     gateway1.convertionMatrix.push_back(true);
192     gateway1.name = "gateway";
193
194     ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
195     ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
196
197     std::vector<am_Route_s> listRoutes;
198     std::vector<am_RoutingElement_s> listRoutingElements;
199     am_RoutingElement_s hopp1;
200     am_RoutingElement_s hopp2;
201     am_RoutingElement_s hopp3;
202
203     hopp1.sourceID = sourceID;
204     hopp1.sinkID = gwSinkID;
205     hopp1.domainID = domainID1;
206     hopp1.connectionFormat = source.listConnectionFormats[0];
207
208     hopp2.sourceID = gwSourceID;
209     hopp2.sinkID = gwSinkID1;
210     hopp2.domainID = domainID2;
211     hopp2.connectionFormat = gwSink1.listConnectionFormats[0];
212
213     hopp3.sourceID = gwSourceID1;
214     hopp3.sinkID = sinkID;
215     hopp3.domainID = domainID3;
216     hopp3.connectionFormat = sink.listConnectionFormats[0];
217
218     listRoutingElements.push_back(hopp1);
219     listRoutingElements.push_back(hopp2);
220     listRoutingElements.push_back(hopp3);
221
222     am_Route_s compareRoute;
223     compareRoute.route = listRoutingElements;
224     compareRoute.sinkID = sinkID;
225     compareRoute.sourceID = sourceID;
226
227     ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
228     ASSERT_EQ(0, listRoutes.size());
229 }
230 //test that checks just 2 domains, one sink one source with only one connection format each
231 TEST_F(routingTest,simpleRoute2Domains)
232 {
233     EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
234     EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
235     EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(),Return(E_OK)));
236
237     //initialize 2 domains
238     am_Domain_s domain1, domain2;
239     am_domainID_t domainID1, domainID2;
240
241     domain1.domainID = 0;
242     domain1.name = "domain1";
243     domain1.busname = "domain1bus";
244     domain1.state = DS_CONTROLLED;
245     domain2.domainID = 0;
246     domain2.name = "domain2";
247     domain2.busname = "domain2bus";
248     domain2.state = DS_CONTROLLED;
249
250     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
251     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
252
253     am_Source_s source, gwSource;
254     am_sourceID_t sourceID, gwSourceID;
255
256     source.domainID = domainID1;
257     source.name = "source1";
258     source.sourceState = SS_ON;
259     source.sourceID = 0;
260     source.sourceClassID = 5;
261     source.listConnectionFormats.push_back(CF_ANALOG);
262
263     gwSource.domainID = domainID2;
264     gwSource.name = "gwsource1";
265     gwSource.sourceState = SS_ON;
266     gwSource.sourceID = 0;
267     gwSource.sourceClassID = 5;
268     gwSource.listConnectionFormats.push_back(CF_MONO);
269
270     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
271     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
272
273     am_Sink_s sink, gwSink;
274     am_sinkID_t sinkID, gwSinkID;
275
276     sink.domainID = domainID2;
277     sink.name = "sink1";
278     sink.sinkID = 0;
279     sink.sinkClassID = 5;
280     sink.muteState = MS_MUTED;
281     sink.listConnectionFormats.push_back(CF_MONO);
282
283     gwSink.domainID = domainID1;
284     gwSink.name = "gwSink";
285     gwSink.sinkID = 0;
286     gwSink.sinkClassID = 5;
287     gwSink.muteState = MS_MUTED;
288     gwSink.listConnectionFormats.push_back(CF_ANALOG);
289
290     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
291     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
292
293     am_Gateway_s gateway;
294     am_gatewayID_t gatewayID;
295
296     gateway.controlDomainID = domainID1;
297     gateway.gatewayID = 0;
298     gateway.sinkID = gwSinkID;
299     gateway.sourceID = gwSourceID;
300     gateway.domainSourceID = domainID2;
301     gateway.domainSinkID = domainID1;
302     gateway.listSinkFormats = gwSink.listConnectionFormats;
303     gateway.listSourceFormats = gwSource.listConnectionFormats;
304     gateway.convertionMatrix.push_back(true);
305     gateway.name = "gateway";
306
307     ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
308
309     std::vector<am_Route_s> listRoutes;
310     std::vector<am_RoutingElement_s> listRoutingElements;
311     am_RoutingElement_s hopp1;
312     am_RoutingElement_s hopp2;
313
314     hopp1.sinkID = gwSinkID;
315     hopp1.sourceID = sourceID;
316     hopp1.domainID = domainID1;
317     hopp1.connectionFormat = source.listConnectionFormats[0];
318
319     hopp2.sinkID = sinkID;
320     hopp2.sourceID = gwSourceID;
321     hopp2.domainID = domainID2;
322     hopp2.connectionFormat = sink.listConnectionFormats[0];
323
324     listRoutingElements.push_back(hopp1);
325     listRoutingElements.push_back(hopp2);
326
327     am_Route_s compareRoute;
328     compareRoute.route = listRoutingElements;
329     compareRoute.sinkID = sinkID;
330     compareRoute.sourceID = sourceID;
331
332     ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
333     ASSERT_EQ(1, listRoutes.size());
334     ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
335
336 }
337
338 //test that checks just 2 domains, one sink one source but the connectionformat of source
339 TEST_F(routingTest,simpleRoute2DomainsNoMatchConnectionFormats)
340 {
341     EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
342     EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
343     EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(),Return(E_OK)));
344
345     //initialize 2 domains
346     am_Domain_s domain1, domain2;
347     am_domainID_t domainID1, domainID2;
348
349     domain1.domainID = 0;
350     domain1.name = "domain1";
351     domain1.busname = "domain1bus";
352     domain1.state = DS_CONTROLLED;
353     domain2.domainID = 0;
354     domain2.name = "domain2";
355     domain2.busname = "domain2bus";
356     domain2.state = DS_CONTROLLED;
357
358     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
359     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
360
361     am_Source_s source, gwSource;
362     am_sourceID_t sourceID, gwSourceID;
363
364     source.domainID = domainID1;
365     source.name = "source1";
366     source.sourceState = SS_ON;
367     source.sourceID = 0;
368     source.sourceClassID = 5;
369     source.listConnectionFormats.push_back(CF_STEREO);
370
371     gwSource.domainID = domainID2;
372     gwSource.name = "gwsource1";
373     gwSource.sourceState = SS_ON;
374     gwSource.sourceID = 0;
375     gwSource.sourceClassID = 5;
376     gwSource.listConnectionFormats.push_back(CF_MONO);
377
378     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
379     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
380
381     am_Sink_s sink, gwSink;
382     am_sinkID_t sinkID, gwSinkID;
383
384     sink.domainID = domainID2;
385     sink.name = "sink1";
386     sink.sinkID = 0;
387     sink.sinkClassID = 5;
388     sink.muteState = MS_MUTED;
389     sink.listConnectionFormats.push_back(CF_MONO);
390
391     gwSink.domainID = domainID1;
392     gwSink.name = "gwSink";
393     gwSink.sinkID = 0;
394     gwSink.sinkClassID = 5;
395     gwSink.muteState = MS_MUTED;
396     gwSink.listConnectionFormats.push_back(CF_ANALOG);
397
398     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
399     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
400
401     am_Gateway_s gateway;
402     am_gatewayID_t gatewayID;
403
404     gateway.controlDomainID = domainID1;
405     gateway.gatewayID = 0;
406     gateway.sinkID = gwSinkID;
407     gateway.sourceID = gwSourceID;
408     gateway.domainSourceID = domainID2;
409     gateway.domainSinkID = domainID1;
410     gateway.listSinkFormats = gwSink.listConnectionFormats;
411     gateway.listSourceFormats = gwSource.listConnectionFormats;
412     gateway.convertionMatrix.push_back(true);
413     gateway.name = "gateway";
414
415     ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
416
417     std::vector<am_Route_s> listRoutes;
418     std::vector<am_RoutingElement_s> listRoutingElements;
419     am_RoutingElement_s hopp1;
420     am_RoutingElement_s hopp2;
421
422     hopp1.sinkID = gwSinkID;
423     hopp1.sourceID = sourceID;
424     hopp1.domainID = domainID1;
425     hopp1.connectionFormat = source.listConnectionFormats[0];
426
427     hopp2.sinkID = sinkID;
428     hopp2.sourceID = gwSourceID;
429     hopp2.domainID = domainID2;
430     hopp2.connectionFormat = sink.listConnectionFormats[0];
431
432     listRoutingElements.push_back(hopp1);
433     listRoutingElements.push_back(hopp2);
434
435     am_Route_s compareRoute;
436     compareRoute.route = listRoutingElements;
437     compareRoute.sinkID = sinkID;
438     compareRoute.sourceID = sourceID;
439
440     ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
441     ASSERT_EQ(0, listRoutes.size());
442 }
443
444 //test that checks 3 domains, one sink one source.
445 TEST_F(routingTest,simpleRoute3Domains)
446 {
447     EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
448     EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
449     EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(),Return(E_OK)));
450
451     //initialize 2 domains
452     am_Domain_s domain1, domain2, domain3;
453     am_domainID_t domainID1, domainID2, domainID3;
454
455     domain1.domainID = 0;
456     domain1.name = "domain1";
457     domain1.busname = "domain1bus";
458     domain1.state = DS_CONTROLLED;
459     domain2.domainID = 0;
460     domain2.name = "domain2";
461     domain2.busname = "domain2bus";
462     domain2.state = DS_CONTROLLED;
463     domain3.domainID = 0;
464     domain3.name = "domain3";
465     domain3.busname = "domain3bus";
466     domain3.state = DS_CONTROLLED;
467
468     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
469     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
470     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
471
472     am_Source_s source, gwSource, gwSource1;
473     am_sourceID_t sourceID, gwSourceID, gwSourceID1;
474
475     source.domainID = domainID1;
476     source.name = "source1";
477     source.sourceState = SS_ON;
478     source.sourceID = 0;
479     source.sourceClassID = 5;
480     source.listConnectionFormats.push_back(CF_MONO);
481
482     gwSource.domainID = domainID2;
483     gwSource.name = "gwsource1";
484     gwSource.sourceState = SS_ON;
485     gwSource.sourceID = 0;
486     gwSource.sourceClassID = 5;
487     gwSource.listConnectionFormats.push_back(CF_ANALOG);
488
489     gwSource1.domainID = domainID3;
490     gwSource1.name = "gwsource2";
491     gwSource1.sourceState = SS_ON;
492     gwSource1.sourceID = 0;
493     gwSource1.sourceClassID = 5;
494     gwSource1.listConnectionFormats.push_back(CF_MONO);
495
496     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
497     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
498     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
499
500     am_Sink_s sink, gwSink, gwSink1;
501     am_sinkID_t sinkID, gwSinkID, gwSinkID1;
502
503     sink.domainID = domainID3;
504     sink.name = "sink1";
505     sink.sinkID = 0;
506     sink.sinkClassID = 5;
507     sink.muteState = MS_MUTED;
508     sink.listConnectionFormats.push_back(CF_MONO);
509
510     gwSink.domainID = domainID1;
511     gwSink.name = "gwSink";
512     gwSink.sinkID = 0;
513     gwSink.sinkClassID = 5;
514     gwSink.muteState = MS_MUTED;
515     gwSink.listConnectionFormats.push_back(CF_MONO);
516
517     gwSink1.domainID = domainID2;
518     gwSink1.name = "gwSink1";
519     gwSink1.sinkID = 0;
520     gwSink1.sinkClassID = 5;
521     gwSink1.muteState = MS_MUTED;
522     gwSink1.listConnectionFormats.push_back(CF_ANALOG);
523
524     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
525     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
526     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
527
528     am_Gateway_s gateway, gateway1;
529     am_gatewayID_t gatewayID, gatewayID1;
530
531     gateway.controlDomainID = domainID1;
532     gateway.gatewayID = 0;
533     gateway.sinkID = gwSinkID;
534     gateway.sourceID = gwSourceID;
535     gateway.domainSourceID = domainID2;
536     gateway.domainSinkID = domainID1;
537     gateway.listSinkFormats = gwSink.listConnectionFormats;
538     gateway.listSourceFormats = gwSource.listConnectionFormats;
539     gateway.convertionMatrix.push_back(true);
540     gateway.name = "gateway";
541
542     gateway1.controlDomainID = domainID2;
543     gateway1.gatewayID = 0;
544     gateway1.sinkID = gwSinkID1;
545     gateway1.sourceID = gwSourceID1;
546     gateway1.domainSourceID = domainID3;
547     gateway1.domainSinkID = domainID2;
548     gateway1.listSinkFormats = gwSink1.listConnectionFormats;
549     gateway1.listSourceFormats = gwSource1.listConnectionFormats;
550     gateway1.convertionMatrix.push_back(true);
551     gateway1.name = "gateway";
552
553     ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
554     ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
555
556     std::vector<am_Route_s> listRoutes;
557     std::vector<am_RoutingElement_s> listRoutingElements;
558     am_RoutingElement_s hopp1;
559     am_RoutingElement_s hopp2;
560     am_RoutingElement_s hopp3;
561
562     hopp1.sourceID = sourceID;
563     hopp1.sinkID = gwSinkID;
564     hopp1.domainID = domainID1;
565     hopp1.connectionFormat = source.listConnectionFormats[0];
566
567     hopp2.sourceID = gwSourceID;
568     hopp2.sinkID = gwSinkID1;
569     hopp2.domainID = domainID2;
570     hopp2.connectionFormat = gwSink1.listConnectionFormats[0];
571
572     hopp3.sourceID = gwSourceID1;
573     hopp3.sinkID = sinkID;
574     hopp3.domainID = domainID3;
575     hopp3.connectionFormat = sink.listConnectionFormats[0];
576
577     listRoutingElements.push_back(hopp1);
578     listRoutingElements.push_back(hopp2);
579     listRoutingElements.push_back(hopp3);
580
581     am_Route_s compareRoute;
582     compareRoute.route = listRoutingElements;
583     compareRoute.sinkID = sinkID;
584     compareRoute.sourceID = sourceID;
585
586     ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
587     ASSERT_EQ(1, listRoutes.size());
588     ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
589 }
590
591 int main(int argc, char **argv)
592 {
593     ::testing::InitGoogleTest(&argc, argv);
594     return RUN_ALL_TESTS();
595 }
596