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> 51 throw (CORBA::SystemException)
58 throw (CORBA::SystemException)
71 RTC::ExecutionContextServiceList
ecMine;
80 bool chk_ecMine(
int id, RTC::ExecutionContext_ptr exec_context)
82 RTC::ExecutionContextService_var ecs;
83 ecs = RTC::ExecutionContextService::_narrow(exec_context);
94 std::vector<RTC::ExecutionContextBase*>
eclist;
108 for (
int i = 0; i < (int)
m_log.size(); ++i)
110 if (
m_log[i] == line) ++count;
131 RTObject_impl::shutdown();
136 void log(
const std::string& msg)
138 m_log.push_back(msg);
231 :
public POA_SDOPackage::SDOService,
232 public virtual PortableServer::RefCountServantBase
238 PortFinder(
const RTC::PortService_ptr& port) : m_port(port) {}
241 return m_port->_is_equivalent(port);
248 :
public POA_SDOPackage::SDOSystemElement,
249 public virtual PortableServer::RefCountServantBase
254 :
public POA_SDOPackage::Organization,
255 public virtual PortableServer::RefCountServantBase
264 return CORBA::string_dup(m_id);
297 virtual CORBA::Boolean
set_owner(SDOPackage::SDOSystemElement_ptr sdo)
307 virtual CORBA::Boolean
set_members(
const SDOPackage::SDOList& sdos)
312 virtual CORBA::Boolean
add_members(
const SDOPackage::SDOList& sdo_list)
324 return SDOPackage::NO_DEPENDENCY;
340 bool operator()(
const RTC::ExecutionContextService_ptr& ecSvc)
342 return m_ecSvc->_is_equivalent(ecSvc);
344 const RTC::ExecutionContextService_ptr&
m_ecSvc;
352 return strcmp(m_id, (
const char*)(svcProf.id)) == 0;
362 return strcmp(m_id, org->get_organization_id()) == 0;
368 :
public CppUnit::TestFixture
372 CPPUNIT_TEST(test_finalizeContexts);
373 CPPUNIT_TEST(test_bindContext);
374 CPPUNIT_TEST(test_add_removePort);
375 CPPUNIT_TEST(test_readAll);
376 CPPUNIT_TEST(test_writeAll);
377 CPPUNIT_TEST(test_initialize_invoking_on_initialize);
378 CPPUNIT_TEST(test_initialize_in_Alive);
379 CPPUNIT_TEST(test_finalize_invoking_on_finalize);
380 CPPUNIT_TEST(test_finalize_participating_in_execution_context);
381 CPPUNIT_TEST(test_finalize_in_Created);
383 CPPUNIT_TEST(test_exit);
384 CPPUNIT_TEST(test_exit_in_Created);
385 CPPUNIT_TEST(test_detach_executioncontext);
386 CPPUNIT_TEST(test_detach_executioncontext_with_illegal_id);
387 CPPUNIT_TEST(test_get_context);
388 CPPUNIT_TEST(test_get_contexts);
389 CPPUNIT_TEST(test_get_component_profile);
390 CPPUNIT_TEST(test_get_ports);
393 CPPUNIT_TEST(test_get_sdo_id);
394 CPPUNIT_TEST(test_get_sdo_type);
397 CPPUNIT_TEST(test_get_service_profile_with_illegal_arguments);
398 CPPUNIT_TEST(test_get_sdo_service);
399 CPPUNIT_TEST(test_get_sdo_service_with_illegal_arguments);
400 CPPUNIT_TEST(test_get_configuration_and_set_device_profile_and_get_device_profile);
401 CPPUNIT_TEST(test_get_configuration_and_set_service_profile_and_get_service_profile);
402 CPPUNIT_TEST(test_get_configuration_and_set_service_profile_and_get_service_profiles);
403 CPPUNIT_TEST(test_get_configuration_and_set_service_profile_and_get_sdo_service);
404 CPPUNIT_TEST(test_get_configuration_and_remove_service_profile);
405 CPPUNIT_TEST(test_get_configuration_and_add_organization_and_get_organizations);
406 CPPUNIT_TEST(test_get_configuration_and_remove_organization);
408 CPPUNIT_TEST(test_get_status);
409 CPPUNIT_TEST(test_get_status_list);
411 CPPUNIT_TEST_SUITE_END();
425 m_pORB = CORBA::ORB_init(argc, argv);
426 m_pPOA = PortableServer::POA::_narrow(
427 m_pORB->resolve_initial_references(
"RootPOA"));
428 m_pPOA->the_POAManager()->activate();
462 CPPUNIT_ASSERT_EQUAL(0, rto->
countLog(
"on_initialize"));
464 prop.setProperty(
"exec_cxt.periodic.type",
"PeriodicExecutionContext");
465 prop.setProperty(
"exec_cxt.periodic.rate",
"1000");
468 CPPUNIT_ASSERT_EQUAL(1, rto->
countLog(
"on_initialize"));
484 prop.
setProperty(
"exec_cxt.periodic.type",
"PeriodicExecutionContext");
489 RTC::ExecutionContext_ptr
ec;
491 CPPUNIT_ASSERT_EQUAL(
true, rto->
is_alive(ec));
510 prop.
setProperty(
"exec_cxt.periodic.type",
"PeriodicExecutionContext");
514 RTC::ExecutionContext_ptr
ec;
516 CPPUNIT_ASSERT_EQUAL(
true, rto->
is_alive(ec));
519 CPPUNIT_ASSERT_EQUAL(0, rto->
countLog(
"on_finalize"));
521 CPPUNIT_ASSERT_EQUAL(
true, rto->
is_alive(ec));
524 CPPUNIT_ASSERT_EQUAL(1, rto->
countLog(
"on_finalize"));
539 prop.
setProperty(
"exec_cxt.periodic.type",
"PeriodicExecutionContext");
544 RTC::ExecutionContext_ptr
ec;
546 CPPUNIT_ASSERT_EQUAL(
true, rto->
is_alive(ec));
549 CPPUNIT_ASSERT_EQUAL(
RTC::RTC_OK, ec->add_component(rto->_this()));
554 CPPUNIT_ASSERT_EQUAL(
RTC::RTC_OK, ec->remove_component(rto->_this()));
595 prop.
setProperty(
"exec_cxt.periodic.type",
"PeriodicExecutionContext");
600 RTC::ExecutionContext_ptr
ec;
602 CPPUNIT_ASSERT_EQUAL(
true, rto->
is_alive(ec));
605 CPPUNIT_ASSERT_EQUAL(
RTC::RTC_OK, ec->add_component(rto->_this()));
606 CPPUNIT_ASSERT_EQUAL(
RTC::RTC_OK, ec->activate_component(rto->_this()));
613 CPPUNIT_ASSERT_EQUAL(0, rto->
countLog(
"on_finalize"));
618 ec->remove_component(rto->_this());
620 CPPUNIT_ASSERT_EQUAL(1, rto->
countLog(
"on_finalize"));
621 CPPUNIT_ASSERT_EQUAL(
true, rto->
is_alive(ec));
662 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(ec));
704 CPPUNIT_ASSERT(id1 != id2);
707 RTC::ExecutionContext_ptr ecPtr1 = rto->
get_context(id1);
708 CPPUNIT_ASSERT(ecPtr1->_is_equivalent(ec1->_this()));
709 RTC::ExecutionContext_ptr ecPtr2 = rto->
get_context(id2);
710 CPPUNIT_ASSERT(ecPtr2->_is_equivalent(ec2->_this()));
714 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(ec2));
716 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(ec1));
747 CPPUNIT_ASSERT(ecList != NULL);
748 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), ecList->length());
749 CPPUNIT_ASSERT(! (*ecList)[0]->_is_equivalent((*ecList)[1]));
750 CPPUNIT_ASSERT((*ecList)[0]->_is_equivalent(ec1->_this())
751 || (*ecList)[0]->_is_equivalent(ec2->_this()));
752 CPPUNIT_ASSERT((*ecList)[1]->_is_equivalent(ec1->_this())
753 || (*ecList)[1]->_is_equivalent(ec2->_this()));
759 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(ec2));
761 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(ec1));
779 prop.
setProperty(
"instance_name",
"INSTANCE_NAME");
789 CPPUNIT_ASSERT(compProf != NULL);
791 CPPUNIT_ASSERT_EQUAL(std::string(
"INSTANCE_NAME"),
792 std::string(compProf->instance_name));
793 CPPUNIT_ASSERT_EQUAL(std::string(
"TYPE_NAME"),
794 std::string(compProf->type_name));
795 CPPUNIT_ASSERT_EQUAL(std::string(
"DESCRIPTION"),
796 std::string(compProf->description));
797 CPPUNIT_ASSERT_EQUAL(std::string(
"VERSION"),
798 std::string(compProf->version));
799 CPPUNIT_ASSERT_EQUAL(std::string(
"VENDOR"),
800 std::string(compProf->vendor));
801 CPPUNIT_ASSERT_EQUAL(std::string(
"CATEGORY"),
802 std::string(compProf->category));
822 CPPUNIT_ASSERT_EQUAL(
true, rto->
addPort(*port0));
829 port1->setName(
"port1");
830 CPPUNIT_ASSERT_EQUAL(
true, rto->
addPort(*port1));
834 CPPUNIT_ASSERT(portList != NULL);
835 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), portList->length());
838 CPPUNIT_ASSERT_EQUAL(
true, rto->
removePort(*port1));
839 CPPUNIT_ASSERT_EQUAL(
true, rto->
removePort(*port0));
844 CPPUNIT_ASSERT_EQUAL(
true, rto->
addInPort(
"in",*inport0));
845 CPPUNIT_ASSERT_EQUAL(
true, rto->
addOutPort(
"out", *outport0));
854 CPPUNIT_ASSERT(portList != NULL);
855 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), portList->length());
858 CPPUNIT_ASSERT_EQUAL(
true, rto->
removeInPort(*inport0));
862 CPPUNIT_ASSERT(portList != NULL);
863 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), portList->length());
895 CPPUNIT_ASSERT_EQUAL(
true, rto->
readAll());
908 CPPUNIT_ASSERT_EQUAL(
false, rto->
readAll());
916 CPPUNIT_ASSERT_EQUAL(
false, rto->
readAll());
970 CPPUNIT_ASSERT_EQUAL(
true, rto->
writeAll());
983 CPPUNIT_ASSERT_EQUAL(
false, rto->
writeAll());
991 CPPUNIT_ASSERT_EQUAL(
false, rto->
writeAll());
1045 CPPUNIT_ASSERT(portList != NULL);
1046 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), portList->length());
1047 CPPUNIT_ASSERT(CORBA::Long(-1)
1049 CPPUNIT_ASSERT(CORBA::Long(-1)
1052 CPPUNIT_ASSERT_EQUAL(
true, rto->
removePort(*port1));
1053 CPPUNIT_ASSERT_EQUAL(
true, rto->
removePort(*port0));
1113 CPPUNIT_ASSERT(
"INSTANCE_NAME 1" == str1);
1117 CPPUNIT_ASSERT(
"INSTANCE_NAME 2" == str2);
1121 CPPUNIT_ASSERT(id1 != NULL);
1123 CPPUNIT_ASSERT(id2 != NULL);
1129 CPPUNIT_ASSERT(id1 != id2);
1153 CPPUNIT_ASSERT(sdoType != NULL);
1193 CPPUNIT_FAIL(
"Exception not thrown.");
1195 catch (SDOPackage::InvalidParameter expected)
1202 CPPUNIT_FAIL(
"Unexpected exception caught.");
1209 CPPUNIT_FAIL(
"Exception not thrown.");
1211 catch (SDOPackage::InvalidParameter expected)
1218 CPPUNIT_FAIL(
"Unexpected exception caught.");
1242 CPPUNIT_FAIL(
"Exception not thrown.");
1244 catch (SDOPackage::InvalidParameter expected)
1251 CPPUNIT_FAIL(
"Unexpected exception caught.");
1258 CPPUNIT_FAIL(
"Exception not thrown.");
1260 catch (SDOPackage::InvalidParameter expected)
1267 CPPUNIT_FAIL(
"Unexpected exception caught.");
1285 SDOPackage::DeviceProfile
devProf;
1286 devProf.device_type =
"DEVICE_TYPE";
1287 devProf.manufacturer =
"MANUFACTURER";
1288 devProf.model =
"MODEL";
1289 devProf.version =
"VERSION";
1290 devProf.properties.length(1);
1291 devProf.properties[0].name =
"PROPERTIES NAME";
1292 devProf.properties[0].value <<=
"PROPERTIES VALUE";
1296 cfg->set_device_profile(devProf);
1299 CPPUNIT_ASSERT_EQUAL(std::string(
"DEVICE_TYPE"),
1300 std::string(devProfRet->device_type));
1301 CPPUNIT_ASSERT_EQUAL(std::string(
"MANUFACTURER"),
1302 std::string(devProfRet->manufacturer));
1303 CPPUNIT_ASSERT_EQUAL(std::string(
"MODEL"),
1304 std::string(devProfRet->model));
1305 CPPUNIT_ASSERT_EQUAL(std::string(
"VERSION"),
1306 std::string(devProfRet->version));
1307 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), devProfRet->properties.length());
1308 CPPUNIT_ASSERT_EQUAL(std::string(
"PROPERTIES NAME"),
1309 std::string(devProfRet->properties[0].name));
1311 const char* value; devProfRet->properties[0].value >>= value;
1312 CPPUNIT_ASSERT_EQUAL(std::string(
"PROPERTIES VALUE"), std::string(value));
1334 SDOPackage::ServiceProfile svcProf1;
1335 svcProf1.id =
"ID 1";
1336 svcProf1.interface_type =
"INTERFACE_TYPE 1";
1337 svcProf1.properties.length(1);
1338 svcProf1.properties[0].name =
"PROPERTIES NAME 1";
1339 svcProf1.properties[0].value <<=
"3.14159";
1340 svcProf1.service = sdoSvc1->_this();
1342 SDOPackage::ServiceProfile svcProf2;
1343 svcProf2.id =
"ID 2";
1344 svcProf2.interface_type =
"INTERFACE_TYPE 2";
1345 svcProf2.properties.length(1);
1346 svcProf2.properties[0].name =
"PROPERTIES NAME 2";
1347 svcProf2.properties[0].value <<=
"2.71828";
1348 svcProf2.service = sdoSvc2->_this();
1352 CPPUNIT_ASSERT(! CORBA::is_nil(cfg));
1353 cfg->add_service_profile(svcProf1);
1354 cfg->add_service_profile(svcProf2);
1358 CPPUNIT_ASSERT(svcProfRet1 != NULL);
1359 CPPUNIT_ASSERT_EQUAL(std::string(
"ID 1"), std::string(svcProfRet1->id));
1360 CPPUNIT_ASSERT_EQUAL(std::string(
"INTERFACE_TYPE 1"),
1361 std::string(svcProfRet1->interface_type));
1362 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfRet1->properties.length());
1363 CPPUNIT_ASSERT_EQUAL(std::string(
"PROPERTIES NAME 1"),
1364 std::string(svcProfRet1->properties[0].name));
1366 const char* value; svcProfRet1->properties[0].value >>= value;
1367 CPPUNIT_ASSERT_EQUAL(std::string(
"3.14159"), std::string(value));
1371 CPPUNIT_ASSERT(svcProfRet2 != NULL);
1372 CPPUNIT_ASSERT_EQUAL(std::string(
"ID 2"), std::string(svcProfRet2->id));
1373 CPPUNIT_ASSERT_EQUAL(std::string(
"INTERFACE_TYPE 2"),
1374 std::string(svcProfRet2->interface_type));
1375 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfRet2->properties.length());
1376 CPPUNIT_ASSERT_EQUAL(std::string(
"PROPERTIES NAME 2"),
1377 std::string(svcProfRet2->properties[0].name));
1379 const char* value; svcProfRet2->properties[0].value >>= value;
1380 CPPUNIT_ASSERT_EQUAL(std::string(
"2.71828"), std::string(value));
1383 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(sdoSvc2));
1385 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(sdoSvc1));
1406 SDOPackage::ServiceProfile svcProf1;
1407 svcProf1.id =
"ID 1";
1408 svcProf1.interface_type =
"INTERFACE_TYPE 1";
1409 svcProf1.properties.length(1);
1410 svcProf1.properties[0].name =
"PROPERTIES NAME 1";
1411 svcProf1.properties[0].value <<=
"3.14159";
1412 svcProf1.service = sdoSvc1->_this();
1414 SDOPackage::ServiceProfile svcProf2;
1415 svcProf2.id =
"ID 2";
1416 svcProf2.interface_type =
"INTERFACE_TYPE 2";
1417 svcProf2.properties.length(1);
1418 svcProf2.properties[0].name =
"PROPERTIES NAME 2";
1419 svcProf2.properties[0].value <<=
"2.71828";
1420 svcProf2.service = sdoSvc2->_this();
1424 CPPUNIT_ASSERT(! CORBA::is_nil(cfg));
1425 cfg->add_service_profile(svcProf1);
1426 cfg->add_service_profile(svcProf2);
1430 CPPUNIT_ASSERT(svcProfList != NULL);
1434 CPPUNIT_ASSERT(CORBA::Long(-1) != svcProfIdx1);
1435 CPPUNIT_ASSERT_EQUAL(std::string(
"ID 1"),
1436 std::string((*svcProfList)[svcProfIdx1].
id));
1437 CPPUNIT_ASSERT_EQUAL(std::string(
"INTERFACE_TYPE 1"),
1438 std::string((*svcProfList)[svcProfIdx1].interface_type));
1439 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1),
1440 (*svcProfList)[svcProfIdx1].properties.length());
1441 CPPUNIT_ASSERT_EQUAL(std::string(
"PROPERTIES NAME 1"),
1442 std::string((*svcProfList)[svcProfIdx1].properties[0].name));
1444 const char* value; (*svcProfList)[svcProfIdx1].properties[0].value >>= value;
1445 CPPUNIT_ASSERT_EQUAL(std::string(
"3.14159"), std::string(value));
1450 CPPUNIT_ASSERT(CORBA::Long(-1) != svcProfIdx2);
1451 CPPUNIT_ASSERT_EQUAL(std::string(
"ID 2"),
1452 std::string((*svcProfList)[svcProfIdx2].
id));
1453 CPPUNIT_ASSERT_EQUAL(std::string(
"INTERFACE_TYPE 2"),
1454 std::string((*svcProfList)[svcProfIdx2].interface_type));
1455 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1),
1456 (*svcProfList)[svcProfIdx2].properties.length());
1457 CPPUNIT_ASSERT_EQUAL(std::string(
"PROPERTIES NAME 2"),
1458 std::string((*svcProfList)[svcProfIdx2].properties[0].name));
1460 const char* value; (*svcProfList)[svcProfIdx2].properties[0].value >>= value;
1461 CPPUNIT_ASSERT_EQUAL(std::string(
"2.71828"), std::string(value));
1464 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(sdoSvc2));
1466 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(sdoSvc1));
1488 SDOPackage::ServiceProfile svcProf1;
1489 svcProf1.id =
"ID 1";
1490 svcProf1.interface_type =
"INTERFACE_TYPE 1";
1491 svcProf1.properties.length(1);
1492 svcProf1.properties[0].name =
"PROPERTIES NAME 1";
1493 svcProf1.properties[0].value <<=
"3.14159";
1494 svcProf1.service = sdoSvc1->_this();
1496 SDOPackage::ServiceProfile svcProf2;
1497 svcProf2.id =
"ID 2";
1498 svcProf2.interface_type =
"INTERFACE_TYPE 2";
1499 svcProf2.properties.length(1);
1500 svcProf2.properties[0].name =
"PROPERTIES NAME 2";
1501 svcProf2.properties[0].value <<=
"2.71828";
1502 svcProf2.service = sdoSvc2->_this();
1506 CPPUNIT_ASSERT(! CORBA::is_nil(cfg));
1507 cfg->add_service_profile(svcProf1);
1508 cfg->add_service_profile(svcProf2);
1512 CPPUNIT_ASSERT(! CORBA::is_nil(sdoSvcRet1));
1513 CPPUNIT_ASSERT(sdoSvcRet1->_is_equivalent(sdoSvc1->_this()));
1516 CPPUNIT_ASSERT(! CORBA::is_nil(sdoSvcRet2));
1517 CPPUNIT_ASSERT(sdoSvcRet2->_is_equivalent(sdoSvc2->_this()));
1519 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(sdoSvc2));
1521 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(sdoSvc1));
1543 SDOPackage::ServiceProfile svcProf1;
1544 svcProf1.id =
"ID 1";
1545 svcProf1.interface_type =
"INTERFACE_TYPE 1";
1546 svcProf1.properties.length(1);
1547 svcProf1.properties[0].name =
"PROPERTIES NAME 1";
1548 svcProf1.properties[0].value <<=
"3.14159";
1549 svcProf1.service = sdoSvc1->_this();
1551 SDOPackage::ServiceProfile svcProf2;
1552 svcProf2.id =
"ID 2";
1553 svcProf2.interface_type =
"INTERFACE_TYPE 2";
1554 svcProf2.properties.length(1);
1555 svcProf2.properties[0].name =
"PROPERTIES NAME 2";
1556 svcProf2.properties[0].value <<=
"2.71828";
1557 svcProf2.service = sdoSvc2->_this();
1561 CPPUNIT_ASSERT(! CORBA::is_nil(cfg));
1562 cfg->add_service_profile(svcProf1);
1563 cfg->add_service_profile(svcProf2);
1568 CPPUNIT_ASSERT_EQUAL(
true, cfg->remove_service_profile(
"ID 1"));
1572 CPPUNIT_FAIL(
"Expected exception not thrown.");
1574 catch (SDOPackage::InvalidParameter expected) {}
1577 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(sdoSvc2));
1579 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(sdoSvc1));
1602 CPPUNIT_ASSERT(! CORBA::is_nil(cfg));
1603 CPPUNIT_ASSERT_EQUAL(
true, cfg->add_organization(org1->_this()));
1604 CPPUNIT_ASSERT_EQUAL(
true, cfg->add_organization(org2->_this()));
1608 CPPUNIT_ASSERT(orgList != NULL);
1609 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList->length());
1612 CPPUNIT_ASSERT(CORBA::Long(-1) != orgIdx1);
1613 CPPUNIT_ASSERT_EQUAL(std::string(
"ORG 1"),
1614 std::string((*orgList)[orgIdx1]->get_organization_id()));
1617 CPPUNIT_ASSERT(CORBA::Long(-1) != orgIdx2);
1618 CPPUNIT_ASSERT_EQUAL(std::string(
"ORG 2"),
1619 std::string((*orgList)[orgIdx2]->get_organization_id()));
1621 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(org2));
1623 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(org1));
1645 CPPUNIT_ASSERT(! CORBA::is_nil(cfg));
1646 CPPUNIT_ASSERT_EQUAL(
true, cfg->add_organization(org1->_this()));
1647 CPPUNIT_ASSERT_EQUAL(
true, cfg->add_organization(org2->_this()));
1651 CPPUNIT_ASSERT(orgList != NULL);
1652 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList->length());
1655 CPPUNIT_ASSERT_EQUAL(
true, cfg->remove_organization(
"ORG 1"));
1657 CPPUNIT_ASSERT(orgList != NULL);
1658 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), orgList->length());
1660 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(org2));
1662 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(org1));
1687 CORBA::Any valueAny1; valueAny1 <<= CORBA::Float(3.14159);
1690 CORBA::Any valueAny2; valueAny2 <<= CORBA::Float(2.71828);
1694 CORBA::Any* valueAnyRet1 = rto->
get_status(
"STATUS 1");
1695 CPPUNIT_ASSERT(valueAnyRet1 != NULL);
1697 CORBA::Float value; *valueAnyRet1 >>= value;
1698 CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value);
1701 CORBA::Any* valueAnyRet2 = rto->
get_status(
"STATUS 2");
1702 CPPUNIT_ASSERT(valueAnyRet2 != NULL);
1704 CORBA::Float value; *valueAnyRet2 >>= value;
1705 CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value);
1723 CORBA::Any valueAny1; valueAny1 <<= CORBA::Float(3.14159);
1726 CORBA::Any valueAny2; valueAny2 <<= CORBA::Float(2.71828);
1731 CPPUNIT_ASSERT(statusList != NULL);
1732 CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), statusList->length());
1734 const CORBA::Any& valueAnyRet1 =
NVUtil::find(*statusList,
"STATUS 1");
1736 CORBA::Float value; valueAnyRet1 >>= value;
1737 CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value);
1740 const CORBA::Any& valueAnyRet2 =
NVUtil::find(*statusList,
"STATUS 2");
1742 CORBA::Float value; valueAnyRet2 >>= value;
1743 CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value);
1759 prop.
setProperty(
"exec_cxt.periodic.type",
"PeriodicExecutionContext");
1760 prop.
setProperty(
"exec_cxt.periodic.rate",
"1000");
1770 RTC::ExecutionContext_ptr
ec;
1772 CPPUNIT_ASSERT_EQUAL(
true, rto->
is_alive(ec));
1790 prop.
setProperty(
"exec_cxt.periodic.type",
"PeriodicExecutionContext");
1791 prop.
setProperty(
"exec_cxt.periodic.rate",
"1000");
1794 RTC::ExecutionContext_ptr
ec;
1797 ec = RTC::ExecutionContext::_nil();
1799 CPPUNIT_ASSERT_EQUAL(-1,
id);
1807 CPPUNIT_ASSERT_EQUAL(0,
id);
1813 rto->
ecMine[0] = RTC::ExecutionContextService::_nil();
1820 CPPUNIT_ASSERT_EQUAL(0,
id);
1827 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(pec));
1829 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(pec2));
1846 int main(
int argc,
char* argv[])
1859 std::string arg(argv[i]);
1860 std::string next_arg;
1861 if (i + 1 < argc) next_arg = argv[i + 1];
1864 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
1877 ofs.open(fname.c_str());
1879 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
1880 if ( arg ==
"--cerr" ) { target = 1;
break; }
1881 if ( arg ==
"--xsl" )
1883 if (next_arg ==
"") xsl =
"default.xsl";
1884 else xsl = next_arg;
1886 if ( arg ==
"--namespace" )
1890 std::cerr <<
"no namespace specified" << std::endl;
1900 CppUnit::TextUi::TestRunner runner;
1902 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
1904 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
1905 CppUnit::Outputter* outputter = 0;
1906 std::ostream* stream = target ? &std::cerr : &std::cout;
1910 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
1913 std::cout <<
"XML_OUT" << std::endl;
1914 outputter =
new CppUnit::XmlOutputter(&runner.result(),
1916 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
1919 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
1922 runner.setOutputter(outputter);
1927 #endif // RTObject_cpp
int countLog(std::string line)
void test_get_configuration_and_set_service_profile_and_get_sdo_service()
get_configuration()メソッドとget_sdo_service()メソッドのテスト
int main(int argc, char **argv)
void test_bindContext()
bindContext()メソッドのテスト
virtual char * get_organization_id()
virtual SDOPackage::ServiceProfileList * get_service_profiles()
[SDO interface] Get SDO ServiceProfile
void finalizeContexts()
The ExecutionContextBase list is deleted.
void log(const std::string &msg)
virtual ComponentProfile * get_component_profile()
[RTObject CORBA interface] Get RTC's profile
RTObjectMock(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa)
virtual SDOPackage::OrganizationProperty * get_organization_property()
virtual char * get_sdo_id()
[SDO interface] Get the SDO ID
ServiceProfileFinder(const char *id)
PortFinder(const RTC::PortService_ptr &port)
virtual ExecutionContextService_ptr getObjRef(void)
Get the reference to the CORBA object.
void test_get_sdo_service()
get_sdo_service()メソッドのテスト
PortableServer::POA_ptr m_pPOA
virtual ReturnCode_t initialize()
[CORBA interface] Initialize the RTC that realizes this interface.
virtual CORBA::Boolean remove_member(const char *id)
void test_finalize_participating_in_execution_context()
finalize()メソッドのテスト
const RTC::ExecutionContextService_ptr & m_ecSvc
unsigned int sleep(unsigned int seconds)
Stop a processing at specified second time.
UniqueId bindContext(ExecutionContext_ptr exec_context)
void test_get_sdo_type()
get_sdo_type()メソッドのテスト
ReturnCode_t detach_context(UniqueId exec_handle)
[CORBA interface] Detach ExecutionContext.
void test_initialize_invoking_on_initialize()
initialize()メソッドのテスト
void test_readAll()
readAll(),setReadAll()メソッドのテスト
std::vector< std::pair< std::string, std::string > > NVList
void test_finalize_invoking_on_finalize()
finalize()メソッドのテスト
void test_get_context()
get_context()メソッドのテスト
bool removeInPort(InPortBase &port)
[local interface] Unregister InPort
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
virtual RTC::ReturnCode_t publishInterfaces(RTC::ConnectorProfile &connector_profile)
ExecutionContextServiceFinder(const RTC::ExecutionContextService_ptr &ecSvc)
virtual SDOPackage::SDOList * get_members()
virtual CORBA::Boolean add_members(const SDOPackage::SDOList &sdo_list)
void test_finalizeContexts()
finalizeContexts()メソッドのテスト
virtual ExecutionContextList * get_participating_contexts()
[CORBA interface] Get participating ExecutionContextList.
std::vector< std::string > m_log
virtual PortServiceList * get_ports()
[RTObject CORBA interface] Get Ports
bool removePort(PortBase &port)
[local interface] Unregister Port
void test_get_status()
get_status()メソッドのテスト
std::vector< RTC::ExecutionContextBase * > eclist
void test_detach_executioncontext_with_illegal_id()
detach_executioncontext()メソッドのテスト
virtual void tearDown()
Test finalization.
virtual RTC::ReturnCode_t on_finalize()
[ComponentAction CORBA interface] Finalize RTC
virtual SDOPackage::Configuration_ptr get_configuration()
[SDO interface] Get Configuration object
UniqueId attach_context(ExecutionContext_ptr exec_context)
[CORBA interface] Attach ExecutionContext
SDOPackage::NVList m_sdoStatus
SDO Status.
bool addOutPort(const char *name, OutPortBase &outport)
[local interface] Register DataOutPort
virtual CORBA::Boolean add_organization_property(const SDOPackage::OrganizationProperty &organization_property)
virtual ReturnCode_t on_finalize()
[ComponentAction CORBA interface] Finalize RTC
virtual RTC::ReturnCode_t on_initialize()
[RTObject CORBA interface] Get ExecutionContextAdmin
virtual void unsubscribeInterfaces(const RTC::ConnectorProfile &connector_profile)
void test_get_service_profile()
get_service_profile()メソッドのテスト
virtual ReturnCode_t finalize()
[CORBA interface] Finalize the RTC for destruction
void test_is_alive()
is_alive()メソッドのテスト
const CORBA::Long find_index(const SDOPackage::NVList &nv, const char *name)
Return the index of element specified by name from NVList.
void test_get_device_profile()
get_device_profile()メソッドのテスト
void test_get_sdo_service_with_illegal_arguments()
std::vector< ExecutionContext * > ExecutionContextList
void test_get_monitoring()
get_monitoring()メソッドのテスト
void set_status(const char *name, const CORBA::Any &value)
InPortMock(const char *name, const char *data_type)
virtual CORBA::Boolean set_members(const SDOPackage::SDOList &sdos)
void setObjRef(const RTObject_ptr rtobj)
[local interface] Set the object reference
bool removeOutPort(OutPortBase &port)
[local interface] Unregister OutPort
bool operator()(const RTC::ExecutionContextService_ptr &ecSvc)
ExecutionContextHandle_t UniqueId
void test_get_ports()
get_ports()メソッドのテスト
virtual void activateInterfaces()
Activate all Port interfaces.
void test_exit_in_Created()
exit()メソッドのテスト
std::vector< ExecutionContextBase * > m_eclist
List of ExecutionContextBase.
RTObject_impl(Manager *manager)
Constructor.
void test_get_configuration_and_set_service_profile_and_get_service_profiles()
get_configuration()メソッドとget_service_profiles()メソッドのテスト
virtual CORBA::Boolean set_organization_property_value(const char *name, const CORBA::Any &value)
const CORBA::Any & find(const SDOPackage::NVList &nv, const char *name)
Return the value specified by name from NVList.
CORBA::Long find(const CorbaSequence &seq, Functor f)
Return the index of CORBA sequence element that functor matches.
void test_get_configuration_and_remove_organization()
Configuration::remove_organization()メソッドのテスト
virtual ExecutionContext_ptr get_context(UniqueId exec_handle)
[CORBA interface] Get ExecutionContext.
virtual void deactivateInterfaces()
Deactivate all Port interfaces.
void test_get_owned_organizations()
get_execution_context_services()メソッドのテスト
devProf
Configuration::set_device_profile (in DeviceProfile dProfile);.
RTObjectTests()
Constructor.
std::string setProperty(const std::string &key, const std::string &value)
Set a value associated with key in the property list.
void test_get_configuration_and_remove_service_profile()
Configuration::remove_service_profile()メソッドのテスト
void test_get_component_profile()
get_component_profile()メソッドのテスト
const RTC::PortService_ptr & m_port
virtual RTC::ReturnCode_t subscribeInterfaces(const RTC::ConnectorProfile &connector_profile)
virtual CORBA::Any * get_organization_property_value(const char *name)
ExecutionContextServiceList m_ecMine
List of owned ExecutionContextService.
bool operator()(const SDOPackage::ServiceProfile &svcProf)
virtual ReturnCode_t exit()
[CORBA interface]top the RTC's execution context(s) and finalize it along with its contents...
void test_get_status_list()
get_status_list()メソッドのテスト
virtual SDOPackage::NVList * get_status_list()
[SDO interface] Get SDO Status list
virtual SDOPackage::DeviceProfile * get_device_profile()
[SDO interface] Get SDO DeviceProfile list
void set_return(bool ret)
RTC::ExecutionContextServiceList ecMine
const char * getInstanceName()
[local interface] Get instance name
void set_return(bool ret)
prop
Organization::get_organization_property ();.
void test_detach_executioncontext()
detach_executioncontext()メソッドのテスト
void test_get_configuration_and_add_organization_and_get_organizations()
get_configuration()メソッドとget_organizations()メソッドのテスト
Class represents a set of properties.
bool chk_ecMine(int id, RTC::ExecutionContext_ptr exec_context)
void test_get_configuration_and_set_device_profile_and_get_device_profile()
get_configuration()メソッドのテスト
void test_get_service_profile_with_illegal_arguments()
get_service_profile()メソッドのテスト
OrganizationFinder(const char *id)
std::vector< IPortService * > PortServiceList
void test_finalize_in_Created()
finalize()メソッドのテスト
virtual void setUp()
Test initialization.
PeriodicExecutionContext class.
void setWriteAll(bool write=true, bool completion=false)
Set whether to execute the writeAll() method.
void test_get_sdo_id()
get_sdo_id()メソッドのテスト
virtual ReturnCode_t on_initialize()
[RTObject CORBA interface] Get ExecutionContextAdmin
bool addPort(PortBase &port)
[local interface] Register Port
virtual RTC::UniqueId bindContext(RTC::ExecutionContext_ptr exec_context)
bool writeAll()
The write() method of all OutPort is called.
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
virtual SDOPackage::SDOService_ptr get_sdo_service(const char *id)
[SDO interface] Get specified SDO Service's reference
void test_get_configuration_and_set_service_profile_and_get_service_profile()
get_configuration()メソッドとget_serivce_profile()メソッドのテスト
void setInstanceName(const char *instance_name)
[local interface] Set instance name
void setReadAll(bool read=true, bool completion=false)
Set whether to execute the readAll() method.
virtual SDOPackage::SDOSystemElement_ptr get_owner()
PeriodicExecutionContext class.
bool operator()(const SDOPackage::Organization_ptr &org)
bool operator()(const RTC::PortService_ptr &port)
virtual SDOPackage::OrganizationList * get_organizations()
[SDO interface] Get Organization list
void test_add_removePort()
add[In/Out]Port(),addPort()メソッドのテスト
CPPUNIT_TEST_SUITE_REGISTRATION(RTObject::RTObjectTests)
virtual CORBA::Boolean remove_organization_property(const char *name)
virtual CORBA::Boolean is_alive(ExecutionContext_ptr exec_context)
[CORBA interface] Confirm whether RTC is the alive state
void test_writeAll()
writeAll(),setWriteAll()メソッドのテスト
virtual SDOPackage::DependencyType get_dependency()
OutPortMock(const char *name, const char *data_type)
virtual ~RTObjectTests()
Destructor.
void test_get_contexts()
get_contexts()メソッドのテスト
bool addInPort(const char *name, InPortBase &inport)
[local interface] Register DataInPort
virtual ReturnCode_t on_execute(UniqueId exec_handle)
[DataFlowComponentAction CORBA interface] Primary Periodic Operation of RTC
void test_initialize_in_Alive()
initialize()メソッドのテスト
virtual char * get_sdo_type()
[SDO interface] Get SDO type
bool readAll()
Readout the value from All InPorts.
void setName(const char *name)
Set the name of this Port.
void setProperties(const coil::Properties &prop)
[local interface] Set RTC property
virtual CORBA::Any * get_status(const char *name)
[SDO interface] Get SDO Status
SDOPackage::NameValue newNVAny(const char *name, const CORBA::Any &value)
Create NameValue typed CORBA::Any.
void test_exit()
exit()メソッドのテスト
virtual CORBA::Boolean set_dependency(SDOPackage::DependencyType dependency)
OrganizationMock(const char *id)
virtual CORBA::Boolean set_owner(SDOPackage::SDOSystemElement_ptr sdo)
virtual SDOPackage::ServiceProfile * get_service_profile(const char *id)
[SDO interface] Get specified ServiceProfile
bool read()
It is a virtual method that is called from RTObject_impl::readAll(). This method reads out data from ...