]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
PR: more test on LifeCycleCORBA BR_UnitTests_20051010
authorprascle <prascle>
Tue, 11 Oct 2005 07:00:18 +0000 (07:00 +0000)
committerprascle <prascle>
Tue, 11 Oct 2005 07:00:18 +0000 (07:00 +0000)
src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx
src/LifeCycleCORBA/Test/LifeCycleCORBATest.hxx

index d8b20edf7a33321d9b79c3d5b980613d6b47edcd..dc30adfed8dca7a0001e33021ee0d7f3e0e1e0f8 100644 (file)
@@ -49,6 +49,7 @@ LifeCycleCORBATest::setUp()
   string s = "file:";
   s += theFileName;
   //s="local";
+  //s="with_logger";
   CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
 
   ofstream traceFile;
@@ -431,7 +432,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsLocalContainer()
   Engines::TestComponent_var m1;
   m1 = Engines::TestComponent::_narrow(mycompo);
 
-  // --- check container is on local computer
+  // --- check that container is on local computer
 
   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
   Engines::Container_var c1 = m1->GetContainerRef();
@@ -465,7 +466,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsContainerName()
   Engines::TestComponent_var m1;
   m1 = Engines::TestComponent::_narrow(mycompo);
 
-  // --- check container has good name
+  // --- check that container has good name
 
   CPPUNIT_ASSERT(!CORBA::is_nil(m1));
   Engines::Container_var c1 = m1->GetContainerRef();
@@ -476,6 +477,114 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsContainerName()
   CPPUNIT_ASSERT(cname1.find(containerName) != string::npos);
 }
 
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component on remote computer
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_RemoteComputer()
+{
+  SALOME_LifeCycleCORBA _LCC(&_NS);
+
+  string remoteHost = GetRemoteHost();
+
+  string containerName = remoteHost;
+  containerName += "/aContainer";
+  DEVTRACE("containerName = " << containerName);
+  Engines::Component_var mycompo1 =
+    _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
+  CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
+
+  // --- check narrow
+
+  Engines::TestComponent_var m1;
+  m1 = Engines::TestComponent::_narrow(mycompo1);
+
+  // --- check that container is on good computer
+
+  CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+  Engines::Container_var c1 = m1->GetContainerRef();
+  CPPUNIT_ASSERT(!CORBA::is_nil(c1));
+  string hostname1 = c1->getHostName();
+  CPPUNIT_ASSERT_EQUAL(hostname1, remoteHost);
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component with params on remote computer
+ * params empty except hostname 
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_ParamsRemoteComputer()
+{
+  SALOME_LifeCycleCORBA _LCC(&_NS);
+
+  string remoteHost = GetRemoteHost();
+
+  Engines::MachineParameters params;
+  _LCC.preSet(params); 
+  params.hostname = remoteHost.c_str();
+
+  Engines::Component_var mycompo1 =
+    _LCC.FindOrLoad_Component(params,"SalomeTestComponent");
+  CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
+
+  // --- check narrow
+
+  Engines::TestComponent_var m1;
+  m1 = Engines::TestComponent::_narrow(mycompo1);
+
+  // --- check that container is on good computer
+
+  CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+  Engines::Container_var c1 = m1->GetContainerRef();
+  CPPUNIT_ASSERT(!CORBA::is_nil(c1));
+  string hostname1 = c1->getHostName();
+  CPPUNIT_ASSERT_EQUAL(hostname1, remoteHost);
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component with params on remote computer
+ * params empty except hostname and container_name
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_ParamsRemoteComputer2()
+{
+  SALOME_LifeCycleCORBA _LCC(&_NS);
+
+  string remoteHost = GetRemoteHost();
+
+  Engines::MachineParameters params;
+  _LCC.preSet(params); 
+  params.hostname = remoteHost.c_str();
+  params.container_name = "anotherContainer";
+
+  Engines::Component_var mycompo1 =
+    _LCC.FindOrLoad_Component(params,"SalomeTestComponent");
+  CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
+
+  // --- check narrow
+
+  Engines::TestComponent_var m1;
+  m1 = Engines::TestComponent::_narrow(mycompo1);
+
+  // --- check that container is on good computer
+
+  CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+  Engines::Container_var c1 = m1->GetContainerRef();
+  CPPUNIT_ASSERT(!CORBA::is_nil(c1));
+  string hostname1 = c1->getHostName();
+  CPPUNIT_ASSERT_EQUAL(hostname1, remoteHost);
+}
+
+
 
 // ============================================================================
 /*!
@@ -488,3 +597,48 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsContainerName()
 // {
 // }
 
+
+
+
+
+
+
+
+// ============================================================================
+/*!
+ *  Get a remote HostName in the Resource Catalog
+ */
+// ============================================================================
+
+string LifeCycleCORBATest::GetRemoteHost()
+{
+  SALOME_LifeCycleCORBA _LCC(&_NS);
+
+  CORBA::Object_var obj = _NS.Resolve("/ContainerManager");
+  CPPUNIT_ASSERT(!CORBA::is_nil(obj));
+  Engines::ContainerManager_var containerManager =
+    Engines::ContainerManager::_narrow(obj);
+  CPPUNIT_ASSERT(!CORBA::is_nil(containerManager));
+
+  Engines::MachineParameters params;
+  _LCC.preSet(params);               // empty params to get all the machines
+
+  Engines::MachineList_var hostList =
+    containerManager->GetFittingResources(params,"SalomeTestComponent");
+  CPPUNIT_ASSERT(hostList->length() > 1);
+
+  string localHost = GetHostname();
+  string remoteHost;
+  for (unsigned int i=0; i < hostList->length(); i++)
+    {
+      const char* aMachine = hostList[i];
+      string machine(aMachine);
+      if (machine != localHost)
+       {
+         remoteHost = machine;
+         break;
+       }
+    }
+  CPPUNIT_ASSERT(remoteHost != "");
+  return remoteHost;
+}
index 56858599ccfaa4150e66b2c14f3847ff91158cda..2f457f09db6c5842cba88b8ddf1bbd40bdec0569 100644 (file)
@@ -23,6 +23,10 @@ class LifeCycleCORBATest : public CppUnit::TestFixture
   CPPUNIT_TEST( testFindOrLoad_Component_ParamsEmpty );
   CPPUNIT_TEST( testFindOrLoad_Component_ParamsLocalContainer );
   CPPUNIT_TEST( testFindOrLoad_Component_ParamsContainerName );
+  CPPUNIT_TEST( testFindOrLoad_Component_RemoteComputer );
+  CPPUNIT_TEST( testFindOrLoad_Component_ParamsRemoteComputer );
+  CPPUNIT_TEST( testFindOrLoad_Component_ParamsRemoteComputer2 );
+//   CPPUNIT_TEST( testFindOrLoad_Component_ );
 //   CPPUNIT_TEST( testFindOrLoad_Component_ );
 //   CPPUNIT_TEST(  );
 //   CPPUNIT_TEST(  );
@@ -44,9 +48,14 @@ public:
   void testFindOrLoad_Component_ParamsEmpty();
   void testFindOrLoad_Component_ParamsLocalContainer();
   void testFindOrLoad_Component_ParamsContainerName();
+  void testFindOrLoad_Component_RemoteComputer();
+  void testFindOrLoad_Component_ParamsRemoteComputer();
+  void testFindOrLoad_Component_ParamsRemoteComputer2();
+//   void testFindOrLoad_Component_();
 //   void testFindOrLoad_Component_();
 
 protected:
+  std::string GetRemoteHost();
   CORBA::ORB_var _orb;
   SALOME_NamingService _NS;
 };