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