test_Manager.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 
4 #
5 # \file test_Manager.py
6 # \brief test for RTComponent manager class
7 # \date $Date: $
8 # \author Shinji Kurihara
9 #
10 # Copyright (C) 2006
11 # Task-intelligence Research Group,
12 # Intelligent Systems Research Institute,
13 # National Institute of
14 # Advanced Industrial Science and Technology (AIST), Japan
15 # All rights reserved.
16 #
17 
18 import sys
19 sys.path.insert(1,"../")
20 
21 import unittest
22 import time
23 
24 #from Manager import *
25 import OpenRTM_aist
26 import RTC, RTC__POA
27 
28 testcomp_spec = ["implementation_id", "TestComp",
29  "type_name", "TestComp",
30  "description", "Test example component",
31  "version", "1.0",
32  "vendor", "Shinji Kurihara, AIST",
33  "category", "example",
34  "activity_type", "DataFlowComponent",
35  "max_instance", "10",
36  "language", "C++",
37  "lang_type", "compile",
38  # Configuration variables
39  "conf.default.int_param0", "0",
40  "conf.default.int_param1", "1",
41  "conf.default.double_param0", "0.11",
42  "conf.default.double_param1", "9.9",
43  "conf.default.str_param0", "hoge",
44  "conf.default.str_param1", "dara",
45  "conf.default.vector_param0", "0.0,1.0,2.0,3.0,4.0",
46  ""]
47 
49  def __init__(self, manager):
50  OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
51  return
52 
53 
54 def TestCompInit(manager):
55  profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
56  manager.registerFactory(profile,
57  TestComp,
58  OpenRTM_aist.Delete)
59 
60 #def TestCompInit(manager):
61 def MyModuleInit(manager):
62  TestCompInit(manager)
63  com = manager.createComponent("TestComp")
64 
65 def TestEcInit(manager):
66  profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
67  manager.registerECFactory("Art",
68  TestComp,
69  OpenRTM_aist.Delete)
70  manager.createComponent("TestEc")
71 
72 
73 class TestManager(unittest.TestCase):
74 
75  def setUp(self):
76  global manager
77  #manager = OpenRTM_aist.Manager.init(sys.argv)
78  #self.manager = manager
79  self.manager = OpenRTM_aist.Manager.init(sys.argv)
80 
81  def tearDown(self):
82  self.manager.shutdownManager()
83  time.sleep(0.1)
84 
85 ### def COMMENTtest_terminate(self):
86 ### self.manager.activateManager()
87 ### self.manager.runManager(True)
88 ### self.manager.terminate()
89 ### return
90 ###
91 ### def COMMENTtest_shutdown(self):
92 ### self.manager.activateManager()
93 ### self.manager.runManager(True)
94 ### time.sleep(0.1)
95 ### self.manager.shutdown()
96 ### #self.manager.runManager()
97 ###
98 ###
99  def test_init(self):
100  #self.assertEqual(self.manager,OpenRTM_aist.Manager.init(sys.argv))
101  return
102 
103  def test_instance(self):
104  self.assertEqual(OpenRTM_aist.Manager.instance(), self.manager)
105  return
106 
107 
108  def test_load_unload(self):
109  self.manager.load("hoge", "echo")
110  self.manager.unload("hoge")
111  self.manager.unloadAll()
112  self.manager.load("hoge", "echo")
113  self.assertEqual(len(self.manager.getLoadedModules()), 1)
114  #self.assertEqual(len(self.manager.getLoadableModules()), 1)
115  return
116 
118  self.manager.activateManager()
119  self.assertEqual(self.manager.getLoadedModules(),[])
120  return
121 
123  self.manager.activateManager()
124  # hoge.py is loadable module.
125  #self.assertNotEqual(self.manager.getLoadableModules(),[])
126  return
127 
129  profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
130  self.assertEqual(self.manager.registerFactory(profile,
131  TestComp,
132  OpenRTM_aist.Delete),
133  True)
134  return
135 
137  self.manager.getFactoryProfiles()
138  return
139 
141  profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
142  self.assertEqual(self.manager.registerECFactory("Art",
143  TestComp,
144  OpenRTM_aist.Delete),
145  True)
146  return
147 
149  self.assertEqual(self.manager.getModulesFactories()[0],'PeriodicECSharedComposite')
150  return
151 
153  self.manager.activateManager()
154  profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
155  self.manager.registerFactory(profile,
156  TestComp,
157  OpenRTM_aist.Delete)
158  com = self.manager.createComponent("TestComp")
159  self.assertNotEqual(com,None)
160  #self.assertEqual(self.manager.getComponent("TestComp0"),self.manager.getComponents()[0])
161  #self.manager.deleteComponent("TestComp0")
162  self.manager.shutdownComponents()
163  time.sleep(0.1)
164  return
165 
166  def test_getORB(self):
167  self.manager.getORB()
168  return
169 
170  def test_getPOA(self):
171  self.manager.getPOA()
172  return
173 
175  self.manager.getPOAManager()
176  return
177 
178 
180  self.manager.activateManager()
181  profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
182  self.manager.registerFactory(profile,
183  TestComp,
184  OpenRTM_aist.Delete)
185  com = self.manager.createComponent("TestComp")
186  self.assertEqual(self.manager.registerComponent(com),True)
187  self.manager.shutdownComponents()
188  return
189 ###
190 ### def COMMENTtest_unregisterComponent(self):
191 ### self.manager.activateManager()
192 ### profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
193 ### self.manager.registerFactory(profile,
194 ### TestComp,
195 ### OpenRTM_aist.Delete)
196 ### com = self.manager.createComponent("TestComp")
197 ### self.assertEqual(self.manager.unregisterComponent(com),True)
198 ### self.manager.shutdownComponents()
199 ### return
200 ###
202  ec_args = "PeriodicExecutionContext?rate="
203  self.manager.activateManager()
204  ec = self.manager.createContext(ec_args)
205  self.assertNotEqual(ec,None)
206  ec.stop()
207  self.manager.getPOA().deactivate_object(self.manager.getPOA().servant_to_id(ec))
208  del ec
209  return
210 ###
211 ###
212 ###
213 ### def test_shutdownManager(self):
214 ### return
215 ###
216 ### def test_shutdownOnNoRtcs(self):
217 ### return
218 ###
219 ###
220 ### def test_createORBEndpoints(self):
221 ### self.manager.activateManager()
222 ### l=[]
223 ### self.manager.createORBEndpoints(l)
224 ### return
225 ###
227  self.manager.activateManager()
228  self.manager.createORBEndpointOption("",[])
229  return
230 ###
231 ###
232 ###
233 ### def test_shutdownORB(self):
234 ### return
235 ###
236 ### def test_shutdownComponents(self):
237 ### return
238 ###
239 ###
240 ###
242  self.manager.activateManager()
243  profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
244  self.manager.registerFactory(profile,
245  TestComp,
246  OpenRTM_aist.Delete)
247  com = self.manager.createComponent("TestComp")
248  self.assertEqual(self.manager.registerComponent(com),True)
249  self.manager.cleanupComponent(com)
250  com.exit()
251  self.manager.shutdownComponents()
252  return
253 
254 
256  self.manager.activateManager()
257  profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
258  self.manager.registerFactory(profile,
259  TestComp,
260  OpenRTM_aist.Delete)
261  com = self.manager.createComponent("TestComp")
262  #self.manager.notifyFinalized(com)
263  #self.manager.cleanupComponents()
264  self.manager.shutdownComponents()
265  return
266 
267 
268  def test_initManager(self):
269  self.manager.initManager(sys.argv)
270  #self.manager.shutdownManager()
271  return
272 
273  def test_initLogger(self):
274  self.manager.initLogger()
275  #self.manager.shutdownLogger()
276  return
277 
278  def test_initORB(self):
279  #self.assertEqual(self.manager.initORB(),True)
280  #self.manager.shutdownORB()
281  return
282 
283 
284  def test_initNaming(self):
285  self.assertEqual(self.manager.initNaming(),True)
286  #self.manager.shutdownNaming()
287  return
288 
289 
291  self.assertEqual(self.manager.initExecContext(),True)
292  return
293 
295  self.assertEqual(self.manager.initComposite(),True)
296  return
297 
298 
300  self.assertEqual(self.manager.initFactories(),True)
301  return
302 
304  self.assertEqual(self.manager.initManagerServant(), True)
305  return
306 
307 
309  comp_id = OpenRTM_aist.Properties()
310  comp_conf = OpenRTM_aist.Properties()
311 
312  self.assertEqual(self.manager.procComponentArgs("TestComp?instance_name=test&exported_ports=ConsoleIn0.out,ConsoleOut0.in",comp_id,comp_conf),True)
313  self.assertEqual(comp_id.getProperty("implementation_id"),"TestComp")
314  self.assertEqual(comp_conf.getProperty("instance_name"),"test")
315  self.assertEqual(comp_conf.getProperty("exported_ports"),"ConsoleIn0.out,ConsoleOut0.in")
316  return
317 
319  ec_id = [""]
320  ec_conf = OpenRTM_aist.Properties()
321  self.assertEqual(self.manager.procContextArgs("PeriodicExecutionContext?rate=1000",ec_id,ec_conf),True)
322  self.assertEqual(ec_id[0],"PeriodicExecutionContext")
323  self.assertEqual(ec_conf.getProperty("rate"),"1000")
324  return
325 
327  self.manager.activateManager()
328  profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
329  self.manager.registerFactory(profile,
330  TestComp,
331  OpenRTM_aist.Delete)
332  com = self.manager.createComponent("TestComp")
333  prop = OpenRTM_aist.Properties()
334  self.manager.configureComponent(com,prop)
335  self.manager.cleanupComponent(com)
336  com.exit()
337  self.manager.shutdownComponents()
338  return
339 
340  def test_formatString(self):
341  profile = OpenRTM_aist.Properties(defaults_str=testcomp_spec)
342  self.assertEqual(self.manager.formatString("rtc.log",profile),"rtc.log")
343  print self.manager.formatString("$(PWD)",profile)
344  print self.manager.formatString("%n.%t.%m.%v.%V.%c.%h.%M.%p",profile)
345  return
346 
347  def test_getLogbuf(self):
348  self.manager.getLogbuf()
349  return
350 
351  def test_getConfig(self):
352  self.manager.getConfig()
353  return
354 
355 
356 
357 
358 ############### test #################
359 if __name__ == '__main__':
360  unittest.main()
def test_createContext(self)
def COMMENTtest_unregisterComponent(self): self.manager.activateManager() profile = OpenRTM_aist...
def test_getLoadableModules(self)
def test_configureComponent(self)
def test_createORBEndpointOption(self)
def test_shutdownManager(self): return
def test_registerECFactory(self)
The Properties class represents a persistent set of properties.
Definition: Properties.py:83
def test_init(self)
def COMMENTtest_terminate(self): self.manager.activateManager() self.manager.runManager(True) self...
Definition: test_Manager.py:99
def TestCompInit(manager)
Definition: test_Manager.py:54
def __init__(self, manager)
Definition: test_Manager.py:49
def MyModuleInit(manager)
Definition: test_Manager.py:61
def test_initManagerServant(self)
def test_cleanupComponent(self)
def test_shutdownORB(self): return
def test_procComponentArgs(self)
def TestEcInit(manager)
Definition: test_Manager.py:65
def test_getFactoryProfiles(self)
def test_getModulesFactories(self)
def test_registerComponent(self)


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Jun 6 2019 19:11:34