Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/kernel.git] / src / LifeCycleCORBA / Test / LifeCycleCORBATest.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20
21 #include "LifeCycleCORBATest.hxx"
22 #include "SALOME_LifeCycleCORBA.hxx"
23 #include "SALOME_FileTransferCORBA.hxx"
24 #include "Utils_ORB_INIT.hxx"
25 #include "Utils_SINGLETON.hxx"
26 #include "OpUtil.hxx"
27
28 #include <iostream>
29 #include <fstream>
30 #include <string>
31 #include <cstdlib>
32
33 using namespace std;
34
35 // --- uncomment to have some traces on standard error
36 //     (useful only when adding new tests...)
37 //#define _DEVDEBUG_
38
39 #ifdef _DEVDEBUG_
40 #define MYDEVTRACE {std::cerr << __FILE__ << " [" << __LINE__ << "] : ";}
41 #define DEVTRACE(msg) {MYDEVTRACE; std::cerr<<msg<<std::endl<<std::flush;}
42 #else
43 #define MYDEVTRACE
44 #define DEVTRACE(msg)
45 #endif
46
47 #define TRACEFILE "/tmp/traceUnitTest.log"
48
49 // ============================================================================
50 /*!
51  * Set Trace mecanism
52  * - delete preexisting trace classes if any
53  * - set trace on file
54  * Get or initialize the orb
55  * Create a SALOME_NamingService instance
56  */
57 // ============================================================================
58
59 void 
60 LifeCycleCORBATest::setUp()
61 {
62   LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
63   CPPUNIT_ASSERT(bp1);
64   bp1->deleteInstance(bp1);
65
66   // --- trace on file
67   char *theFileName = TRACEFILE;
68
69   string s = "file:";
70   s += theFileName;
71   //s="local";
72   //s="with_logger";
73   CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
74
75   ofstream traceFile;
76   //  traceFile.open(theFileName, ios::out | ios::trunc);
77   traceFile.open(theFileName, ios::out | ios::app);
78   CPPUNIT_ASSERT(traceFile); // file created empty, then closed
79   traceFile.close();
80
81   bp1 = LocalTraceBufferPool::instance();
82   CPPUNIT_ASSERT(bp1);
83
84   // --- Get or initialize the orb
85
86   int _argc = 1;
87   char* _argv[] = {""};
88   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
89   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
90   _orb = init(_argc , _argv ) ;
91
92   // --- Create a SALOME_NamingService instance
93
94   _NS.init_orb(_orb) ;
95 }
96
97 // ============================================================================
98 /*!
99  *  - delete trace classes
100  */
101 // ============================================================================
102
103 void 
104 LifeCycleCORBATest::tearDown()
105 {
106
107   LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
108   CPPUNIT_ASSERT(bp1);
109   bp1->deleteInstance(bp1);
110 }
111
112 // ============================================================================
113 /*!
114  * Check FindOrLoad_Component.
115  * - get a local container (no hostname given),
116  *       load an engine, check that the CORBA object is not null.
117  * - check narrow
118  */
119 // ============================================================================
120
121 void
122 LifeCycleCORBATest::testFindOrLoad_Component_LaunchContainer()
123 {
124   SALOME_LifeCycleCORBA _LCC(&_NS);
125
126   // --- get a local container,
127   //     load an engine, check that the CORBA object is not null
128
129   string containerName = "myContainer";
130   Engines::Component_var mycompo =
131     _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
132   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo));
133
134   // --- check narrow
135
136   Engines::TestComponent_var m1;
137   m1 = Engines::TestComponent::_narrow(mycompo);
138   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
139 }
140
141 // ============================================================================
142 /*!
143  * Check FindOrLoad_Component.
144  * - Call 2 times FindOrLoad_Component with the same parameters
145  * - check if we get the same engine
146  */
147 // ============================================================================
148
149 void
150 LifeCycleCORBATest::testFindOrLoad_Component_SameInstance()
151 {
152   SALOME_LifeCycleCORBA _LCC(&_NS);
153
154   // --- get a local container,
155   //     load an engine, check that the CORBA object is not null
156
157   string containerName = "myContainer";
158
159   Engines::Component_var mycompo1 =
160     _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
161   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
162
163   Engines::Component_var mycompo2 =
164     _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
165   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo2));
166
167   // --- check narrow
168
169   Engines::TestComponent_var m1;
170   m1 = Engines::TestComponent::_narrow(mycompo1);
171   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
172
173   Engines::TestComponent_var m2;
174   m2 = Engines::TestComponent::_narrow(mycompo2);
175   CPPUNIT_ASSERT(!CORBA::is_nil(m2));
176
177   // --- check equality of instance names
178
179   string name1 = m1->instanceName();
180   string name2 = m2->instanceName();
181   CPPUNIT_ASSERT_EQUAL(name1, name2);
182 }
183
184 // ============================================================================
185 /*!
186  * Check FindOrLoad_Component with Python Component on C++ Container
187  *       load an engine, check that the CORBA object is not null.
188  * - check narrow
189  */
190 // ============================================================================
191
192 void
193 LifeCycleCORBATest::testFindOrLoad_Component_PythonInCppContainer()
194 {
195   SALOME_LifeCycleCORBA _LCC(&_NS);
196
197   // --- get a local container,
198   //     load an engine, check that the CORBA object is not null
199
200   string containerName = "myContainer";
201
202   Engines::Component_var mycompo1 =
203     _LCC.FindOrLoad_Component(containerName.c_str(),"SALOME_TestComponentPy");
204   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
205
206   // --- check narrow
207
208   Engines::TestComponent_var m1;
209   m1 = Engines::TestComponent::_narrow(mycompo1);
210   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
211 }
212
213 // ============================================================================
214 /*!
215  * Check FindOrLoad_Component with Python Component on C++ Container
216  * - Call 2 times FindOrLoad_Component with the same parameters
217  * - check if we get the same engine
218  */
219 // ============================================================================
220
221 void
222 LifeCycleCORBATest::testFindOrLoad_Component_PythonSameInstance()
223 {
224   SALOME_LifeCycleCORBA _LCC(&_NS);
225
226   // --- get a local container (with a name based on local hostname),
227   //     load an engine, check that the CORBA object is not null
228
229   string containerName = "myContainer";
230
231   Engines::Component_var mycompo1 =
232     _LCC.FindOrLoad_Component(containerName.c_str(),"SALOME_TestComponentPy");
233   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
234
235   Engines::Component_var mycompo2 =
236     _LCC.FindOrLoad_Component(containerName.c_str(),"SALOME_TestComponentPy");
237   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo2));
238
239   // --- check narrow
240
241   Engines::TestComponent_var m1;
242   m1 = Engines::TestComponent::_narrow(mycompo1);
243   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
244
245   Engines::TestComponent_var m2;
246   m2 = Engines::TestComponent::_narrow(mycompo2);
247   CPPUNIT_ASSERT(!CORBA::is_nil(m2));
248
249   // --- check equality of instance names
250
251   string name1 = m1->instanceName();
252   string name2 = m2->instanceName();
253   CPPUNIT_ASSERT_EQUAL(name1, name2);
254 }
255
256 // ============================================================================
257 /*!
258  * Check FindOrLoad_Component with a component name not in catalog.
259  * See list of catalog given to module catalog server.
260  * Here, we work with KERNEL_SRC/resources/KERNELCatalog.xml that contains 
261  * only KERNEL, SalomeTestComponent and SALOME_TestComponentPy
262  */
263 // ============================================================================
264
265 void
266 LifeCycleCORBATest::testFindOrLoad_Component_UnknownInCatalog()
267 {
268   SALOME_LifeCycleCORBA _LCC(&_NS);
269
270   // --- get a local container (with a name based on local hostname),
271   //     load an engine, check that the CORBA object is not null
272
273   string containerName = "myContainer";
274
275   Engines::Component_var mycompo1 =
276     _LCC.FindOrLoad_Component(containerName.c_str(),"MyNewComponent");
277   CPPUNIT_ASSERT(CORBA::is_nil(mycompo1));
278 }
279
280 // ============================================================================
281 /*!
282  * Check FindOrLoad_Component with hostname given
283  * - get a local container : getHostName()/componentName,
284  *       load an engine, check that the CORBA object is not null.
285  * - check narrow
286  */
287 // ============================================================================
288
289 void
290 LifeCycleCORBATest::testFindOrLoad_Component_LaunchContainerHostname()
291 {
292   SALOME_LifeCycleCORBA _LCC(&_NS);
293
294   // --- get a local container (with a name based on local hostname),
295   //     load an engine, check that the CORBA object is not null
296
297   string containerName = GetHostname();
298   containerName += "/theContainer";
299   DEVTRACE("containerName = " << containerName);
300   Engines::Component_var mycompo =
301     _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
302   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo));
303
304   // --- check narrow
305
306   Engines::TestComponent_var m1;
307   m1 = Engines::TestComponent::_narrow(mycompo);
308   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
309 }
310
311 // ============================================================================
312 /*!
313  * Check FindOrLoad_Component with and without local hostname given.
314  * We must get the same container, the same instance of component
315  */
316 // ============================================================================
317
318 void
319 LifeCycleCORBATest::testFindOrLoad_Component_SameContainer()
320 {
321   SALOME_LifeCycleCORBA _LCC(&_NS);
322
323   // --- get a local container (with a name based on local hostname),
324   //     load an engine, check that the CORBA object is not null
325
326   string containerName = "aContainer";
327
328   Engines::Component_var mycompo1 =
329     _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
330   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
331
332   containerName = GetHostname();
333   containerName += "/aContainer";
334   DEVTRACE("containerName = " << containerName);
335   Engines::Component_var mycompo2 =
336     _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
337   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo2));
338
339   // --- check narrow
340
341   Engines::TestComponent_var m1;
342   m1 = Engines::TestComponent::_narrow(mycompo1);
343   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
344
345   Engines::TestComponent_var m2;
346   m2 = Engines::TestComponent::_narrow(mycompo2);
347   CPPUNIT_ASSERT(!CORBA::is_nil(m2));
348
349   // --- check equality of instance names
350
351   string name1 = m1->instanceName();
352   string name2 = m2->instanceName();
353   CPPUNIT_ASSERT_EQUAL(name1, name2);
354
355   // --- check containers are the same servant (same container name+hostname)
356
357   Engines::Container_var c1 = m1->GetContainerRef();
358   CPPUNIT_ASSERT(!CORBA::is_nil(c1));
359   Engines::Container_var c2 = m2->GetContainerRef();
360   CPPUNIT_ASSERT(!CORBA::is_nil(c1));
361   string cname1 = c1->name();
362   string cname2 = c2->name();
363   CPPUNIT_ASSERT_EQUAL(cname1, cname2);
364   string hostname1 = c1->getHostName();
365   string hostname2 = c2->getHostName();
366   CPPUNIT_ASSERT_EQUAL(hostname1, hostname2);
367   CORBA::Long pidc1 = c1->getPID();
368   CORBA::Long pidc2 = c2->getPID();
369   CPPUNIT_ASSERT_EQUAL(pidc1, pidc2);
370 }
371
372 // ============================================================================
373 /*!
374  * Check FindOrLoad_Component: check behaviour when ask for an unknown computer
375  * We must catch a Salome Exception with "unknown host" message
376  */
377 // ============================================================================
378
379 void
380 LifeCycleCORBATest::testFindOrLoad_Component_UnknownMachine()
381 {
382   SALOME_LifeCycleCORBA _LCC(&_NS);
383
384   // --- try to get a distant container on an unknown machine (not existing)
385   //     check that the CORBA object is null
386
387   string containerName = "aFarAwayComputer";
388   containerName += "/theContainer";
389 //   CPPUNIT_ASSERT_THROW(Engines::Component_var mycompo =
390 //                     _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");,SALOME::SALOME_Exception);
391   try
392     {
393       Engines::Component_var mycompo =
394         _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
395     }
396   catch(const SALOME::SALOME_Exception &ex)
397     {
398       CPPUNIT_ASSERT(true);
399 //       string expectedMessage = "BAD PARAM";
400 //       std::ostream os;
401 //       os << ex;
402 //       string actualMessage = os.str();
403 //       DEVTRACE("actual Exception Message = " << actualMessage);
404 //       CPPUNIT_ASSERT(actualMessage.find(expectedMessage) != string::npos);
405     }
406 }
407
408 // ============================================================================
409 /*!
410  * Check FindOrLoad_Component, empty params must give an instance
411  */
412 // ============================================================================
413
414 void
415 LifeCycleCORBATest::testFindOrLoad_Component_ParamsEmpty()
416 {
417   SALOME_LifeCycleCORBA _LCC(&_NS);
418
419   Engines::MachineParameters params;
420   _LCC.preSet(params);
421   Engines::Component_var mycompo =
422     _LCC.FindOrLoad_Component(params,"SalomeTestComponent");
423   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo));
424
425   // --- check narrow
426
427   Engines::TestComponent_var m1;
428   m1 = Engines::TestComponent::_narrow(mycompo);
429 }
430
431 // ============================================================================
432 /*!
433  * Check FindOrLoad_Component params = local container 
434  */
435 // ============================================================================
436
437 void
438 LifeCycleCORBATest::testFindOrLoad_Component_ParamsLocalContainer()
439 {
440   SALOME_LifeCycleCORBA _LCC(&_NS);
441
442   Engines::MachineParameters params;
443   _LCC.preSet(params);
444   string hostname=GetHostname();
445   params.hostname=hostname.c_str();
446   Engines::Component_var mycompo =
447     _LCC.FindOrLoad_Component(params,"SalomeTestComponent");
448   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo));
449
450   // --- check narrow
451
452   Engines::TestComponent_var m1;
453   m1 = Engines::TestComponent::_narrow(mycompo);
454
455   // --- check that container is on local computer
456
457   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
458   Engines::Container_var c1 = m1->GetContainerRef();
459   CPPUNIT_ASSERT(!CORBA::is_nil(c1));
460   string hostname1 = c1->getHostName();
461   CPPUNIT_ASSERT_EQUAL(hostname1, GetHostname());
462 }
463
464
465 // ============================================================================
466 /*!
467  * Check FindOrLoad_Component params = containerName
468  */
469 // ============================================================================
470
471 void
472 LifeCycleCORBATest::testFindOrLoad_Component_ParamsContainerName()
473 {
474   SALOME_LifeCycleCORBA _LCC(&_NS);
475
476   Engines::MachineParameters params;
477   _LCC.preSet(params);
478   string containerName = "myContainer";
479   params.container_name = containerName.c_str();
480   Engines::Component_var mycompo =
481     _LCC.FindOrLoad_Component(params,"SalomeTestComponent");
482   CPPUNIT_ASSERT(!CORBA::is_nil(mycompo));
483
484   // --- check narrow
485
486   Engines::TestComponent_var m1;
487   m1 = Engines::TestComponent::_narrow(mycompo);
488
489   // --- check that container has good name
490
491   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
492   Engines::Container_var c1 = m1->GetContainerRef();
493   CPPUNIT_ASSERT(!CORBA::is_nil(c1));
494   string hostname1 = c1->getHostName();
495   CPPUNIT_ASSERT_EQUAL(hostname1, GetHostname());
496   string cname1 = c1->name();
497   CPPUNIT_ASSERT(cname1.find(containerName) != string::npos);
498 }
499
500 // ============================================================================
501 /*!
502  * Check FindOrLoad_Component on remote computer
503  */
504 // ============================================================================
505
506 void
507 LifeCycleCORBATest::testFindOrLoad_Component_RemoteComputer()
508 {
509   SALOME_LifeCycleCORBA _LCC(&_NS);
510
511   string remoteHost = GetRemoteHost();
512
513   string containerName = remoteHost;
514   containerName += "/aContainer";
515   DEVTRACE("containerName = " << containerName);
516   Engines::Component_var mycompo1 =
517     _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
518   CPPUNIT_ASSERT_MESSAGE("Test validity requires connection to remote "\
519                          "computers from ResourcesCatalog",
520                          !CORBA::is_nil(mycompo1));
521
522   // --- check narrow
523
524   Engines::TestComponent_var m1;
525   m1 = Engines::TestComponent::_narrow(mycompo1);
526
527   // --- check that container is on good computer
528
529   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
530   Engines::Container_var c1 = m1->GetContainerRef();
531   CPPUNIT_ASSERT(!CORBA::is_nil(c1));
532   string hostname1 = c1->getHostName();
533   CPPUNIT_ASSERT_EQUAL(hostname1, remoteHost);
534 }
535
536 // ============================================================================
537 /*!
538  * Check FindOrLoad_Component with params on remote computer
539  * params empty except hostname 
540  */
541 // ============================================================================
542
543 void
544 LifeCycleCORBATest::testFindOrLoad_Component_ParamsRemoteComputer()
545 {
546   SALOME_LifeCycleCORBA _LCC(&_NS);
547
548   string remoteHost = GetRemoteHost();
549
550   Engines::MachineParameters params;
551   _LCC.preSet(params); 
552   params.hostname = remoteHost.c_str();
553
554   Engines::Component_var mycompo1 =
555     _LCC.FindOrLoad_Component(params,"SalomeTestComponent");
556   CPPUNIT_ASSERT_MESSAGE("Test validity requires connection to remote "\
557                          "computers from ResourcesCatalog",
558                          !CORBA::is_nil(mycompo1));
559
560   // --- check narrow
561
562   Engines::TestComponent_var m1;
563   m1 = Engines::TestComponent::_narrow(mycompo1);
564
565   // --- check that container is on good computer
566
567   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
568   Engines::Container_var c1 = m1->GetContainerRef();
569   CPPUNIT_ASSERT(!CORBA::is_nil(c1));
570   string hostname1 = c1->getHostName();
571   CPPUNIT_ASSERT_EQUAL(hostname1, remoteHost);
572 }
573
574 // ============================================================================
575 /*!
576  * Check FindOrLoad_Component with params on remote computer
577  * params empty except hostname and container_name
578  */
579 // ============================================================================
580
581 void
582 LifeCycleCORBATest::testFindOrLoad_Component_ParamsRemoteComputer2()
583 {
584   SALOME_LifeCycleCORBA _LCC(&_NS);
585
586   string remoteHost = GetRemoteHost();
587
588   Engines::MachineParameters params;
589   _LCC.preSet(params); 
590   params.hostname = remoteHost.c_str();
591   params.container_name = "anotherContainer";
592
593   Engines::Component_var mycompo1 =
594     _LCC.FindOrLoad_Component(params,"SalomeTestComponent");
595   CPPUNIT_ASSERT_MESSAGE("Test validity requires connection to remote "\
596                          "computers from ResourcesCatalog",
597                          !CORBA::is_nil(mycompo1));
598
599   // --- check narrow
600
601   Engines::TestComponent_var m1;
602   m1 = Engines::TestComponent::_narrow(mycompo1);
603
604   // --- check that container is on good computer
605
606   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
607   Engines::Container_var c1 = m1->GetContainerRef();
608   CPPUNIT_ASSERT(!CORBA::is_nil(c1));
609   string hostname1 = c1->getHostName();
610   CPPUNIT_ASSERT_EQUAL(hostname1, remoteHost);
611 }
612
613 // ============================================================================
614 /*!
615  * Check SALOME_FileTransferCORBA on local machine
616  */
617 // ============================================================================
618
619 void  LifeCycleCORBATest::testgetLocalFile_localComputer()
620 {
621   SALOME_LifeCycleCORBA _LCC(&_NS);
622   string origFileName = getenv("KERNEL_ROOT_DIR");
623   origFileName += "/lib/salome/libSalomeLifeCycleCORBA.so.0.0.0";
624   SALOME_FileTransferCORBA transfer( GetHostname(),
625                                      origFileName);
626   string local = transfer.getLocalFile();
627   CPPUNIT_ASSERT(!local.empty());
628   CPPUNIT_ASSERT_EQUAL(local, origFileName);
629 }
630
631 // ============================================================================
632 /*!
633  * Check SALOME_FileTransferCORBA on remote machine
634  */
635 // ============================================================================
636
637 void  LifeCycleCORBATest::testgetLocalFile_remoteComputer()
638 {
639   SALOME_LifeCycleCORBA _LCC(&_NS);
640   string origFileName = getenv("KERNEL_ROOT_DIR");
641   origFileName += "/lib/salome/libSalomeContainer.so.0.0.0";
642   SALOME_FileTransferCORBA transfer( GetRemoteHost(),
643                                      origFileName);
644   string local = transfer.getLocalFile();
645   CPPUNIT_ASSERT(!local.empty());
646   string local2 = transfer.getLocalFile();
647   CPPUNIT_ASSERT(!local2.empty());
648   CPPUNIT_ASSERT_EQUAL(local, local2);
649 }
650
651 // ============================================================================
652 /*!
653  * Check FindOrLoad_Component params = containerName
654  */
655 // ============================================================================
656
657 // void
658 // LifeCycleCORBATest::testFindOrLoad_Component_()
659 // {
660 // }
661
662
663
664
665 // ============================================================================
666 /*!
667  *  Get a remote HostName in the Resource Catalog
668  */
669 // ============================================================================
670
671 string LifeCycleCORBATest::GetRemoteHost()
672 {
673   SALOME_LifeCycleCORBA _LCC(&_NS);
674
675   CORBA::Object_var obj = _NS.Resolve("/ResourcesManager");
676   CPPUNIT_ASSERT(!CORBA::is_nil(obj));
677   Engines::ResourcesManager_var resourcesManager =
678     Engines::ResourcesManager::_narrow(obj);
679   CPPUNIT_ASSERT(!CORBA::is_nil(resourcesManager));
680
681   Engines::MachineParameters params;
682   _LCC.preSet(params);               // empty params to get all the machines
683
684   Engines::CompoList clist;
685   clist.length(1);
686   clist[0] = "SalomeTestComponent";
687   Engines::MachineList_var hostList =
688     resourcesManager->GetFittingResources(params,clist);
689   CPPUNIT_ASSERT(hostList->length() > 1);
690
691   string localHost = GetHostname();
692   string remoteHost;
693   for (unsigned int i=0; i < hostList->length(); i++)
694     {
695       const char* aMachine = hostList[i];
696       string machine(aMachine);
697       if (machine != localHost)
698         {
699           remoteHost = machine;
700           break;
701         }
702     }
703   CPPUNIT_ASSERT(remoteHost != "");
704   return remoteHost;
705 }