32 #ifndef SdoOrganization_cpp 33 #define SdoOrganization_cpp 35 #include <cppunit/ui/text/TestRunner.h> 36 #include <cppunit/TextOutputter.h> 37 #include <cppunit/extensions/TestFactoryRegistry.h> 38 #include <cppunit/extensions/HelperMacros.h> 39 #include <cppunit/TestAssert.h> 55 :
public CppUnit::TestFixture
59 CPPUNIT_TEST(test_get_organization_id);
60 CPPUNIT_TEST(test_set_get_organization_property);
61 CPPUNIT_TEST(test_set_get_organization_property_value);
62 CPPUNIT_TEST(test_remove_organization_property);
63 CPPUNIT_TEST(test_set_get_owner);
64 CPPUNIT_TEST(test_set_get_members);
65 CPPUNIT_TEST(test_add_remove_members);
66 CPPUNIT_TEST(test_set_get_dependency);
68 CPPUNIT_TEST_SUITE_END();
96 rtobj = new ::RTC::RTObject_impl(&mgr);
105 m_pOi->_remove_ref();
106 rtobj->_remove_ref();
116 CPPUNIT_ASSERT(m_id != NULL);
126 OrganizationProperty_var get_prop;
127 OrganizationProperty set_prop;
163 set_prop.properties = nvList;
171 str = (get_prop->properties[0]).name;
172 (get_prop->properties[0]).value >>= rft;
173 CPPUNIT_ASSERT(str ==
"hoge");
174 CPPUNIT_ASSERT(rft == ft);
177 nv.name =
"hogehoge";
184 set_prop.properties = nvList;
193 str = ((get_prop->properties[0]).name);
194 (get_prop->properties[0]).value >>= rft;
195 CPPUNIT_ASSERT(str ==
"hogehoge");
196 CPPUNIT_ASSERT(rft == ft);
240 set_prop.properties = nvList;
249 str = ((get_prop->properties[0]).name);
250 (get_prop->properties[0]).value >>= rst;
251 CPPUNIT_ASSERT(str ==
"short");
252 CPPUNIT_ASSERT(rst == st);
254 str = ((get_prop->properties[1]).name);
255 (get_prop->properties[1]).value >>= rlg;
256 CPPUNIT_ASSERT(str ==
"long");
257 CPPUNIT_ASSERT(rlg == lg);
259 str = ((get_prop->properties[2]).name);
260 (get_prop->properties[2]).value >>= rft;
261 CPPUNIT_ASSERT(str ==
"float");
262 CPPUNIT_ASSERT(rft == ft);
264 str = ((get_prop->properties[3]).name);
265 (get_prop->properties[3]).value >>= rdb;
266 CPPUNIT_ASSERT(str ==
"double");
267 CPPUNIT_ASSERT(rdb == db);
281 catch (InvalidParameter ip) {
282 cout <<
"InvalidParameter exception." << endl;
284 catch (NotAvailable na) {
285 cout <<
"NotAvailable exception." << endl;
287 catch (InternalError ip) {
288 cout <<
"InternalError exception." << endl;
291 cout <<
"othrer exception." << endl;
301 OrganizationProperty_var get_prop;
302 OrganizationProperty set_prop;
338 CPPUNIT_ASSERT_EQUAL(ft, rft);
350 CPPUNIT_ASSERT_EQUAL(st, rst);
362 CPPUNIT_ASSERT_EQUAL(st, rst);
370 catch (InvalidParameter ip) {
374 CPPUNIT_ASSERT(sflg == 1);
382 catch (InvalidParameter ip) {
386 CPPUNIT_ASSERT(sflg == 1);
394 catch (InvalidParameter ip) {
398 CPPUNIT_ASSERT(sflg == 1);
400 catch (InvalidParameter ip) {
401 cout <<
"InvalidParameter exception." << endl;
403 catch (NotAvailable na) {
404 cout <<
"NotAvailable exception." << endl;
406 catch (InternalError ip) {
407 cout <<
"InternalError exception." << endl;
410 cout <<
"othrer exception." << endl;
421 OrganizationProperty set_prop;
436 set_prop.properties = nvList;
446 cout <<
"Couldn't remove name: short" << endl;
450 catch (InvalidParameter ip) {
454 catch (NotAvailable na) {
455 cout <<
"NotAvailable exception." << endl;
458 catch (InternalError ip) {
459 cout <<
"InternalError exception." << endl;
463 cout <<
"othrer exception." << endl;
466 CPPUNIT_ASSERT(sflg == 1);
473 cout <<
"Couldn't remove name: hoge" << endl;
478 catch (InvalidParameter ip) {
479 cout <<
"InvalidParameter exception." << endl;
482 catch (NotAvailable na) {
483 cout <<
"NotAvailable exception." << endl;
486 catch (InternalError ip) {
487 cout <<
"InternalError exception." << endl;
491 cout <<
"othrer exception." << endl;
494 CPPUNIT_ASSERT(sflg == 0);
505 SDOPackage::SDOSystemElement_var varOwner;
506 SDOPackage::SDOSystemElement_ptr ptrOwner;
511 CPPUNIT_ASSERT(!::CORBA::is_nil(varOwner));
517 ptrOwner = SDOPackage::SDOSystemElement::_nil();
522 catch (InvalidParameter ip) {
526 catch (NotAvailable na) {
527 cout <<
"NotAvailable exception." << endl;
530 catch (InternalError ip) {
531 cout <<
"InternalError exception." << endl;
535 cout <<
"othrer exception." << endl;
538 CPPUNIT_ASSERT(sflg == 1);
546 rtobj2 = new ::RTC::RTObject_impl(&mgr2);
552 rtobj2->_remove_ref();
554 catch (InvalidParameter ip) {
555 cout <<
"InvalidParameter exception." << endl;
558 catch (NotAvailable na) {
559 cout <<
"NotAvailable exception." << endl;
562 catch (InternalError ip) {
563 cout <<
"InternalError exception." << endl;
567 cout <<
"othrer exception." << endl;
570 CPPUNIT_ASSERT(sflg == 0);
572 catch (InvalidParameter ip) {
573 cout <<
"InvalidParameter exception." << endl;
575 catch (NotAvailable na) {
576 cout <<
"NotAvailable exception." << endl;
578 catch (InternalError ip) {
579 cout <<
"InternalError exception." << endl;
582 cout <<
"othrer exception." << endl;
594 SDOPackage::SDO_var sdo;
595 SDOPackage::SDOList slist;
596 SDOPackage::SDOList* rslist;
609 catch (InvalidParameter ip) {
610 cout <<
"InvalidParameter exception." << endl;
613 catch (NotAvailable na) {
614 cout <<
"NotAvailable exception." << endl;
617 catch (InternalError ip) {
618 cout <<
"InternalError exception." << endl;
622 cout <<
"othrer exception." << endl;
625 CPPUNIT_ASSERT(sflg == 0);
629 CPPUNIT_ASSERT(rslist->length() == 0);
637 rtobj2 = new ::RTC::RTObject_impl(&mgr2);
638 sdo = SDOPackage::SDO::_duplicate(rtobj2->
getObjRef());
643 rtobj2->_remove_ref();
645 catch (InvalidParameter ip) {
646 cout <<
"InvalidParameter exception." << endl;
649 catch (NotAvailable na) {
650 cout <<
"NotAvailable exception." << endl;
653 catch (InternalError ip) {
654 cout <<
"InternalError exception." << endl;
658 cout <<
"othrer exception." << endl;
661 CPPUNIT_ASSERT(sflg == 0);
665 CPPUNIT_ASSERT(rslist->length() == 1);
676 SDOPackage::SDO_var sdo;
677 SDOPackage::SDOList slist;
678 SDOPackage::SDOList* rslist;
686 rtobj2 = new ::RTC::RTObject_impl(&mgr2);
701 catch (InvalidParameter ip) {
702 cout <<
"InvalidParameter exception." << endl;
705 catch (NotAvailable na) {
706 cout <<
"NotAvailable exception." << endl;
709 catch (InternalError ip) {
710 cout <<
"InternalError exception." << endl;
714 cout <<
"othrer exception." << endl;
717 CPPUNIT_ASSERT(sflg == 0);
722 sdo = SDOPackage::SDO::_duplicate(rtobj2->
getObjRef());
735 catch (InvalidParameter ip) {
736 cout <<
"InvalidParameter exception." << endl;
739 catch (NotAvailable na) {
740 cout <<
"NotAvailable exception." << endl;
743 catch (InternalError ip) {
744 cout <<
"InternalError exception." << endl;
748 cout <<
"othrer exception." << endl;
751 CPPUNIT_ASSERT(sflg == 0);
755 CPPUNIT_ASSERT(rslist->length() == 1);
764 catch (InvalidParameter ip) {
768 catch (NotAvailable na) {
769 cout <<
"NotAvailable exception." << endl;
772 catch (InternalError ip) {
773 cout <<
"InternalError exception." << endl;
777 cout <<
"othrer exception." << endl;
780 CPPUNIT_ASSERT(sflg == 1);
789 catch (InvalidParameter ip) {
793 catch (NotAvailable na) {
794 cout <<
"NotAvailable exception." << endl;
797 catch (InternalError ip) {
798 cout <<
"InternalError exception." << endl;
802 cout <<
"othrer exception." << endl;
805 CPPUNIT_ASSERT(sflg == 1);
814 catch (InvalidParameter ip) {
815 cout <<
"InvalidParameter exception." << endl;
818 catch (NotAvailable na) {
819 cout <<
"NotAvailable exception." << endl;
822 catch (InternalError ip) {
823 cout <<
"InternalError exception." << endl;
827 cout <<
"othrer exception." << endl;
830 CPPUNIT_ASSERT(sflg == 0);
834 CPPUNIT_ASSERT(rslist->length() == 0);
836 if ( !CORBA::is_nil( mgr2.
getPOA()) ) {
841 rtobj2->_remove_ref();
842 m_pOi2->_remove_ref();
852 DependencyType depType;
858 CPPUNIT_ASSERT(depType == 0);
863 CPPUNIT_ASSERT(depType == 2);
882 int main(
int argc,
char* argv[])
895 std::string arg(argv[i]);
896 std::string next_arg;
897 if (i + 1 < argc) next_arg = argv[i + 1];
900 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
913 ofs.open(fname.c_str());
915 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
916 if ( arg ==
"--cerr" ) { target = 1;
break; }
917 if ( arg ==
"--xsl" )
919 if (next_arg ==
"") xsl =
"default.xsl";
922 if ( arg ==
"--namespace" )
926 std::cerr <<
"no namespace specified" << std::endl;
936 CppUnit::TextUi::TestRunner runner;
938 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
940 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
941 CppUnit::Outputter* outputter = 0;
942 std::ostream* stream = target ? &std::cerr : &std::cout;
946 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
949 std::cout <<
"XML_OUT" << std::endl;
950 outputter =
new CppUnit::XmlOutputter(&runner.result(),
952 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
955 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
958 runner.setOutputter(outputter);
963 #endif // SdoOrganization_cpp int main(int argc, char **argv)
PortableServer::POAManager_ptr getPOAManager()
Get POAManager that Manager has.
virtual CORBA::Boolean add_organization_property(const OrganizationProperty &org_property)
[CORBA interface] Set OrganizationProperty
virtual SDOList * get_members()
[CORBA interface] Get the member list of the Organization
Organization_impl * m_pOi
PortableServer::POA_ptr getPOA()
Get a pointer to RootPOA held by Manager.
void test_set_get_owner()
set_owner() and get_owner()
virtual SDOSystemElement_ptr get_owner()
[CORBA interface] Get the owner of Organization
void test_set_get_organization_property_value()
set_organization_property_value() and get_organization_property_value()
std::vector< std::pair< std::string, std::string > > NVList
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
virtual char * get_organization_id()
[CORBA interface] Get Organization ID
SDO Organization implementation class.
static Manager & instance()
Get instance of the manager.
virtual CORBA::Boolean remove_organization_property(const char *name)
[CORBA interface] Remove specified OrganizationProperty
void test_set_get_dependency()
set_dependency() and get_dependency()
::RTC::RTObject_impl * rtobj
virtual CORBA::Boolean set_organization_property_value(const char *name, const CORBA::Any &value)
[CORBA interface] Set specified value of OrganizationProperty
RTComponent manager class.
virtual DependencyType get_dependency()
[CORBA interface] Get the DependencyType of the Organization
virtual CORBA::Boolean set_members(const SDOList &sdos)
[CORBA interface] Set SDO
virtual void tearDown()
Test finalization.
Organization implementation class.
virtual CORBA::Boolean remove_member(const char *id)
[CORBA interface] Remove member SDO from Organization
~SdoOrganizationTests()
Destructor.
void test_set_get_organization_property()
set_organization_property() and get_organization_property()
void test_set_get_members()
set_members() and get_members()
bool activateManager()
Activate the Manager.
void test_remove_organization_property()
add_organization_property() and remove_organization_property()
virtual CORBA::Boolean set_owner(SDOSystemElement_ptr sdo)
[CORBA interface] Set the owner to the Organization
void test_add_remove_members()
add_members() and remove_member()
SdoOrganizationTests()
Constructor.
virtual void setUp()
Test initialization.
virtual OrganizationProperty * get_organization_property()
[CORBA interface] Get OrganizationProperty
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
void setInstanceName(const char *instance_name)
[local interface] Set instance name
CPPUNIT_TEST_SUITE_REGISTRATION(SdoOrganization::SdoOrganizationTests)
virtual CORBA::Any * get_organization_property_value(const char *name)
[CORBA interface] Get specified value of OrganizationProperty
void test_get_organization_id()
get_organization_id()
RTObject_ptr getObjRef() const
[local interface] Get the object reference
virtual CORBA::Boolean add_members(const SDOList &sdo_list)
[CORBA interface] Add the member SDOs
virtual CORBA::Boolean set_dependency(DependencyType dependency)
[CORBA interface] Set the DependencyType of the Organization