1 // SALOME TestContainer : test of container creation and its life cycle
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : TestContainer.cxx
25 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
30 #include "utilities.h"
33 #include <SALOMEconfig.h>
34 #include CORBA_CLIENT_HEADER(SALOME_Component)
35 #include CORBA_CLIENT_HEADER(SALOME_TestComponent)
37 #include "SALOME_NamingService.hxx"
40 int main (int argc, char * argv[])
45 // Initializing omniORB
46 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
48 // use IOR to find container
49 //if (argc != 2) { return 1; }
50 //CORBA::Object_var obj = orb->string_to_object(argv[1]);
51 //Engines::Container_var iGenFact = Engines::Container::_narrow(obj);
53 // Obtain a reference to the root POA
54 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
55 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
57 // Use Name Service to find container
58 SALOME_NamingService _NS(orb) ;
59 string containerName = "/Containers/" ;
60 string hostName = GetHostname();
61 containerName += hostName + "/FactoryServer";
63 obj = _NS.Resolve(containerName.c_str()) ;
64 Engines::Container_var iGenFact = Engines::Container::_narrow(obj);
66 Engines::TestComponent_var m1;
68 for (int iter = 0; iter < 3 ; iter++)
70 INFOS("----------------------------------------------------" << iter);
71 string dirn = getenv("SALOME_ROOT_DIR");
72 dirn += "/lib/libSalomeTestComponentEngine.so";
73 obj = iGenFact->load_impl("SalomeTestComponent",dirn.c_str());
74 m1 = Engines::TestComponent::_narrow(obj);
76 SCRUTE(m1->instanceName());
77 INFOS("Coucou " << m1->Coucou(1L));
78 iGenFact->remove_impl(m1) ;
79 //iGenFact->finalize_removal() ; // unpredictable results ...
83 iGenFact->finalize_removal() ;
86 catch(CORBA::COMM_FAILURE& ex) {
87 INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.")
89 catch(CORBA::SystemException&) {
90 INFOS("Caught a CORBA::SystemException.")
92 catch(CORBA::Exception&) {
93 INFOS("Caught CORBA::Exception.")
96 INFOS("Caught unknown exception.")