ConfigurationProxyTests.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
12 /*
13  * $Log$
14  *
15  */
16 
17 #ifndef ConfigurationProxy_cpp
18 #define ConfigurationProxy_cpp
19 
20 #include <cppunit/ui/text/TestRunner.h>
21 #include <cppunit/TextOutputter.h>
22 #include <cppunit/extensions/TestFactoryRegistry.h>
23 #include <cppunit/extensions/HelperMacros.h>
24 #include <cppunit/TestAssert.h>
25 #include <string>
26 #include <iostream>
27 #include <idl/SDOPackageSkel.h>
28 #include <idl/RTCSkel.h>
29 #include <ConfigurationProxy.h>
30 #include <rtm/NVUtil.h>
31 #include <ISDOService.h>
32 #include <ISDOSystemElement.h>
33 #include <IOrganization.h>
35 
36 
42 {
43  class Logger
44  {
45  public:
46  void log(const std::string& msg)
47  {
48  m_log.push_back(msg);
49  }
50 
51  int countLog(const std::string& msg)
52  {
53  int count = 0;
54  for (int i = 0; i < (int) m_log.size(); ++i)
55  {
56  if (m_log[i] == msg) ++count;
57  }
58  return count;
59  }
60 
61  private:
62  std::vector<std::string> m_log;
63  };
64 
72  : public virtual ::POA_SDOPackage::Organization,
73  public virtual ::doil::CORBA::CORBAServantBase
74  {
75  public:
77  : ::doil::CORBA::CORBAServantBase(impl), m_impl(NULL)
78  {
79  m_impl = dynamic_cast< ::SDOPackage::Local::IOrganization* >(impl);
80  }
82  virtual char* get_organization_id(){return "OrganizationServantMock";}
83  virtual ::SDOPackage::OrganizationProperty* get_organization_property()
84  {
85  ::SDOPackage::OrganizationProperty_var ret
86  = new ::SDOPackage::OrganizationProperty ();
87  return ret._retn();
88  }
89  virtual ::CORBA::Any* get_organization_property_value(const char* name)
90  {
91  CORBA::Any_var value;
92  value = new CORBA::Any();
93  return value._retn();
94 // return new ::CORBA::Any();
95  }
96  virtual ::CORBA::Boolean set_organization_property(
97  const ::SDOPackage::OrganizationProperty& organization_property)
98  {
99  return true;
100  }
101  virtual ::CORBA::Boolean set_organization_property_value(
102  const char* name, const CORBA::Any& value)
103  {
104  return true;
105  }
106  virtual ::CORBA::Boolean remove_organization_property(const char* name)
107  {
108  return true;
109  }
110  virtual ::SDOPackage::SDOSystemElement_ptr get_owner()
111  {
112  return m_varOwner._retn();
113  }
114  virtual ::CORBA::Boolean set_owner(
115  ::SDOPackage::SDOSystemElement_ptr sdo)
116  {
117  return true;
118  }
119  virtual ::SDOPackage::SDOList* get_members()
120  {
121 // ::SDOPackage::SDOList* ret = new ::SDOPackage::SDOList ();
122 // return ret;
123  ::SDOPackage::SDOList_var sdos;
124  sdos = new ::SDOPackage::SDOList(m_memberList);
125  return sdos._retn();
126  }
127  virtual CORBA::Boolean set_members(
128  const ::SDOPackage::SDOList& sdos)
129  {
130  m_memberList = sdos;
131  return true;
132  }
133  virtual CORBA::Boolean add_members(
134  const ::SDOPackage::SDOList& sdo_list)
135  {
136  return true;
137  }
138  virtual CORBA::Boolean remove_member(const char* id){return true;}
139  virtual ::SDOPackage::DependencyType get_dependency()
140  {
141  return m_dependency;
142  }
143  virtual CORBA::Boolean set_dependency(
144  ::SDOPackage::DependencyType dependency)
145  {
146  m_dependency = dependency;
147  return true;
148  }
149 
150 
151  private:
152  ::SDOPackage::Local::IOrganization* m_impl;
153  ::SDOPackage::SDOSystemElement_var m_varOwner;
154  ::SDOPackage::DependencyType m_dependency;
155  ::SDOPackage::SDOList m_memberList;
156  };
157 
164  : public virtual ::POA_SDOPackage::SDOService,
165  public virtual ::doil::CORBA::CORBAServantBase
166  {
167  public:
169  : ::doil::CORBA::CORBAServantBase(impl)
170  {
171  m_impl = dynamic_cast< ::SDOPackage::Local::ISDOService* >(impl);
172  }
174 
175 
176  private:
177  ::SDOPackage::Local::ISDOService* m_impl;
178  };
185  : public virtual ::SDOPackage::Local::ISDOService
186  {
187  public:
189  : m_refcount(0)
190  {}
191  virtual ~ISDOServiceMock(){}
192  const char* id() {return "ISDOServiceMock";}
193  const char* name() {return "ISDOServiceMock";}
194  void incRef()
195  {
196  ++m_refcount;
197  }
198  void decRef()
199  {
200  --m_refcount;
201  if (m_refcount == 0)
202  delete this;
203  }
204 
205  private:
206  std::string m_name;
208  };
215  : public virtual ::SDOPackage::Local::IOrganization
216  {
217  public:
219  : m_refcount(0)
220  {}
221  virtual ~IOrganizationMock(){}
222 
223  virtual ::std::string get_organization_id()
224  throw (::SDOPackage::Local::InvalidParameter,
225  ::SDOPackage::Local::NotAvailable,
226  ::SDOPackage::Local::InternalError)
227  {
228  return "IOrganizationMock";
229  }
230 
231  virtual ::SDOPackage::Local::OrganizationProperty get_organization_property()
232  throw (::SDOPackage::Local::NotAvailable,
233  ::SDOPackage::Local::InternalError)
234  {
235  ::SDOPackage::Local::OrganizationProperty ret;
236  return ret;
237  }
238 
239  virtual ::std::string get_organization_property_value(const ::std::string& name)
240  throw (::SDOPackage::Local::InvalidParameter,
241  ::SDOPackage::Local::NotAvailable,
242  ::SDOPackage::Local::InternalError)
243  {
244  return "IOrganizationMock";
245  }
246  virtual bool set_organization_property(const ::SDOPackage::Local::OrganizationProperty& organization_property)
247  throw (::SDOPackage::Local::InvalidParameter,
248  ::SDOPackage::Local::NotAvailable,
249  ::SDOPackage::Local::InternalError)
250  {
251  return true;
252  }
253 
254  virtual bool set_organization_property_value(const ::std::string&name, const ::std::string& value)
255  throw (::SDOPackage::Local::InvalidParameter,
256  ::SDOPackage::Local::NotAvailable,
257  ::SDOPackage::Local::InternalError)
258  {
259  return true;
260  }
261 
262  virtual bool remove_organization_property(const ::std::string& name)
263  throw (::SDOPackage::Local::InvalidParameter,
264  ::SDOPackage::Local::NotAvailable,
265  ::SDOPackage::Local::InternalError)
266  {
267  return true;
268  }
269 
270  virtual ::SDOPackage::Local::ISDOSystemElement* get_owner()
271  throw (::SDOPackage::Local::NotAvailable,
272  ::SDOPackage::Local::InternalError)
273  {
274  return NULL;
275  }
276 
277  virtual bool set_owner(const ::SDOPackage::Local::ISDOSystemElement* sdo)
278  throw (::SDOPackage::Local::InvalidParameter,
279  ::SDOPackage::Local::NotAvailable,
280  ::SDOPackage::Local::InternalError)
281  {
282  return true;
283  }
284 
285  virtual ::SDOPackage::Local::SDOList get_members()
286  throw (::SDOPackage::Local::NotAvailable,
287  ::SDOPackage::Local::InternalError)
288  {
289  ::SDOPackage::Local::SDOList ret;
290  return ret;
291  }
292 
293  virtual bool set_members(const ::SDOPackage::Local::SDOList& sdos)
294  throw (::SDOPackage::Local::InvalidParameter,
295  ::SDOPackage::Local::NotAvailable,
296  ::SDOPackage::Local::InternalError)
297  {
298  return true;
299  }
300 
301  virtual bool add_members(const ::SDOPackage::Local::SDOList& sdo_list)
302  throw (::SDOPackage::Local::InvalidParameter,
303  ::SDOPackage::Local::NotAvailable,
304  ::SDOPackage::Local::InternalError)
305  {
306  return true;
307  }
308 
309  virtual bool remove_member(const ::std::string& id)
310  throw (::SDOPackage::Local::InvalidParameter,
311  ::SDOPackage::Local::NotAvailable,
312  ::SDOPackage::Local::InternalError)
313  {
314  return true;
315  }
316 
317  virtual ::SDOPackage::Local::DependencyType get_dependency()
318  throw (::SDOPackage::Local::NotAvailable,
319  ::SDOPackage::Local::InternalError)
320  {
321  return m_dependency;
322  }
323 
324  virtual bool set_dependency(::SDOPackage::Local::DependencyType dependency)
325  throw (::SDOPackage::Local::NotAvailable,
326  ::SDOPackage::Local::InternalError)
327  {
328  m_dependency = dependency;
329  return true;
330  }
331 
332 
333  const char* id() {return "IOrganizationMock";}
334  const char* name() {return "IOrganizationMock";}
335  void incRef()
336  {
337  ++m_refcount;
338  }
339  void decRef()
340  {
341  --m_refcount;
342  if (m_refcount == 0)
343  delete this;
344  }
345 
346  private:
347  std::string m_name;
349  ::SDOPackage::Local::DependencyType m_dependency;
350  };
357  : public virtual ::POA_SDOPackage::Configuration
358  {
359  protected:
360  ::std::vector<std::string> m_log;
361  private:
362  ::std::string m_name;
363  ::std::string m_code;
364  ::std::string m_val;
365  ::SDOPackage::Parameter m_par;
366  ::SDOPackage::StringList m_stlist;
367  ::SDOPackage::EnumerationType m_etype;
368  ::CORBA::Any m_any;
369  public :
372  {
373  }
374 
376  {
377  m_logger = logger;
378  }
379 
383  ::CORBA::Boolean set_device_profile(const ::SDOPackage::DeviceProfile& dProfile)
384  throw (CORBA::SystemException,
385  ::SDOPackage::InvalidParameter,
386  ::SDOPackage::NotAvailable,
387  ::SDOPackage::InternalError)
388  {
389  if (m_logger != NULL) m_logger->log("set_device_profile");
390  return true;
391  }
395  ::CORBA::Boolean set_service_profile(const ::SDOPackage::ServiceProfile& sProfile)
396  throw (CORBA::SystemException,
397  ::SDOPackage::InvalidParameter,
398  ::SDOPackage::NotAvailable,
399  ::SDOPackage::InternalError)
400  {
401  if (m_logger != NULL) m_logger->log("set_service_profile");
402  return true;
403  }
407  ::CORBA::Boolean add_organization(::SDOPackage::Organization_ptr org)
408  throw (CORBA::SystemException,
409  ::SDOPackage::InvalidParameter,
410  ::SDOPackage::NotAvailable,
411  ::SDOPackage::InternalError)
412  {
413  if (m_logger != NULL) m_logger->log("add_organization");
414  return true;
415  }
419  ::CORBA::Boolean remove_service_profile(const char* id)
420  throw (CORBA::SystemException,
421  ::SDOPackage::InvalidParameter,
422  ::SDOPackage::NotAvailable,
423  ::SDOPackage::InternalError)
424  {
425  if (m_logger != NULL)
426  {
427  m_logger->log("remove_service_profile");
428  m_logger->log(id);
429  }
430  return true;
431  }
435  ::CORBA::Boolean remove_organization(const char* organization_id)
436  throw (CORBA::SystemException,
437  ::SDOPackage::InvalidParameter,
438  ::SDOPackage::NotAvailable,
439  ::SDOPackage::InternalError)
440  {
441  if (m_logger != NULL)
442  {
443  m_logger->log("remove_organization");
444  m_logger->log(organization_id);
445  }
446  return true;
447  }
451  ::SDOPackage::ParameterList* get_configuration_parameters()
452  throw (CORBA::SystemException,
453  ::SDOPackage::NotAvailable,
454  ::SDOPackage::InternalError)
455  {
456  if (m_logger != NULL)
457  {
458  m_logger->log("get_configuration_parameters");
459  }
460  m_name = "test_get_configuration_parameters";
461 // m_code = "5";
462 // m_any <<= m_code.c_str();
463  m_any <<= (short)5;
464  m_par.name = m_name.c_str();
465  m_par.type = m_any.type();
466  char* cp = "999";
467  ::SDOPackage::StringList* stlist;
468  stlist = new ::SDOPackage::StringList((::CORBA::ULong)1,
469  (::CORBA::ULong)1,
470  &cp,
471  (::CORBA::Boolean)0);
472  m_stlist = *stlist;
473  m_etype.enumerated_values = m_stlist;
474  delete stlist;
475  m_par.allowed_values.allowed_enum(m_etype);
476 
477  ::SDOPackage::ParameterList_var param;
478  param = new ::SDOPackage::ParameterList((::CORBA::ULong)1,
479  (::CORBA::ULong)1,
480  &m_par,
481  (::CORBA::Boolean)0);
482 
483 
484  return param._retn();
485  }
490  throw (CORBA::SystemException,
491  ::SDOPackage::NotAvailable,
492  ::SDOPackage::InternalError)
493  {
494  if (m_logger != NULL)
495  {
496  m_logger->log("get_configuration_parameter_values");
497  }
498 
499  const char* name_str = "get_configuration_parameter_values_name";
500  const char* value_str = "5";
503  ::CORBA::string_dup(name_str),
504  ::CORBA::string_dup(value_str));
505  ::SDOPackage::NVList_var nvlist;
506  nvlist = new ::SDOPackage::NVList(nv);
507  return nvlist._retn();
508  }
512  ::CORBA::Any* get_configuration_parameter_value(const char* name)
513  throw (CORBA::SystemException,
514  ::SDOPackage::InvalidParameter,
515  ::SDOPackage::NotAvailable,
516  ::SDOPackage::InternalError)
517  {
518  if (m_logger != NULL)
519  {
520  m_logger->log("get_configuration_parameter_value");
521  m_logger->log(name);
522  }
523  if (::std::string(name).empty())
524  throw ::SDOPackage::InvalidParameter("Name is empty.");
525  CORBA::Any val;
526  val <<= name;
527 
528  CORBA::Any_var value;
529  value = new CORBA::Any(val);
530  return value._retn();
531  }
535  ::CORBA::Boolean set_configuration_parameter(const char* name,
536  const CORBA::Any& value)
537  throw (CORBA::SystemException,
538  ::SDOPackage::InvalidParameter,
539  ::SDOPackage::NotAvailable,
540  ::SDOPackage::InternalError)
541  {
542  if (m_logger != NULL)
543  {
544  m_logger->log("set_configuration_parameter");
545  m_logger->log(name);
546 
547  const char* ch;
548  ::CORBA::ULong ul = 4;
549  ::CORBA::Any::to_string to_str(ch, ul);
550  value >>= to_str;
551  m_logger->log(to_str.val);
552 
553  }
554  return true;
555  }
559  ::SDOPackage::ConfigurationSetList* get_configuration_sets()
560  throw (CORBA::SystemException,
561  ::SDOPackage::NotAvailable,
562  ::SDOPackage::InternalError)
563  {
564  const char* id_str = "test_get_configuration_sets_id";
565  const char* description_str =
566  "test_get_configuration_sets_description";
567  const char* name_str = "test_get_configuration_sets_nv_name";
568  const char* value_str = "5";
569  if (m_logger != NULL)
570  {
571  m_logger->log("get_configuration_sets");
572  }
573 
574 
575  ::SDOPackage::ConfigurationSetList_var config_sets;
576  config_sets
577  = new ::SDOPackage::ConfigurationSetList((CORBA::ULong)0);
578  config_sets->length(1);
579  config_sets[0].id = ::CORBA::string_dup(id_str);
580  config_sets[0].description = ::CORBA::string_dup(description_str);
581  ::NVUtil::appendStringValue(config_sets[0].configuration_data,
582  ::CORBA::string_dup(name_str),
583  ::CORBA::string_dup(value_str));
584 
585  return config_sets._retn();
586 
587  }
588 
592  ::SDOPackage::ConfigurationSet* get_configuration_set(const char* id)
593  throw (CORBA::SystemException,
594  ::SDOPackage::NotAvailable,
595  ::SDOPackage::InternalError)
596  {
597  const char* id_str = "test_get_configuration_set_id";
598  const char* description_str =
599  "test_get_configuration_set_description";
600  const char* name_str = "test_get_configuration_set_nv_name";
601  const char* value_str = "5";
602 
603  if (m_logger != NULL)
604  {
605  m_logger->log("get_configuration_set");
606  m_logger->log(id);
607  }
608  if (std::string(id).empty())
609  throw ::SDOPackage::InternalError("ID is empty");
610 
611  ::SDOPackage::ConfigurationSet_var config;
612  config = new ::SDOPackage::ConfigurationSet();
613 // ::SDOPackage::ConfigurationSet* obj;
614 // obj = new ::SDOPackage::ConfigurationSet();
615 // ::SDOPackage::ConfigurationSet_ptr config = obj->_this();
616 
617 
618  config->id.out() = ::CORBA::string_dup(id_str);
619  config->description.out() = ::CORBA::string_dup(description_str);
620  ::NVUtil::appendStringValue(config->configuration_data,
621  ::CORBA::string_dup(name_str),
622  ::CORBA::string_dup(value_str));
623 
624  return config._retn();
625 
626  }
627 
632  const char* id,
633  const ::SDOPackage::ConfigurationSet& configuration_set)
634  throw (CORBA::SystemException,
635  ::SDOPackage::InvalidParameter,
636  ::SDOPackage::NotAvailable,
637  ::SDOPackage::InternalError)
638  {
639  if (m_logger != NULL)
640  {
641  m_logger->log("set_configuration_set_values");
642  m_logger->log(id);
643  m_logger->log(configuration_set.id.in());
644  m_logger->log(configuration_set.description.in());
645  m_logger->log(configuration_set.configuration_data[0].name.in());
646  ::CORBA::Any any;
647 // any = ::NVUtil::find(
648 // configuration_set.configuration_data,
649 // configuration_set.configuration_data[0].name.in());
650  any = configuration_set.configuration_data[0].value;
651  const char* ch;
652  ::CORBA::ULong ul = 1;
653  ::CORBA::Any::to_string to_str(ch, ul);
654  any >>= to_str;
655  m_logger->log(to_str.val);
656  }
657  if (std::string(id).empty())
658  throw ::SDOPackage::InvalidParameter("ID is empty.");
659  return true;
660  }
664  ::SDOPackage::ConfigurationSet* get_active_configuration_set()
665  throw (CORBA::SystemException,
666  ::SDOPackage::NotAvailable,
667  ::SDOPackage::InternalError)
668  {
669  const char* id_str = "test_get_active_configuration_set_id";
670  const char* description_str =
671  "test_get_active_configuration_set_description";
672  const char* name_str = "test_get_active_configuration_set_nv_name";
673  const char* value_str = "5";
674  if (m_logger != NULL)
675  {
676  m_logger->log("get_active_configuration_set");
677  }
678  ::SDOPackage::ConfigurationSet_var config;
679  config = new ::SDOPackage::ConfigurationSet();
680  config->id.out() = ::CORBA::string_dup(id_str);
681  config->description.out() = ::CORBA::string_dup(description_str);
682  ::NVUtil::appendStringValue(config->configuration_data,
683  ::CORBA::string_dup(name_str),
684  ::CORBA::string_dup(value_str));
685  return config._retn();
686  }
690  ::CORBA::Boolean add_configuration_set(
691  const ::SDOPackage::ConfigurationSet& configuration_set)
692  throw (CORBA::SystemException,
693  ::SDOPackage::InvalidParameter,
694  ::SDOPackage::NotAvailable,
695  ::SDOPackage::InternalError)
696  {
697  if (m_logger != NULL)
698  {
699  m_logger->log("add_configuration_set");
700  m_logger->log(configuration_set.id.in());
701  m_logger->log(configuration_set.description.in());
702  m_logger->log(configuration_set.configuration_data[0].name.in());
703  ::CORBA::Any any;
704  any = configuration_set.configuration_data[0].value;
705  const char* ch;
706  ::CORBA::ULong ul = 1;
707  ::CORBA::Any::to_string to_str(ch, ul);
708  any >>= to_str;
709  m_logger->log(to_str.val);
710  }
711  return true;
712  }
716  ::CORBA::Boolean remove_configuration_set(const char* id)
717  throw (CORBA::SystemException,
718  ::SDOPackage::InvalidParameter,
719  ::SDOPackage::NotAvailable,
720  ::SDOPackage::InternalError)
721  {
722  if (m_logger != NULL)
723  {
724  m_logger->log("remove_configuration_set");
725  m_logger->log(id);
726  }
727  if (std::string(id).empty())
728  throw ::SDOPackage::InvalidParameter("ID is empty.");
729  return false;
730  }
734  ::CORBA::Boolean activate_configuration_set(const char* id)
735  throw (CORBA::SystemException,
736  ::SDOPackage::InvalidParameter,
737  ::SDOPackage::NotAvailable,
738  ::SDOPackage::InternalError)
739  {
740  if (m_logger != NULL)
741  {
742  m_logger->log("activate_configuration_set");
743  m_logger->log(id);
744  }
745  if (std::string(id).empty())
746  throw ::SDOPackage::InvalidParameter("ID is empty.");
747  return true;
748  }
749  private:
751 
752  };
753 
755  : public CppUnit::TestFixture
756  {
757  CPPUNIT_TEST_SUITE(ConfigurationProxyTests);
758  CPPUNIT_TEST(test_set_device_profile);
759  CPPUNIT_TEST(test_set_service_profile);
760  CPPUNIT_TEST(test_add_organization);
761  CPPUNIT_TEST(test_remove_service_profile);
762  CPPUNIT_TEST(test_remove_organization);
763  CPPUNIT_TEST(test_get_configuration_parameters);
764  CPPUNIT_TEST(test_get_configuration_parameter_values);
765  CPPUNIT_TEST(test_get_configuration_parameter_value);
766  CPPUNIT_TEST(test_set_configuration_parameter);
767  CPPUNIT_TEST(test_get_configuration_sets);
768  CPPUNIT_TEST(test_get_configuration_set);
769  CPPUNIT_TEST(test_set_configuration_set_values);
770  CPPUNIT_TEST(test_get_active_configuration_set);
771  CPPUNIT_TEST(test_add_configuration_set);
772  CPPUNIT_TEST(test_remove_configuration_set);
773  CPPUNIT_TEST(test_activate_configuration_set);
774  CPPUNIT_TEST_SUITE_END();
775 
776  private:
777  CORBA::ORB_ptr m_pORB;
778  PortableServer::POA_ptr m_pPOA;
779 
780  public:
781 
786  {
787  int argc = 0;
788  char** argv = NULL;
789  m_pORB = CORBA::ORB_init(argc, argv);
790  m_pPOA = PortableServer::POA::_narrow(
791  m_pORB->resolve_initial_references("RootPOA"));
792  m_pPOA->the_POAManager()->activate();
793  }
794 
799  {
800  }
801 
805  virtual void setUp()
806  {
807  }
808 
812  virtual void tearDown()
813  {
814  }
815 
822  {
824  ::CORBA::Object_ptr ref = obj->_this();
825  if(::CORBA::is_nil(ref))
826  {
827  std::cout<<"ref is nil.Abort test."<<std::endl;
828  return;
829  }
830  ::SDOPackage::CORBA::ConfigurationProxy* ap
831  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
832 
833  Logger logger;
834  obj->setLogger(&logger);
835 
836  CPPUNIT_ASSERT_EQUAL(0, logger.countLog("set_device_profile"));
837  const ::SDOPackage::Local::DeviceProfile porf;
838  ap->set_device_profile(porf);
839  CPPUNIT_ASSERT_EQUAL(1, logger.countLog("set_device_profile"));
840 
841 
842 
843  delete ap;
844  CORBA::release(ref);
845  }
852  {
855  std::cout <<"Manager Name==>"<< mgr.name() << std::endl;
856 
858  ::CORBA::Object_ptr ref = obj->_this();
859  if(::CORBA::is_nil(ref))
860  {
861  std::cout<<"ref is nil.Abort test."<<std::endl;
862  return;
863  }
864  ::SDOPackage::CORBA::ConfigurationProxy* ap
865  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
866 
867  Logger logger;
868  obj->setLogger(&logger);
869 
870  CPPUNIT_ASSERT_EQUAL(0, logger.countLog("set_service_profile"));
871  ::SDOPackage::Local::ServiceProfile porf;
873 
874  mgr.registerFactory(service.id(),
875  doil::New<ISDOServiceServantMock>,
876  doil::Delete<ISDOServiceServantMock>);
877  mgr.activateObject(&service);
878 
879  porf.service = &service;
880  const ::SDOPackage::Local::ServiceProfile _porf = porf;
881  ap->set_service_profile(_porf);
882  CPPUNIT_ASSERT_EQUAL(1, logger.countLog("set_service_profile"));
883 
884  mgr.deactivateObject(&service);
885 
886  delete ap;
887  CORBA::release(ref);
888  }
895  {
898  std::cout <<"Manager Name==>"<< mgr.name() << std::endl;
899 
901  ::CORBA::Object_ptr ref = obj->_this();
902  if(::CORBA::is_nil(ref))
903  {
904  std::cout<<"ref is nil.Abort test."<<std::endl;
905  return;
906  }
907  ::SDOPackage::CORBA::ConfigurationProxy* ap
908  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
909 
910  Logger logger;
911  obj->setLogger(&logger);
912  CPPUNIT_ASSERT_EQUAL(0, logger.countLog("add_organization"));
913 
915  mgr.registerFactory(org.id(),
916  doil::New<OrganizationServantMock>,
917  doil::Delete<OrganizationServantMock>);
918  mgr.activateObject(&org);
919  const IOrganizationMock _org(org);
920  ap->add_organization(&_org);
921 
922  CPPUNIT_ASSERT_EQUAL(1, logger.countLog("add_organization"));
923  mgr.deactivateObject(&org);
924 
925  delete ap;
926  CORBA::release(ref);
927  }
934  {
936  ::CORBA::Object_ptr ref = obj->_this();
937  if(::CORBA::is_nil(ref))
938  {
939  std::cout<<"ref is nil.Abort test."<<std::endl;
940  return;
941  }
942  ::SDOPackage::CORBA::ConfigurationProxy* ap
943  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
944 
945  Logger logger;
946  obj->setLogger(&logger);
947 
948  const ::std::string str = "test_remove_service_profile";
949  CPPUNIT_ASSERT_EQUAL(0, logger.countLog("remove_service_profile"));
950  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(str));
951  ap->remove_service_profile(str);
952  CPPUNIT_ASSERT_EQUAL(1, logger.countLog("remove_service_profile"));
953  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(str));
954 
955  delete ap;
956  CORBA::release(ref);
957  }
964  {
966  ::CORBA::Object_ptr ref = obj->_this();
967  if(::CORBA::is_nil(ref))
968  {
969  std::cout<<"ref is nil.Abort test."<<std::endl;
970  return;
971  }
972  ::SDOPackage::CORBA::ConfigurationProxy* ap
973  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
974 
975  Logger logger;
976  obj->setLogger(&logger);
977  const ::std::string str = "test_remove_organization";
978 
979  CPPUNIT_ASSERT_EQUAL(0, logger.countLog("remove_organization"));
980  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(str));
981  ap->remove_organization(str);
982  CPPUNIT_ASSERT_EQUAL(1, logger.countLog("remove_organization"));
983  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(str));
984 
985  delete ap;
986  CORBA::release(ref);
987  }
994  {
995 std::cout<<"test_get_configuration_parameters"<<std::endl;
997  ::CORBA::Object_ptr ref = obj->_this();
998  if(::CORBA::is_nil(ref))
999  {
1000  std::cout<<"ref is nil.Abort test."<<std::endl;
1001  return;
1002  }
1003  ::SDOPackage::CORBA::ConfigurationProxy* ap
1004  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1005 
1006  Logger logger;
1007  obj->setLogger(&logger);
1008 
1009  ::SDOPackage::Local::ParameterList pl;
1010  CPPUNIT_ASSERT_EQUAL(0,
1011  logger.countLog("get_configuration_parameters"));
1012  pl = ap->get_configuration_parameters();
1013  CPPUNIT_ASSERT_EQUAL(1,
1014  logger.countLog("get_configuration_parameters"));
1015  CPPUNIT_ASSERT(pl[0].name ==
1016  "test_get_configuration_parameters");
1017 
1018 
1019  delete ap;
1020  CORBA::release(ref);
1021  }
1028  {
1029  ConfigurationMock* obj = new ConfigurationMock();
1030  ::CORBA::Object_ptr ref = obj->_this();
1031  if(::CORBA::is_nil(ref))
1032  {
1033  std::cout<<"ref is nil.Abort test."<<std::endl;
1034  return;
1035  }
1036  ::SDOPackage::CORBA::ConfigurationProxy* ap
1037  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1038 
1039  Logger logger;
1040  obj->setLogger(&logger);
1041 
1043  CPPUNIT_ASSERT_EQUAL(0,
1044  logger.countLog("get_configuration_parameter_values"));
1045  nvlist = ap->get_configuration_parameter_values();
1046  CPPUNIT_ASSERT_EQUAL(1,
1047  logger.countLog("get_configuration_parameter_values"));
1048 
1049 
1050  CPPUNIT_ASSERT(nvlist[0].name ==
1051  "get_configuration_parameter_values_name");
1052  CPPUNIT_ASSERT(nvlist[0].value == "5");
1053 
1054  delete ap;
1055  CORBA::release(ref);
1056  }
1063  {
1064  ConfigurationMock* obj = new ConfigurationMock();
1065  ::CORBA::Object_ptr ref = obj->_this();
1066  if(::CORBA::is_nil(ref))
1067  {
1068  std::cout<<"ref is nil.Abort test."<<std::endl;
1069  return;
1070  }
1071  ::SDOPackage::CORBA::ConfigurationProxy* ap
1072  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1073 
1074  Logger logger;
1075  obj->setLogger(&logger);
1076 
1077  const ::std::string str = "test_get_configuration_parameter_value";
1078  ::std::string ret;
1079  CPPUNIT_ASSERT_EQUAL(0,
1080  logger.countLog("get_configuration_parameter_value"));
1081  ret = ap->get_configuration_parameter_value(str);
1082  CPPUNIT_ASSERT_EQUAL(1,
1083  logger.countLog("get_configuration_parameter_value"));
1084 
1085  CPPUNIT_ASSERT(ret == str);
1086  delete ap;
1087  CORBA::release(ref);
1088 
1089  }
1096  {
1097  ConfigurationMock* obj = new ConfigurationMock();
1098  ::CORBA::Object_ptr ref = obj->_this();
1099  if(::CORBA::is_nil(ref))
1100  {
1101  std::cout<<"ref is nil.Abort test."<<std::endl;
1102  return;
1103  }
1104  ::SDOPackage::CORBA::ConfigurationProxy* ap
1105  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1106 
1107  Logger logger;
1108  obj->setLogger(&logger);
1109 
1110  const ::std::string str1 = "configuration_parameter";
1111  const ::std::string str2 = "5555";
1112  CPPUNIT_ASSERT_EQUAL(0,
1113  logger.countLog("set_configuration_parameter"));
1114  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(str1));
1115  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(str2));
1116  ap->set_configuration_parameter(str1,str2);
1117  CPPUNIT_ASSERT_EQUAL(1,
1118  logger.countLog("set_configuration_parameter"));
1119  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(str1));
1120  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(str2));
1121 
1122 
1123  delete ap;
1124  CORBA::release(ref);
1125  }
1132  {
1133  ConfigurationMock* obj = new ConfigurationMock();
1134  ::CORBA::Object_ptr ref = obj->_this();
1135  if(::CORBA::is_nil(ref))
1136  {
1137  std::cout<<"ref is nil.Abort test."<<std::endl;
1138  return;
1139  }
1140  ::SDOPackage::CORBA::ConfigurationProxy* ap
1141  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1142 
1143  Logger logger;
1144  obj->setLogger(&logger);
1145  ::SDOPackage::Local::ConfigurationSetList configlist;
1146 
1147  CPPUNIT_ASSERT_EQUAL(0, logger.countLog("get_configuration_sets"));
1148  configlist = ap->get_configuration_sets();
1149  CPPUNIT_ASSERT_EQUAL(1, logger.countLog("get_configuration_sets"));
1150 
1151  CPPUNIT_ASSERT(configlist[0].id ==
1152  "test_get_configuration_sets_id");
1153  CPPUNIT_ASSERT(configlist[0].description ==
1154  "test_get_configuration_sets_description");
1155  CPPUNIT_ASSERT(configlist[0].configuration_data[0].name ==
1156  "test_get_configuration_sets_nv_name");
1157  CPPUNIT_ASSERT(configlist[0].configuration_data[0].value == "5");
1158 
1159 
1160  delete ap;
1161  CORBA::release(ref);
1162  }
1169  {
1170  ConfigurationMock* obj = new ConfigurationMock();
1171  ::CORBA::Object_ptr ref = obj->_this();
1172  if(::CORBA::is_nil(ref))
1173  {
1174  std::cout<<"ref is nil.Abort test."<<std::endl;
1175  return;
1176  }
1177  ::SDOPackage::CORBA::ConfigurationProxy* ap
1178  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1179 
1180  Logger logger;
1181  obj->setLogger(&logger);
1182 
1183  const ::std::string str = "get_configuration_set_config_id";
1184  ::SDOPackage::Local::ConfigurationSet confset;
1185 
1186  CPPUNIT_ASSERT_EQUAL(0, logger.countLog("get_configuration_set"));
1187  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(str));
1188  confset = ap->get_configuration_set(str);
1189  CPPUNIT_ASSERT_EQUAL(1, logger.countLog("get_configuration_set"));
1190  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(str));
1191 
1192  CPPUNIT_ASSERT(confset.id ==
1193  "test_get_configuration_set_id");
1194  CPPUNIT_ASSERT(confset.description ==
1195  "test_get_configuration_set_description");
1196  CPPUNIT_ASSERT(confset.configuration_data[0].name ==
1197  "test_get_configuration_set_nv_name");
1198  CPPUNIT_ASSERT(confset.configuration_data[0].value == "5");
1199 
1200  delete ap;
1201  CORBA::release(ref);
1202 
1203  }
1210  {
1211  ConfigurationMock* obj = new ConfigurationMock();
1212  ::CORBA::Object_ptr ref = obj->_this();
1213  if(::CORBA::is_nil(ref))
1214  {
1215  std::cout<<"ref is nil.Abort test."<<std::endl;
1216  return;
1217  }
1218  ::SDOPackage::CORBA::ConfigurationProxy* ap
1219  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1220 
1221  Logger logger;
1222  obj->setLogger(&logger);
1223 
1224  const ::std::string str = "set_configuration_set_values_config_id";
1225  const ::std::string id_str = "test_set_configuration_set_valuest_id";
1226  const ::std::string description_str =
1227  "test_set_configuration_set_values_description";
1228  const ::std::string name_str =
1229  "test_set_configuration_set_values_nv_name";
1230  const ::std::string value_str = "5";
1231 
1232  ::SDOPackage::Local::NameValue nv;
1233  nv.name = name_str;
1234  nv.value = value_str;
1236  nvlist.push_back(nv);
1237 
1238  ::SDOPackage::Local::ConfigurationSet configuration_set;
1239  configuration_set.id = id_str;
1240  configuration_set.description = description_str;
1241  configuration_set.configuration_data = nvlist;
1242 
1243  CPPUNIT_ASSERT_EQUAL(0,
1244  logger.countLog("set_configuration_set_values"));
1245  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(str));
1246  ap->set_configuration_set_values(str,configuration_set);
1247  CPPUNIT_ASSERT_EQUAL(1,
1248  logger.countLog("set_configuration_set_values"));
1249  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(str));
1250 
1251  delete ap;
1252  CORBA::release(ref);
1253  }
1260  {
1261  ConfigurationMock* obj = new ConfigurationMock();
1262  ::CORBA::Object_ptr ref = obj->_this();
1263  if(::CORBA::is_nil(ref))
1264  {
1265  std::cout<<"ref is nil.Abort test."<<std::endl;
1266  return;
1267  }
1268  ::SDOPackage::CORBA::ConfigurationProxy* ap
1269  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1270 
1271  Logger logger;
1272  obj->setLogger(&logger);
1273 
1274  ::SDOPackage::Local::ConfigurationSet confset;
1275  CPPUNIT_ASSERT_EQUAL(0,
1276  logger.countLog("get_active_configuration_set"));
1277  confset = ap->get_active_configuration_set();
1278  CPPUNIT_ASSERT_EQUAL(1,
1279  logger.countLog("get_active_configuration_set"));
1280 
1281  CPPUNIT_ASSERT(confset.id ==
1282  "test_get_active_configuration_set_id");
1283  CPPUNIT_ASSERT(confset.description ==
1284  "test_get_active_configuration_set_description");
1285  CPPUNIT_ASSERT(confset.configuration_data[0].name ==
1286  "test_get_active_configuration_set_nv_name");
1287  CPPUNIT_ASSERT(confset.configuration_data[0].value == "5");
1288 
1289  delete ap;
1290  CORBA::release(ref);
1291  }
1298  {
1299  ConfigurationMock* obj = new ConfigurationMock();
1300  ::CORBA::Object_ptr ref = obj->_this();
1301  if(::CORBA::is_nil(ref))
1302  {
1303  std::cout<<"ref is nil.Abort test."<<std::endl;
1304  return;
1305  }
1306  ::SDOPackage::CORBA::ConfigurationProxy* ap
1307  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1308 
1309  Logger logger;
1310  obj->setLogger(&logger);
1311 
1312  const ::std::string id_str = "test_add_configuration_set_id";
1313  const ::std::string description_str =
1314  "test_add_configuration_set_description";
1315  const ::std::string name_str = "test_add_configuration_set_nv_name";
1316  const ::std::string value_str = "5";
1317 
1318  ::SDOPackage::Local::NameValue nv;
1319  nv.name = name_str;
1320  nv.value = value_str;
1322  nvlist.push_back(nv);
1323 
1324  ::SDOPackage::Local::ConfigurationSet configuration_set;
1325  configuration_set.id = id_str;
1326  configuration_set.description = description_str;
1327  configuration_set.configuration_data = nvlist;
1328 
1329  CPPUNIT_ASSERT_EQUAL(0, logger.countLog("add_configuration_set"));
1330  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(id_str));
1331  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(description_str));
1332  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(name_str));
1333  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(value_str));
1334  ap->add_configuration_set(configuration_set);
1335  CPPUNIT_ASSERT_EQUAL(1, logger.countLog("add_configuration_set"));
1336  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(id_str));
1337  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(description_str));
1338  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(name_str));
1339  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(value_str));
1340  delete ap;
1341  CORBA::release(ref);
1342 
1343  }
1350  {
1351  ConfigurationMock* obj = new ConfigurationMock();
1352  ::CORBA::Object_ptr ref = obj->_this();
1353  if(::CORBA::is_nil(ref))
1354  {
1355  std::cout<<"ref is nil.Abort test."<<std::endl;
1356  return;
1357  }
1358  ::SDOPackage::CORBA::ConfigurationProxy* ap
1359  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1360 
1361  Logger logger;
1362  obj->setLogger(&logger);
1363 
1364  const ::std::string str = "test_remove_configuration_set";
1365  CPPUNIT_ASSERT_EQUAL(0, logger.countLog("remove_configuration_set"));
1366  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(str));
1367  ap->remove_configuration_set(str);
1368  CPPUNIT_ASSERT_EQUAL(1, logger.countLog("remove_configuration_set"));
1369  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(str));
1370 
1371  delete ap;
1372  CORBA::release(ref);
1373  }
1380  {
1381  ConfigurationMock* obj = new ConfigurationMock();
1382  ::CORBA::Object_ptr ref = obj->_this();
1383  if(::CORBA::is_nil(ref))
1384  {
1385  std::cout<<"ref is nil.Abort test."<<std::endl;
1386  delete obj;
1387  return;
1388  }
1389  ::SDOPackage::CORBA::ConfigurationProxy* ap
1390  = new ::SDOPackage::CORBA::ConfigurationProxy(ref);
1391 
1392  Logger logger;
1393  obj->setLogger(&logger);
1394 
1395  const ::std::string str = "test_activate_configuration_set";
1396  CPPUNIT_ASSERT_EQUAL(0,
1397  logger.countLog("activate_configuration_set"));
1398  CPPUNIT_ASSERT_EQUAL(0, logger.countLog(str));
1399  ap->activate_configuration_set(str);
1400  CPPUNIT_ASSERT_EQUAL(1,
1401  logger.countLog("activate_configuration_set"));
1402  CPPUNIT_ASSERT_EQUAL(1, logger.countLog(str));
1403 
1404  delete ap;
1405  CORBA::release(ref);
1406  }
1407  /* test case */
1408  void test_case0()
1409  {
1410  }
1411  };
1412 }; // namespace ConfigurationProxy
1413 
1414 /*
1415  * Register test suite
1416  */
1418 
1419 #ifdef LOCAL_MAIN
1420 int main(int argc, char* argv[])
1421 {
1422  CppUnit::TextUi::TestRunner runner;
1423  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
1424  CppUnit::Outputter* outputter =
1425  new CppUnit::TextOutputter(&runner.result(), std::cout);
1426  runner.setOutputter(outputter);
1427  bool retcode = runner.run();
1428  return !retcode;
1429 }
1430 #endif // MAIN
1431 #endif // ConfigurationProxy_cpp
::CORBA::Boolean activate_configuration_set(const char *id)
virtual ::CORBA::Any * get_organization_property_value(const char *name)
int main(int argc, char **argv)
virtual const char * name()
Getting ORB&#39;s name.
::CORBA::Boolean remove_organization(const char *organization_id)
virtual bool set_members(const ::SDOPackage::Local::SDOList &sdos)
virtual ReturnCode_t registerFactory(const char *id, doil::ServantNewFunc new_func, doil::ServantDeleteFunc delete_func)
Register servant&#39;s factory.
::CORBA::Boolean remove_service_profile(const char *id)
bool appendStringValue(SDOPackage::NVList &nv, const char *name, const char *value)
Append the specified string to element of NVList.
Definition: NVUtil.cpp:313
::SDOPackage::ConfigurationSetList * get_configuration_sets()
std::vector< std::pair< std::string, std::string > > NVList
Definition: IRTC.h:67
virtual ::SDOPackage::Local::ISDOSystemElement * get_owner()
static CORBAManager & instance()
getting instance
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
virtual bool set_dependency(::SDOPackage::Local::DependencyType dependency)
virtual ::SDOPackage::SDOSystemElement_ptr get_owner()
virtual ::std::string get_organization_property_value(const ::std::string &name)
::SDOPackage::ParameterList * get_configuration_parameters()
SDO Package.
def description()
Definition: cxx_gen.py:27
virtual CORBA::Boolean set_dependency(::SDOPackage::DependencyType dependency)
int countLog(const std::string &msg)
::CORBA::Boolean add_configuration_set(const ::SDOPackage::ConfigurationSet &configuration_set)
CORBA manager for doil.
string service
Definition: README_gen.py:139
::SDOPackage::ConfigurationSet * get_configuration_set(const char *id)
::SDOPackage::Local::DependencyType m_dependency
NameValue and NVList utility functions.
virtual bool remove_organization_property(const ::std::string &name)
::SDOPackage::NVList * get_configuration_parameter_values()
virtual bool set_owner(const ::SDOPackage::Local::ISDOSystemElement *sdo)
virtual CORBA::Boolean add_members(const ::SDOPackage::SDOList &sdo_list)
void log(const std::string &msg)
::CORBA::Boolean add_organization(::SDOPackage::Organization_ptr org)
::CORBA::Boolean set_configuration_parameter(const char *name, const CORBA::Any &value)
virtual ::CORBA::Boolean set_organization_property(const ::SDOPackage::OrganizationProperty &organization_property)
CPPUNIT_TEST_SUITE_REGISTRATION(ConfigurationProxy::ConfigurationProxyTests)
virtual bool set_organization_property(const ::SDOPackage::Local::OrganizationProperty &organization_property)
::CORBA::Boolean set_device_profile(const ::SDOPackage::DeviceProfile &dProfile)
virtual ::CORBA::Boolean set_organization_property_value(const char *name, const CORBA::Any &value)
virtual ::SDOPackage::OrganizationProperty * get_organization_property()
::SDOPackage::Local::IOrganization * m_impl
::SDOPackage::ConfigurationSet * get_active_configuration_set()
::OutPortBase::Logger logger
::CORBA::Any * get_configuration_parameter_value(const char *name)
virtual CORBA::Boolean remove_member(const char *id)
virtual ReturnCode_t deactivateObject(doil::ImplBase *impl)
Deactivate object.
virtual bool set_organization_property_value(const ::std::string &name, const ::std::string &value)
virtual ::CORBA::Boolean remove_organization_property(const char *name)
::CORBA::Boolean remove_configuration_set(const char *id)
virtual bool add_members(const ::SDOPackage::Local::SDOList &sdo_list)
::CORBA::Boolean set_configuration_set_values(const char *id, const ::SDOPackage::ConfigurationSet &configuration_set)
virtual ReturnCode_t activateObject(doil::ImplBase *impl)
Activate object.
::CORBA::Boolean set_service_profile(const ::SDOPackage::ServiceProfile &sProfile)
virtual CORBA::Boolean set_members(const ::SDOPackage::SDOList &sdos)
virtual ::SDOPackage::DependencyType get_dependency()
std::vector< std::string > m_log
virtual ::CORBA::Boolean set_owner(::SDOPackage::SDOSystemElement_ptr sdo)
virtual bool remove_member(const ::std::string &id)
virtual ::SDOPackage::Local::SDOList get_members()
virtual ::SDOPackage::Local::DependencyType get_dependency()
virtual ::SDOPackage::Local::OrganizationProperty get_organization_property()


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:42