2 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
3 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # File : LifeCycleCORBA_SWIGTest.py
24 # Author : Paul RASCLE, EDF
30 from omniORB import CORBA
36 class LifeCycleCORBA_SWIGTest(unittest.TestCase):
39 self.lcc = LifeCycleCORBA.LifeCycleCORBA()
45 def test001_FindOrLoad_Component_LaunchContainer(self):
47 get a local container (no hostname given),
48 load an engine, check that the CORBA object is not null.
51 containerName = "swMyContainer"
52 comp=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
53 self.assertNotEqual(comp,None)
54 testComp=comp._narrow(Engines.TestComponent)
55 self.assertNotEqual(testComp,None)
58 def test002_FindOrLoad_Component_SameInstance(self):
60 Check FindOrLoad_Component.
61 Call 2 times FindOrLoad_Component with the same parameters,
62 check if we get the same engine
64 containerName = "swMyContainer"
65 cp1=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
66 self.assertNotEqual(cp1,None)
67 cp2=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
68 self.assertNotEqual(cp2,None)
69 m1=cp1._narrow(Engines.TestComponent)
70 self.assertNotEqual(m1,None)
71 m2=cp2._narrow(Engines.TestComponent)
72 self.assertNotEqual(m2,None)
73 name1=m1._get_instanceName()
74 name2=m2._get_instanceName()
75 self.assertEqual(name1,name2)
78 def test003_FindOrLoad_Component_PythonInCppContainer(self):
80 Check FindOrLoad_Component with Python Component on C++ Container,
81 load an engine, check that the CORBA object is not null.
84 containerName = "swMyContainer"
85 cp1=self.lcc.FindOrLoad_Component(containerName,"SALOME_TestComponentPy")
86 self.assertNotEqual(cp1,None)
87 m1=cp1._narrow(Engines.TestComponent)
88 self.assertNotEqual(m1,None)
91 def test004_FindOrLoad_Component_PythonSameInstance(self):
93 Check FindOrLoad_Component with Python Component on C++ Container,
94 Call 2 times FindOrLoad_Component with the same parameters,
95 check if we get the same engine,
97 containerName = "swMyContainer"
98 cp1=self.lcc.FindOrLoad_Component(containerName,"SALOME_TestComponentPy")
99 self.assertNotEqual(cp1,None)
100 cp2=self.lcc.FindOrLoad_Component(containerName,"SALOME_TestComponentPy")
101 self.assertNotEqual(cp2,None)
102 m1=cp1._narrow(Engines.TestComponent)
103 self.assertNotEqual(m1,None)
104 m2=cp2._narrow(Engines.TestComponent)
105 self.assertNotEqual(m2,None)
106 name1=m1._get_instanceName()
107 name2=m2._get_instanceName()
108 self.assertEqual(name1,name2)
111 def test005_FindOrLoad_Component_UnknownInCatalog(self):
113 Check FindOrLoad_Component with a component name not in catalog.
114 See list of catalog given to module catalog server.
115 Here, we work with KERNEL_SRC/resources/KERNELCatalog.xml that contains
116 only KERNEL, SalomeTestComponent and SALOME_TestComponentPy
118 containerName = "swMyContainer"
119 cp1=self.lcc.FindOrLoad_Component(containerName,"MyNewComponent")
120 self.assertEqual(cp1,None)
123 def test006_FindOrLoad_Component_LaunchContainerHostname(self):
125 Check FindOrLoad_Component with hostname given.
126 get a local container : getHostName()/componentName,
127 load an engine, check that the CORBA object is not null.
130 containerName = Utils_Identity.getShortHostName()
131 containerName += "/swTheContainer"
132 cp1=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
133 self.assertNotEqual(cp1,None)
134 m1=cp1._narrow(Engines.TestComponent)
135 self.assertNotEqual(m1,None)
138 def test007_FindOrLoad_Component_SameContainer(self):
140 Check FindOrLoad_Component with and without local hostname given.
141 We must get the same container, the same instance of component
143 containerName = "swAContainer"
144 cp1=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
145 self.assertNotEqual(cp1,None)
146 containerName = Utils_Identity.getShortHostName()
147 containerName += "/swAContainer"
148 cp2=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
149 self.assertNotEqual(cp2,None)
150 m1=cp1._narrow(Engines.TestComponent)
151 self.assertNotEqual(m1,None)
152 m2=cp2._narrow(Engines.TestComponent)
153 self.assertNotEqual(m2,None)
154 name1=m1._get_instanceName()
155 name2=m2._get_instanceName()
156 self.assertEqual(name1,name2)
157 c1=m1.GetContainerRef()
158 self.assertNotEqual(c1,None)
159 c2=m2.GetContainerRef()
160 self.assertNotEqual(c2,None)
161 cname1=c1._get_name()
162 cname2=c2._get_name()
163 self.assertEqual(cname1,cname2)
164 hostname1=c1.getHostName()
165 hostname2=c2.getHostName()
166 self.assertEqual(hostname1,hostname2)
169 self.assertEqual(pidc1,pidc2)
172 def test008_FindOrLoad_Component_UnknownMachine(self):
174 Check FindOrLoad_Component: check behaviour when ask for an unknown
175 computer. We must catch a Salome Exception with "unknown host" message
177 containerName = "aFarAwayContainer"
178 containerName += "/swTheContainer"
179 cp1=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent")
184 return unittest.makeSuite(LifeCycleCORBA_SWIGTest,'test')
187 return unittest.TextTestRunner().run(suite())
189 if __name__ == '__main__':
190 unittest.TextTestRunner(verbosity=2).run(suite())