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