Salome HOME
SWP12966 - MutiFile is not saved correctly
[modules/kernel.git] / src / TestContainer / TestComponentPy.py
1 #! /usr/bin/env python
2 #
3 #  SALOME TestContainer : test of container creation and its life cycle
4 #
5 #  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
7
8 #  This library is free software; you can redistribute it and/or 
9 #  modify it under the terms of the GNU Lesser General Public 
10 #  License as published by the Free Software Foundation; either 
11 #  version 2.1 of the License. 
12
13 #  This library is distributed in the hope that it will be useful, 
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of 
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
16 #  Lesser General Public License for more details. 
17
18 #  You should have received a copy of the GNU Lesser General Public 
19 #  License along with this library; if not, write to the Free Software 
20 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
21
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #
24 #
25 #
26 #  File   : TestComponentPy.py
27 #  Author : Paul RASCLE, EDF
28 #  Module : SALOME
29 #  $Header$
30
31 import os
32 import sys
33 import string
34 from omniORB import CORBA
35 import CosNaming
36 import Engines
37 from Utils_Identity import getShortHostName
38
39
40 #initialise the ORB
41 orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
42
43 #obtain a reference to the root naming context
44 obj = orb.resolve_initial_references("NameService")
45 rootContext = obj._narrow(CosNaming.NamingContext)
46
47 if rootContext is None:
48     print "Name Service Reference is invalid"
49     sys.exit(1)
50
51 #resolve the name /Containers.dir/FactoryServerPy.object
52 machineName=getShortHostName()
53 containerName = "FactoryServerPy"
54 name = [CosNaming.NameComponent("Containers","dir"),
55         CosNaming.NameComponent(machineName,"dir"),
56         CosNaming.NameComponent(containerName,"object")]
57
58 try:
59     obj = rootContext.resolve(name)
60 except CosNaming.NamingContext.NotFound, ex:
61     print  containerName , " not found in Naming Service"
62     sys.exit(1)
63
64 container = obj._narrow(Engines.Container)
65 print container.getHostName()
66 comp = container.load_impl("SALOME_TestComponentPy","SALOME_TestComponentPy")
67 print comp._get_instanceName()
68 comp.ping()
69 comptest = comp._narrow(Engines.TestComponent)
70 if comptest is None:
71     print "probleme cast"
72 print comptest.Coucou(1)
73
74