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