2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # SALOME TestContainer : test of container creation and its life cycle
24 # File : TestComponentPy.py
25 # Author : Paul RASCLE, EDF
32 from omniORB import CORBA
35 from Utils_Identity import getShortHostName
39 orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
41 #obtain a reference to the root naming context
42 obj = orb.resolve_initial_references("NameService")
43 rootContext = obj._narrow(CosNaming.NamingContext)
45 if rootContext is None:
46 print "Name Service Reference is invalid"
49 #resolve the name /Containers.dir/FactoryServerPy.object
50 machineName=getShortHostName()
51 containerName = "FactoryServerPy"
52 name = [CosNaming.NameComponent("Containers","dir"),
53 CosNaming.NameComponent(machineName,"dir"),
54 CosNaming.NameComponent(containerName,"object")]
57 obj = rootContext.resolve(name)
58 except CosNaming.NamingContext.NotFound, ex:
59 print containerName , " not found in Naming Service"
62 container = obj._narrow(Engines.Container)
63 print container.getHostName()
64 comp = container.load_impl("SALOME_TestComponentPy","SALOME_TestComponentPy")
65 print comp._get_instanceName()
67 comptest = comp._narrow(Engines.TestComponent)
70 print comptest.Coucou(1)