InPortBaseTests.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
12 /*
13  * $Log: InPortBaseTests.cpp,v $
14  *
15  *
16  */
17 
18 #ifndef InPortBase_cpp
19 #define InPortBase_cpp
20 
21 #include <cppunit/ui/text/TestRunner.h>
22 #include <cppunit/TextOutputter.h>
23 #include <cppunit/extensions/TestFactoryRegistry.h>
24 #include <cppunit/extensions/HelperMacros.h>
25 #include <cppunit/TestAssert.h>
26 
27 #include <rtm/idl/BasicDataTypeSkel.h>
28 #include <rtm/idl/DataPortSkel.h>
29 #include <rtm/RTC.h>
30 #include <rtm/Typename.h>
31 #include <rtm/InPortBase.h>
32 #include <rtm/CdrBufferBase.h>
33 #include <rtm/PortAdmin.h>
34 #include <rtm/InPortConnector.h>
35 #include <rtm/InPortProvider.h>
36 #include <rtm/InPortConsumer.h>
37 #include <rtm/OutPortProvider.h>
38 #include <rtm/OutPortConsumer.h>
39 #include <rtm/CorbaConsumer.h>
41 #include <rtm/InPortProvider.h>
42 #include <rtm/ConnectorListener.h>
43 #include <rtm/OutPort.h>
44 #include <rtm/OutPortBase.h>
47 
48 // ConnectorDataListenerType count
49 #define cdl_len 10
50 // ConnectorListenerType count
51 #define cl_len 7
52 
53 namespace InPortBase
54 {
55 
56  // ConnectorDataListenerType
57  static const char* str_cdl[] =
58  {
59  "ON_BUFFER_WRITE",
60  "ON_BUFFER_FULL",
61  "ON_BUFFER_WRITE_TIMEOUT",
62  "ON_BUFFER_OVERWRITE",
63  "ON_BUFFER_READ",
64  "ON_SEND",
65  "ON_RECEIVED",
66  "ON_RECEIVER_FULL",
67  "ON_RECEIVER_TIMEOUT",
68  "ON_RECEIVER_ERROR"
69  };
70 
71  // ConnectorListenerType
72  static const char* str_cl[] =
73  {
74  "ON_BUFFER_EMPTY",
75  "ON_BUFFER_READ_TIMEOUT",
76  "ON_SENDER_EMPTY",
77  "ON_SENDER_TIMEOUT",
78  "ON_SENDER_ERROR",
79  "ON_CONNECT",
80  "ON_DISCONNECT"
81  };
82 
83  static int cdl_count;
84  static int cl_count;
85 
87  : public RTC::ConnectorDataListenerT<RTC::TimedLong>
88  {
89  public:
90  DataListener(const char* name) : m_name(name)
91  {
92  ++cdl_count;
93  }
94  virtual ~DataListener()
95  {
96  --cdl_count;
97  }
98 
99  virtual void operator()(const RTC::ConnectorInfo& info,
100  const RTC::TimedLong& data)
101  {
102  std::cout << "------------------------------" << std::endl;
103  std::cout << "Data Listener: " << m_name << std::endl;
104  std::cout << "Profile::name: " << info.name << std::endl;
105  std::cout << "------------------------------" << std::endl;
106  };
107  std::string m_name;
108  };
109 
110 
112  : public RTC::ConnectorListener
113  {
114  public:
115  ConnListener(const char* name) : m_name(name)
116  {
117  ++cl_count;
118  }
119  virtual ~ConnListener()
120  {
121  --cl_count;
122  }
123 
124  virtual void operator()(const RTC::ConnectorInfo& info)
125  {
126  std::cout << "------------------------------" << std::endl;
127  std::cout << "Connector Listener: " << m_name << std::endl;
128  std::cout << "Profile::name: " << info.name << std::endl;
129  std::cout << "------------------------------" << std::endl;
130  };
131  std::string m_name;
132  };
133 
139  class Logger
140  {
141  public:
142  void log(const std::string& msg)
143  {
144  m_log.push_back(msg);
145  }
146 
147  int countLog(const std::string& msg)
148  {
149  int count = 0;
150  for (int i = 0; i < (int) m_log.size(); ++i)
151  {
152  if (m_log[i] == msg) ++count;
153  }
154  return count;
155  }
156 
157  void clearLog(void)
158  {
159  m_log.clear();
160  }
161  private:
162  std::vector<std::string> m_log;
163  };
164 
170  template <class DataType>
172  : public RTC::BufferBase<DataType>
173  {
174  public:
176  RingBufferMock(long int length = 8)
177  {
178  m_logger = NULL;
179  logger.log("RingBufferMock::Constructor");
180  m_read_return_value = BUFFER_OK;
181  }
182  virtual ~RingBufferMock(void)
183  {
184  }
185 
186 
192  {
193  m_read_return_value = value;
194  }
199  virtual void init(const coil::Properties& prop)
200  {
201  }
206  virtual size_t length(void) const
207  {
208  return 0;
209  }
214  virtual ReturnCode length(size_t n)
215  {
216  return ::RTC::BufferStatus::BUFFER_OK; //BUFFER_OK;
217  }
222  virtual ReturnCode reset()
223  {
224  return ::RTC::BufferStatus::BUFFER_OK; //BUFFER_OK;
225  }
230  virtual DataType* wptr(long int n = 0)
231  {
232  return &m_data;
233  }
238  virtual ReturnCode advanceWptr(long int n = 1)
239  {
240  return ::RTC::BufferStatus::BUFFER_OK; //BUFFER_OK;
241  }
246  virtual ReturnCode put(const DataType& value)
247  {
248  return ::RTC::BufferStatus::BUFFER_OK; //BUFFER_OK;
249  }
254  virtual ReturnCode write(const DataType& value,
255  long int sec = -1, long int nsec = -1)
256  {
257  return ::RTC::BufferStatus::BUFFER_OK; //BUFFER_OK;
258  }
263  virtual size_t writable() const
264  {
265  return 0;
266  }
271  virtual bool full(void) const
272  {
273  return true;
274  }
279  virtual DataType* rptr(long int n = 0)
280  {
281  return &m_data;
282  }
287  virtual ReturnCode advanceRptr(long int n = 1)
288  {
289  return ::RTC::BufferStatus::BUFFER_OK; //BUFFER_OK;
290  }
295  virtual ReturnCode get(DataType& value)
296  {
297  return ::RTC::BufferStatus::BUFFER_OK; //BUFFER_OK;
298  }
303  virtual DataType& get()
304  {
305  return m_data;
306  }
311  virtual ReturnCode read(DataType& value,
312  long int sec = -1, long int nsec = -1)
313  {
314  if (m_logger != NULL)
315  {
316  m_logger->log("RingBufferMock::read");
317  }
318  logger.log("RingBufferMock::read");
319  return m_read_return_value; //BUFFER_OK;
320  }
325  virtual size_t readable() const
326  {
327  return 0;
328  }
333  virtual bool empty(void) const
334  {
335  return true;
336  }
342  {
343  m_logger = logger;
344  }
345 
346  static Logger logger;
347  private:
348  DataType m_data;
349  std::vector<DataType> m_buffer;
352  };
353 
354  template <class DataType>
357 
364  : public RTC::InPortProvider,
365  public virtual POA_OpenRTM::InPortCdr,
366  public virtual PortableServer::RefCountServantBase
367  {
368 
369  public:
371  {
372  m_logger = NULL;
373  // PortProfile setting
374  setInterfaceType("corba_cdr");
375 
376  // ConnectorProfile setting
377  m_objref = this->_this();
378 
379  // set InPort's reference
380  CORBA::ORB_ptr orb = ::RTC::Manager::instance().getORB();
382  push_back(m_properties,
383  NVUtil::newNV("dataport.corba_cdr.inport_ior",
384  orb->object_to_string(m_objref.in())));
386  push_back(m_properties,
387  NVUtil::newNV("dataport.corba_cdr.inport_ref",
388  m_objref));
389  }
391  {
392  PortableServer::ObjectId_var oid;
393  oid = _default_POA()->servant_to_id(this);
394  _default_POA()->deactivate_object(oid);
395  }
401  {
402  if (m_logger != NULL)
403  {
404  m_logger->log("InPortCorbaCdrProviderMock::setBuffer");
405  }
406  }
411  ::OpenRTM::PortStatus put(const ::OpenRTM::CdrData& data)
412  throw (CORBA::SystemException)
413  {
414  return ::OpenRTM::PORT_OK;
415  }
421  {
422  if (m_logger != NULL)
423  {
424  m_logger->log("InPortCorbaCdrProviderMock::init");
425  }
426  }
431  RTC::InPortConsumer::ReturnCode put(const cdrMemoryStream& data)
432  {
433  return PORT_OK;
434  }
440  {
441  return;
442  }
443 
448  bool subscribeInterface(const SDOPackage::NVList& properties)
449  {
450 
451  return true;;
452  }
453 
458  void unsubscribeInterface(const SDOPackage::NVList& properties)
459  {
460  }
461 
462 
467 /*
468  bool publishInterface(SDOPackage::NVList& prop)
469  {
470  return true;
471  }
472 */
478  {
479  m_logger = logger;
480  }
481 
483  RTC::ConnectorListeners* listeners)
484  {
485  // m_profile = info;
486  // m_listeners = listeners;
487  }
489  {
490  // m_connector = connector;
491  }
492 
493  private:
495  ::OpenRTM::InPortCdr_var m_objref;
496 
497  };
498 
505  : public RTC::OutPortConsumer,
506  public RTC::CorbaConsumer< ::OpenRTM::OutPortCdr >
507  {
508 
509  public:
511  {
512  m_logger = NULL;
513  }
515  {
516  }
522  {
523  if (m_logger != NULL)
524  {
525  m_logger->log("OutPortCorbaCdrConsumerMock::setBuffer");
526  }
527  }
532  ::OpenRTM::PortStatus put(const ::OpenRTM::CdrData& data)
533  throw (CORBA::SystemException)
534  {
535  return ::OpenRTM::PORT_OK;
536  }
542  {
543  if (m_logger != NULL)
544  {
545  m_logger->log("OutPortCorbaCdrConsumerMock::init");
546  }
547  }
552  RTC::OutPortConsumer::ReturnCode put(const cdrMemoryStream& data)
553  {
554  return PORT_OK;
555  }
561  {
562  return;
563  }
564 
569  bool subscribeInterface(const SDOPackage::NVList& properties)
570  {
571 
572  return true;;
573  }
574 
579  void unsubscribeInterface(const SDOPackage::NVList& properties)
580  {
581  }
586  virtual ReturnCode get(cdrMemoryStream& data)
587  {
588  return PORT_OK;
589  }
590 
592  RTC::ConnectorListeners* listeners)
593  {
594  // m_profile = info;
595  // m_listeners = listeners;
596  }
597 
603  {
604  m_logger = logger;
605  }
606  private:
608 
609  };
610 
616  : public RTC::InPortBase
617  {
618  public:
623  InPortBaseMock(const char* name, const char* data_type)
624  : RTC::InPortBase(name , data_type)
625  {
626  rtclog.setLevel("PARANOID");
627  }
632  virtual ~InPortBaseMock()
633  {
634  }
640  {
641  return m_thebuffer;
642  }
648  {
649  return m_providerTypes;
650  }
656  {
657  return m_consumerTypes;
658  }
664  {
665  initConsumers();
666  }
672  {
673  initProviders();
674  }
680  {
681  m_singlebuffer = true;
682  }
688  {
689  m_singlebuffer = false;
690  }
696  {
697  return m_connectors;
698  }
703  virtual RTC::ReturnCode_t publishInterfaces_public(RTC::ConnectorProfile& connector_profile)
704  {
706  return ret;
707  }
712  virtual RTC::ReturnCode_t subscribeInterfaces_public(RTC::ConnectorProfile& connector_profile)
713  {
715  return ret;
716  }
722  createConnector_public(RTC::ConnectorProfile& cprof,
725  {
726  return RTC::InPortBase::createConnector(cprof, prop, provider);
727  }
732  RTC::InPortProvider* createProvider_public(RTC::ConnectorProfile& cprof,
734  {
735  return RTC::InPortBase::createProvider(cprof, prop);
736  }
742  {
743  return m_properties;
744  }
750  {
751  RTC::InPortBase::init(prop);
752  }
756  bool read()
757  {
758  return true;
759  }
760  };
761 
762  template <class DataType>
764  : public RTC::OutPort<DataType>
765  {
766  public:
767  OutPortMock(const char* name, DataType& value)
768  : RTC::OutPort<DataType>(name, value)
769  {
770  }
771 
772  virtual ~OutPortMock()
773  {
774  }
775  };
776 
778  : public CppUnit::TestFixture
779  {
780  CPPUNIT_TEST_SUITE(InPortBaseTests);
781 
782  CPPUNIT_TEST(test_constructor);
783  CPPUNIT_TEST(test_init);
784  CPPUNIT_TEST(test_init2); //multibuffer
785  CPPUNIT_TEST(test_init3); //Buffers are not registered in Factory.
786  CPPUNIT_TEST(test_initProviders);
787  CPPUNIT_TEST(test_initProviders2);//Providers are not registered in Factory.
788  CPPUNIT_TEST(test_initConsumers);
789  CPPUNIT_TEST(test_initConsumers2);//Consumers are not registered in Factory.
790  CPPUNIT_TEST(test_activateInterfaces_deactivateInterfaces);
791  CPPUNIT_TEST(test_publishInterfaces);
792  CPPUNIT_TEST(test_publishInterfaces2);//dataport.dataflow_type is "pull"
793  CPPUNIT_TEST(test_publishInterfaces3);//dataport.dataflow_type is "else"
794  CPPUNIT_TEST(test_publishInterfaces4);//Provider is deleted.
795  CPPUNIT_TEST(test_publishInterfaces5);
796  CPPUNIT_TEST(test_subscribeInterfaces);
797  CPPUNIT_TEST(test_subscribeInterfaces2);//dataport.dataflow_type is "push"
798  CPPUNIT_TEST(test_subscribeInterfaces3);//dataport.dataflow_type is "else"
799  CPPUNIT_TEST(test_subscribeInterfaces4);//Consumer is deleted.
800  CPPUNIT_TEST(test_subscribeInterfaces5);//Buffer is deleted.
801  CPPUNIT_TEST(test_createConnector);
802  CPPUNIT_TEST(test_createConnector2);
803  CPPUNIT_TEST(test_ConnectorListener);
804 
805  CPPUNIT_TEST_SUITE_END();
806 
807  private:
808  CORBA::ORB_ptr m_pORB;
809  PortableServer::POA_ptr m_pPOA;
811  DataListener *m_datalisteners[cdl_len];
812  ConnListener *m_connlisteners[cl_len];
813 
814  public:
815 
820  {
821  int argc(0);
822  char** argv(NULL);
823  m_pORB = CORBA::ORB_init(argc, argv);
824  m_pPOA = PortableServer::POA::_narrow(
825  m_pORB->resolve_initial_references("RootPOA"));
826  m_pPOA->the_POAManager()->activate();
827  }
828 
833  {
834  }
835 
839  virtual void setUp()
840  {
841  //既に "corba_cdr" で登録されている場合は削除する。
842  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
843  {
844  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
845  }
846  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
848  addFactory("corba_cdr",
853 
854  //既に "corba_cdr" で登録されている場合は削除する。
855  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
856  {
857  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
858  }
859  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
861  addFactory("corba_cdr",
866 
867  //既に "ring_buffer" で登録されている場合は削除する。
868  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
869  {
870  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
871  }
872  //"ring_buffer" に CdrRingBufferMock を登録する。
874  addFactory("ring_buffer",
875  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
876  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
877  }
878 
882  virtual void tearDown()
883  {
884  }
885 
891  {
892  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
893 
894  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
895  portAdmin.registerPort(inport);
896 
897  RTC::PortProfile profile = inport.getPortProfile();
898  coil::Properties prop = NVUtil::toProperties(profile.properties);
899  CPPUNIT_ASSERT_EQUAL(std::string("DataInPort"), prop["port.port_type"] );
900  CPPUNIT_ASSERT_EQUAL(std::string(toTypename<RTC::TimedFloat>()),
901  prop["dataport.data_type"] );
902  CPPUNIT_ASSERT_EQUAL(std::string("Any"),
903  prop["dataport.subscription_type"]);
904 
905  portAdmin.deletePort(inport);
906 
907 
908  }
913  void test_init()
914  {
915  //
916  //Condition
917  // m_singlebuffer is true(singlebuffer).
918  // m_thebuffer is CdrRingBufferMock.
919  //Check
920  // Check that buffer is generated.
921  //
922  //既に "corba_cdr" で登録されている場合は削除する。
923  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
924  {
925  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
926  }
927  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
929  addFactory("corba_cdr",
934 
935  //既に "corba_cdr" で登録されている場合は削除する。
936  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
937  {
938  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
939  }
940  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
942  addFactory("corba_cdr",
947 
948  //既に "ring_buffer" で登録されている場合は削除する。
949  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
950  {
951  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
952  }
953 
954  //"ring_buffer" に CdrRingBufferMock を登録する。
956  addFactory("ring_buffer",
957  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
958  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
959 
960 
961  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
962 
963  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
964  portAdmin.registerPort(inport);
965 
966  CPPUNIT_ASSERT(0==inport.getThebuffer());
967  RTC::PortProfile profile = inport.getPortProfile();
968  coil::Properties prop = NVUtil::toProperties(profile.properties);
969  CPPUNIT_ASSERT_EQUAL(std::string(""),
970  prop["dataport.dataflow_type"]);
971  CPPUNIT_ASSERT_EQUAL(std::string(""),
972  prop["dataport.interface_type"]);
973 
974  coil::vstring pstr = inport.getProviderTypes();
975  CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size());
976  coil::vstring cstr = inport.get_m_consumerTypes();
977  CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size());
979  CPPUNIT_ASSERT_EQUAL(0,
980  CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor"));
981 
982  coil::Properties dummy;
983  inport.init(dummy);
984 
985  //m_singlebufferがtrueの場合m_thebufferが取得される CPPUNIT_ASSERT(0!=inport.getThebuffer()); CPPUNIT_ASSERT_EQUAL(1, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief init()メソッドのテスト * */ void test_init2() { // //Condition // m_singlebuffer is false(multibuffer). // m_thebuffer is CdrRingBufferMock. //Check // Check that buffer is not generated. // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); CPPUNIT_ASSERT(0==inport.getThebuffer()); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); CdrRingBufferMock::logger.clearLog(); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); inport.setMultibuffer(); coil::Properties dummy; inport.init(dummy); CPPUNIT_ASSERT(0==inport.getThebuffer()); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief init()メソッドのテスト * */ void test_init3() { // //Condition // m_singlebuffer is true(singlebuffer). // m_thebuffer is unset.(The buffer is not registered in Factory.) //Check // Check that buffer is not generated. // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); CPPUNIT_ASSERT(0==inport.getThebuffer()); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); CdrRingBufferMock::logger.clearLog(); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); coil::Properties dummy; inport.init(dummy); //m_singlebufferがtrueの場合m_thebufferが取得される CPPUNIT_ASSERT(0==inport.getThebuffer()); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * */ void test_initProviders() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0!= pstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * The provider is not registered in Factory. * */ void test_initProviders2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
986  CPPUNIT_ASSERT(0!=inport.getThebuffer());
987  CPPUNIT_ASSERT_EQUAL(1,
988  CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor"));
989 
990  profile = inport.getPortProfile();
991  prop = NVUtil::toProperties(profile.properties);
992 
993  //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief init()メソッドのテスト * */ void test_init2() { // //Condition // m_singlebuffer is false(multibuffer). // m_thebuffer is CdrRingBufferMock. //Check // Check that buffer is not generated. // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); CPPUNIT_ASSERT(0==inport.getThebuffer()); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); CdrRingBufferMock::logger.clearLog(); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); inport.setMultibuffer(); coil::Properties dummy; inport.init(dummy); CPPUNIT_ASSERT(0==inport.getThebuffer()); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief init()メソッドのテスト * */ void test_init3() { // //Condition // m_singlebuffer is true(singlebuffer). // m_thebuffer is unset.(The buffer is not registered in Factory.) //Check // Check that buffer is not generated. // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); CPPUNIT_ASSERT(0==inport.getThebuffer()); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); CdrRingBufferMock::logger.clearLog(); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); coil::Properties dummy; inport.init(dummy); //m_singlebufferがtrueの場合m_thebufferが取得される CPPUNIT_ASSERT(0==inport.getThebuffer()); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * */ void test_initProviders() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0!= pstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * The provider is not registered in Factory. * */ void test_initProviders2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
994  CPPUNIT_ASSERT_EQUAL(std::string("push,pull"),
995  prop["dataport.dataflow_type"]);
996  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
997  prop["dataport.interface_type"]);
998 
999  //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief init()メソッドのテスト * */ void test_init2() { // //Condition // m_singlebuffer is false(multibuffer). // m_thebuffer is CdrRingBufferMock. //Check // Check that buffer is not generated. // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); CPPUNIT_ASSERT(0==inport.getThebuffer()); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); CdrRingBufferMock::logger.clearLog(); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); inport.setMultibuffer(); coil::Properties dummy; inport.init(dummy); CPPUNIT_ASSERT(0==inport.getThebuffer()); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief init()メソッドのテスト * */ void test_init3() { // //Condition // m_singlebuffer is true(singlebuffer). // m_thebuffer is unset.(The buffer is not registered in Factory.) //Check // Check that buffer is not generated. // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); CPPUNIT_ASSERT(0==inport.getThebuffer()); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); CdrRingBufferMock::logger.clearLog(); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); coil::Properties dummy; inport.init(dummy); //m_singlebufferがtrueの場合m_thebufferが取得される CPPUNIT_ASSERT(0==inport.getThebuffer()); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * */ void test_initProviders() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0!= pstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * The provider is not registered in Factory. * */ void test_initProviders2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1000  pstr = inport.getProviderTypes();
1001  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1002  pstr[0]);
1003  cstr = inport.get_m_consumerTypes();
1004  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1005  cstr[0]);
1006 
1007  portAdmin.deletePort(inport);
1008  }
1013  void test_init2()
1014  {
1015  //
1016  //Condition
1017  // m_singlebuffer is false(multibuffer).
1018  // m_thebuffer is CdrRingBufferMock.
1019  //Check
1020  // Check that buffer is not generated.
1021  //
1022  //既に "corba_cdr" で登録されている場合は削除する。
1023  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1024  {
1025  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1026  }
1027  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1029  addFactory("corba_cdr",
1034 
1035  //既に "corba_cdr" で登録されている場合は削除する。
1036  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1037  {
1038  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1039  }
1040  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1042  addFactory("corba_cdr",
1047 
1048  //既に "ring_buffer" で登録されている場合は削除する。
1049  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1050  {
1051  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1052  }
1053  //"ring_buffer" に CdrRingBufferMock を登録する。
1055  addFactory("ring_buffer",
1056  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
1057  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
1058  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1059 
1060  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1061  portAdmin.registerPort(inport);
1062 
1063  CPPUNIT_ASSERT(0==inport.getThebuffer());
1064  RTC::PortProfile profile = inport.getPortProfile();
1065  coil::Properties prop = NVUtil::toProperties(profile.properties);
1066  CPPUNIT_ASSERT_EQUAL(std::string(""),
1067  prop["dataport.dataflow_type"]);
1068  CPPUNIT_ASSERT_EQUAL(std::string(""),
1069  prop["dataport.interface_type"]);
1070 
1071  coil::vstring pstr = inport.getProviderTypes();
1072  CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size());
1073  coil::vstring cstr = inport.get_m_consumerTypes();
1074  CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size());
1076  CPPUNIT_ASSERT_EQUAL(0,
1077  CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor"));
1078 
1079  inport.setMultibuffer();
1080  coil::Properties dummy;
1081  inport.init(dummy);
1082 
1083  CPPUNIT_ASSERT(0==inport.getThebuffer());
1084  CPPUNIT_ASSERT_EQUAL(0,
1085  CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor"));
1086 
1087  profile = inport.getPortProfile();
1088  prop = NVUtil::toProperties(profile.properties);
1089 
1090  //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief init()メソッドのテスト * */ void test_init3() { // //Condition // m_singlebuffer is true(singlebuffer). // m_thebuffer is unset.(The buffer is not registered in Factory.) //Check // Check that buffer is not generated. // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); CPPUNIT_ASSERT(0==inport.getThebuffer()); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); CdrRingBufferMock::logger.clearLog(); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); coil::Properties dummy; inport.init(dummy); //m_singlebufferがtrueの場合m_thebufferが取得される CPPUNIT_ASSERT(0==inport.getThebuffer()); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * */ void test_initProviders() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0!= pstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * The provider is not registered in Factory. * */ void test_initProviders2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1091  CPPUNIT_ASSERT_EQUAL(std::string("push,pull"),
1092  prop["dataport.dataflow_type"]);
1093  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1094  prop["dataport.interface_type"]);
1095 
1096  //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief init()メソッドのテスト * */ void test_init3() { // //Condition // m_singlebuffer is true(singlebuffer). // m_thebuffer is unset.(The buffer is not registered in Factory.) //Check // Check that buffer is not generated. // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); CPPUNIT_ASSERT(0==inport.getThebuffer()); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); CdrRingBufferMock::logger.clearLog(); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); coil::Properties dummy; inport.init(dummy); //m_singlebufferがtrueの場合m_thebufferが取得される CPPUNIT_ASSERT(0==inport.getThebuffer()); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * */ void test_initProviders() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0!= pstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * The provider is not registered in Factory. * */ void test_initProviders2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1097  pstr = inport.getProviderTypes();
1098  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1099  pstr[0]);
1100  cstr = inport.get_m_consumerTypes();
1101  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1102  cstr[0]);
1103 
1104  portAdmin.deletePort(inport);
1105  }
1110  void test_init3()
1111  {
1112  //
1113  //Condition
1114  // m_singlebuffer is true(singlebuffer).
1115  // m_thebuffer is unset.(The buffer is not registered in Factory.)
1116  //Check
1117  // Check that buffer is not generated.
1118  //
1119  //既に "corba_cdr" で登録されている場合は削除する。
1120  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1121  {
1122  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1123  }
1124  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1126  addFactory("corba_cdr",
1131 
1132  //既に "corba_cdr" で登録されている場合は削除する。
1133  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1134  {
1135  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1136  }
1137  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1139  addFactory("corba_cdr",
1144 
1145  //既に "ring_buffer" で登録されている場合は削除する。
1146  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1147  {
1148  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1149  }
1150 
1151  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1152 
1153  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1154  portAdmin.registerPort(inport);
1155 
1156  CPPUNIT_ASSERT(0==inport.getThebuffer());
1157  RTC::PortProfile profile = inport.getPortProfile();
1158  coil::Properties prop = NVUtil::toProperties(profile.properties);
1159  CPPUNIT_ASSERT_EQUAL(std::string(""),
1160  prop["dataport.dataflow_type"]);
1161  CPPUNIT_ASSERT_EQUAL(std::string(""),
1162  prop["dataport.interface_type"]);
1163 
1164  coil::vstring pstr = inport.getProviderTypes();
1165  CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size());
1166  coil::vstring cstr = inport.get_m_consumerTypes();
1167  CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size());
1169  CPPUNIT_ASSERT_EQUAL(0,
1170  CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor"));
1171 
1172  coil::Properties dummy;
1173  inport.init(dummy);
1174 
1175  //m_singlebufferがtrueの場合m_thebufferが取得される CPPUNIT_ASSERT(0==inport.getThebuffer()); CPPUNIT_ASSERT_EQUAL(0, CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor")); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * */ void test_initProviders() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0!= pstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * The provider is not registered in Factory. * */ void test_initProviders2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1176  CPPUNIT_ASSERT(0==inport.getThebuffer());
1177  CPPUNIT_ASSERT_EQUAL(0,
1178  CdrRingBufferMock::logger.countLog("RingBufferMock::Constructor"));
1179 
1180  profile = inport.getPortProfile();
1181  prop = NVUtil::toProperties(profile.properties);
1182 
1183  //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push,pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * */ void test_initProviders() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0!= pstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * The provider is not registered in Factory. * */ void test_initProviders2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1184  CPPUNIT_ASSERT_EQUAL(std::string("push,pull"),
1185  prop["dataport.dataflow_type"]);
1186  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1187  prop["dataport.interface_type"]);
1188 
1189  //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * */ void test_initProviders() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0!= pstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * The provider is not registered in Factory. * */ void test_initProviders2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1190  pstr = inport.getProviderTypes();
1191  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1192  pstr[0]);
1193  cstr = inport.get_m_consumerTypes();
1194  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1195  cstr[0]);
1196 
1197 
1198  portAdmin.deletePort(inport);
1199  }
1205  {
1206  //既に "corba_cdr" で登録されている場合は削除する。
1207  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1208  {
1209  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1210  }
1211  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1213  addFactory("corba_cdr",
1218 
1219  //既に "ring_buffer" で登録されている場合は削除する。
1220  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1221  {
1222  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1223  }
1224 
1225  //既に "corba_cdr" で登録されている場合は削除する。
1226  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1227  {
1228  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1229  }
1230  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1232  addFactory("corba_cdr",
1237 
1238  //"ring_buffer" に CdrRingBufferMock を登録する。
1240  addFactory("ring_buffer",
1241  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
1242  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
1243 
1244 
1245  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1246 
1247  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1248  portAdmin.registerPort(inport);
1249 
1250  RTC::PortProfile profile = inport.getPortProfile();
1251  coil::Properties prop = NVUtil::toProperties(profile.properties);
1252  CPPUNIT_ASSERT_EQUAL(std::string(""),
1253  prop["dataport.dataflow_type"]);
1254  CPPUNIT_ASSERT_EQUAL(std::string(""),
1255  prop["dataport.interface_type"]);
1256 
1257  coil::vstring pstr = inport.getProviderTypes();
1258  CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size());
1259  inport.initProviders_public();
1260 
1261 
1262  profile = inport.getPortProfile();
1263  prop = NVUtil::toProperties(profile.properties);
1264 
1265  //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("push"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0!= pstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * The provider is not registered in Factory. * */ void test_initProviders2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1266  CPPUNIT_ASSERT_EQUAL(std::string("push"),
1267  prop["dataport.dataflow_type"]);
1268  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1269  prop["dataport.interface_type"]);
1270 
1271  //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0!= pstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), pstr[0]); portAdmin.deletePort(inport); } /*! * @brief initProviders()メソッドのテスト * The provider is not registered in Factory. * */ void test_initProviders2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring pstr = inport.getProviderTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size()); inport.initProviders_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1272  pstr = inport.getProviderTypes();
1273  CPPUNIT_ASSERT((size_t)0!= pstr.size());
1274  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1275  pstr[0]);
1276 
1277  portAdmin.deletePort(inport);
1278  }
1285  {
1286  //既に "corba_cdr" で登録されている場合は削除する。
1287  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1288  {
1289  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1290  }
1291 
1292  //既に "corba_cdr" で登録されている場合は削除する。
1293  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1294  {
1295  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1296  }
1297  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1299  addFactory("corba_cdr",
1304 
1305  //既に "ring_buffer" で登録されている場合は削除する。
1306  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1307  {
1308  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1309  }
1310  //"ring_buffer" に CdrRingBufferMock を登録する。
1312  addFactory("ring_buffer",
1313  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
1314  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
1315 
1316 
1317  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1318 
1319  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1320  portAdmin.registerPort(inport);
1321 
1322  RTC::PortProfile profile = inport.getPortProfile();
1323  coil::Properties prop = NVUtil::toProperties(profile.properties);
1324  CPPUNIT_ASSERT_EQUAL(std::string(""),
1325  prop["dataport.dataflow_type"]);
1326  CPPUNIT_ASSERT_EQUAL(std::string(""),
1327  prop["dataport.interface_type"]);
1328 
1329  coil::vstring pstr = inport.getProviderTypes();
1330  CPPUNIT_ASSERT_EQUAL((size_t)0, pstr.size());
1331  inport.initProviders_public();
1332 
1333 
1334  profile = inport.getPortProfile();
1335  prop = NVUtil::toProperties(profile.properties);
1336 
1337  //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1338  CPPUNIT_ASSERT_EQUAL(std::string(""),
1339  prop["dataport.dataflow_type"]);
1340  CPPUNIT_ASSERT_EQUAL(std::string(""),
1341  prop["dataport.interface_type"]);
1342 
1343  //ProviderTypes,ConsumerTypesが取得される pstr = inport.getProviderTypes(); CPPUNIT_ASSERT((size_t)0== pstr.size()); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1344  pstr = inport.getProviderTypes();
1345  CPPUNIT_ASSERT((size_t)0== pstr.size());
1346 
1347  portAdmin.deletePort(inport);
1348  }
1354  {
1355  //既に "corba_cdr" で登録されている場合は削除する。
1356  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1357  {
1358  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1359  }
1360  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1362  addFactory("corba_cdr",
1367 
1368  //既に "corba_cdr" で登録されている場合は削除する。
1369  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1370  {
1371  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1372  }
1373  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1375  addFactory("corba_cdr",
1380 
1381  //既に "ring_buffer" で登録されている場合は削除する。
1382  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1383  {
1384  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1385  }
1386  //"ring_buffer" に CdrRingBufferMock を登録する。
1388  addFactory("ring_buffer",
1389  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
1390  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
1391 
1392  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1393 
1394  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1395  portAdmin.registerPort(inport);
1396 
1397  RTC::PortProfile profile = inport.getPortProfile();
1398  coil::Properties prop = NVUtil::toProperties(profile.properties);
1399  CPPUNIT_ASSERT_EQUAL(std::string(""),
1400  prop["dataport.dataflow_type"]);
1401  CPPUNIT_ASSERT_EQUAL(std::string(""),
1402  prop["dataport.interface_type"]);
1403 
1404  coil::vstring cstr = inport.get_m_consumerTypes();
1405  CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size());
1406 
1407  inport.initConsumers_public();
1408 
1409  profile = inport.getPortProfile();
1410  prop = NVUtil::toProperties(profile.properties);
1411 
1412  //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string("pull"), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1413  CPPUNIT_ASSERT_EQUAL(std::string("pull"),
1414  prop["dataport.dataflow_type"]);
1415  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1416  prop["dataport.interface_type"]);
1417 
1418  //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0!= cstr.size()); CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"), cstr[0]); portAdmin.deletePort(inport); } /*! * @brief initConsumers()メソッドのテスト * */ void test_initConsumers2() { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::PortProfile profile = inport.getPortProfile(); coil::Properties prop = NVUtil::toProperties(profile.properties); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); coil::vstring cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size()); inport.initConsumers_public(); profile = inport.getPortProfile(); prop = NVUtil::toProperties(profile.properties); //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1419  cstr = inport.get_m_consumerTypes();
1420  CPPUNIT_ASSERT((size_t)0!= cstr.size());
1421  CPPUNIT_ASSERT_EQUAL(std::string("corba_cdr"),
1422  cstr[0]);
1423 
1424  portAdmin.deletePort(inport);
1425 
1426  }
1432  {
1433  //既に "corba_cdr" で登録されている場合は削除する。
1434  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1435  {
1436  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1437  }
1438  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1440  addFactory("corba_cdr",
1445 
1446  //既に "corba_cdr" で登録されている場合は削除する。
1447  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1448  {
1449  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1450  }
1451 
1452  //既に "ring_buffer" で登録されている場合は削除する。
1453  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1454  {
1455  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1456  }
1457  //"ring_buffer" に CdrRingBufferMock を登録する。
1459  addFactory("ring_buffer",
1460  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
1461  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
1462 
1463  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1464 
1465  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1466  portAdmin.registerPort(inport);
1467 
1468  RTC::PortProfile profile = inport.getPortProfile();
1469  coil::Properties prop = NVUtil::toProperties(profile.properties);
1470  CPPUNIT_ASSERT_EQUAL(std::string(""),
1471  prop["dataport.dataflow_type"]);
1472  CPPUNIT_ASSERT_EQUAL(std::string(""),
1473  prop["dataport.interface_type"]);
1474 
1475  coil::vstring cstr = inport.get_m_consumerTypes();
1476  CPPUNIT_ASSERT_EQUAL((size_t)0, cstr.size());
1477 
1478  inport.initConsumers_public();
1479 
1480  profile = inport.getPortProfile();
1481  prop = NVUtil::toProperties(profile.properties);
1482 
1483  //getPortProfileのpropertiesに以下が追加される CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.dataflow_type"]); CPPUNIT_ASSERT_EQUAL(std::string(""), prop["dataport.interface_type"]); //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1484  CPPUNIT_ASSERT_EQUAL(std::string(""),
1485  prop["dataport.dataflow_type"]);
1486  CPPUNIT_ASSERT_EQUAL(std::string(""),
1487  prop["dataport.interface_type"]);
1488 
1489  //ProviderTypes,ConsumerTypesが取得される cstr = inport.get_m_consumerTypes(); CPPUNIT_ASSERT((size_t)0== cstr.size()); portAdmin.deletePort(inport); } /*! * @brief activateInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_activateInterfaces_deactivateInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); inport.publishInterfaces_public(prof); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); inport.publishInterfaces_public(prof); // getConnectorProfiles() RTC::ConnectorInfoList cilist = inport.getConnectorProfiles(); CPPUNIT_ASSERT(cilist.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size()); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name)); CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size()); // getConnectorIds() coil::vstring ids = inport.getConnectorIds(); CPPUNIT_ASSERT(ids.size() == 2); CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0])); CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1])); // getConnectorNames() coil::vstring names = inport.getConnectorNames(); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0])); CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1])); // getConnectorById() RTC::InPortConnector* ic = inport.getConnectorById("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorById("id0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorById("id1"); CPPUNIT_ASSERT(ic != 0); // getConnectorByName() ic = inport.getConnectorByName("unknown"); CPPUNIT_ASSERT(ic == 0); ic = inport.getConnectorByName("InPortBaseTest0"); CPPUNIT_ASSERT(ic != 0); ic = inport.getConnectorByName("InPortBaseTest1"); CPPUNIT_ASSERT(ic != 0); // getConnectorProfileById() RTC::ConnectorInfo info; bool bret = inport.getConnectorProfileById("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileById("id0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileById("id1", info); CPPUNIT_ASSERT( bret ); // getConnectorProfileByName() bret = inport.getConnectorProfileByName("unknown", info); CPPUNIT_ASSERT( !bret ); bret = inport.getConnectorProfileByName("InPortBaseTest0", info); CPPUNIT_ASSERT( bret ); bret = inport.getConnectorProfileByName("InPortBaseTest1", info); CPPUNIT_ASSERT( bret ); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); std::vector<RTC::InPortConnector*> list = inport.get_m_connectors(); inport.activateInterfaces(); inport.deactivateInterfaces(); portAdmin.deletePort(inport); ic = NULL; delete ic; } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでpublisherInterfaceをコール * * */ void test_publishInterfaces2(void) { // //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1490  cstr = inport.get_m_consumerTypes();
1491  CPPUNIT_ASSERT((size_t)0== cstr.size());
1492 
1493  portAdmin.deletePort(inport);
1494 
1495  }
1501  {
1502  //既に "corba_cdr" で登録されている場合は削除する。
1503  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1504  {
1505  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1506  }
1507  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1509  addFactory("corba_cdr",
1514 
1515  //既に "corba_cdr" で登録されている場合は削除する。
1516  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1517  {
1518  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1519  }
1520  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1522  addFactory("corba_cdr",
1527 
1528  //既に "ring_buffer" で登録されている場合は削除する。
1529  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1530  {
1531  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1532  }
1533 
1534  //"ring_buffer" に CdrRingBufferMock を登録する。
1536  addFactory("ring_buffer",
1537  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
1538  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
1539 
1540  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1541  coil::Properties dummy;
1542  inport.init(dummy);
1543 
1544  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1545  portAdmin.registerPort(inport);
1546  RTC::ConnectorProfile prof;
1547  prof.connector_id = "id0";
1548  prof.name = CORBA::string_dup("InPortBaseTest0");
1549  prof.ports.length(1);
1550  prof.ports[0] = inport.get_port_profile()->port_ref;
1551  CORBA_SeqUtil::push_back(prof.properties,
1552  NVUtil::newNV("dataport.interface_type",
1553  "corba_cdr"));
1554  CORBA_SeqUtil::push_back(prof.properties,
1555  NVUtil::newNV("dataport.dataflow_type",
1556  "push"));
1557  CORBA_SeqUtil::push_back(prof.properties,
1558  NVUtil::newNV("dataport.subscription_type",
1559  "new"));
1560  inport.publishInterfaces_public(prof);
1561  prof.connector_id = "id1";
1562  prof.name = CORBA::string_dup("InPortBaseTest1");
1563  inport.publishInterfaces_public(prof);
1564 
1565  // getConnectorProfiles()
1566  RTC::ConnectorInfoList cilist = inport.getConnectorProfiles();
1567  CPPUNIT_ASSERT(cilist.size() == 2);
1568  CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(cilist[0].id));
1569  CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(cilist[0].name));
1570  CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[0].ports.size());
1571  CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(cilist[1].id));
1572  CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(cilist[1].name));
1573  CPPUNIT_ASSERT_EQUAL((size_t)1, cilist[1].ports.size());
1574 
1575  // getConnectorIds()
1576  coil::vstring ids = inport.getConnectorIds();
1577  CPPUNIT_ASSERT(ids.size() == 2);
1578  CPPUNIT_ASSERT_EQUAL(std::string("id0"), std::string(ids[0]));
1579  CPPUNIT_ASSERT_EQUAL(std::string("id1"), std::string(ids[1]));
1580 
1581  // getConnectorNames()
1582  coil::vstring names = inport.getConnectorNames();
1583  CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest0"), std::string(names[0]));
1584  CPPUNIT_ASSERT_EQUAL(std::string("InPortBaseTest1"), std::string(names[1]));
1585 
1586  // getConnectorById()
1587  RTC::InPortConnector* ic = inport.getConnectorById("unknown");
1588  CPPUNIT_ASSERT(ic == 0);
1589  ic = inport.getConnectorById("id0");
1590  CPPUNIT_ASSERT(ic != 0);
1591  ic = inport.getConnectorById("id1");
1592  CPPUNIT_ASSERT(ic != 0);
1593 
1594  // getConnectorByName()
1595  ic = inport.getConnectorByName("unknown");
1596  CPPUNIT_ASSERT(ic == 0);
1597  ic = inport.getConnectorByName("InPortBaseTest0");
1598  CPPUNIT_ASSERT(ic != 0);
1599  ic = inport.getConnectorByName("InPortBaseTest1");
1600  CPPUNIT_ASSERT(ic != 0);
1601 
1602  // getConnectorProfileById()
1603  RTC::ConnectorInfo info;
1604  bool bret = inport.getConnectorProfileById("unknown", info);
1605  CPPUNIT_ASSERT( !bret );
1606  bret = inport.getConnectorProfileById("id0", info);
1607  CPPUNIT_ASSERT( bret );
1608  bret = inport.getConnectorProfileById("id1", info);
1609  CPPUNIT_ASSERT( bret );
1610 
1611  // getConnectorProfileByName()
1612  bret = inport.getConnectorProfileByName("unknown", info);
1613  CPPUNIT_ASSERT( !bret );
1614  bret = inport.getConnectorProfileByName("InPortBaseTest0", info);
1615  CPPUNIT_ASSERT( bret );
1616  bret = inport.getConnectorProfileByName("InPortBaseTest1", info);
1617  CPPUNIT_ASSERT( bret );
1618 
1619  CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size());
1620  std::vector<RTC::InPortConnector*> list = inport.get_m_connectors();
1621  inport.activateInterfaces();
1622  inport.deactivateInterfaces();
1623 
1624  portAdmin.deletePort(inport);
1625 
1626  ic = NULL;
1627  delete ic;
1628  }
1634  {
1635  //既に "corba_cdr" で登録されている場合は削除する。
1636  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1637  {
1638  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1639  }
1640  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1642  addFactory("corba_cdr",
1647 
1648  //既に "corba_cdr" で登録されている場合は削除する。
1649  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1650  {
1651  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1652  }
1653  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1655  addFactory("corba_cdr",
1660 
1661  //既に "ring_buffer" で登録されている場合は削除する。
1662  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1663  {
1664  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1665  }
1666 
1667  //"ring_buffer" に CdrRingBufferMock を登録する。
1669  addFactory("ring_buffer",
1670  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
1671  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
1672 
1673  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1674  coil::Properties dummy;
1675  inport.init(dummy);
1676 
1677  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1678  portAdmin.registerPort(inport);
1679  RTC::ConnectorProfile prof;
1680  prof.connector_id = "id0";
1681  prof.name = CORBA::string_dup("InPortBaseTest0");
1682  prof.ports.length(1);
1683  prof.ports[0] = inport.get_port_profile()->port_ref;
1684  CORBA_SeqUtil::push_back(prof.properties,
1685  NVUtil::newNV("dataport.interface_type",
1686  "corba_cdr"));
1687  CORBA_SeqUtil::push_back(prof.properties,
1688  NVUtil::newNV("dataport.dataflow_type",
1689  "push"));
1690  CORBA_SeqUtil::push_back(prof.properties,
1691  NVUtil::newNV("dataport.subscription_type",
1692  "new"));
1694  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
1695  retcode = inport.publishInterfaces_public(prof);
1696  CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size());
1697  CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode);
1698 
1699  prof.connector_id = "id1";
1700  prof.name = CORBA::string_dup("InPortBaseTest1");
1701  retcode = inport.publishInterfaces_public(prof);
1702  CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size());
1703  CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode);
1704 
1705  portAdmin.deletePort(inport);
1706  }
1714  {
1715  //
1716  //dataport.dataflow_typeがpullでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1717  //
1718 
1719  //既に "corba_cdr" で登録されている場合は削除する。
1720  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1721  {
1722  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1723  }
1724  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1726  addFactory("corba_cdr",
1731 
1732  //既に "corba_cdr" で登録されている場合は削除する。
1733  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1734  {
1735  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1736  }
1737  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1739  addFactory("corba_cdr",
1744 
1745  //既に "ring_buffer" で登録されている場合は削除する。
1746  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1747  {
1748  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1749  }
1750 
1751  //"ring_buffer" に CdrRingBufferMock を登録する。
1753  addFactory("ring_buffer",
1754  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
1755  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
1756 
1757  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1758  coil::Properties dummy;
1759  inport.init(dummy);
1760 
1761  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1762  portAdmin.registerPort(inport);
1763  RTC::ConnectorProfile prof;
1764  prof.connector_id = "id0";
1765  prof.name = CORBA::string_dup("InPortBaseTest0");
1766  prof.ports.length(1);
1767  prof.ports[0] = inport.get_port_profile()->port_ref;
1768  CORBA_SeqUtil::push_back(prof.properties,
1769  NVUtil::newNV("dataport.interface_type",
1770  "corba_cdr"));
1771  CORBA_SeqUtil::push_back(prof.properties,
1772  NVUtil::newNV("dataport.dataflow_type",
1773  "pull"));
1774  CORBA_SeqUtil::push_back(prof.properties,
1775  NVUtil::newNV("dataport.subscription_type",
1776  "new"));
1778  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
1779  retcode = inport.publishInterfaces_public(prof);
1780  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
1781  CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode);
1782 
1783  prof.connector_id = "id1";
1784  prof.name = CORBA::string_dup("InPortBaseTest1");
1785  retcode = inport.publishInterfaces_public(prof);
1786  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
1787  CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode);
1788 
1789  portAdmin.deletePort(inport);
1790  }
1796  {
1797  //
1798  //dataport.dataflow_typeが不正な状態でpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces(),deactivateInterfaces()メソッドのテスト * */ void test_publishInterfaces4(void) { // //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1799  //
1800 
1801  //既に "corba_cdr" で登録されている場合は削除する。
1802  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1803  {
1804  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1805  }
1806  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1808  addFactory("corba_cdr",
1813 
1814  //既に "corba_cdr" で登録されている場合は削除する。
1815  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1816  {
1817  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1818  }
1819  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1821  addFactory("corba_cdr",
1826 
1827  //既に "ring_buffer" で登録されている場合は削除する。
1828  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1829  {
1830  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1831  }
1832 
1833  //"ring_buffer" に CdrRingBufferMock を登録する。
1835  addFactory("ring_buffer",
1836  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
1837  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
1838 
1839  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1840  coil::Properties dummy;
1841  inport.init(dummy);
1842 
1843  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1844  portAdmin.registerPort(inport);
1845  RTC::ConnectorProfile prof;
1846  prof.connector_id = "id0";
1847  prof.name = CORBA::string_dup("InPortBaseTest0");
1848  prof.ports.length(1);
1849  prof.ports[0] = inport.get_port_profile()->port_ref;
1850  CORBA_SeqUtil::push_back(prof.properties,
1851  NVUtil::newNV("dataport.interface_type",
1852  "corba_cdr"));
1853  CORBA_SeqUtil::push_back(prof.properties,
1854  NVUtil::newNV("dataport.dataflow_type",
1855  "else"));
1856  CORBA_SeqUtil::push_back(prof.properties,
1857  NVUtil::newNV("dataport.subscription_type",
1858  "new"));
1860  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
1861  retcode = inport.publishInterfaces_public(prof);
1862  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
1863  CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode);
1864 
1865  prof.connector_id = "id1";
1866  prof.name = CORBA::string_dup("InPortBaseTest1");
1867  retcode = inport.publishInterfaces_public(prof);
1868  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
1869  CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode);
1870 
1871  portAdmin.deletePort(inport);
1872  }
1878  {
1879  //
1880  //ProviderなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief publishInterfaces()メソッドのテスト * */ void test_publishInterfaces5(void) { // //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1881  //
1882 
1883  //既に "corba_cdr" で登録されている場合は削除する。
1884  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1885  {
1886  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1887  }
1888 
1889  //既に "corba_cdr" で登録されている場合は削除する。
1890  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1891  {
1892  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1893  }
1894  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1896  addFactory("corba_cdr",
1901 
1902  //既に "ring_buffer" で登録されている場合は削除する。
1903  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1904  {
1905  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1906  }
1907 
1908  //"ring_buffer" に CdrRingBufferMock を登録する。
1910  addFactory("ring_buffer",
1911  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
1912  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
1913 
1914  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1915  coil::Properties dummy;
1916  inport.init(dummy);
1917 
1918  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1919  portAdmin.registerPort(inport);
1920  RTC::ConnectorProfile prof;
1921  prof.connector_id = "id0";
1922  prof.name = CORBA::string_dup("InPortBaseTest0");
1923  prof.ports.length(1);
1924  prof.ports[0] = inport.get_port_profile()->port_ref;
1925  CORBA_SeqUtil::push_back(prof.properties,
1926  NVUtil::newNV("dataport.interface_type",
1927  "corba_cdr"));
1928  CORBA_SeqUtil::push_back(prof.properties,
1929  NVUtil::newNV("dataport.dataflow_type",
1930  "else"));
1931  CORBA_SeqUtil::push_back(prof.properties,
1932  NVUtil::newNV("dataport.subscription_type",
1933  "new"));
1935  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
1936  retcode = inport.publishInterfaces_public(prof);
1937  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
1938  CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode);
1939 
1940  portAdmin.deletePort(inport);
1941  }
1947  {
1948  //
1949  //BufferなしでpublisherInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.publishInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces(void) { //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); prof.connector_id = "id1"; prof.name = CORBA::string_dup("InPortBaseTest1"); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * dataport.dataflow_typeがpullでsubscribeInterfaceをコール * */ void test_subscribeInterfaces2(void) { // //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
1950  //
1951 
1952  //既に "corba_cdr" で登録されている場合は削除する。
1953  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
1954  {
1955  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
1956  }
1957  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1959  addFactory("corba_cdr",
1964 
1965  //既に "corba_cdr" で登録されている場合は削除する。
1966  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
1967  {
1968  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
1969  }
1970  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
1972  addFactory("corba_cdr",
1977 
1978  //既に "ring_buffer" で登録されている場合は削除する。
1979  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
1980  {
1981  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
1982  }
1983 
1984 
1985  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
1986  coil::Properties dummy;
1987  inport.init(dummy);
1988 
1989  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
1990  portAdmin.registerPort(inport);
1991  RTC::ConnectorProfile prof;
1992  prof.connector_id = "id0";
1993  prof.name = CORBA::string_dup("InPortBaseTest0");
1994  prof.ports.length(1);
1995  prof.ports[0] = inport.get_port_profile()->port_ref;
1996  CORBA_SeqUtil::push_back(prof.properties,
1997  NVUtil::newNV("dataport.interface_type",
1998  "corba_cdr"));
1999  CORBA_SeqUtil::push_back(prof.properties,
2000  NVUtil::newNV("dataport.dataflow_type",
2001  "else"));
2002  CORBA_SeqUtil::push_back(prof.properties,
2003  NVUtil::newNV("dataport.subscription_type",
2004  "new"));
2006  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2007  retcode = inport.publishInterfaces_public(prof);
2008  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2009  CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode);
2010 
2011 
2012  portAdmin.deletePort(inport);
2013  }
2019  {
2020  //既に "corba_cdr" で登録されている場合は削除する。
2021  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
2022  {
2023  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
2024  }
2025  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
2027  addFactory("corba_cdr",
2032 
2033  //既に "corba_cdr" で登録されている場合は削除する。
2034  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
2035  {
2036  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
2037  }
2038  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
2040  addFactory("corba_cdr",
2045 
2046  //既に "ring_buffer" で登録されている場合は削除する。
2047  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
2048  {
2049  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
2050  }
2051 
2052  //"ring_buffer" に CdrRingBufferMock を登録する。
2054  addFactory("ring_buffer",
2055  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
2056  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
2057 
2058  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
2059  coil::Properties dummy;
2060  inport.init(dummy);
2061 
2062  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
2063  portAdmin.registerPort(inport);
2064  RTC::ConnectorProfile prof;
2065  prof.connector_id = "id0";
2066  prof.name = CORBA::string_dup("InPortBaseTest0");
2067  prof.ports.length(1);
2068  prof.ports[0] = inport.get_port_profile()->port_ref;
2069  CORBA_SeqUtil::push_back(prof.properties,
2070  NVUtil::newNV("dataport.interface_type",
2071  "corba_cdr"));
2072  CORBA_SeqUtil::push_back(prof.properties,
2073  NVUtil::newNV("dataport.dataflow_type",
2074  "pull"));
2075  CORBA_SeqUtil::push_back(prof.properties,
2076  NVUtil::newNV("dataport.subscription_type",
2077  "new"));
2079  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2080  retcode = inport.subscribeInterfaces_public(prof);
2081  CPPUNIT_ASSERT_EQUAL(1,(int)inport.get_m_connectors().size());
2082  CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode);
2083 
2084  prof.connector_id = "id1";
2085  prof.name = CORBA::string_dup("InPortBaseTest1");
2086  retcode = inport.subscribeInterfaces_public(prof);
2087  CPPUNIT_ASSERT_EQUAL(2,(int)inport.get_m_connectors().size());
2088  CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK,retcode);
2089 
2090  portAdmin.deletePort(inport);
2091  }
2098  {
2099  //
2100  //dataport.dataflow_typeがpullでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces3(void) { // //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
2101  //
2102 
2103  //既に "corba_cdr" で登録されている場合は削除する。
2104  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
2105  {
2106  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
2107  }
2108  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
2110  addFactory("corba_cdr",
2115 
2116  //既に "corba_cdr" で登録されている場合は削除する。
2117  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
2118  {
2119  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
2120  }
2121  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
2123  addFactory("corba_cdr",
2128 
2129  //既に "ring_buffer" で登録されている場合は削除する。
2130  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
2131  {
2132  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
2133  }
2134 
2135  //"ring_buffer" に CdrRingBufferMock を登録する。
2137  addFactory("ring_buffer",
2138  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
2139  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
2140 
2141  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
2142  coil::Properties dummy;
2143  inport.init(dummy);
2144 
2145  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
2146  portAdmin.registerPort(inport);
2147  RTC::ConnectorProfile prof;
2148  prof.connector_id = "id0";
2149  prof.name = CORBA::string_dup("InPortBaseTest0");
2150  prof.ports.length(1);
2151  prof.ports[0] = inport.get_port_profile()->port_ref;
2152  CORBA_SeqUtil::push_back(prof.properties,
2153  NVUtil::newNV("dataport.interface_type",
2154  "corba_cdr"));
2155  CORBA_SeqUtil::push_back(prof.properties,
2156  NVUtil::newNV("dataport.dataflow_type",
2157  "push"));
2158  CORBA_SeqUtil::push_back(prof.properties,
2159  NVUtil::newNV("dataport.subscription_type",
2160  "new"));
2162  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2163  retcode = inport.subscribeInterfaces_public(prof);
2164  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2165  CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode);
2166 
2167 
2168  portAdmin.deletePort(inport);
2169  }
2175  {
2176  //
2177  //dataport.dataflow_typeが不正な状態でsubscrtibeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "else")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces4(void) { // //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
2178  //
2179 
2180  //既に "corba_cdr" で登録されている場合は削除する。
2181  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
2182  {
2183  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
2184  }
2185  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
2187  addFactory("corba_cdr",
2192 
2193  //既に "corba_cdr" で登録されている場合は削除する。
2194  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
2195  {
2196  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
2197  }
2198  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
2200  addFactory("corba_cdr",
2205 
2206  //既に "ring_buffer" で登録されている場合は削除する。
2207  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
2208  {
2209  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
2210  }
2211 
2212  //"ring_buffer" に CdrRingBufferMock を登録する。
2214  addFactory("ring_buffer",
2215  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
2216  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
2217 
2218  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
2219  coil::Properties dummy;
2220  inport.init(dummy);
2221 
2222  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
2223  portAdmin.registerPort(inport);
2224  RTC::ConnectorProfile prof;
2225  prof.connector_id = "id0";
2226  prof.name = CORBA::string_dup("InPortBaseTest0");
2227  prof.ports.length(1);
2228  prof.ports[0] = inport.get_port_profile()->port_ref;
2229  CORBA_SeqUtil::push_back(prof.properties,
2230  NVUtil::newNV("dataport.interface_type",
2231  "corba_cdr"));
2232  CORBA_SeqUtil::push_back(prof.properties,
2233  NVUtil::newNV("dataport.dataflow_type",
2234  "else"));
2235  CORBA_SeqUtil::push_back(prof.properties,
2236  NVUtil::newNV("dataport.subscription_type",
2237  "new"));
2239  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2240  retcode = inport.subscribeInterfaces_public(prof);
2241  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2242  CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode);
2243 
2244 
2245  portAdmin.deletePort(inport);
2246  }
2252  {
2253  //
2254  //ConsumerなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode); portAdmin.deletePort(inport); } /*! * @brief subscribeInterfaces()メソッドのテスト * */ void test_subscribeInterfaces5(void) { // //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
2255  //
2256 
2257  //既に "corba_cdr" で登録されている場合は削除する。
2258  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
2259  {
2260  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
2261  }
2262  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
2264  addFactory("corba_cdr",
2269 
2270  //既に "corba_cdr" で登録されている場合は削除する。
2271  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
2272  {
2273  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
2274  }
2275 
2276  //既に "ring_buffer" で登録されている場合は削除する。
2277  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
2278  {
2279  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
2280  }
2281 
2282  //"ring_buffer" に CdrRingBufferMock を登録する。
2284  addFactory("ring_buffer",
2285  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
2286  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
2287 
2288  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
2289  coil::Properties dummy;
2290  inport.init(dummy);
2291 
2292  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
2293  portAdmin.registerPort(inport);
2294  RTC::ConnectorProfile prof;
2295  prof.connector_id = "id0";
2296  prof.name = CORBA::string_dup("InPortBaseTest0");
2297  prof.ports.length(1);
2298  prof.ports[0] = inport.get_port_profile()->port_ref;
2299  CORBA_SeqUtil::push_back(prof.properties,
2300  NVUtil::newNV("dataport.interface_type",
2301  "corba_cdr"));
2302  CORBA_SeqUtil::push_back(prof.properties,
2303  NVUtil::newNV("dataport.dataflow_type",
2304  "pull"));
2305  CORBA_SeqUtil::push_back(prof.properties,
2306  NVUtil::newNV("dataport.subscription_type",
2307  "new"));
2309  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2310  retcode = inport.subscribeInterfaces_public(prof);
2311  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2312  CPPUNIT_ASSERT_EQUAL(RTC::BAD_PARAMETER,retcode);
2313 
2314  portAdmin.deletePort(inport);
2315  }
2321  {
2322  //
2323  //BufferなしでsubscribeInterfaceをコール // //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>, ::coil::Destructor< ::RTC::InPortProvider, InPortCorbaCdrProviderMock>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>, ::coil::Destructor< ::RTC::OutPortConsumer, OutPortCorbaCdrConsumerMock>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>()); coil::Properties dummy; inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("InPortBaseTest0"); prof.ports.length(1); prof.ports[0] = inport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "pull")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "new")); RTC::ReturnCode_t retcode; CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); retcode = inport.subscribeInterfaces_public(prof); CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size()); CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode); portAdmin.deletePort(inport); } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0!= connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief createConnector()メソッドのテスト * */ void test_createConnector2(void) { InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>()); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; coil::Properties prop(inport.properties()); prop.setProperty("InPortBaseTests","bad_alloc"); RTC::InPortProvider* provider = new InPortCorbaCdrProviderMock(); RTC::InPortConnector* connector = inport.createConnector_public(prof, prop, provider); CPPUNIT_ASSERT(0 != connector); portAdmin.deletePort(inport); // delete provider; } /*! * @brief addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト * */ void test_ConnectorListener(void) { RTC::TimedLong tdl; OutPortMock<RTC::TimedLong> outport("OutPort", tdl); coil::Properties dummy; outport.init(dummy); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") ) { RTC::InPortProviderFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::InPortProviderFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>, ::coil::Destructor< ::RTC::InPortProvider, ::RTC::InPortCorbaCdrProvider>); //既に "corba_cdr" で登録されている場合は削除する。 if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") ) { RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr"); } //"corba_cdr" に InPortCorbaCdrProvider を登録する。 RTC::OutPortConsumerFactory::instance(). addFactory("corba_cdr", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>, ::coil::Destructor< ::RTC::OutPortConsumer, ::RTC::OutPortCorbaCdrConsumer>); //既に "ring_buffer" で登録されている場合は削除する。 if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") ) { RTC::CdrBufferFactory::instance().removeFactory("ring_buffer"); } //"ring_buffer" に CdrRingBufferMock を登録する。 RTC::CdrBufferFactory::instance(). addFactory("ring_buffer", coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>, coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>); InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>()); inport.init(dummy); RTC::PortAdmin portAdmin(m_pORB,m_pPOA); portAdmin.registerPort(inport); RTC::ConnectorProfile prof; prof.connector_id = "id0"; prof.name = CORBA::string_dup("connectTest0"); prof.ports.length(2); prof.ports[0] = inport.get_port_profile()->port_ref; prof.ports[1] = outport.get_port_profile()->port_ref; CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.interface_type", "corba_cdr")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.dataflow_type", "push")); CORBA_SeqUtil::push_back(prof.properties, NVUtil::newNV("dataport.subscription_type", "flush")); //ConnectorDataListeners settting for (int i(0); i<cdl_len; ++i) { m_datalisteners[i] = new DataListener(str_cdl[i]); } //ConnectorListeners settting for (int i(0); i<cl_len; ++i) { m_connlisteners[i] = new ConnListener(str_cl[i]); } // addConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.addConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i], true); } // addConnectorListener() for (int i(0); i<cl_len; ++i) { inport.addConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i], true); } // Listener add count check CPPUNIT_ASSERT_EQUAL(10, cdl_count); CPPUNIT_ASSERT_EQUAL(7, cl_count); inport.publishInterfaces_public(prof); // connect() RTC::ReturnCode_t ret; ret = inport.connect(prof); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); // isLittleEndian() // little set & check bool bret = inport.isLittleEndian(); CPPUNIT_ASSERT( bret ); tdl.data = 100; outport.write(tdl); inport.activateInterfaces(); inport.deactivateInterfaces(); ret = inport.disconnect_all(); CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret); portAdmin.deletePort(inport); // removeConnectorDataListener() for (int i(0); i<cdl_len; ++i) { inport.removeConnectorDataListener((RTC::ConnectorDataListenerType)i, m_datalisteners[i]); } // removeConnectorListener() for (int i(0); i<cl_len; ++i) { inport.removeConnectorListener((RTC::ConnectorListenerType)i, m_connlisteners[i]); } // Listener remove count check CPPUNIT_ASSERT_EQUAL(0, cdl_count); CPPUNIT_ASSERT_EQUAL(0, cl_count); } }; }; // namespace OutPortBase /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // OutPortBase_cpp
2324  //
2325 
2326  //既に "corba_cdr" で登録されている場合は削除する。
2327  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
2328  {
2329  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
2330  }
2331  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
2333  addFactory("corba_cdr",
2338 
2339  //既に "corba_cdr" で登録されている場合は削除する。
2340  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
2341  {
2342  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
2343  }
2344  //"corba_cdr" に InPortCorbaCdrProviderMock を登録する。
2346  addFactory("corba_cdr",
2351 
2352  //既に "ring_buffer" で登録されている場合は削除する。
2353  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
2354  {
2355  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
2356  }
2357 
2358  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedFloat>());
2359  coil::Properties dummy;
2360  inport.init(dummy);
2361 
2362  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
2363  portAdmin.registerPort(inport);
2364  RTC::ConnectorProfile prof;
2365  prof.connector_id = "id0";
2366  prof.name = CORBA::string_dup("InPortBaseTest0");
2367  prof.ports.length(1);
2368  prof.ports[0] = inport.get_port_profile()->port_ref;
2369  CORBA_SeqUtil::push_back(prof.properties,
2370  NVUtil::newNV("dataport.interface_type",
2371  "corba_cdr"));
2372  CORBA_SeqUtil::push_back(prof.properties,
2373  NVUtil::newNV("dataport.dataflow_type",
2374  "pull"));
2375  CORBA_SeqUtil::push_back(prof.properties,
2376  NVUtil::newNV("dataport.subscription_type",
2377  "new"));
2379  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2380  retcode = inport.subscribeInterfaces_public(prof);
2381  CPPUNIT_ASSERT_EQUAL(0,(int)inport.get_m_connectors().size());
2382  CPPUNIT_ASSERT_EQUAL(RTC::RTC_ERROR,retcode);
2383 
2384  portAdmin.deletePort(inport);
2385  }
2391  {
2392  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>());
2393 
2394  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
2395  portAdmin.registerPort(inport);
2396 
2397  RTC::ConnectorProfile prof;
2398 
2399  coil::Properties prop(inport.properties());
2401  RTC::InPortConnector* connector
2402  = inport.createConnector_public(prof, prop, provider);
2403  CPPUNIT_ASSERT(0!= connector);
2404 
2405  portAdmin.deletePort(inport);
2406 // delete provider;
2407  }
2413  {
2414  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedDouble>());
2415 
2416  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
2417  portAdmin.registerPort(inport);
2418 
2419  RTC::ConnectorProfile prof;
2420 
2421  coil::Properties prop(inport.properties());
2422  prop.setProperty("InPortBaseTests","bad_alloc");
2424  RTC::InPortConnector* connector
2425  = inport.createConnector_public(prof, prop, provider);
2426  CPPUNIT_ASSERT(0 != connector);
2427 
2428  portAdmin.deletePort(inport);
2429 // delete provider;
2430  }
2431 
2437  {
2438  RTC::TimedLong tdl;
2439  OutPortMock<RTC::TimedLong> outport("OutPort", tdl);
2440  coil::Properties dummy;
2441  outport.init(dummy);
2442 
2443  //既に "corba_cdr" で登録されている場合は削除する。
2444  if( RTC::InPortProviderFactory::instance().hasFactory("corba_cdr") )
2445  {
2446  RTC::InPortProviderFactory::instance().removeFactory("corba_cdr");
2447  }
2448  //"corba_cdr" に InPortCorbaCdrProvider を登録する。
2450  addFactory("corba_cdr",
2455 
2456  //既に "corba_cdr" で登録されている場合は削除する。
2457  if( RTC::OutPortConsumerFactory::instance().hasFactory("corba_cdr") )
2458  {
2459  RTC::OutPortConsumerFactory::instance().removeFactory("corba_cdr");
2460  }
2461  //"corba_cdr" に InPortCorbaCdrProvider を登録する。
2463  addFactory("corba_cdr",
2468 
2469  //既に "ring_buffer" で登録されている場合は削除する。
2470  if( RTC::CdrBufferFactory::instance().hasFactory("ring_buffer") )
2471  {
2472  RTC::CdrBufferFactory::instance().removeFactory("ring_buffer");
2473  }
2474 
2475  //"ring_buffer" に CdrRingBufferMock を登録する。
2477  addFactory("ring_buffer",
2478  coil::Creator<RTC::CdrBufferBase, CdrRingBufferMock>,
2479  coil::Destructor<RTC::CdrBufferBase, CdrRingBufferMock>);
2480 
2481  InPortBaseMock inport("InPortBaseTest", toTypename<RTC::TimedLong>());
2482  inport.init(dummy);
2483 
2484  RTC::PortAdmin portAdmin(m_pORB,m_pPOA);
2485  portAdmin.registerPort(inport);
2486  RTC::ConnectorProfile prof;
2487  prof.connector_id = "id0";
2488  prof.name = CORBA::string_dup("connectTest0");
2489  prof.ports.length(2);
2490  prof.ports[0] = inport.get_port_profile()->port_ref;
2491  prof.ports[1] = outport.get_port_profile()->port_ref;
2492  CORBA_SeqUtil::push_back(prof.properties,
2493  NVUtil::newNV("dataport.interface_type",
2494  "corba_cdr"));
2495  CORBA_SeqUtil::push_back(prof.properties,
2496  NVUtil::newNV("dataport.dataflow_type",
2497  "push"));
2498  CORBA_SeqUtil::push_back(prof.properties,
2499  NVUtil::newNV("dataport.subscription_type",
2500  "flush"));
2501 
2502  //ConnectorDataListeners settting
2503  for (int i(0); i<cdl_len; ++i)
2504  {
2505  m_datalisteners[i] = new DataListener(str_cdl[i]);
2506  }
2507 
2508  //ConnectorListeners settting
2509  for (int i(0); i<cl_len; ++i)
2510  {
2511  m_connlisteners[i] = new ConnListener(str_cl[i]);
2512  }
2513 
2514  // addConnectorDataListener()
2515  for (int i(0); i<cdl_len; ++i)
2516  {
2518  m_datalisteners[i], true);
2519  }
2520 
2521  // addConnectorListener()
2522  for (int i(0); i<cl_len; ++i)
2523  {
2525  m_connlisteners[i], true);
2526  }
2527 
2528  // Listener add count check
2529  CPPUNIT_ASSERT_EQUAL(10, cdl_count);
2530  CPPUNIT_ASSERT_EQUAL(7, cl_count);
2531 
2532  inport.publishInterfaces_public(prof);
2533 
2534  // connect()
2536  ret = inport.connect(prof);
2537  CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret);
2538 
2539  // isLittleEndian()
2540  // little set & check
2541  bool bret = inport.isLittleEndian();
2542  CPPUNIT_ASSERT( bret );
2543 
2544  tdl.data = 100;
2545  outport.write(tdl);
2546 
2547  inport.activateInterfaces();
2548  inport.deactivateInterfaces();
2549  ret = inport.disconnect_all();
2550  CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret);
2551 
2552  portAdmin.deletePort(inport);
2553  // removeConnectorDataListener()
2554  for (int i(0); i<cdl_len; ++i)
2555  {
2557  m_datalisteners[i]);
2558  }
2559 
2560  // removeConnectorListener()
2561  for (int i(0); i<cl_len; ++i)
2562  {
2564  m_connlisteners[i]);
2565  }
2566 
2567  // Listener remove count check
2568  CPPUNIT_ASSERT_EQUAL(0, cdl_count);
2569  CPPUNIT_ASSERT_EQUAL(0, cl_count);
2570 
2571  }
2572 
2573  };
2574 }; // namespace OutPortBase
2575 
2576 
2577 /*
2578  * Register test suite
2579  */
2581 
2582 #ifdef LOCAL_MAIN
2583 int main(int argc, char* argv[])
2584 {
2585 
2586  FORMAT format = TEXT_OUT;
2587  int target = 0;
2588  std::string xsl;
2589  std::string ns;
2590  std::string fname;
2591  std::ofstream ofs;
2592 
2593  int i(1);
2594  while (i < argc)
2595  {
2596  std::string arg(argv[i]);
2597  std::string next_arg;
2598  if (i + 1 < argc) next_arg = argv[i + 1];
2599  else next_arg = "";
2600 
2601  if (arg == "--text") { format = TEXT_OUT; break; }
2602  if (arg == "--xml")
2603  {
2604  if (next_arg == "")
2605  {
2606  fname = argv[0];
2607  fname += ".xml";
2608  }
2609  else
2610  {
2611  fname = next_arg;
2612  }
2613  format = XML_OUT;
2614  ofs.open(fname.c_str());
2615  }
2616  if ( arg == "--compiler" ) { format = COMPILER_OUT; break; }
2617  if ( arg == "--cerr" ) { target = 1; break; }
2618  if ( arg == "--xsl" )
2619  {
2620  if (next_arg == "") xsl = "default.xsl";
2621  else xsl = next_arg;
2622  }
2623  if ( arg == "--namespace" )
2624  {
2625  if (next_arg == "")
2626  {
2627  std::cerr << "no namespace specified" << std::endl;
2628  exit(1);
2629  }
2630  else
2631  {
2632  xsl = next_arg;
2633  }
2634  }
2635  ++i;
2636  }
2637  CppUnit::TextUi::TestRunner runner;
2638  if ( ns.empty() )
2639  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
2640  else
2641  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
2642  CppUnit::Outputter* outputter = 0;
2643  std::ostream* stream = target ? &std::cerr : &std::cout;
2644  switch ( format )
2645  {
2646  case TEXT_OUT :
2647  outputter = new CppUnit::TextOutputter(&runner.result(),*stream);
2648  break;
2649  case XML_OUT :
2650  std::cout << "XML_OUT" << std::endl;
2651  outputter = new CppUnit::XmlOutputter(&runner.result(),
2652  ofs, "shift_jis");
2653  static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl);
2654  break;
2655  case COMPILER_OUT :
2656  outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream);
2657  break;
2658  }
2659  runner.setOutputter(outputter);
2660  runner.run();
2661  return 0; // runner.run() ? 0 : 1;
2662 }
2663 #endif // MAIN
2664 #endif // OutPortBase_cpp
SDOPackage::NameValue newNV(const char *name, Value value)
Create NameValue.
Definition: NVUtil.h:79
void test_subscribeInterfaces2(void)
subscribeInterfaces()メソッドのテスト dataport.dataflow_typeがpullでsubscribeInterfaceをコール
void set_read_return_value(::RTC::BufferStatus::Enum value)
ConnectorListeners class.
void test_initConsumers()
initConsumers()メソッドのテスト
#define RTC_ERROR(fmt)
Error log output macro.
Definition: SystemLogger.h:422
int main(int argc, char **argv)
virtual ReturnCode_t subscribeInterfaces(const ConnectorProfile &connector_profile)
Subscribe to the interface.
Definition: InPortBase.cpp:541
coil::Properties & properties()
Get properties.
Definition: InPortBase.cpp:134
void setBuffer(RTC::BufferBase< cdrMemoryStream > *buffer)
Setting outside buffer&#39;s pointer.
InPortConnector base class.
CORBA Consumer class.
InPortProvider class.
void test_subscribeInterfaces5(void)
subscribeInterfaces()メソッドのテスト
RT-Component.
ConnListener(const char *name)
RTC::CdrBufferBase * getThebuffer()
virtual ReturnCode_t connect(ConnectorProfile &connector_profile)
[CORBA interface] Connect the Port
Definition: InPortBase.cpp:433
ConnectorListener class.
virtual void setUp()
Test initialization.
::OpenRTM::PortStatus put(const ::OpenRTM::CdrData &data)
AbstractClass * Creator()
Creator template.
ReturnCode_t
Definition: doil.h:53
void test_init3()
init()メソッドのテスト
std::vector< std::pair< std::string, std::string > > NVList
Definition: IRTC.h:67
void log(const std::string &msg)
void log(const std::string &msg)
BUFFERSTATUS_ENUM RingBufferMock(long int length=8)
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
OutPort class.
::OpenRTM::PortStatus put(const ::OpenRTM::CdrData &data)
PortableServer::POA_ptr m_pPOA
virtual void init(const coil::Properties &prop)
Set the buffer.
void test_publishInterfaces(void)
publishInterfaces()メソッドのテスト
void test_init2()
init()メソッドのテスト
CORBA::ORB_ptr getORB()
Get the pointer to ORB.
Definition: Manager.cpp:832
std::vector< ConnectorInfo > ConnectorInfoList
RingBufferMock< cdrMemoryStream > CdrRingBufferMock
void test_init()
init()メソッドのテスト
Typename function.
OutPortConsumer class.
void setListener(RTC::ConnectorInfo &info, RTC::ConnectorListeners *listeners)
Set the listener.
bool isLittleEndian()
return it whether endian setting.
Definition: InPortBase.cpp:421
InPortBaseMock(const char *name, const char *data_type)
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
Definition: Singleton.h:131
static Manager & instance()
Get instance of the manager.
Definition: Manager.cpp:140
virtual void deactivateInterfaces()
Deactivate all Port interfaces.
Definition: InPortBase.cpp:322
static const char * str_cl[]
bool read()
It is a virtual method that is called from RTObject_impl::readAll(). This method reads out data from ...
coil::vstring get_m_consumerTypes()
string outport
Definition: README_gen.py:115
Enum
DataPortStatus return codes.
Definition: BufferStatus.h:84
OutPortCorbaCdrConsumer class.
virtual void activateInterfaces()
Activate all Port interfaces.
Definition: InPortBase.cpp:302
void init(coil::Properties &prop)
virtual size_t readable() const
Write data into the buffer.
InPortProvider.
PortAdmin class.
Definition: PortAdmin.h:52
void unsubscribeInterface(const SDOPackage::NVList &properties)
Unsubscribe the data receive notification.
InPortCorbaCdrProvider class.
void setLogger(Logger *logger)
virtual ReturnCode advanceRptr(long int n=1)
Forward n reading pointers.
virtual ReturnCode length(size_t n)
Set the buffer length.
std::vector< std::string > vstring
Definition: stringutil.h:37
ConnectorDataListenerType
The types of ConnectorDataListener.
InPortConnector * createConnector(ConnectorProfile &cprof, coil::Properties &prop, InPortProvider *provider)
InPortPushConnector creation.
Definition: InPortBase.cpp:902
OutPortMock(const char *name, DataType &value)
bool subscribeInterface(const SDOPackage::NVList &properties)
void test_createConnector(void)
createConnector()メソッドのテスト
#define BUFFERSTATUS_ENUM
Importing RTC::BufferStatus macro.
Definition: BufferStatus.h:157
string inport
Definition: README_gen.py:90
InPortConnector * getConnectorByName(const char *name)
Getting Connector by name.
Definition: InPortBase.cpp:238
void setConnector(RTC::InPortConnector *connector)
set Connector
InPortCorbaCdrProvider class.
#define cl_len
static int cl_count
coil::Properties get_m_properties()
void test_publishInterfaces2(void)
publishInterfaces()メソッドのテスト dataport.dataflow_typeがpullでpublisherInterfaceをコール
ConnectorDataListenerT class.
void removeConnectorDataListener(ConnectorDataListenerType listener_type, ConnectorDataListener *listener)
Removing BufferDataListener type listener.
Definition: InPortBase.cpp:363
void registerPort(PortBase &port)
Regsiter the Port.
Definition: PortAdmin.cpp:239
InPortConnector base class.
virtual RTC::ReturnCode_t publishInterfaces_public(RTC::ConnectorProfile &connector_profile)
virtual ReturnCode write(const DataType &value, long int sec=-1, long int nsec=-1)
Write data into the buffer.
RTC::InPortProvider * createProvider_public(RTC::ConnectorProfile &cprof, coil::Properties &prop)
virtual void tearDown()
Test finalization.
void init(coil::Properties &prop)
Initializing configuration.
bool getConnectorProfileById(const char *id, ConnectorInfo &prof)
Getting ConnectorProfile by name.
Definition: InPortBase.cpp:261
OutPortProvider class.
void test_publishInterfaces5(void)
publishInterfaces()メソッドのテスト
ConnectorInfoList getConnectorProfiles()
ConnectorProfile list.
Definition: InPortBase.cpp:161
void test_subscribeInterfaces(void)
subscribeInterfaces()メソッドのテスト
Push type connector class.
virtual bool empty(void) const
Check on whether the buffer is empty.
coil::vstring getConnectorIds()
ConnectorId list.
Definition: InPortBase.cpp:179
std::string name
Connection name.
void init(coil::Properties &prop)
Initializing properties.
bool getConnectorProfileByName(const char *name, ConnectorInfo &prof)
Getting ConnectorProfile by name.
Definition: InPortBase.cpp:281
void addConnectorListener(ConnectorListenerType callback_type, ConnectorListener *listener, bool autoclean=true)
Adding ConnectorListener type listener.
Definition: InPortBase.cpp:386
OutPortCorbaCdrConsumer class.
Port for InPort.
Definition: InPortBase.h:67
void test_initConsumers2()
initConsumers()メソッドのテスト
virtual DataType * rptr(long int n=0)
Get the reading pointer.
RTC::ConnectorListeners m_listeners
::RTC::BufferStatus::Enum ReturnCode
prop
Organization::get_organization_property ();.
virtual PortProfile * get_port_profile()
[CORBA interface] Get the PortProfile of the Port
Definition: PortBase.cpp:100
#define cdl_len
RTC::Port implementation for InPort.
coil::Properties toProperties(const SDOPackage::NVList &nv)
Transform NVList to the properties.
Definition: NVUtil.cpp:180
InPortBase base class.
void test_subscribeInterfaces4(void)
subscribeInterfaces()メソッドのテスト
void test_activateInterfaces_deactivateInterfaces(void)
activateInterfaces(),deactivateInterfaces()メソッドのテスト
void Destructor(AbstractClass *&obj)
Destructor template.
ConnectorListenerType
The types of ConnectorListener.
Class represents a set of properties.
Definition: Properties.h:101
virtual size_t length(void) const
Get the buffer length.
void removeConnectorListener(ConnectorListenerType callback_type, ConnectorListener *listener)
Removing BufferDataListener type listener.
Definition: InPortBase.cpp:401
std::vector< std::string > m_log
virtual ReturnCode put(const DataType &value)
Write data into the buffer.
void test_publishInterfaces3(void)
publishInterfaces()メソッドのテスト
void setBuffer(RTC::BufferBase< cdrMemoryStream > *buffer)
Setting outside buffer&#39;s pointer.
void setListener(RTC::ConnectorInfo &info, RTC::ConnectorListeners *listeners)
Set the listener.
virtual size_t writable() const
Get a writable number.
virtual bool full(void) const
Check on whether the buffer is full.
OutPort template class.
Definition: OutPort.h:106
virtual ReturnCode reset()
Reset the buffer status.
virtual bool write(DataType &value)
Write data.
Definition: OutPort.h:203
::OutPortBase::Logger logger
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
OutPortConsumer abstract class.
std::vector< DataType > m_buffer
RTComponent header.
bret
7 送受信データ比較
Definition: ConnectTest.py:377
std::vector< ConnectorBase * > ConnectorList
void test_subscribeInterfaces3(void)
subscribeInterfaces()メソッドのテスト
virtual void operator()(const RTC::ConnectorInfo &info, const RTC::TimedLong &data)
Virtual Callback method.
coil::vstring getConnectorNames()
Connector name list.
Definition: InPortBase.cpp:197
void deletePort(PortBase &port)
Unregister the Port registration.
Definition: PortAdmin.cpp:297
InPortConnector * getConnectorById(const char *id)
Getting ConnectorProfile by ID.
Definition: InPortBase.cpp:215
void test_initProviders2()
initProviders()メソッドのテスト The provider is not registered in Factory.
virtual RTC::ReturnCode_t subscribeInterfaces_public(RTC::ConnectorProfile &connector_profile)
void init(coil::Properties &prop)
Initializing properties.
Definition: InPortBase.cpp:96
virtual ReturnCode_t disconnect_all()
[CORBA interface] Disconnect the All Ports
Definition: PortBase.cpp:454
RTC::InPortConsumer::ReturnCode put(const cdrMemoryStream &data)
void test_createConnector2(void)
createConnector()メソッドのテスト
void test_publishInterfaces4(void)
publishInterfaces(),deactivateInterfaces()メソッドのテスト
void publishInterfaceProfile(SDOPackage::NVList &properties)
BufferBase abstract class.
Definition: BufferBase.h:104
void test_initProviders()
initProviders()メソッドのテスト
DataListener(const char *name)
void unsubscribeInterface(const SDOPackage::NVList &properties)
virtual ReturnCode advanceWptr(long int n=1)
Forward n writing pointers.
void init(coil::Properties &prop)
Initializing configuration.
InPortConsumer class.
connector listener class
void addConnectorDataListener(ConnectorDataListenerType listener_type, ConnectorDataListener *listener, bool autoclean=true)
Adding BufferDataListener type listener.
Definition: InPortBase.cpp:347
static const char * str_cdl[]
void test_constructor()
コンスラクタのテスト
static int cdl_count
RTC&#39;s Port administration class.
void publishInterfaceProfile(SDOPackage::NVList &properties)
Publish InterfaceProfile information.
int countLog(const std::string &msg)
CPPUNIT_TEST_SUITE_REGISTRATION(InPortBase::InPortBaseTests)
RTC::InPortConnector * createConnector_public(RTC::ConnectorProfile &cprof, coil::Properties &prop, RTC::InPortProvider *provider)
InPortProvider * createProvider(ConnectorProfile &cprof, coil::Properties &prop)
InPort provider creation.
Definition: InPortBase.cpp:803
virtual DataType * wptr(long int n=0)
Get the writing pointer.
const PortProfile & getPortProfile() const
Get the PortProfile of the Port.
Definition: PortBase.cpp:119
::RTC::BufferStatus::Enum m_read_return_value
virtual void operator()(const RTC::ConnectorInfo &info)
Virtual Callback method.
bool subscribeInterface(const SDOPackage::NVList &properties)
Subscribe the data receive notification.
void test_ConnectorListener(void)
addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト
virtual ReturnCode read(DataType &value, long int sec=-1, long int nsec=-1)
Read data from the buffer.
virtual ReturnCode_t publishInterfaces(ConnectorProfile &connector_profile)
Publish interface information.
Definition: InPortBase.cpp:462
RTC::OutPortConsumer::ReturnCode put(const cdrMemoryStream &data)


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:52