00001
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef PortBase_cpp
00049 #define PortBase_cpp
00050
00051 #include <cppunit/ui/text/TestRunner.h>
00052 #include <cppunit/TextOutputter.h>
00053 #include <cppunit/extensions/TestFactoryRegistry.h>
00054 #include <cppunit/extensions/HelperMacros.h>
00055 #include <cppunit/TestAssert.h>
00056
00057 #include <vector>
00058 #include <string>
00059 #include <rtm/RTC.h>
00060 #include <rtm/PortBase.h>
00061 #include <rtm/RTObject.h>
00062 #include <rtm/PortCallback.h>
00063
00069 namespace PortBase
00070 {
00071
00072 class ConnectionCallbackMock : public RTC::ConnectionCallback
00073 {
00074 public:
00075 ConnectionCallbackMock(const char* name) : m_name(name) {}
00076 virtual ~ConnectionCallbackMock()
00077 {
00078
00079 }
00080
00081 virtual void operator()(RTC::ConnectorProfile& profile)
00082 {
00083 std::cout << "---------------------------------------------" << std::endl;
00084 std::cout << "Connection Callback: " << m_name << std::endl;
00085 std::cout << "Profile::name: " << profile.name << std::endl;
00086 std::cout << "---------------------------------------------" << std::endl;
00087 };
00088 std::string m_name;
00089 };
00090
00091
00092 class PortBaseMock : public RTC::PortBase
00093 {
00094 public:
00095
00096 PortBaseMock(const RTC::PortProfile& profile)
00097 {
00098 this->m_profile = profile;
00099 this->m_profile.connector_profiles[0].ports.length(1);
00100 this->m_profile.connector_profiles[0].ports[0] = this->m_objref;
00101 this->m_profile.port_ref = this->m_objref;
00102 }
00103
00104 const std::string getUUID() const
00105 {
00106 return RTC::PortBase::getUUID();
00107 }
00108
00109 virtual RTC::ReturnCode_t notify_connect(RTC::ConnectorProfile& connector_profile)
00110 throw (CORBA::SystemException)
00111 {
00112 _notifyConnectTimes.push_back(getNow());
00113 return PortBase::notify_connect(connector_profile);
00114 }
00115
00116 virtual RTC::ReturnCode_t notify_disconnect(const char* connector_id)
00117 throw (CORBA::SystemException)
00118 {
00119 _notifyDisconnectTimes.push_back(getNow());
00120 return PortBase::notify_disconnect(connector_id);
00121 }
00122 void erase_m_profile(void)
00123 {
00124 CORBA_SeqUtil::erase(this->m_profile.connector_profiles, 0);
00125 }
00126
00127 protected:
00128
00129 virtual RTC::ReturnCode_t publishInterfaces(RTC::ConnectorProfile& connector_profile)
00130 {
00131 _publishIfsTimes.push_back(getNow());
00132 return RTC::RTC_OK;
00133 }
00134
00135 virtual RTC::ReturnCode_t subscribeInterfaces(const RTC::ConnectorProfile& connector_profile)
00136 {
00137 _subscribeIfsTimes.push_back(getNow());
00138 return RTC::RTC_OK;
00139 }
00140
00141 virtual void unsubscribeInterfaces(const RTC::ConnectorProfile& connector_profile)
00142 {
00143 _unsubscribeIfsTimes.push_back(getNow());
00144 }
00145 virtual void activateInterfaces()
00146 {
00147 }
00148 virtual void deactivateInterfaces()
00149 {
00150 }
00151
00152 private:
00153
00154 std::vector<timeval> _notifyConnectTimes;
00155 std::vector<timeval> _notifyDisconnectTimes;
00156 std::vector<timeval> _publishIfsTimes;
00157 std::vector<timeval> _subscribeIfsTimes;
00158 std::vector<timeval> _unsubscribeIfsTimes;
00159
00160 private:
00161
00162 timeval getNow() const
00163 {
00164 timeval now;
00165 gettimeofday(&now, 0);
00166 return now;
00167 }
00168
00169 public:
00170
00171 const std::vector<timeval>& getNotifyConnectTimes() const
00172 {
00173 return _notifyConnectTimes;
00174 }
00175
00176 const std::vector<timeval>& getNotifyDisconnectTimes() const
00177 {
00178 return _notifyDisconnectTimes;
00179 }
00180
00181 const std::vector<timeval>& getPublishIfsTimes() const
00182 {
00183 return _publishIfsTimes;
00184 }
00185
00186 const std::vector<timeval>& getSubscribeIfsTimes() const
00187 {
00188 return _subscribeIfsTimes;
00189 }
00190
00191 const std::vector<timeval>& getUnsubscribeIfsTimes() const
00192 {
00193 return _unsubscribeIfsTimes;
00194 }
00195 };
00196
00197
00198 int g_argc;
00199 std::vector<std::string> g_argv;
00200
00201 class PortBaseTests
00202 : public CppUnit::TestFixture
00203 {
00204 CPPUNIT_TEST_SUITE(PortBaseTests);
00205
00206 CPPUNIT_TEST(test_get_port_profile);
00207 CPPUNIT_TEST(test_getPortProfile);
00208 CPPUNIT_TEST(test_get_connector_profiles);
00209 CPPUNIT_TEST(test_get_connector_profile);
00210 CPPUNIT_TEST(test_connect);
00211 CPPUNIT_TEST(test_notify_connect);
00212 CPPUNIT_TEST(test_disconnect);
00213 CPPUNIT_TEST(test_setName);
00214 CPPUNIT_TEST(test_getProfile);
00215 CPPUNIT_TEST(test_setPortRef);
00216 CPPUNIT_TEST(test_getPortRef);
00217 CPPUNIT_TEST(test_getUUID);
00218 CPPUNIT_TEST(test_disconnect_all);
00219 CPPUNIT_TEST(test_setOwner);
00220
00221 CPPUNIT_TEST_SUITE_END();
00222
00223 private:
00224
00225 CORBA::ORB_ptr m_orb;
00226 RTC::PortBase* m_pPortBase;
00227 RTC::PortBase* m_pPortBase_2;
00228 RTC::PortBase* m_pPortBase_3;
00229
00230 public:
00231 ConnectionCallbackMock* m_on_publish;
00232 ConnectionCallbackMock* m_on_subscribe;
00233 ConnectionCallbackMock* m_on_connected;
00234 ConnectionCallbackMock* m_on_unsubscribe;
00235 ConnectionCallbackMock* m_on_disconnected;
00236 ConnectionCallbackMock* m_on_connection_lost;
00237
00241 PortBaseTests()
00242 {
00243 }
00244
00248 ~PortBaseTests()
00249 {
00250 }
00251
00264 virtual void setUp()
00265 {
00266 char* argv[g_argc];
00267 for (int i = 0; i < g_argc; i++) {
00268 argv[i] = (char *)g_argv[i].c_str();
00269 }
00270
00271
00272 m_orb = CORBA::ORB_init(g_argc, argv);
00273 PortableServer::POA_ptr poa = PortableServer::POA::_narrow(
00274 m_orb->resolve_initial_references("RootPOA"));
00275
00276
00277 RTC::PortInterfaceProfile portIfProfile;
00278 portIfProfile.instance_name = "PortInterfaceProfile-instance_name";
00279 portIfProfile.type_name = "PortInterfaceProfile-type_name";
00280 portIfProfile.polarity = RTC::REQUIRED;
00281
00282 RTC::PortInterfaceProfileList portIfProfiles;
00283 portIfProfiles.length(1);
00284 portIfProfiles[0] = portIfProfile;
00285
00286
00287 SDOPackage::NameValue connProfileProperty;
00288 connProfileProperty.name = "ConnectorProfile-properties0-name";
00289 connProfileProperty.value <<= CORBA::Float(1.1);
00290
00291 SDOPackage::NVList connProfileProperties;
00292 connProfileProperties.length(1);
00293 connProfileProperties[0] = connProfileProperty;
00294 RTC::ConnectorProfile connProfile;
00295 connProfile.name = "ConnectorProfile-name";
00296 connProfile.connector_id = "connect_id0";
00297 connProfile.properties = connProfileProperties;
00298
00299 RTC::ConnectorProfileList connProfiles;
00300 connProfiles.length(1);
00301 connProfiles[0] = connProfile;
00302
00303
00304 SDOPackage::NameValue portProfileProperty;
00305 portProfileProperty.name = "PortProfile-properties0-name";
00306 portProfileProperty.value <<= CORBA::Float(2.2);
00307 SDOPackage::NVList portProfileProperties;
00308 portProfileProperties.length(1);
00309 portProfileProperties[0] = portProfileProperty;
00310
00311
00312 RTC::PortProfile portProfile;
00313 portProfile.name = "inport0";
00314 portProfile.interfaces = portIfProfiles;
00315 portProfile.connector_profiles = connProfiles;
00316 portProfile.properties = portProfileProperties;
00317
00318
00319 m_pPortBase = new PortBaseMock(portProfile);
00320 m_pPortBase_2 = new PortBaseMock(portProfile);
00321 m_pPortBase_3 = new PortBaseMock(portProfile);
00322
00323
00324 PortableServer::POAManager_var poaMgr = poa->the_POAManager();
00325 poaMgr->activate();
00326
00327 m_on_publish = new ConnectionCallbackMock("OnPublishInterfaces");
00328 m_on_subscribe = new ConnectionCallbackMock("OnSubscribeInterfaces");
00329 m_on_connected = new ConnectionCallbackMock("OnConnected");
00330 m_on_unsubscribe = new ConnectionCallbackMock("OnUnsubscribeInterfaces");
00331 m_on_disconnected = new ConnectionCallbackMock("OnDisconnected");
00332 m_on_connection_lost = new ConnectionCallbackMock("OnConnectionLost");
00333
00334 m_pPortBase->setOnPublishInterfaces(m_on_publish);
00335 m_pPortBase->setOnSubscribeInterfaces(m_on_subscribe);
00336 m_pPortBase->setOnConnected(m_on_connected);
00337 m_pPortBase->setOnUnsubscribeInterfaces(m_on_unsubscribe);
00338 m_pPortBase->setOnDisconnected(m_on_disconnected);
00339 m_pPortBase->setOnConnectionLost(m_on_connection_lost);
00340
00341 }
00342
00346 virtual void tearDown()
00347 {
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364 }
00365
00375 void test_get_port_profile()
00376 {
00377
00378
00379
00380 const RTC::PortService_ptr portRef = m_pPortBase->getPortRef();
00381 const RTC::PortProfile* pPortProfile = portRef->get_port_profile();
00382
00383
00384 CPPUNIT_ASSERT_EQUAL(
00385 std::string("inport0"),
00386 std::string(pPortProfile->name));
00387
00388
00389 const RTC::PortInterfaceProfile& portIfProfile = pPortProfile->interfaces[0];
00390
00391 CPPUNIT_ASSERT_EQUAL(
00392 std::string("PortInterfaceProfile-instance_name"),
00393 std::string(portIfProfile.instance_name));
00394
00395
00396 CPPUNIT_ASSERT_EQUAL(
00397 std::string("PortInterfaceProfile-type_name"),
00398 std::string(portIfProfile.type_name));
00399
00400
00401 CPPUNIT_ASSERT_EQUAL(RTC::REQUIRED, portIfProfile.polarity);
00402
00403
00404 const RTC::ConnectorProfile& connProfile = pPortProfile->connector_profiles[0];
00405
00406 CPPUNIT_ASSERT_EQUAL(
00407 std::string("ConnectorProfile-name"),
00408 std::string(connProfile.name));
00409
00410
00411 CPPUNIT_ASSERT_EQUAL(
00412 std::string("connect_id0"),
00413 std::string(connProfile.connector_id));
00414
00415
00416 CPPUNIT_ASSERT_EQUAL(
00417 std::string("ConnectorProfile-properties0-name"),
00418 std::string(connProfile.properties[0].name));
00419
00420 {
00421 CORBA::Float value;
00422 connProfile.properties[0].value >>= value;
00423 CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.1), value);
00424 }
00425
00426
00427 CPPUNIT_ASSERT_EQUAL(
00428 std::string("PortProfile-properties0-name"),
00429 std::string(pPortProfile->properties[0].name));
00430
00431 {
00432 CORBA::Float value;
00433 pPortProfile->properties[0].value >>= value;
00434 CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.2), value);
00435 }
00436 }
00437
00446 void test_getPortProfile()
00447 {
00448 const RTC::PortProfile& portProfile = m_pPortBase->getPortProfile();
00449
00450
00451 CPPUNIT_ASSERT_EQUAL(
00452 std::string("inport0"),
00453 std::string(portProfile.name));
00454
00455
00456 const RTC::PortInterfaceProfile& portIfProfile = portProfile.interfaces[0];
00457
00458 CPPUNIT_ASSERT_EQUAL(
00459 std::string("PortInterfaceProfile-instance_name"),
00460 std::string(portIfProfile.instance_name));
00461
00462
00463 CPPUNIT_ASSERT_EQUAL(
00464 std::string("PortInterfaceProfile-type_name"),
00465 std::string(portIfProfile.type_name));
00466
00467
00468 CPPUNIT_ASSERT_EQUAL(RTC::REQUIRED, portIfProfile.polarity);
00469
00470
00471 const RTC::ConnectorProfile& connProfile = portProfile.connector_profiles[0];
00472
00473 CPPUNIT_ASSERT_EQUAL(
00474 std::string("ConnectorProfile-name"),
00475 std::string(connProfile.name));
00476
00477
00478 CPPUNIT_ASSERT_EQUAL(
00479 std::string("connect_id0"),
00480 std::string(connProfile.connector_id));
00481
00482
00483 CPPUNIT_ASSERT_EQUAL(
00484 std::string("ConnectorProfile-properties0-name"),
00485 std::string(connProfile.properties[0].name));
00486
00487 {
00488 CORBA::Float value;
00489 connProfile.properties[0].value >>= value;
00490 CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.1), value);
00491 }
00492
00493
00494 CPPUNIT_ASSERT_EQUAL(
00495 std::string("PortProfile-properties0-name"),
00496 std::string(portProfile.properties[0].name));
00497
00498 {
00499 CORBA::Float value;
00500 portProfile.properties[0].value >>= value;
00501 CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.2), value);
00502 }
00503 }
00504
00513 void test_get_connector_profiles()
00514 {
00515
00516
00517
00518 const RTC::PortService_ptr portRef = m_pPortBase->getPortRef();
00519 const RTC::ConnectorProfileList* pConnProfList = portRef->get_connector_profiles();
00520
00521
00522 const RTC::ConnectorProfile& connProfile = (*pConnProfList)[0];
00523
00524 CPPUNIT_ASSERT_EQUAL(
00525 std::string("ConnectorProfile-name"),
00526 std::string(connProfile.name));
00527
00528
00529 CPPUNIT_ASSERT_EQUAL(
00530 std::string("connect_id0"),
00531 std::string(connProfile.connector_id));
00532
00533
00534 const SDOPackage::NameValue& property = connProfile.properties[0];
00535
00536 CPPUNIT_ASSERT_EQUAL(
00537 std::string("ConnectorProfile-properties0-name"),
00538 std::string(property.name));
00539
00540
00541 {
00542 CORBA::Float value;
00543 property.value >>= value;
00544 CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.1), value);
00545 }
00546 }
00547
00556 void test_get_connector_profile()
00557 {
00558
00559
00560
00561 const RTC::PortService_ptr portRef = m_pPortBase->getPortRef();
00562 const RTC::ConnectorProfile* pConnProfile = portRef->get_connector_profile("connect_id0");
00563
00564
00565 CPPUNIT_ASSERT_EQUAL(
00566 std::string("ConnectorProfile-name"),
00567 std::string(pConnProfile->name));
00568
00569
00570 CPPUNIT_ASSERT_EQUAL(
00571 std::string("connect_id0"),
00572 std::string(pConnProfile->connector_id));
00573
00574
00575 const SDOPackage::NameValue& property = pConnProfile->properties[0];
00576
00577 CPPUNIT_ASSERT_EQUAL(
00578 std::string("ConnectorProfile-properties0-name"),
00579 std::string(property.name));
00580
00581
00582 {
00583 CORBA::Float value;
00584 property.value >>= value;
00585 CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.1), value);
00586 }
00587 }
00588
00596 void test_connect()
00597 {
00598
00599
00600
00601 RTC::PortService_ptr portRef = m_pPortBase->getPortRef();
00602
00603
00604 RTC::ConnectorProfile connProfile;
00605 connProfile.name = "ConnectorProfile-name";
00606 connProfile.connector_id = "connect_id1";
00607 connProfile.ports.length(1);
00608 connProfile.ports[0] = portRef;
00609
00610
00611 CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, portRef->connect(connProfile));
00612
00613
00614 const PortBaseMock* pPortBaseMock = dynamic_cast<const PortBaseMock*>(m_pPortBase);
00615 CPPUNIT_ASSERT(pPortBaseMock != 0);
00616 CPPUNIT_ASSERT_EQUAL(1, (int) pPortBaseMock->getNotifyConnectTimes().size());
00617 }
00618
00622 void test_notify_connect()
00623 {
00624
00625 }
00626
00634 void test_disconnect()
00635 {
00636
00637
00638
00639 RTC::PortService_ptr portRef = m_pPortBase->getPortRef();
00640
00641
00642 RTC::ConnectorProfile connProfile;
00643 connProfile.name = "ConnectorProfile-name";
00644 connProfile.connector_id = "connect_id2";
00645 connProfile.ports.length(1);
00646 connProfile.ports[0] = portRef;
00647
00648
00649 CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, portRef->connect(connProfile));
00650
00651
00652 CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, portRef->disconnect(connProfile.connector_id));
00653
00654
00655 const PortBaseMock* pPortBaseMock = dynamic_cast<const PortBaseMock*>(m_pPortBase);
00656 CPPUNIT_ASSERT(pPortBaseMock != 0);
00657 CPPUNIT_ASSERT_EQUAL(1, (int) pPortBaseMock->getNotifyDisconnectTimes().size());
00658 }
00659
00660 void test_disconnect_all()
00661 {
00662 RTC::PortService_ptr portRef_1 = m_pPortBase->getPortRef();
00663 RTC::PortService_ptr portRef_2 = m_pPortBase_2->getPortRef();
00664 RTC::PortService_ptr portRef_3 = m_pPortBase_3->getPortRef();
00665
00666
00667
00668
00669
00670
00671 PortBaseMock* pPBMock
00672 = dynamic_cast<PortBaseMock*>(m_pPortBase);
00673 pPBMock->erase_m_profile();
00674
00675
00676 RTC::ConnectorProfile connProfile;
00677 connProfile.name = "ConnectorProfile-name";
00678 connProfile.connector_id = "connect_id3";
00679 connProfile.ports.length(3);
00680 connProfile.ports[0] = portRef_1;
00681 connProfile.ports[1] = portRef_2;
00682 connProfile.ports[2] = portRef_3;
00683
00684 const PortBaseMock* pPortBaseMock_1 = dynamic_cast<const PortBaseMock*>(m_pPortBase);
00685 CPPUNIT_ASSERT(pPortBaseMock_1 != 0);
00686 CPPUNIT_ASSERT_EQUAL(0, (int) pPortBaseMock_1->getNotifyDisconnectTimes().size());
00687 const PortBaseMock* pPortBaseMock_2 = dynamic_cast<const PortBaseMock*>(m_pPortBase_2);
00688 CPPUNIT_ASSERT(pPortBaseMock_2 != 0);
00689 CPPUNIT_ASSERT_EQUAL(0, (int) pPortBaseMock_2->getNotifyDisconnectTimes().size());
00690 const PortBaseMock* pPortBaseMock_3 = dynamic_cast<const PortBaseMock*>(m_pPortBase_3);
00691 CPPUNIT_ASSERT(pPortBaseMock_3 != 0);
00692 CPPUNIT_ASSERT_EQUAL(0, (int) pPortBaseMock_3->getNotifyDisconnectTimes().size());
00693 CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, portRef_1->connect(connProfile));
00694 CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, portRef_1->disconnect_all());
00695 CPPUNIT_ASSERT_EQUAL(1, (int) pPortBaseMock_1->getNotifyDisconnectTimes().size());
00696 CPPUNIT_ASSERT_EQUAL(1, (int) pPortBaseMock_2->getNotifyDisconnectTimes().size());
00697 CPPUNIT_ASSERT_EQUAL(1, (int) pPortBaseMock_3->getNotifyDisconnectTimes().size());
00698
00699 }
00700
00706 void test_setName()
00707 {
00708
00709 m_pPortBase->setName("inport0-changed");
00710
00711
00712 std::string str(m_pPortBase->getName());
00713 CPPUNIT_ASSERT_EQUAL(std::string("inport0-changed"), str);
00714
00715
00716 const RTC::PortProfile& portProfile = m_pPortBase->getPortProfile();
00717 CPPUNIT_ASSERT_EQUAL(std::string("inport0-changed"), std::string(portProfile.name));
00718 }
00719
00728 void test_getProfile()
00729 {
00730 const RTC::PortProfile& portProfile = m_pPortBase->getProfile();
00731
00732
00733 CPPUNIT_ASSERT_EQUAL(std::string("inport0"), std::string(portProfile.name));
00734
00735
00736 const RTC::PortInterfaceProfile& portIfProfile = portProfile.interfaces[0];
00737
00738 CPPUNIT_ASSERT_EQUAL(
00739 std::string("PortInterfaceProfile-instance_name"),
00740 std::string(portIfProfile.instance_name));
00741
00742
00743 CPPUNIT_ASSERT_EQUAL(
00744 std::string("PortInterfaceProfile-type_name"),
00745 std::string(portIfProfile.type_name));
00746
00747
00748 CPPUNIT_ASSERT_EQUAL(RTC::REQUIRED, portIfProfile.polarity);
00749
00750
00751 const RTC::ConnectorProfile& connProfile = portProfile.connector_profiles[0];
00752
00753 CPPUNIT_ASSERT_EQUAL(
00754 std::string("ConnectorProfile-name"),
00755 std::string(connProfile.name));
00756
00757
00758 CPPUNIT_ASSERT_EQUAL(
00759 std::string("connect_id0"),
00760 std::string(connProfile.connector_id));
00761
00762
00763 {
00764 const SDOPackage::NameValue& property = connProfile.properties[0];
00765
00766 CPPUNIT_ASSERT_EQUAL(
00767 std::string("ConnectorProfile-properties0-name"),
00768 std::string(property.name));
00769
00770
00771 {
00772 CORBA::Float value;
00773 property.value >>= value;
00774 CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.1), value);
00775 }
00776 }
00777
00778
00779 {
00780 const SDOPackage::NameValue& property = portProfile.properties[0];
00781
00782 CPPUNIT_ASSERT_EQUAL(
00783 std::string("PortProfile-properties0-name"),
00784 std::string(property.name));
00785
00786
00787 {
00788 CORBA::Float value;
00789 property.value >>= value;
00790 CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.2), value);
00791 }
00792 }
00793 }
00794
00800 void test_setPortRef()
00801 {
00802
00803 m_pPortBase->_remove_ref();
00804
00805
00806
00807
00808 RTC::PortService_var port = m_pPortBase->_this();
00809 RTC::PortService_ptr portRef = port._retn();
00810 m_pPortBase->setPortRef(portRef);
00811
00812 CPPUNIT_ASSERT_EQUAL(portRef, m_pPortBase->getPortRef());
00813 }
00814
00818 void test_getPortRef()
00819 {
00820
00821 }
00822
00828 void test_getUUID()
00829 {
00830
00831 PortBaseMock* pPortBase = dynamic_cast<PortBaseMock*>(m_pPortBase);
00832 CPPUNIT_ASSERT(pPortBase != 0);
00833
00834
00835 std::string uuid = pPortBase->getUUID();
00836 CPPUNIT_ASSERT(uuid.length() > 0);
00837
00838 }
00843 void test_setOwner()
00844 {
00845 PortableServer::POA_ptr poa = PortableServer::POA::_narrow(
00846 m_orb->resolve_initial_references("RootPOA"));
00847 RTC::RTObject_impl* obj = new RTC::RTObject_impl(m_orb,poa);
00848 RTC::RTObject_ptr owner = obj->getObjRef();
00849 RTC::PortProfile portprofile = m_pPortBase->getProfile();
00850 CPPUNIT_ASSERT(CORBA::is_nil(portprofile.owner));
00851 m_pPortBase->setOwner(owner);
00852 portprofile = m_pPortBase->getProfile();
00853 CPPUNIT_ASSERT(!CORBA::is_nil(portprofile.owner));
00854
00855 poa->the_POAManager()->deactivate(false, true);
00856 obj->finalize();
00857 delete obj;
00858 }
00859 };
00860 };
00861
00862
00863
00864
00865 CPPUNIT_TEST_SUITE_REGISTRATION(PortBase::PortBaseTests);
00866
00867 #ifdef LOCAL_MAIN
00868 int main(int argc, char* argv[])
00869 {
00870
00871 FORMAT format = TEXT_OUT;
00872 int target = 0;
00873 std::string xsl;
00874 std::string ns;
00875 std::string fname;
00876 std::ofstream ofs;
00877
00878 int i(1);
00879 while (i < argc)
00880 {
00881 std::string arg(argv[i]);
00882 std::string next_arg;
00883 if (i + 1 < argc) next_arg = argv[i + 1];
00884 else next_arg = "";
00885
00886 if (arg == "--text") { format = TEXT_OUT; break; }
00887 if (arg == "--xml")
00888 {
00889 if (next_arg == "")
00890 {
00891 fname = argv[0];
00892 fname += ".xml";
00893 }
00894 else
00895 {
00896 fname = next_arg;
00897 }
00898 format = XML_OUT;
00899 ofs.open(fname.c_str());
00900 }
00901 if ( arg == "--compiler" ) { format = COMPILER_OUT; break; }
00902 if ( arg == "--cerr" ) { target = 1; break; }
00903 if ( arg == "--xsl" )
00904 {
00905 if (next_arg == "") xsl = "default.xsl";
00906 else xsl = next_arg;
00907 }
00908 if ( arg == "--namespace" )
00909 {
00910 if (next_arg == "")
00911 {
00912 std::cerr << "no namespace specified" << std::endl;
00913 exit(1);
00914 }
00915 else
00916 {
00917 xsl = next_arg;
00918 }
00919 }
00920 ++i;
00921 }
00922 CppUnit::TextUi::TestRunner runner;
00923 if ( ns.empty() )
00924 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
00925 else
00926 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
00927 CppUnit::Outputter* outputter = 0;
00928 std::ostream* stream = target ? &std::cerr : &std::cout;
00929 switch ( format )
00930 {
00931 case TEXT_OUT :
00932 outputter = new CppUnit::TextOutputter(&runner.result(),*stream);
00933 break;
00934 case XML_OUT :
00935 std::cout << "XML_OUT" << std::endl;
00936 outputter = new CppUnit::XmlOutputter(&runner.result(),
00937 ofs, "shift_jis");
00938 static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl);
00939 break;
00940 case COMPILER_OUT :
00941 outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream);
00942 break;
00943 }
00944 runner.setOutputter(outputter);
00945 runner.run();
00946 return 0;
00947 }
00948 #endif // MAIN
00949 #endif // PortBase_cpp