SdoConfigurationTests.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
21 /*
22  * $Log: SdoConfigurationTests.cpp,v $
23  * Revision 1.3 2008/04/23 10:43:41 arafune
24  * Modified / Added some tests.
25  *
26  * Revision 1.2 2008/04/17 13:21:45 arafune
27  * Modified some tests, and added new tests.
28  *
29  * Revision 1.1 2007/12/20 07:50:18 arafune
30  * *** empty log message ***
31  *
32  * Revision 1.2 2007/01/24 16:04:18 n-ando
33  * The SdoConfiguration's ctor. was changed.
34  *
35  * Revision 1.1 2006/11/27 08:26:07 n-ando
36  * TestSuites are devided into each directory.
37  *
38  * Revision 1.3 2006/11/10 07:13:44 kurihara
39  * A test after SdoConfiguration class revision.
40  *
41  * Revision 1.2 2006/11/09 09:29:47 kurihara
42  * A test after SdoConfiguration class revision.
43  *
44  * Revision 1.1 2006/11/01 11:23:35 kurihara
45  * test program for SdoConfiguration class.
46  *
47  */
48 
49 #ifndef SdoConfiguration_cpp
50 #define SdoConfiguration_cpp
51 
52 #include <cppunit/ui/text/TestRunner.h>
53 #include <cppunit/TextOutputter.h>
54 #include <cppunit/extensions/TestFactoryRegistry.h>
55 #include <cppunit/extensions/HelperMacros.h>
56 #include <cppunit/TestAssert.h>
57 
58 #include <vector>
59 #include <string>
60 
61 #include <rtm/CORBA_SeqUtil.h>
62 #include <rtm/SdoConfiguration.h>
63 #include <rtm/RTObject.h>
64 #include <rtm/Manager.h>
65 #include <rtm/SdoOrganization.h>
66 
72 {
73  using namespace SDOPackage;
74  using namespace std;
75 
77  {
78  ServiceProfileFinder(const std::string& id) : _id(id) { }
79 
80  bool operator()(const ServiceProfile& svcProf)
81  {
82  return (_id == std::string(svcProf.id));
83  }
84 
85  std::string _id;
86  };
87 
89  : public CppUnit::TestFixture
90  {
91  CPPUNIT_TEST_SUITE(SdoConfigurationTests);
92 
93  CPPUNIT_TEST(test_set_device_profile_and_getDeviceProfile);
94  CPPUNIT_TEST(test_set_service_profile_and_getServiceProfile);
95  CPPUNIT_TEST(test_getServiceProfiles);
96  CPPUNIT_TEST(test_remove_service_profile);
97  CPPUNIT_TEST(test_add_organization_and_getOrganizations);
98  CPPUNIT_TEST(test_remove_organization);
99  CPPUNIT_TEST(test_add_configuration_set_and_get_configuration_set);
100  CPPUNIT_TEST(test_remove_configuration_set);
101  CPPUNIT_TEST(test_set_configuration_set_values);
102  CPPUNIT_TEST(test_activate_configuration_set_and_get_active_configuration_set);
103  //CPPUNIT_TEST(test_get_configuration_parameters); //̤¼ÂÁõ¤Î¤¿¤á̤¥Æ¥¹¥È //CPPUNIT_TEST(test_get_configuration_parameter_values); //̤¼ÂÁõ¤Î¤¿¤á̤¥Æ¥¹¥È //CPPUNIT_TEST(test_get_configuration_parameter_value); //̤¼ÂÁõ¤Î¤¿¤á̤¥Æ¥¹¥È //CPPUNIT_TEST(test_set_configuration_parameter); //̤¼ÂÁõ¤Î¤¿¤á̤¥Æ¥¹¥È CPPUNIT_TEST_SUITE_END(); private: CORBA::ORB_ptr m_pORB; PortableServer::POA_ptr m_pPOA; public: /*! * @brief Constructor */ SdoConfigurationTests() { int argc(0); char** argv(NULL); m_pORB = CORBA::ORB_init(argc, argv); m_pPOA = PortableServer::POA::_narrow( m_pORB->resolve_initial_references("RootPOA")); m_pPOA->the_POAManager()->activate(); } /*! * @brief Destructor */ ~SdoConfigurationTests() { } /*! * @brief Test initialization */ virtual void setUp() { usleep(100000); } /*! * @brief Test finalization */ virtual void tearDown() { } /*! * set_device_profile()¥á¥½¥Ã¥É¤ÈgetDeviceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_device_profile()¤ÇÀßÄꤷ¤¿DeviceProfile¤ò¡¢getDeviceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_device_profile_and_getDeviceProfile() { // std::cout << "test_set_device_profile_and_getDeviceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // DeviceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::DeviceProfile devProf; devProf.device_type = "DEVICE_TYPE"; devProf.manufacturer = "MANUFACTURER"; devProf.model = "MODEL"; devProf.version = "VERSION"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); devProf.properties = properties; } // set_device_profile()¤ò¸Æ½Ð¤·¤Æ¡¢½àÈ÷¤·¤¿DeviceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_device_profile(devProf)); // getDeviceProfile()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëDeviceProfile¤ò¼è¤ê½Ð¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ¹¤ë¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::DeviceProfile devProfRet = sdoCfg->getDeviceProfile(); CPPUNIT_ASSERT_EQUAL(std::string("DEVICE_TYPE"), std::string(devProfRet.device_type)); CPPUNIT_ASSERT_EQUAL(std::string("MANUFACTURER"), std::string(devProfRet.manufacturer)); CPPUNIT_ASSERT_EQUAL(std::string("MODEL"), std::string(devProfRet.model)); CPPUNIT_ASSERT_EQUAL(std::string("VERSION"), std::string(devProfRet.version)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(devProfRet.properties[0].name)); { CORBA::Float value; devProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(devProfRet.properties[1].name)); { CORBA::Float value; devProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_device_profile_and_getDeviceProfile() OUT" << std::endl; } /*! * @brief set_service_profile()¥á¥½¥Ã¥É¤ÈgetServiceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_service_profile()¤ÇÀßÄꤷ¤¿ServiceProfile¤ò¡¢getServiceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_service_profile_and_getServiceProfile() { // std::cout << "test_set_service_profile_and_getServiceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf; svcProf.id = "ID"; svcProf.interface_type = "INTERFACE_TYPE"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); svcProf.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf)); // getServiceProfile()¤ÇServiceProfile¤ò¼èÆÀ¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ·¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID"); CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"), std::string(svcProfRet.interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(svcProfRet.properties[0].name)); { CORBA::Float value; svcProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(svcProfRet.properties[1].name)); { CORBA::Float value; svcProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl; } /*! * @brief getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÊ£¿ô¤ÎServiceProfile¤ò¡¢getServiceProfiles()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_getServiceProfiles() { // std::cout << "test_getServiceProfiles() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
104  //CPPUNIT_TEST(test_get_configuration_parameter_values); //̤¼ÂÁõ¤Î¤¿¤á̤¥Æ¥¹¥È //CPPUNIT_TEST(test_get_configuration_parameter_value); //̤¼ÂÁõ¤Î¤¿¤á̤¥Æ¥¹¥È //CPPUNIT_TEST(test_set_configuration_parameter); //̤¼ÂÁõ¤Î¤¿¤á̤¥Æ¥¹¥È CPPUNIT_TEST_SUITE_END(); private: CORBA::ORB_ptr m_pORB; PortableServer::POA_ptr m_pPOA; public: /*! * @brief Constructor */ SdoConfigurationTests() { int argc(0); char** argv(NULL); m_pORB = CORBA::ORB_init(argc, argv); m_pPOA = PortableServer::POA::_narrow( m_pORB->resolve_initial_references("RootPOA")); m_pPOA->the_POAManager()->activate(); } /*! * @brief Destructor */ ~SdoConfigurationTests() { } /*! * @brief Test initialization */ virtual void setUp() { usleep(100000); } /*! * @brief Test finalization */ virtual void tearDown() { } /*! * set_device_profile()¥á¥½¥Ã¥É¤ÈgetDeviceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_device_profile()¤ÇÀßÄꤷ¤¿DeviceProfile¤ò¡¢getDeviceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_device_profile_and_getDeviceProfile() { // std::cout << "test_set_device_profile_and_getDeviceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // DeviceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::DeviceProfile devProf; devProf.device_type = "DEVICE_TYPE"; devProf.manufacturer = "MANUFACTURER"; devProf.model = "MODEL"; devProf.version = "VERSION"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); devProf.properties = properties; } // set_device_profile()¤ò¸Æ½Ð¤·¤Æ¡¢½àÈ÷¤·¤¿DeviceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_device_profile(devProf)); // getDeviceProfile()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëDeviceProfile¤ò¼è¤ê½Ð¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ¹¤ë¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::DeviceProfile devProfRet = sdoCfg->getDeviceProfile(); CPPUNIT_ASSERT_EQUAL(std::string("DEVICE_TYPE"), std::string(devProfRet.device_type)); CPPUNIT_ASSERT_EQUAL(std::string("MANUFACTURER"), std::string(devProfRet.manufacturer)); CPPUNIT_ASSERT_EQUAL(std::string("MODEL"), std::string(devProfRet.model)); CPPUNIT_ASSERT_EQUAL(std::string("VERSION"), std::string(devProfRet.version)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(devProfRet.properties[0].name)); { CORBA::Float value; devProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(devProfRet.properties[1].name)); { CORBA::Float value; devProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_device_profile_and_getDeviceProfile() OUT" << std::endl; } /*! * @brief set_service_profile()¥á¥½¥Ã¥É¤ÈgetServiceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_service_profile()¤ÇÀßÄꤷ¤¿ServiceProfile¤ò¡¢getServiceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_service_profile_and_getServiceProfile() { // std::cout << "test_set_service_profile_and_getServiceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf; svcProf.id = "ID"; svcProf.interface_type = "INTERFACE_TYPE"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); svcProf.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf)); // getServiceProfile()¤ÇServiceProfile¤ò¼èÆÀ¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ·¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID"); CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"), std::string(svcProfRet.interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(svcProfRet.properties[0].name)); { CORBA::Float value; svcProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(svcProfRet.properties[1].name)); { CORBA::Float value; svcProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl; } /*! * @brief getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÊ£¿ô¤ÎServiceProfile¤ò¡¢getServiceProfiles()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_getServiceProfiles() { // std::cout << "test_getServiceProfiles() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
105  //CPPUNIT_TEST(test_get_configuration_parameter_value); //̤¼ÂÁõ¤Î¤¿¤á̤¥Æ¥¹¥È //CPPUNIT_TEST(test_set_configuration_parameter); //̤¼ÂÁõ¤Î¤¿¤á̤¥Æ¥¹¥È CPPUNIT_TEST_SUITE_END(); private: CORBA::ORB_ptr m_pORB; PortableServer::POA_ptr m_pPOA; public: /*! * @brief Constructor */ SdoConfigurationTests() { int argc(0); char** argv(NULL); m_pORB = CORBA::ORB_init(argc, argv); m_pPOA = PortableServer::POA::_narrow( m_pORB->resolve_initial_references("RootPOA")); m_pPOA->the_POAManager()->activate(); } /*! * @brief Destructor */ ~SdoConfigurationTests() { } /*! * @brief Test initialization */ virtual void setUp() { usleep(100000); } /*! * @brief Test finalization */ virtual void tearDown() { } /*! * set_device_profile()¥á¥½¥Ã¥É¤ÈgetDeviceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_device_profile()¤ÇÀßÄꤷ¤¿DeviceProfile¤ò¡¢getDeviceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_device_profile_and_getDeviceProfile() { // std::cout << "test_set_device_profile_and_getDeviceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // DeviceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::DeviceProfile devProf; devProf.device_type = "DEVICE_TYPE"; devProf.manufacturer = "MANUFACTURER"; devProf.model = "MODEL"; devProf.version = "VERSION"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); devProf.properties = properties; } // set_device_profile()¤ò¸Æ½Ð¤·¤Æ¡¢½àÈ÷¤·¤¿DeviceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_device_profile(devProf)); // getDeviceProfile()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëDeviceProfile¤ò¼è¤ê½Ð¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ¹¤ë¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::DeviceProfile devProfRet = sdoCfg->getDeviceProfile(); CPPUNIT_ASSERT_EQUAL(std::string("DEVICE_TYPE"), std::string(devProfRet.device_type)); CPPUNIT_ASSERT_EQUAL(std::string("MANUFACTURER"), std::string(devProfRet.manufacturer)); CPPUNIT_ASSERT_EQUAL(std::string("MODEL"), std::string(devProfRet.model)); CPPUNIT_ASSERT_EQUAL(std::string("VERSION"), std::string(devProfRet.version)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(devProfRet.properties[0].name)); { CORBA::Float value; devProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(devProfRet.properties[1].name)); { CORBA::Float value; devProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_device_profile_and_getDeviceProfile() OUT" << std::endl; } /*! * @brief set_service_profile()¥á¥½¥Ã¥É¤ÈgetServiceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_service_profile()¤ÇÀßÄꤷ¤¿ServiceProfile¤ò¡¢getServiceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_service_profile_and_getServiceProfile() { // std::cout << "test_set_service_profile_and_getServiceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf; svcProf.id = "ID"; svcProf.interface_type = "INTERFACE_TYPE"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); svcProf.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf)); // getServiceProfile()¤ÇServiceProfile¤ò¼èÆÀ¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ·¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID"); CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"), std::string(svcProfRet.interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(svcProfRet.properties[0].name)); { CORBA::Float value; svcProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(svcProfRet.properties[1].name)); { CORBA::Float value; svcProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl; } /*! * @brief getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÊ£¿ô¤ÎServiceProfile¤ò¡¢getServiceProfiles()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_getServiceProfiles() { // std::cout << "test_getServiceProfiles() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
106  //CPPUNIT_TEST(test_set_configuration_parameter); //̤¼ÂÁõ¤Î¤¿¤á̤¥Æ¥¹¥È CPPUNIT_TEST_SUITE_END(); private: CORBA::ORB_ptr m_pORB; PortableServer::POA_ptr m_pPOA; public: /*! * @brief Constructor */ SdoConfigurationTests() { int argc(0); char** argv(NULL); m_pORB = CORBA::ORB_init(argc, argv); m_pPOA = PortableServer::POA::_narrow( m_pORB->resolve_initial_references("RootPOA")); m_pPOA->the_POAManager()->activate(); } /*! * @brief Destructor */ ~SdoConfigurationTests() { } /*! * @brief Test initialization */ virtual void setUp() { usleep(100000); } /*! * @brief Test finalization */ virtual void tearDown() { } /*! * set_device_profile()¥á¥½¥Ã¥É¤ÈgetDeviceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_device_profile()¤ÇÀßÄꤷ¤¿DeviceProfile¤ò¡¢getDeviceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_device_profile_and_getDeviceProfile() { // std::cout << "test_set_device_profile_and_getDeviceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // DeviceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::DeviceProfile devProf; devProf.device_type = "DEVICE_TYPE"; devProf.manufacturer = "MANUFACTURER"; devProf.model = "MODEL"; devProf.version = "VERSION"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); devProf.properties = properties; } // set_device_profile()¤ò¸Æ½Ð¤·¤Æ¡¢½àÈ÷¤·¤¿DeviceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_device_profile(devProf)); // getDeviceProfile()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëDeviceProfile¤ò¼è¤ê½Ð¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ¹¤ë¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::DeviceProfile devProfRet = sdoCfg->getDeviceProfile(); CPPUNIT_ASSERT_EQUAL(std::string("DEVICE_TYPE"), std::string(devProfRet.device_type)); CPPUNIT_ASSERT_EQUAL(std::string("MANUFACTURER"), std::string(devProfRet.manufacturer)); CPPUNIT_ASSERT_EQUAL(std::string("MODEL"), std::string(devProfRet.model)); CPPUNIT_ASSERT_EQUAL(std::string("VERSION"), std::string(devProfRet.version)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(devProfRet.properties[0].name)); { CORBA::Float value; devProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(devProfRet.properties[1].name)); { CORBA::Float value; devProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_device_profile_and_getDeviceProfile() OUT" << std::endl; } /*! * @brief set_service_profile()¥á¥½¥Ã¥É¤ÈgetServiceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_service_profile()¤ÇÀßÄꤷ¤¿ServiceProfile¤ò¡¢getServiceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_service_profile_and_getServiceProfile() { // std::cout << "test_set_service_profile_and_getServiceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf; svcProf.id = "ID"; svcProf.interface_type = "INTERFACE_TYPE"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); svcProf.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf)); // getServiceProfile()¤ÇServiceProfile¤ò¼èÆÀ¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ·¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID"); CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"), std::string(svcProfRet.interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(svcProfRet.properties[0].name)); { CORBA::Float value; svcProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(svcProfRet.properties[1].name)); { CORBA::Float value; svcProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl; } /*! * @brief getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÊ£¿ô¤ÎServiceProfile¤ò¡¢getServiceProfiles()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_getServiceProfiles() { // std::cout << "test_getServiceProfiles() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
107 
108  CPPUNIT_TEST_SUITE_END();
109 
110  private:
111  CORBA::ORB_ptr m_pORB;
112  PortableServer::POA_ptr m_pPOA;
113 
114  public:
119  {
120  int argc(0);
121  char** argv(NULL);
122  m_pORB = CORBA::ORB_init(argc, argv);
123  m_pPOA = PortableServer::POA::_narrow(
124  m_pORB->resolve_initial_references("RootPOA"));
125  m_pPOA->the_POAManager()->activate();
126  }
127 
132  {
133  }
134 
138  virtual void setUp()
139  {
140  usleep(100000);
141  }
142 
146  virtual void tearDown()
147  {
148  }
149 
156  {
157 // std::cout << "test_set_device_profile_and_getDeviceProfile() IN" << std::endl;
158  coil::Properties cfgAdminProp;
159  RTC::ConfigAdmin cfgAdmin(cfgAdminProp);
160  SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin);
161 
162  // DeviceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::DeviceProfile devProf; devProf.device_type = "DEVICE_TYPE"; devProf.manufacturer = "MANUFACTURER"; devProf.model = "MODEL"; devProf.version = "VERSION"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); devProf.properties = properties; } // set_device_profile()¤ò¸Æ½Ð¤·¤Æ¡¢½àÈ÷¤·¤¿DeviceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_device_profile(devProf)); // getDeviceProfile()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëDeviceProfile¤ò¼è¤ê½Ð¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ¹¤ë¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::DeviceProfile devProfRet = sdoCfg->getDeviceProfile(); CPPUNIT_ASSERT_EQUAL(std::string("DEVICE_TYPE"), std::string(devProfRet.device_type)); CPPUNIT_ASSERT_EQUAL(std::string("MANUFACTURER"), std::string(devProfRet.manufacturer)); CPPUNIT_ASSERT_EQUAL(std::string("MODEL"), std::string(devProfRet.model)); CPPUNIT_ASSERT_EQUAL(std::string("VERSION"), std::string(devProfRet.version)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(devProfRet.properties[0].name)); { CORBA::Float value; devProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(devProfRet.properties[1].name)); { CORBA::Float value; devProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_device_profile_and_getDeviceProfile() OUT" << std::endl; } /*! * @brief set_service_profile()¥á¥½¥Ã¥É¤ÈgetServiceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_service_profile()¤ÇÀßÄꤷ¤¿ServiceProfile¤ò¡¢getServiceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_service_profile_and_getServiceProfile() { // std::cout << "test_set_service_profile_and_getServiceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf; svcProf.id = "ID"; svcProf.interface_type = "INTERFACE_TYPE"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); svcProf.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf)); // getServiceProfile()¤ÇServiceProfile¤ò¼èÆÀ¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ·¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID"); CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"), std::string(svcProfRet.interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(svcProfRet.properties[0].name)); { CORBA::Float value; svcProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(svcProfRet.properties[1].name)); { CORBA::Float value; svcProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl; } /*! * @brief getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÊ£¿ô¤ÎServiceProfile¤ò¡¢getServiceProfiles()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_getServiceProfiles() { // std::cout << "test_getServiceProfiles() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
163  SDOPackage::DeviceProfile devProf;
164  devProf.device_type = "DEVICE_TYPE";
165  devProf.manufacturer = "MANUFACTURER";
166  devProf.model = "MODEL";
167  devProf.version = "VERSION";
168  {
169  SDOPackage::NVList properties;
170  properties.length(2);
171  properties[0].name = "name 0";
172  properties[0].value <<= CORBA::Float(3.14159);
173  properties[1].name = "name 1";
174  properties[1].value <<= CORBA::Float(2.71828);
175  devProf.properties = properties;
176  }
177 
178  // set_device_profile()¤ò¸Æ½Ð¤·¤Æ¡¢½àÈ÷¤·¤¿DeviceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_device_profile(devProf)); // getDeviceProfile()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëDeviceProfile¤ò¼è¤ê½Ð¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ¹¤ë¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::DeviceProfile devProfRet = sdoCfg->getDeviceProfile(); CPPUNIT_ASSERT_EQUAL(std::string("DEVICE_TYPE"), std::string(devProfRet.device_type)); CPPUNIT_ASSERT_EQUAL(std::string("MANUFACTURER"), std::string(devProfRet.manufacturer)); CPPUNIT_ASSERT_EQUAL(std::string("MODEL"), std::string(devProfRet.model)); CPPUNIT_ASSERT_EQUAL(std::string("VERSION"), std::string(devProfRet.version)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(devProfRet.properties[0].name)); { CORBA::Float value; devProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(devProfRet.properties[1].name)); { CORBA::Float value; devProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_device_profile_and_getDeviceProfile() OUT" << std::endl; } /*! * @brief set_service_profile()¥á¥½¥Ã¥É¤ÈgetServiceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_service_profile()¤ÇÀßÄꤷ¤¿ServiceProfile¤ò¡¢getServiceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_service_profile_and_getServiceProfile() { // std::cout << "test_set_service_profile_and_getServiceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf; svcProf.id = "ID"; svcProf.interface_type = "INTERFACE_TYPE"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); svcProf.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf)); // getServiceProfile()¤ÇServiceProfile¤ò¼èÆÀ¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ·¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID"); CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"), std::string(svcProfRet.interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(svcProfRet.properties[0].name)); { CORBA::Float value; svcProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(svcProfRet.properties[1].name)); { CORBA::Float value; svcProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl; } /*! * @brief getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÊ£¿ô¤ÎServiceProfile¤ò¡¢getServiceProfiles()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_getServiceProfiles() { // std::cout << "test_getServiceProfiles() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
179  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_device_profile(devProf));
180 
181  // getDeviceProfile()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëDeviceProfile¤ò¼è¤ê½Ð¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ¹¤ë¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::DeviceProfile devProfRet = sdoCfg->getDeviceProfile(); CPPUNIT_ASSERT_EQUAL(std::string("DEVICE_TYPE"), std::string(devProfRet.device_type)); CPPUNIT_ASSERT_EQUAL(std::string("MANUFACTURER"), std::string(devProfRet.manufacturer)); CPPUNIT_ASSERT_EQUAL(std::string("MODEL"), std::string(devProfRet.model)); CPPUNIT_ASSERT_EQUAL(std::string("VERSION"), std::string(devProfRet.version)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(devProfRet.properties[0].name)); { CORBA::Float value; devProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(devProfRet.properties[1].name)); { CORBA::Float value; devProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_device_profile_and_getDeviceProfile() OUT" << std::endl; } /*! * @brief set_service_profile()¥á¥½¥Ã¥É¤ÈgetServiceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - set_service_profile()¤ÇÀßÄꤷ¤¿ServiceProfile¤ò¡¢getServiceProfile()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_set_service_profile_and_getServiceProfile() { // std::cout << "test_set_service_profile_and_getServiceProfile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf; svcProf.id = "ID"; svcProf.interface_type = "INTERFACE_TYPE"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); svcProf.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf)); // getServiceProfile()¤ÇServiceProfile¤ò¼èÆÀ¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ·¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID"); CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"), std::string(svcProfRet.interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(svcProfRet.properties[0].name)); { CORBA::Float value; svcProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(svcProfRet.properties[1].name)); { CORBA::Float value; svcProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl; } /*! * @brief getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÊ£¿ô¤ÎServiceProfile¤ò¡¢getServiceProfiles()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_getServiceProfiles() { // std::cout << "test_getServiceProfiles() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
182  const SDOPackage::DeviceProfile devProfRet = sdoCfg->getDeviceProfile();
183  CPPUNIT_ASSERT_EQUAL(std::string("DEVICE_TYPE"),
184  std::string(devProfRet.device_type));
185  CPPUNIT_ASSERT_EQUAL(std::string("MANUFACTURER"),
186  std::string(devProfRet.manufacturer));
187  CPPUNIT_ASSERT_EQUAL(std::string("MODEL"),
188  std::string(devProfRet.model));
189  CPPUNIT_ASSERT_EQUAL(std::string("VERSION"),
190  std::string(devProfRet.version));
191  CPPUNIT_ASSERT_EQUAL(std::string("name 0"),
192  std::string(devProfRet.properties[0].name));
193  {
194  CORBA::Float value; devProfRet.properties[0].value >>= value;
195  CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value);
196  }
197  CPPUNIT_ASSERT_EQUAL(std::string("name 1"),
198  std::string(devProfRet.properties[1].name));
199  {
200  CORBA::Float value; devProfRet.properties[1].value >>= value;
201  CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value);
202  }
203  sdoCfg->_remove_ref();
204 // std::cout << "test_set_device_profile_and_getDeviceProfile() OUT" << std::endl;
205  }
206 
213  {
214 // std::cout << "test_set_service_profile_and_getServiceProfile() IN" << std::endl;
215  coil::Properties cfgAdminProp;
216  RTC::ConfigAdmin cfgAdmin(cfgAdminProp);
217  SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin);
218 
219  // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf; svcProf.id = "ID"; svcProf.interface_type = "INTERFACE_TYPE"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 1"; properties[1].value <<= CORBA::Float(2.71828); svcProf.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf)); // getServiceProfile()¤ÇServiceProfile¤ò¼èÆÀ¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ·¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID"); CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"), std::string(svcProfRet.interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(svcProfRet.properties[0].name)); { CORBA::Float value; svcProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(svcProfRet.properties[1].name)); { CORBA::Float value; svcProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl; } /*! * @brief getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÊ£¿ô¤ÎServiceProfile¤ò¡¢getServiceProfiles()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_getServiceProfiles() { // std::cout << "test_getServiceProfiles() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
220  SDOPackage::ServiceProfile svcProf;
221  svcProf.id = "ID";
222  svcProf.interface_type = "INTERFACE_TYPE";
223  {
224  SDOPackage::NVList properties;
225  properties.length(2);
226  properties[0].name = "name 0";
227  properties[0].value <<= CORBA::Float(3.14159);
228  properties[1].name = "name 1";
229  properties[1].value <<= CORBA::Float(2.71828);
230  svcProf.properties = properties;
231  }
232 
233  // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf)); // getServiceProfile()¤ÇServiceProfile¤ò¼èÆÀ¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ·¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID"); CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"), std::string(svcProfRet.interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(svcProfRet.properties[0].name)); { CORBA::Float value; svcProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(svcProfRet.properties[1].name)); { CORBA::Float value; svcProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl; } /*! * @brief getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÊ£¿ô¤ÎServiceProfile¤ò¡¢getServiceProfiles()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_getServiceProfiles() { // std::cout << "test_getServiceProfiles() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
234  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf));
235 
236  // getServiceProfile()¤ÇServiceProfile¤ò¼èÆÀ¤·¡¢ÀßÄꤷ¤¿¤â¤Î¤È°ìÃפ·¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID"); CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"), std::string(svcProfRet.interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0"), std::string(svcProfRet.properties[0].name)); { CORBA::Float value; svcProfRet.properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1"), std::string(svcProfRet.properties[1].name)); { CORBA::Float value; svcProfRet.properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } sdoCfg->_remove_ref(); // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl; } /*! * @brief getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÊ£¿ô¤ÎServiceProfile¤ò¡¢getServiceProfiles()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_getServiceProfiles() { // std::cout << "test_getServiceProfiles() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
237  const SDOPackage::ServiceProfile svcProfRet = sdoCfg->getServiceProfile("ID");
238  CPPUNIT_ASSERT_EQUAL(std::string("ID"), std::string(svcProfRet.id));
239  CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE"),
240  std::string(svcProfRet.interface_type));
241  CPPUNIT_ASSERT_EQUAL(std::string("name 0"),
242  std::string(svcProfRet.properties[0].name));
243  {
244  CORBA::Float value; svcProfRet.properties[0].value >>= value;
245  CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value);
246  }
247  CPPUNIT_ASSERT_EQUAL(std::string("name 1"),
248  std::string(svcProfRet.properties[1].name));
249  {
250  CORBA::Float value; svcProfRet.properties[1].value >>= value;
251  CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value);
252  }
253  sdoCfg->_remove_ref();
254 // std::cout << "test_set_service_profile_and_getServiceProfile() OUT" << std::endl;
255  }
256 
263  {
264 // std::cout << "test_getServiceProfiles() IN" << std::endl;
265  coil::Properties cfgAdminProp;
266  RTC::ConfigAdmin cfgAdmin(cfgAdminProp);
267  SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin);
268 
269  // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
270  SDOPackage::ServiceProfile svcProf0;
271  svcProf0.id = "ID 0";
272  svcProf0.interface_type = "INTERFACE_TYPE 0";
273  {
274  SDOPackage::NVList properties;
275  properties.length(2);
276  properties[0].name = "name 0-0";
277  properties[0].value <<= CORBA::Float(3.14159);
278  properties[1].name = "name 0-1";
279  properties[1].value <<= CORBA::Float(2.71828);
280  svcProf0.properties = properties;
281  }
282 
283  SDOPackage::ServiceProfile svcProf1;
284  svcProf1.id = "ID 1";
285  svcProf1.interface_type = "INTERFACE_TYPE 1";
286  {
287  SDOPackage::NVList properties;
288  properties.length(2);
289  properties[0].name = "name 1-0";
290  properties[0].value <<= CORBA::Float(1.41421356);
291  properties[1].name = "name 1-1";
292  properties[1].value <<= CORBA::Float(1.7320508);
293  svcProf1.properties = properties;
294  }
295 
296  // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
297  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0));
298  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1));
299 
300  // getServiceProfiles()¤ÇÀßÄꤵ¤ì¤Æ¤¤¤ëServiceProfile·²¤ò¼èÆÀ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length()); // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡© { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value); } } { CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(svcProfList[idx].id)); CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"), std::string(svcProfList[idx].interface_type)); CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"), std::string(svcProfList[idx].properties[0].name)); { CORBA::Float value; svcProfList[idx].properties[0].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value); } CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"), std::string(svcProfList[idx].properties[1].name)); { CORBA::Float value; svcProfList[idx].properties[1].value >>= value; CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value); } } sdoCfg->_remove_ref(); // std::cout << "test_getServiceProfiles() OUT" << std::endl; } /*! * @brief remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - »ØÄꤷ¤¿ID¤ò»ý¤ÄServiceProfile¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© */ void test_remove_service_profile() { // std::cout << "test_remove_service_profile() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
301  const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles();
302  CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), svcProfList.length());
303 
304  // ÀßÄꤷ¤¿ServiceProfile¤È°ìÃפ·¤Æ¤¤¤ë¤«¡©
305  {
306  CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"));
307 
308  CPPUNIT_ASSERT_EQUAL(std::string("ID 0"),
309  std::string(svcProfList[idx].id));
310  CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 0"),
311  std::string(svcProfList[idx].interface_type));
312  CPPUNIT_ASSERT_EQUAL(std::string("name 0-0"),
313  std::string(svcProfList[idx].properties[0].name));
314  {
315  CORBA::Float value; svcProfList[idx].properties[0].value >>= value;
316  CPPUNIT_ASSERT_EQUAL(CORBA::Float(3.14159), value);
317  }
318  CPPUNIT_ASSERT_EQUAL(std::string("name 0-1"),
319  std::string(svcProfList[idx].properties[1].name));
320  {
321  CORBA::Float value; svcProfList[idx].properties[1].value >>= value;
322  CPPUNIT_ASSERT_EQUAL(CORBA::Float(2.71828), value);
323  }
324  }
325 
326  {
327  CORBA::ULong idx = CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"));
328 
329  CPPUNIT_ASSERT_EQUAL(std::string("ID 1"),
330  std::string(svcProfList[idx].id));
331  CPPUNIT_ASSERT_EQUAL(std::string("INTERFACE_TYPE 1"),
332  std::string(svcProfList[idx].interface_type));
333  CPPUNIT_ASSERT_EQUAL(std::string("name 1-0"),
334  std::string(svcProfList[idx].properties[0].name));
335  {
336  CORBA::Float value; svcProfList[idx].properties[0].value >>= value;
337  CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.41421356), value);
338  }
339  CPPUNIT_ASSERT_EQUAL(std::string("name 1-1"),
340  std::string(svcProfList[idx].properties[1].name));
341  {
342  CORBA::Float value; svcProfList[idx].properties[1].value >>= value;
343  CPPUNIT_ASSERT_EQUAL(CORBA::Float(1.7320508), value);
344  }
345  }
346  sdoCfg->_remove_ref();
347 // std::cout << "test_getServiceProfiles() OUT" << std::endl;
348  }
349 
356  {
357 // std::cout << "test_remove_service_profile() IN" << std::endl;
358  coil::Properties cfgAdminProp;
359  RTC::ConfigAdmin cfgAdmin(cfgAdminProp);
360  SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin);
361 
362  // ServiceProfile¤ò½àÈ÷¤¹¤ë SDOPackage::ServiceProfile svcProf0; svcProf0.id = "ID 0"; svcProf0.interface_type = "INTERFACE_TYPE 0"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 0-0"; properties[0].value <<= CORBA::Float(3.14159); properties[1].name = "name 0-1"; properties[1].value <<= CORBA::Float(2.71828); svcProf0.properties = properties; } SDOPackage::ServiceProfile svcProf1; svcProf1.id = "ID 1"; svcProf1.interface_type = "INTERFACE_TYPE 1"; { SDOPackage::NVList properties; properties.length(2); properties[0].name = "name 1-0"; properties[0].value <<= CORBA::Float(1.41421356); properties[1].name = "name 1-1"; properties[1].value <<= CORBA::Float(1.7320508); svcProf1.properties = properties; } // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
363  SDOPackage::ServiceProfile svcProf0;
364  svcProf0.id = "ID 0";
365  svcProf0.interface_type = "INTERFACE_TYPE 0";
366  {
367  SDOPackage::NVList properties;
368  properties.length(2);
369  properties[0].name = "name 0-0";
370  properties[0].value <<= CORBA::Float(3.14159);
371  properties[1].name = "name 0-1";
372  properties[1].value <<= CORBA::Float(2.71828);
373  svcProf0.properties = properties;
374  }
375 
376  SDOPackage::ServiceProfile svcProf1;
377  svcProf1.id = "ID 1";
378  svcProf1.interface_type = "INTERFACE_TYPE 1";
379  {
380  SDOPackage::NVList properties;
381  properties.length(2);
382  properties[0].name = "name 1-0";
383  properties[0].value <<= CORBA::Float(1.41421356);
384  properties[1].name = "name 1-1";
385  properties[1].value <<= CORBA::Float(1.7320508);
386  svcProf1.properties = properties;
387  }
388 
389  // ServiceProfile¤òÀßÄꤹ¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1)); // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
390  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf0));
391  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_service_profile(svcProf1));
392 
393  // ÀßÄꤷ¤¿ServiceProfile¤Î¤¦¤Á¡¢ÊÒÊý¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0")); // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
394  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_service_profile("ID 0"));
395 
396  // getServiceProfiles()¤ÇÁ´ServiceProfile¤ò¼èÆÀ¤·¡¢ÅÐÏ¿²ò½ü¤·¤¿¤â¤Î¤¬´Þ¤Þ¤ì¤Ê¤¤¤³¤È¤ò³Îǧ¤¹¤ë const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length()); CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0"))); // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT_EQUAL(CORBA::Long(0), CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1"))); sdoCfg->_remove_ref(); // std::cout << "test_remove_service_profile() OUT" << std::endl; } /* * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
397  const SDOPackage::ServiceProfileList svcProfList = sdoCfg->getServiceProfiles();
398  CPPUNIT_ASSERT_EQUAL(CORBA::ULong(1), svcProfList.length());
399  CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1),
400  CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 0")));
401 
402  // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¡¢°ÍÁ³¤È¤·¤Æ´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¡©
403  CPPUNIT_ASSERT_EQUAL(CORBA::Long(0),
404  CORBA_SeqUtil::find(svcProfList, ServiceProfileFinder("ID 1")));
405 
406  sdoCfg->_remove_ref();
407 // std::cout << "test_remove_service_profile() OUT" << std::endl;
408  }
409 
410  /*
411  * @brief add_organization()¥á¥½¥Ã¥É¤ÈgetOrganizations()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡© * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_organization_and_getOrganizations() { // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
412  *
413  * - add_organization()¤ÇOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹¤òÅÐÏ¿¤Ç¤­¤ë¤«¡©
414  * - getOrganizations()¤ÇÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëOrganization_ptr¥¤¥ó¥¹¥¿¥ó¥¹·²¤ò¼èÆÀ¤Ç¤­¤ë¤«¡©
415  */
417  {
418 // std::cout << "test_add_organization_and_getOrganizations() IN" << std::endl;
419  coil::Properties cfgAdminProp;
420  RTC::ConfigAdmin cfgAdmin(cfgAdminProp);
421  SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin);
422 
423  // Organization¤ò2¤ÄÅÐÏ¿¤¹¤ë SDOPackage::Organization_var org1; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org1._retn())); SDOPackage::Organization_var org2; CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(org2._retn())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length()); sdoCfg->_remove_ref(); // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl; } /* * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
424  SDOPackage::Organization_var org1;
425  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true),
426  sdoCfg->add_organization(org1._retn()));
427 
428  SDOPackage::Organization_var org2;
429  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true),
430  sdoCfg->add_organization(org2._retn()));
431 
432  // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê2¤Ä¤«¡©
433  SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations();
434  CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), orgList.length());
435 
436  sdoCfg->_remove_ref();
437 // std::cout << "test_add_organization_and_getOrganizations() OUT" << std::endl;
438  }
439 
440  /*
441  * @brief remove_organization()¤Î¥Æ¥¹¥È * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡© */ void test_remove_organization() { // std::cout << "test_remove_organization() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); RTC::RTObject_impl* rtobj; SDOPackage::Organization_impl* m_pOi; RTC::Manager& mgr(RTC::Manager::instance()); rtobj = new ::RTC::RTObject_impl(&mgr); m_pOi = new Organization_impl(rtobj->getObjRef()); // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
442  * - add_organization()¤ÇÅÐÏ¿¤·¡¢remove_organization()¤ÇÀµ¤·¤¯ºï½ü¤Ç¤­¤ë¤«¡©
443  */
445  {
446 // std::cout << "test_remove_organization() IN" << std::endl;
447  coil::Properties cfgAdminProp;
448  RTC::ConfigAdmin cfgAdmin(cfgAdminProp);
449  SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin);
450  RTC::RTObject_impl* rtobj;
453  rtobj = new ::RTC::RTObject_impl(&mgr);
454  m_pOi = new Organization_impl(rtobj->getObjRef());
455 
456  // Organization¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_organization(m_pOi->getObjRef())); // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
457  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true),
458  sdoCfg->add_organization(m_pOi->getObjRef()));
459 
460  // organization_id¤ò¼èÆÀ¤¹¤ë std::string id(m_pOi->get_organization_id()); // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
461  std::string id(m_pOi->get_organization_id());
462 
463  // ÅÐÏ¿¤·¤¿Organization¤òºï½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_organization(id.c_str())); // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡© SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations(); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length()); m_pOi->_remove_ref(); rtobj->_remove_ref(); sdoCfg->_remove_ref(); // std::cout << "test_remove_organization() OUT" << std::endl; } /* * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
464  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true),
465  sdoCfg->remove_organization(id.c_str()));
466 
467  // ¼èÆÀ¤µ¤ì¤ëOrganization¤Î¿ô¤Ï¡¢°Õ¿Þ¤É¤ª¤ê0·ï¤«¡©
468  SDOPackage::OrganizationList orgList = sdoCfg->getOrganizations();
469  CPPUNIT_ASSERT_EQUAL(CORBA::ULong(0), orgList.length());
470 
471  m_pOi->_remove_ref();
472  rtobj->_remove_ref();
473  sdoCfg->_remove_ref();
474 // std::cout << "test_remove_organization() OUT" << std::endl;
475  }
476 
477  /*
478  * @brief get_configuration_parameters()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameters() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameters() IN" << std::endl; // std::cout << "test_get_configuration_parameters() OUT" << std::endl; } /*! * @brief get_configuration_parameter_values()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_values() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_values() IN" << std::endl; // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl; } /*! * @brief get_configuration_parameter_value()¤Î¥Æ¥¹¥È */ void test_get_configuration_parameter_value() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_get_configuration_parameter_value() IN" << std::endl; // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl; } /*! * @brief set_configuration_parameter()¤Î¥Æ¥¹¥È */ void test_set_configuration_parameter() { // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬ // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£ // std::cout << "test_set_configuration_parameter() IN" << std::endl; // std::cout << "test_set_configuration_parameter() OUT" << std::endl; } /*! * @brief add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ConfigurationSet¤òadd_configuration_set()¤ÇÀµ¾ï¤ËÅÐÏ¿¤Ç¤­¤ë¤«¡© * - add_configuration_set()¤ÇÅÐÏ¿¤·¤¿ConfigurationSet¤ò¡¢get_configuration_set()¤ÇÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© */ void test_add_configuration_set_and_get_configuration_set() { // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
479  */
481  {
482  // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameters()¤¬
483  // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£
484 // std::cout << "test_get_configuration_parameters() IN" << std::endl;
485 // std::cout << "test_get_configuration_parameters() OUT" << std::endl;
486  }
487 
492  {
493  // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_values()¤¬
494  // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£
495 // std::cout << "test_get_configuration_parameter_values() IN" << std::endl;
496 // std::cout << "test_get_configuration_parameter_values() OUT" << std::endl;
497  }
498 
503  {
504  // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::get_configuration_parameter_value()¤¬
505  // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£
506 // std::cout << "test_get_configuration_parameter_value() IN" << std::endl;
507 // std::cout << "test_get_configuration_parameter_value() OUT" << std::endl;
508  }
509 
514  {
515  // ¥Æ¥¹¥ÈÂоݤǤ¢¤ëSDOPackage::Confirutaion_impl::set_configuration_parameter()¤¬
516  // ̤¼ÂÁõ¤Ç¤¢¤ë¤¿¤á¡¢Ëܥƥ¹¥È¤â̤¼ÂÁõ¤Ç¤¢¤ë¡£
517 // std::cout << "test_set_configuration_parameter() IN" << std::endl;
518 // std::cout << "test_set_configuration_parameter() OUT" << std::endl;
519  }
520 
528  {
529 // std::cout << "test_add_configuration_set_and_get_configuration_set() IN" << std::endl;
530  coil::Properties cfgAdminProp;
531  RTC::ConfigAdmin cfgAdmin(cfgAdminProp);
532  SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin);
533 
534  // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
535  SDOPackage::ConfigurationSet cfgSet0;
536  cfgSet0.id = "ID 0";
537  cfgSet0.description = "DESCRIPTION 0";
538  cfgSet0.configuration_data.length(2);
539  cfgSet0.configuration_data[0].name = "NAME 0-0";
540  cfgSet0.configuration_data[0].value <<= "3.14159";
541  cfgSet0.configuration_data[1].name = "NAME 0-1";
542  cfgSet0.configuration_data[1].value <<= "2.71828";
543 
544  SDOPackage::ConfigurationSet cfgSet1;
545  cfgSet1.id = "ID 1";
546  cfgSet1.description = "DESCRIPTION 1";
547  cfgSet1.configuration_data.length(2);
548  cfgSet1.configuration_data[0].name = "NAME 1-0";
549  cfgSet1.configuration_data[0].value <<= "1.41421356";
550  cfgSet1.configuration_data[1].name = "NAME 1-1";
551  cfgSet1.configuration_data[1].value <<= "1.7320508";
552 
553  // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0"); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } sdoCfg->_remove_ref(); // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl; } /*! * @brief remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤òÀµ¤·¤¯ÅÐÏ¿²ò½ü¤Ç¤­¤ë¤«¡© * - ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¡¢°Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_remove_configuration_set() { // std::cout << "test_remove_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
554  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0));
555  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1));
556 
557  // ÅÐÏ¿¤·¤¿ConfigurationSet¤òÀµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡©
558  SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_configuration_set("ID 0");
559  CPPUNIT_ASSERT_EQUAL(std::string("ID 0"),
560  std::string(cfgSetRet0->id));
561 //Deleted this test, because description was not used.
562 // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"),
563 // std::string(cfgSetRet0->description));
564  CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2),
565  cfgSetRet0->configuration_data.length());
566  CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"),
567  std::string(cfgSetRet0->configuration_data[0].name));
568  {
569  const char* value; cfgSetRet0->configuration_data[0].value >>= value;
570  CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value));
571  }
572  CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"),
573  std::string(cfgSetRet0->configuration_data[1].name));
574  {
575  const char* value; cfgSetRet0->configuration_data[1].value >>= value;
576  CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value));
577  }
578 
579  SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_configuration_set("ID 1");
580  CPPUNIT_ASSERT_EQUAL(std::string("ID 1"),
581  std::string(cfgSetRet1->id));
582 //Deleted this test, because description was not used.
583 // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"),
584 // std::string(cfgSetRet1->description));
585  CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2),
586  cfgSetRet1->configuration_data.length());
587  CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"),
588  std::string(cfgSetRet1->configuration_data[0].name));
589  {
590  const char* value; cfgSetRet1->configuration_data[0].value >>= value;
591  CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value));
592  }
593  CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"),
594  std::string(cfgSetRet1->configuration_data[1].name));
595  {
596  const char* value; cfgSetRet1->configuration_data[1].value >>= value;
597  CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value));
598  }
599 
600  sdoCfg->_remove_ref();
601 // std::cout << "test_add_configuration_set_and_get_configuration_set() OUT" << std::endl;
602  }
603 
611  {
612 // std::cout << "test_remove_configuration_set() IN" << std::endl;
613  coil::Properties cfgAdminProp;
614  RTC::ConfigAdmin cfgAdmin(cfgAdminProp);
615  SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin);
616 
617  // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
618  SDOPackage::ConfigurationSet cfgSet0;
619  cfgSet0.id = "ID 0";
620  cfgSet0.description = "DESCRIPTION 0";
621  cfgSet0.configuration_data.length(2);
622  cfgSet0.configuration_data[0].name = "NAME 0-0";
623  cfgSet0.configuration_data[0].value <<= "3.14159";
624  cfgSet0.configuration_data[1].name = "NAME 0-1";
625  cfgSet0.configuration_data[1].value <<= "2.71828";
626 
627  SDOPackage::ConfigurationSet cfgSet1;
628  cfgSet1.id = "ID 1";
629  cfgSet1.description = "DESCRIPTION 1";
630  cfgSet1.configuration_data.length(2);
631  cfgSet1.configuration_data[0].name = "NAME 1-0";
632  cfgSet1.configuration_data[0].value <<= "1.41421356";
633  cfgSet1.configuration_data[1].name = "NAME 1-1";
634  cfgSet1.configuration_data[1].value <<= "1.7320508";
635 
636  // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
637  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0));
638  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1));
639 
640  // ÅÐÏ¿¤·¤¿¤¦¤Á¡¢ÊÒÊý¤ÎConfigurationSet¤òÅÐÏ¿²ò½ü¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0")); // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set("ID 0"); CPPUNIT_FAIL("ID 0 was not removed."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢ // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->get_configuration_set(""); CPPUNIT_FAIL("ID Not set."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->remove_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} catch (...) {} sdoCfg->_remove_ref(); // std::cout << "test_remove_configuration_set() OUT" << std::endl; } /*! * @brief set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * * - ÅÐÏ¿ºÑ¤ß¤ÎConfigurationSet¤ÎID¤ò»ØÄꤷ¤Æ¡¢Àµ¤·¤¯ConfigurationSet¤ò¹¹¿·¤Ç¤­¤ë¤«¡© * - ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© */ void test_set_configuration_set_values() { // std::cout << "test_set_configuration_set_values() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
641  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->remove_configuration_set("ID 0"));
642 
643  // ÅÐÏ¿²ò½ü¤·¤¿ConfigurationSet¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢
644  // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡©
645  try
646  {
647  sdoCfg->get_configuration_set("ID 0");
648  CPPUNIT_FAIL("ID 0 was not removed.");
649  }
650  catch (SDOPackage::InvalidParameter expected) {}
651  catch (...) {}
652 
653  // ¶õ¤Îid¤ò»ØÄꤷ¤Æ¡¢get_configuration_set()¸Æ½Ð¤ò»î¤ß¤Æ¡¢
654  // °Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡©
655  try
656  {
657  sdoCfg->get_configuration_set("");
658  CPPUNIT_FAIL("ID Not set.");
659  }
660  catch (SDOPackage::InvalidParameter expected) {}
661  catch (...) {}
662 
663  // ÅÐÏ¿²ò½ü¤·¤Æ¤¤¤Ê¤¤ConfigurationSet¤Ï¡¢°ÍÁ³¤È¤·¤Æ¼èÆÀ¤Ç¤­¤ë¤«¡©
664  SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1");
665  CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id));
666 
667  // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤ÆÅÐÏ¿²ò½ü¤ò»î¤ß¤¿¾ì¹ç¤Ë¡¢°Õ¿Þ¤É¤ª¤ê¤ËÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡©
668  try
669  {
670  sdoCfg->remove_configuration_set("inexist ID");
671  CPPUNIT_FAIL("Exception not thrown.");
672  }
673  catch (SDOPackage::InvalidParameter expected) {}
674  catch (...) {}
675 
676  sdoCfg->_remove_ref();
677 // std::cout << "test_remove_configuration_set() OUT" << std::endl;
678  }
679 
687  {
688 // std::cout << "test_set_configuration_set_values() IN" << std::endl;
689  coil::Properties cfgAdminProp;
690  RTC::ConfigAdmin cfgAdmin(cfgAdminProp);
691  SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin);
692 
693  // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; SDOPackage::ConfigurationSet cfgSet1_Modified; cfgSet1_Modified.id = "ID 1"; cfgSet1_Modified.description = "DESCRIPTION 1 M"; cfgSet1_Modified.configuration_data.length(2); cfgSet1_Modified.configuration_data[0].name = "NAME 1-0"; cfgSet1_Modified.configuration_data[0].value <<= "2.23620679"; cfgSet1_Modified.configuration_data[1].name = "NAME 1-1"; cfgSet1_Modified.configuration_data[1].value <<= "2.44948974"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
694  SDOPackage::ConfigurationSet cfgSet0;
695  cfgSet0.id = "ID 0";
696  cfgSet0.description = "DESCRIPTION 0";
697  cfgSet0.configuration_data.length(2);
698  cfgSet0.configuration_data[0].name = "NAME 0-0";
699  cfgSet0.configuration_data[0].value <<= "3.14159";
700  cfgSet0.configuration_data[1].name = "NAME 0-1";
701  cfgSet0.configuration_data[1].value <<= "2.71828";
702 
703  SDOPackage::ConfigurationSet cfgSet1;
704  cfgSet1.id = "ID 1";
705  cfgSet1.description = "DESCRIPTION 1";
706  cfgSet1.configuration_data.length(2);
707  cfgSet1.configuration_data[0].name = "NAME 1-0";
708  cfgSet1.configuration_data[0].value <<= "1.41421356";
709  cfgSet1.configuration_data[1].name = "NAME 1-1";
710  cfgSet1.configuration_data[1].value <<= "1.7320508";
711 
712  SDOPackage::ConfigurationSet cfgSet1_Modified;
713  cfgSet1_Modified.id = "ID 1";
714  cfgSet1_Modified.description = "DESCRIPTION 1 M";
715  cfgSet1_Modified.configuration_data.length(2);
716  cfgSet1_Modified.configuration_data[0].name = "NAME 1-0";
717  cfgSet1_Modified.configuration_data[0].value <<= "2.23620679";
718  cfgSet1_Modified.configuration_data[1].name = "NAME 1-1";
719  cfgSet1_Modified.configuration_data[1].value <<= "2.44948974";
720 
721  // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
722  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0));
723  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1));
724 
725  // ÅÐÏ¿¤·¤¿ConfigurationSet¤Î¤¦¤ÁÊÒÊý¤ò¡¢set_configuration_set_values()¤Ç¹¹¿·¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->set_configuration_set_values(cfgSet1_Modified)); // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1"); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"), // std::string(cfgSetRet->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet->configuration_data.length()); { const char* value; cfgSetRet->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value)); } { const char* value; cfgSetRet->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value)); } // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢ // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { cfgSet1_Modified.id = ""; sdoCfg->set_configuration_set_values(cfgSet1_Modified); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) { } sdoCfg->_remove_ref(); // std::cout << "test_set_configuration_set_values() OUT" << std::endl; } /*! * @brief activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ * get_configuration_sets()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È * */ void test_activate_configuration_set_and_get_active_configuration_set() { // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl; coil::Properties cfgAdminProp; RTC::ConfigAdmin cfgAdmin(cfgAdminProp); SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin); // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
726  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true),
727  sdoCfg->set_configuration_set_values(cfgSet1_Modified));
728 
729  // ¹¹¿·¤·¤¿ConfigurationSet¤ò¡¢Àµ¤·¤¯¼èÆÀ¤Ç¤­¤ë¤«¡©
730  SDOPackage::ConfigurationSet* cfgSetRet = sdoCfg->get_configuration_set("ID 1");
731  CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet->id));
732 
733 //Deleted this test, because description was not used.
734 // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1 M"),
735 // std::string(cfgSetRet->description));
736  CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2),
737  cfgSetRet->configuration_data.length());
738 
739  {
740  const char* value; cfgSetRet->configuration_data[0].value >>= value;
741  CPPUNIT_ASSERT_EQUAL(std::string("2.23620679"), std::string(value));
742  }
743  {
744  const char* value; cfgSetRet->configuration_data[1].value >>= value;
745  CPPUNIT_ASSERT_EQUAL(std::string("2.44948974"), std::string(value));
746  }
747 
748  // ¶õ¤ÎID¤ò»ØÄꤷ¤Æset_configuration_set_values()¤ò¸Æ½Ð¤·¡¢
749  // °Õ¿Þ¤É¤ª¤êÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡©
750  try
751  {
752  cfgSet1_Modified.id = "";
753  sdoCfg->set_configuration_set_values(cfgSet1_Modified);
754  CPPUNIT_FAIL("Exception not thrown.");
755  }
756  catch (SDOPackage::InvalidParameter expected) {
757  }
758 
759  sdoCfg->_remove_ref();
760 // std::cout << "test_set_configuration_set_values() OUT" << std::endl;
761  }
762 
769  {
770 // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() IN" << std::endl;
771  coil::Properties cfgAdminProp;
772  RTC::ConfigAdmin cfgAdmin(cfgAdminProp);
773  SDOPackage::Configuration_impl* sdoCfg = new Configuration_impl(cfgAdmin);
774 
775  // ConfigurationSet¤ò½àÈ÷¤¹¤ë SDOPackage::ConfigurationSet cfgSet0; cfgSet0.id = "ID 0"; cfgSet0.description = "DESCRIPTION 0"; cfgSet0.configuration_data.length(2); cfgSet0.configuration_data[0].name = "NAME 0-0"; cfgSet0.configuration_data[0].value <<= "3.14159"; cfgSet0.configuration_data[1].name = "NAME 0-1"; cfgSet0.configuration_data[1].value <<= "2.71828"; SDOPackage::ConfigurationSet cfgSet1; cfgSet1.id = "ID 1"; cfgSet1.description = "DESCRIPTION 1"; cfgSet1.configuration_data.length(2); cfgSet1.configuration_data[0].name = "NAME 1-0"; cfgSet1.configuration_data[0].value <<= "1.41421356"; cfgSet1.configuration_data[1].name = "NAME 1-1"; cfgSet1.configuration_data[1].value <<= "1.7320508"; // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
776  SDOPackage::ConfigurationSet cfgSet0;
777  cfgSet0.id = "ID 0";
778  cfgSet0.description = "DESCRIPTION 0";
779  cfgSet0.configuration_data.length(2);
780  cfgSet0.configuration_data[0].name = "NAME 0-0";
781  cfgSet0.configuration_data[0].value <<= "3.14159";
782  cfgSet0.configuration_data[1].name = "NAME 0-1";
783  cfgSet0.configuration_data[1].value <<= "2.71828";
784 
785  SDOPackage::ConfigurationSet cfgSet1;
786  cfgSet1.id = "ID 1";
787  cfgSet1.description = "DESCRIPTION 1";
788  cfgSet1.configuration_data.length(2);
789  cfgSet1.configuration_data[0].name = "NAME 1-0";
790  cfgSet1.configuration_data[0].value <<= "1.41421356";
791  cfgSet1.configuration_data[1].name = "NAME 1-1";
792  cfgSet1.configuration_data[1].value <<= "1.7320508";
793 
794  // ½àÈ÷¤·¤¿ConfigurationSet¤òÅÐÏ¿¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0)); CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1)); // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
795  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet0));
796  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->add_configuration_set(cfgSet1));
797 
798  // ConfigurationSet ¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets()); // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡© CPPUNIT_ASSERT(config_sets->length() == 2); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(config_sets[0].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(config_sets[0].configuration_data[0].name)); { const char* value; config_sets[0].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(config_sets[0].configuration_data[1].name)); { const char* value; config_sets[0].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(config_sets[1].id)); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(config_sets[1].configuration_data[0].name)); { const char* value; config_sets[1].configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(config_sets[1].configuration_data[1].name)); { const char* value; config_sets[1].configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
799  ConfigurationSetList_var config_sets(sdoCfg->get_configuration_sets());
800 
801  // ¼èÆÀ¤·¤¿·ï¿ô¤ÈÆâÍƤ¬°ìÃפ·¤Æ¤¤¤ë¤«¡©
802  CPPUNIT_ASSERT(config_sets->length() == 2);
803  CPPUNIT_ASSERT_EQUAL(std::string("ID 0"),
804  std::string(config_sets[0].id));
805  CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"),
806  std::string(config_sets[0].configuration_data[0].name));
807  {
808  const char* value; config_sets[0].configuration_data[0].value >>= value;
809  CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value));
810  }
811  CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"),
812  std::string(config_sets[0].configuration_data[1].name));
813  {
814  const char* value; config_sets[0].configuration_data[1].value >>= value;
815  CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value));
816  }
817 
818  CPPUNIT_ASSERT_EQUAL(std::string("ID 1"),
819  std::string(config_sets[1].id));
820  CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"),
821  std::string(config_sets[1].configuration_data[0].name));
822  {
823  const char* value; config_sets[1].configuration_data[0].value >>= value;
824  CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value));
825  }
826  CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"),
827  std::string(config_sets[1].configuration_data[1].name));
828  {
829  const char* value; config_sets[1].configuration_data[1].value >>= value;
830  CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value));
831  }
832 
833  // "ID 0"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"), // std::string(cfgSetRet0->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet0->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"), std::string(cfgSetRet0->configuration_data[0].name)); { const char* value; cfgSetRet0->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"), std::string(cfgSetRet0->configuration_data[1].name)); { const char* value; cfgSetRet0->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value)); } // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
834  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 0"));
835 
836  // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡©
837  SDOPackage::ConfigurationSet* cfgSetRet0 = sdoCfg->get_active_configuration_set();
838  CPPUNIT_ASSERT_EQUAL(std::string("ID 0"), std::string(cfgSetRet0->id));
839 
840 //Deleted this test, because description was not used.
841 // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 0"),
842 // std::string(cfgSetRet0->description));
843  CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2),
844  cfgSetRet0->configuration_data.length());
845  CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-0"),
846  std::string(cfgSetRet0->configuration_data[0].name));
847  {
848  const char* value; cfgSetRet0->configuration_data[0].value >>= value;
849  CPPUNIT_ASSERT_EQUAL(std::string("3.14159"), std::string(value));
850  }
851  CPPUNIT_ASSERT_EQUAL(std::string("NAME 0-1"),
852  std::string(cfgSetRet0->configuration_data[1].name));
853  {
854  const char* value; cfgSetRet0->configuration_data[1].value >>= value;
855  CPPUNIT_ASSERT_EQUAL(std::string("2.71828"), std::string(value));
856  }
857 
858  // "ID 1"¤Î¤Û¤¦¤ò¥¢¥¯¥Æ¥£¥Ö²½¤¹¤ë CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1")); // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡© SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set(); CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id)); //Deleted this test, because description was not used. // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"), // std::string(cfgSetRet1->description)); CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2), cfgSetRet1->configuration_data.length()); CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"), std::string(cfgSetRet1->configuration_data[0].name)); { const char* value; cfgSetRet1->configuration_data[0].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value)); } CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"), std::string(cfgSetRet1->configuration_data[1].name)); { const char* value; cfgSetRet1->configuration_data[1].value >>= value; CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value)); } // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡© try { sdoCfg->activate_configuration_set("inexist ID"); CPPUNIT_FAIL("Exception not thrown."); } catch (SDOPackage::InvalidParameter expected) {} sdoCfg->_remove_ref(); // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl; } }; }; // namespace SdoConfiguration /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests); #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 // SdoConfiguration_cpp
859  CPPUNIT_ASSERT_EQUAL(CORBA::Boolean(true), sdoCfg->activate_configuration_set("ID 1"));
860 
861  // ¥¢¥¯¥Æ¥£¥Ö¤ÊConfigurationSet¤ò¼èÆÀ¤·¡¢¤½¤ì¤¬¥¢¥¯¥Æ¥£¥Ö²½¤·¤¿¤â¤Î¤È°ìÃפ¹¤ë¤«¡©
862  SDOPackage::ConfigurationSet* cfgSetRet1 = sdoCfg->get_active_configuration_set();
863  CPPUNIT_ASSERT_EQUAL(std::string("ID 1"), std::string(cfgSetRet1->id));
864 
865 //Deleted this test, because description was not used.
866 // CPPUNIT_ASSERT_EQUAL(std::string("DESCRIPTION 1"),
867 // std::string(cfgSetRet1->description));
868  CPPUNIT_ASSERT_EQUAL(CORBA::ULong(2),
869  cfgSetRet1->configuration_data.length());
870  CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-0"),
871  std::string(cfgSetRet1->configuration_data[0].name));
872  {
873  const char* value; cfgSetRet1->configuration_data[0].value >>= value;
874  CPPUNIT_ASSERT_EQUAL(std::string("1.41421356"), std::string(value));
875  }
876  CPPUNIT_ASSERT_EQUAL(std::string("NAME 1-1"),
877  std::string(cfgSetRet1->configuration_data[1].name));
878  {
879  const char* value; cfgSetRet1->configuration_data[1].value >>= value;
880  CPPUNIT_ASSERT_EQUAL(std::string("1.7320508"), std::string(value));
881  }
882 
883  // ¸ºß¤·¤Ê¤¤ID¤ò»ØÄꤷ¤Æactivate_configuration_set()¤ò¸Æ½Ð¤·¡¢°Õ¿Þ¤É¤ª¤ê¤ÎÎã³°¤¬¥¹¥í¡¼¤µ¤ì¤ë¤«¡©
884  try
885  {
886  sdoCfg->activate_configuration_set("inexist ID");
887  CPPUNIT_FAIL("Exception not thrown.");
888  }
889  catch (SDOPackage::InvalidParameter expected) {}
890 
891  sdoCfg->_remove_ref();
892 // std::cout << "test_activate_configuration_set_and_get_active_configuration_set() OUT" << std::endl;
893  }
894 
895  };
896 }; // namespace SdoConfiguration
897 
898 /*
899  * Register test suite
900  */
902 
903 #ifdef LOCAL_MAIN
904 int main(int argc, char* argv[])
905 {
906 
907  FORMAT format = TEXT_OUT;
908  int target = 0;
909  std::string xsl;
910  std::string ns;
911  std::string fname;
912  std::ofstream ofs;
913 
914  int i(1);
915  while (i < argc)
916  {
917  std::string arg(argv[i]);
918  std::string next_arg;
919  if (i + 1 < argc) next_arg = argv[i + 1];
920  else next_arg = "";
921 
922  if (arg == "--text") { format = TEXT_OUT; break; }
923  if (arg == "--xml")
924  {
925  if (next_arg == "")
926  {
927  fname = argv[0];
928  fname += ".xml";
929  }
930  else
931  {
932  fname = next_arg;
933  }
934  format = XML_OUT;
935  ofs.open(fname.c_str());
936  }
937  if ( arg == "--compiler" ) { format = COMPILER_OUT; break; }
938  if ( arg == "--cerr" ) { target = 1; break; }
939  if ( arg == "--xsl" )
940  {
941  if (next_arg == "") xsl = "default.xsl";
942  else xsl = next_arg;
943  }
944  if ( arg == "--namespace" )
945  {
946  if (next_arg == "")
947  {
948  std::cerr << "no namespace specified" << std::endl;
949  exit(1);
950  }
951  else
952  {
953  xsl = next_arg;
954  }
955  }
956  ++i;
957  }
958  CppUnit::TextUi::TestRunner runner;
959  if ( ns.empty() )
960  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
961  else
962  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
963  CppUnit::Outputter* outputter = 0;
964  std::ostream* stream = target ? &std::cerr : &std::cout;
965  switch ( format )
966  {
967  case TEXT_OUT :
968  outputter = new CppUnit::TextOutputter(&runner.result(),*stream);
969  break;
970  case XML_OUT :
971  std::cout << "XML_OUT" << std::endl;
972  outputter = new CppUnit::XmlOutputter(&runner.result(),
973  ofs, "shift_jis");
974  static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl);
975  break;
976  case COMPILER_OUT :
977  outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream);
978  break;
979  }
980  runner.setOutputter(outputter);
981  runner.run();
982  return 0; // runner.run() ? 0 : 1;
983 }
984 #endif // MAIN
985 #endif // SdoConfiguration_cpp
int main(int argc, char **argv)
virtual CORBA::Boolean add_configuration_set(const ConfigurationSet &configuration_set)
[CORBA interface] Add ConfigurationSet
virtual CORBA::Boolean set_configuration_set_values(const ConfigurationSet &configuration_set)
[CORBA interface] Set ConfigurationSet
virtual ConfigurationSet * get_active_configuration_set()
[CORBA interface] Get active ConfigurationSet
void test_remove_configuration_set()
remove_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È
std::vector< std::pair< std::string, std::string > > NVList
Definition: IRTC.h:67
ConfigAdmin class.
Definition: ConfigAdmin.h:534
RT-Component class.
Definition: RTObject.h:89
CPPUNIT_TEST_SUITE_REGISTRATION(SdoConfiguration::SdoConfigurationTests)
void test_add_configuration_set_and_get_configuration_set()
add/get_configuration_set()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È
virtual void tearDown()
Test finalization.
Manager class.
Definition: Manager.h:80
virtual CORBA::Boolean remove_organization(const char *organization_id)
[CORBA interface] Remove the reference of Organization
virtual char * get_organization_id()
[CORBA interface] Get Organization ID
virtual CORBA::Boolean add_organization(Organization_ptr org)
[CORBA interface] Add Organization
virtual CORBA::Boolean add_service_profile(const ServiceProfile &sProfile)
[CORBA interface] Set SDO&#39;s ServiceProfile
void test_get_configuration_parameter_values()
get_configuration_parameter_values()¤Î¥Æ¥¹¥È
SDO Organization implementation class.
static Manager & instance()
Get instance of the manager.
Definition: Manager.cpp:140
SDO Package.
virtual CORBA::Boolean activate_configuration_set(const char *config_id)
[CORBA interface] Activate ConfigurationSet
bool operator()(const ServiceProfile &svcProf)
RTComponent manager class.
virtual void setUp()
Test initialization.
void test_set_service_profile_and_getServiceProfile()
set_service_profile()¥á¥½¥Ã¥É¤ÈgetServiceProfile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È
void test_activate_configuration_set_and_get_active_configuration_set()
activate_configuration_set()¥á¥½¥Ã¥É¡¢get_active_configuration_set()¥á¥½¥Ã¥É¡¢ get_configuration_sets()¥á¥½¥...
CORBA::Long find(const CorbaSequence &seq, Functor f)
Return the index of CORBA sequence element that functor matches.
const OrganizationList getOrganizations()
Get a list of Organization of SDO.
devProf
Configuration::set_device_profile (in DeviceProfile dProfile);.
Organization implementation class.
CORBA sequence utility template functions.
virtual CORBA::Boolean set_device_profile(const DeviceProfile &dProfile)
[CORBA interface] Set DeviceProfile of SDO
virtual ConfigurationSetList * get_configuration_sets()
[CORBA interface] Get a list of ConfigurationSet
Class represents a set of properties.
Definition: Properties.h:101
void test_set_configuration_parameter()
set_configuration_parameter()¤Î¥Æ¥¹¥È
void test_getServiceProfiles()
getServiceProfiles()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È
virtual ConfigurationSet * get_configuration_set(const char *config_id)
[CORBA interface] Get a ConfigurationSet
void test_remove_service_profile()
remove_service_profile()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È
Configuration implementation class.
void test_get_configuration_parameter_value()
get_configuration_parameter_value()¤Î¥Æ¥¹¥È
void test_set_configuration_set_values()
set_configuration_set_values()¥á¥½¥Ã¥É¤Î¥Æ¥¹¥È
const DeviceProfile getDeviceProfile()
Get the DeviceProfile of SDO.
RTObject_ptr getObjRef() const
[local interface] Get the object reference
Definition: RTObject.cpp:1483
RT component base class.
virtual CORBA::Boolean remove_service_profile(const char *id)
[CORBA interface] Remove ServiceProfile
int usleep(useconds_t usec)
Stop a processing at specified micro second time.
Definition: ace/coil/Time.h:51
virtual CORBA::Boolean remove_configuration_set(const char *config_id)
[CORBA interface] Remove ConfigurationSet


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:00