1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2016 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, or (at your option) any later version.
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
24 # File : LifeCycleCORBA_SWIGTest.py
25 # Author : Paul RASCLE, EDF
31 from omniORB import CORBA
37 class LifeCycleCORBA_SWIGTest(unittest.TestCase):
40 self.lcc = LifeCycleCORBA.LifeCycleCORBA()
46 def test001_FindOrLoad_Component_LaunchContainer(self):
48 get a local container (no hostname given),
49 load an engine, check that the CORBA object is not null.
52 containerName = "swMyContainer"
53 comp=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
54 self.assertNotEqual(comp,None)
55 testComp=comp._narrow(Engines.TestComponent)
56 self.assertNotEqual(testComp,None)
59 def test002_FindOrLoad_Component_SameInstance(self):
61 Check FindOrLoad_Component.
62 Call 2 times FindOrLoad_Component with the same parameters,
63 check if we get the same engine
65 containerName = "swMyContainer"
66 cp1=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
67 self.assertNotEqual(cp1,None)
68 cp2=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
69 self.assertNotEqual(cp2,None)
70 m1=cp1._narrow(Engines.TestComponent)
71 self.assertNotEqual(m1,None)
72 m2=cp2._narrow(Engines.TestComponent)
73 self.assertNotEqual(m2,None)
74 name1=m1._get_instanceName()
75 name2=m2._get_instanceName()
76 self.assertEqual(name1,name2)
79 def test003_FindOrLoad_Component_PythonInCppContainer(self):
81 Check FindOrLoad_Component with Python Component on C++ Container,
82 load an engine, check that the CORBA object is not null.
85 containerName = "swMyContainer"
86 cp1=self.lcc.FindOrLoad_Component(containerName,"SALOME_TestComponentPy")
87 self.assertNotEqual(cp1,None)
88 m1=cp1._narrow(Engines.TestComponent)
89 self.assertNotEqual(m1,None)
92 def test004_FindOrLoad_Component_PythonSameInstance(self):
94 Check FindOrLoad_Component with Python Component on C++ Container,
95 Call 2 times FindOrLoad_Component with the same parameters,
96 check if we get the same engine,
98 containerName = "swMyContainer"
99 cp1=self.lcc.FindOrLoad_Component(containerName,"SALOME_TestComponentPy")
100 self.assertNotEqual(cp1,None)
101 cp2=self.lcc.FindOrLoad_Component(containerName,"SALOME_TestComponentPy")
102 self.assertNotEqual(cp2,None)
103 m1=cp1._narrow(Engines.TestComponent)
104 self.assertNotEqual(m1,None)
105 m2=cp2._narrow(Engines.TestComponent)
106 self.assertNotEqual(m2,None)
107 name1=m1._get_instanceName()
108 name2=m2._get_instanceName()
109 self.assertEqual(name1,name2)
112 def test005_FindOrLoad_Component_UnknownInCatalog(self):
114 Check FindOrLoad_Component with a component name not in catalog.
115 See list of catalog given to module catalog server.
116 Here, we work with KERNEL_SRC/resources/KERNELCatalog.xml that contains
117 only KERNEL, SalomeTestComponent and SALOME_TestComponentPy
119 containerName = "swMyContainer"
120 cp1=self.lcc.FindOrLoad_Component(containerName,"MyNewComponent")
121 self.assertEqual(cp1,None)
124 def test006_FindOrLoad_Component_LaunchContainerHostname(self):
126 Check FindOrLoad_Component with hostname given.
127 get a local container : getHostName()/componentName,
128 load an engine, check that the CORBA object is not null.
131 containerName = Utils_Identity.getShortHostName()
132 containerName += "/swTheContainer"
133 cp1=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
134 self.assertNotEqual(cp1,None)
135 m1=cp1._narrow(Engines.TestComponent)
136 self.assertNotEqual(m1,None)
139 def test007_FindOrLoad_Component_SameContainer(self):
141 Check FindOrLoad_Component with and without local hostname given.
142 We must get the same container, the same instance of component
144 containerName = "swAContainer"
145 cp1=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
146 self.assertNotEqual(cp1,None)
147 containerName = Utils_Identity.getShortHostName()
148 containerName += "/swAContainer"
149 cp2=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
150 self.assertNotEqual(cp2,None)
151 m1=cp1._narrow(Engines.TestComponent)
152 self.assertNotEqual(m1,None)
153 m2=cp2._narrow(Engines.TestComponent)
154 self.assertNotEqual(m2,None)
155 name1=m1._get_instanceName()
156 name2=m2._get_instanceName()
157 self.assertEqual(name1,name2)
158 c1=m1.GetContainerRef()
159 self.assertNotEqual(c1,None)
160 c2=m2.GetContainerRef()
161 self.assertNotEqual(c2,None)
162 cname1=c1._get_name()
163 cname2=c2._get_name()
164 self.assertEqual(cname1,cname2)
165 hostname1=c1.getHostName()
166 hostname2=c2.getHostName()
167 self.assertEqual(hostname1,hostname2)
170 self.assertEqual(pidc1,pidc2)
173 def test008_FindOrLoad_Component_UnknownMachine(self):
175 Check FindOrLoad_Component: check behaviour when ask for an unknown
176 computer. We must catch a Salome Exception with "unknown host" message
178 containerName = "aFarAwayContainer"
179 containerName += "/swTheContainer"
181 cp1=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
182 except RuntimeError,ex :
183 self.assertEqual(ex.args[0],'unknown host')
188 return unittest.makeSuite(LifeCycleCORBA_SWIGTest,'test')
191 return unittest.TextTestRunner().run(suite())
193 if __name__ == '__main__':
194 #unittest.TextTestRunner(verbosity=2).run(suite())