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.");