ConfigurationServantTests.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00012 /*
00013  * $Log$
00014  *
00015  */
00016 
00017 #ifndef ConfigurationServant_cpp
00018 #define ConfigurationServant_cpp
00019 
00020 #include <cppunit/ui/text/TestRunner.h>
00021 #include <cppunit/extensions/HelperMacros.h>
00022 #include <cppunit/TestAssert.h>
00023 
00024 #include <ConfigurationServant.h>
00025 
00026 #include <coil/Properties.h>
00027 #include <doil/ImplBase.h>
00028 #include <doil/ServantFactory.h>
00029 #include <doil/corba/CORBAManager.h>
00030 #include <doil/corba/CORBAServantBase.h>
00031 #include <IConfiguration.h>
00032 #include <stubs/ConfigurationImpl.h>
00033 #include <stubs/Logger.h>
00034 
00039 namespace ConfigurationServant
00040 {
00041   class ConfigurationServantTests
00042    : public CppUnit::TestFixture
00043   {
00044     CPPUNIT_TEST_SUITE(ConfigurationServantTests);
00045     CPPUNIT_TEST(test_call_set_device_profile);
00046     CPPUNIT_TEST(test_call_set_service_profile);
00047     CPPUNIT_TEST(test_call_add_organization);
00048     CPPUNIT_TEST(test_call_remove_service_profile);
00049     CPPUNIT_TEST(test_call_remove_organization);
00050     CPPUNIT_TEST(test_call_get_configuration_parameters);
00051     CPPUNIT_TEST(test_call_get_configuration_parameter_values);
00052     CPPUNIT_TEST(test_call_get_configuration_parameter_value);
00053     CPPUNIT_TEST(test_call_set_configuration_parameter);
00054     CPPUNIT_TEST(test_call_get_configuration_sets);
00055     CPPUNIT_TEST(test_call_get_configuration_set);
00056     CPPUNIT_TEST(test_call_set_configuration_set_values);
00057     CPPUNIT_TEST(test_call_get_active_configuration_set);
00058     CPPUNIT_TEST(test_call_add_configuration_set);
00059     CPPUNIT_TEST(test_call_remove_configuration_set);
00060     CPPUNIT_TEST(test_call_activate_configuration_set);
00061     CPPUNIT_TEST_SUITE_END();
00062   
00063   private:
00064     ::UnitTest::Servant::ConfigurationImpl* Impl;
00065     ::UnitTest::Servant::Logger Log;
00066     ::doil::ServantBase* Servant;
00067     ::SDOPackage::CORBA::ConfigurationServant * CServant;
00068 
00069   public:
00070   
00074     ConfigurationServantTests()
00075     {
00076         // registerFactory
00077         Impl = new UnitTest::Servant::ConfigurationImpl(Log);
00078         doil::CORBA::CORBAManager::instance().registerFactory(Impl->id(),
00079             doil::New<SDOPackage::CORBA::ConfigurationServant>,
00080             doil::Delete<SDOPackage::CORBA::ConfigurationServant>);
00081         doil::ReturnCode_t ret = doil::CORBA::CORBAManager::instance().activateObject(Impl);
00082         Servant = doil::CORBA::CORBAManager::instance().toServant(Impl);
00083         CServant = dynamic_cast<SDOPackage::CORBA::ConfigurationServant*>(Servant);
00084 //      std::cout << "ConfigurationServantTests-constractor" << std::endl;
00085     }
00086     
00090     ~ConfigurationServantTests()
00091     {
00092       delete Impl;
00093       Impl = 0;
00094     }
00095 
00099     virtual void setUp()
00100     {
00101 //      std::cout << "ConfigurationServantTests-setUp" << std::endl;
00102     }
00103 
00107     virtual void tearDown()
00108     {
00109 //      std::cout << "ConfigurationServantTests-tearDown" << std::endl;
00110     }
00111 
00112     /* test case */
00118     void test_call_set_device_profile()
00119     {
00120       CPPUNIT_ASSERT(CServant);
00121 
00122       std::string str("set_device_profile");
00123       ::SDOPackage::DeviceProfile dp;
00124       ::CORBA::Boolean result;
00125       result = CServant->set_device_profile(dp);
00126       CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
00127       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00128     }
00129 
00135     void test_call_set_service_profile()
00136     {
00137       CPPUNIT_ASSERT(CServant);
00138 
00139       std::string str("set_service_profile");
00140       ::SDOPackage::ServiceProfile sp;
00141       ::CORBA::Boolean result;
00142       result = CServant->set_service_profile(sp);
00143       CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
00144       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00145     }
00146 
00152     void test_call_add_organization()
00153     {
00154       CPPUNIT_ASSERT(CServant);
00155 
00156       std::string str("add_organization");
00157       ::SDOPackage::Organization_ptr org;
00158       ::CORBA::Boolean result;
00159       result = CServant->add_organization(org);
00160       CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
00161       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00162     }
00163 
00170     void test_call_remove_service_profile()
00171     {
00172       CPPUNIT_ASSERT(CServant);
00173 
00174       std::string str("remove_service_profile");
00175       std::string id("Hoge");
00176       ::CORBA::Boolean result;
00177       result = CServant->remove_service_profile(id.c_str());
00178       CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
00179       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00180       CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), id);
00181     }
00182 
00189     void test_call_remove_organization()
00190     {
00191       CPPUNIT_ASSERT(CServant);
00192 
00193       std::string str("remove_organization");
00194       std::string id("Hoge");
00195       ::CORBA::Boolean result;
00196       result = CServant->remove_organization(id.c_str());
00197       CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
00198       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00199       CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), id);
00200     }
00201 
00207     void test_call_get_configuration_parameters()
00208     {
00209       CPPUNIT_ASSERT(CServant);
00210 
00211       std::string str("get_configuration_parameters");
00212       ::SDOPackage::ParameterList* result;
00213       result = CServant->get_configuration_parameters();
00214       CPPUNIT_ASSERT_MESSAGE("non-exist", result);
00215       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00216     }
00217 
00223     void test_call_get_configuration_parameter_values()
00224     {
00225       CPPUNIT_ASSERT(CServant);
00226 
00227       std::string str("get_configuration_parameter_values");
00228       ::SDOPackage::NVList* result;
00229       result = CServant->get_configuration_parameter_values();
00230       CPPUNIT_ASSERT_MESSAGE("non-exist", result);
00231       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00232     }
00233 
00239     void test_call_get_configuration_parameter_value()
00240     {
00241       CPPUNIT_ASSERT(CServant);
00242 
00243       std::string str("get_configuration_parameter_value");
00244       std::string name("Hoge");
00245       ::CORBA::Any* result;
00246       result = CServant->get_configuration_parameter_value(name.c_str());
00247       CPPUNIT_ASSERT_MESSAGE("non-exist", result);
00248       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00249       CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), name);
00250     }
00251 
00258     void test_call_set_configuration_parameter()
00259     {
00260       CPPUNIT_ASSERT(CServant);
00261 
00262       std::string str("set_configuration_parameter");
00263       std::string name("hoge");
00264       ::CORBA::Any value;
00265       ::CORBA::Boolean result;
00266       result = CServant->set_configuration_parameter(name.c_str(), value);
00267       CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
00268       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00269       CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), name);
00270 //      CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), value);
00271     }
00272 
00278     void test_call_get_configuration_sets()
00279     {
00280       CPPUNIT_ASSERT(CServant);
00281 
00282       std::string str("get_configuration_sets");
00283       ::SDOPackage::ConfigurationSetList* result;
00284       result = CServant->get_configuration_sets();
00285       CPPUNIT_ASSERT_MESSAGE("non-exist", result);
00286       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00287     }
00288 
00295     void test_call_get_configuration_set()
00296     {
00297       CPPUNIT_ASSERT(CServant);
00298 
00299       std::string str("get_configuration_set");
00300       std::string config_id("hoge");
00301       ::SDOPackage::ConfigurationSet* result;
00302       result = CServant->get_configuration_set(config_id.c_str());
00303       CPPUNIT_ASSERT_MESSAGE("non-exist", result);
00304       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00305       CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), config_id);
00306     }
00307 
00314     void test_call_set_configuration_set_values()
00315     {
00316       CPPUNIT_ASSERT(CServant);
00317 
00318       std::string str("set_configuration_set_values");
00319       std::string config_id("hoge");
00320       ::SDOPackage::ConfigurationSet set;
00321       ::CORBA::Boolean result;
00322       result = CServant->set_configuration_set_values(config_id.c_str(), set);
00323       CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
00324       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00325       CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), config_id);
00326     }
00327 
00333     void test_call_get_active_configuration_set()
00334     {
00335       CPPUNIT_ASSERT(CServant);
00336 
00337       std::string str("get_active_configuration_set");
00338       ::SDOPackage::ConfigurationSet* result;
00339       result = CServant->get_active_configuration_set();
00340       CPPUNIT_ASSERT_MESSAGE("non-exist", result);
00341       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00342     }
00343 
00350     void test_call_add_configuration_set()
00351     {
00352       CPPUNIT_ASSERT(CServant);
00353 
00354       std::string str("add_configuration_set");
00355       ::SDOPackage::ConfigurationSet set;
00356       ::CORBA::Boolean result;
00357       result = CServant->add_configuration_set(set);
00358       CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
00359       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00360     }
00361 
00368     void test_call_remove_configuration_set()
00369     {
00370       CPPUNIT_ASSERT(CServant);
00371 
00372       std::string str("remove_configuration_set");
00373       std::string config_id("hoge");
00374       ::CORBA::Boolean result;
00375       result = CServant->remove_configuration_set(config_id.c_str());
00376       CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
00377       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00378       CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), config_id);
00379     }
00380 
00387     void test_call_activate_configuration_set()
00388     {
00389       CPPUNIT_ASSERT(CServant);
00390 
00391       std::string str("activate_configuration_set");
00392       std::string str2("hoge");
00393       ::CORBA::Boolean result;
00394       result = CServant->activate_configuration_set(str2.c_str());
00395       CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
00396       CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
00397       CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), str2);
00398     }
00399   };
00400 }; // namespace ConfigurationServant
00401 
00402 /*
00403  * Register test suite
00404  */
00405 CPPUNIT_TEST_SUITE_REGISTRATION(ConfigurationServant::ConfigurationServantTests);
00406 
00407 #ifdef LOCAL_MAIN
00408 int main(int argc, char* argv[])
00409 {
00410     CppUnit::TextUi::TestRunner runner;
00411     runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
00412     CppUnit::Outputter* outputter = 
00413       new CppUnit::TextOutputter(&runner.result(), std::cout);
00414     runner.setOutputter(outputter);
00415     bool retcode = runner.run();
00416     return !retcode;
00417 }
00418 #endif // MAIN
00419 #endif // ConfigurationServant_cpp


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sun Mar 26 2017 03:37:15