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