ConfigurationServantTests.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
12 /*
13  * $Log$
14  *
15  */
16 
17 #ifndef ConfigurationServant_cpp
18 #define ConfigurationServant_cpp
19 
20 #include <cppunit/ui/text/TestRunner.h>
21 #include <cppunit/extensions/HelperMacros.h>
22 #include <cppunit/TestAssert.h>
23 
24 #include <ConfigurationServant.h>
25 
26 #include <coil/Properties.h>
27 #include <doil/ImplBase.h>
28 #include <doil/ServantFactory.h>
31 #include <IConfiguration.h>
33 #include <stubs/Logger.h>
34 
40 {
42  : public CppUnit::TestFixture
43  {
62 
63  private:
67  ::SDOPackage::CORBA::ConfigurationServant * CServant;
68 
69  public:
70 
75  {
76  // registerFactory
79  doil::New<SDOPackage::CORBA::ConfigurationServant>,
80  doil::Delete<SDOPackage::CORBA::ConfigurationServant>);
83  CServant = dynamic_cast<SDOPackage::CORBA::ConfigurationServant*>(Servant);
84 // std::cout << "ConfigurationServantTests-constractor" << std::endl;
85  }
86 
91  {
92  delete Impl;
93  Impl = 0;
94  }
95 
99  virtual void setUp()
100  {
101 // std::cout << "ConfigurationServantTests-setUp" << std::endl;
102  }
103 
107  virtual void tearDown()
108  {
109 // std::cout << "ConfigurationServantTests-tearDown" << std::endl;
110  }
111 
112  /* test case */
119  {
120  CPPUNIT_ASSERT(CServant);
121 
122  std::string str("set_device_profile");
123  ::SDOPackage::DeviceProfile dp;
124  ::CORBA::Boolean result;
125  result = CServant->set_device_profile(dp);
126  CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
127  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
128  }
129 
136  {
137  CPPUNIT_ASSERT(CServant);
138 
139  std::string str("set_service_profile");
140  ::SDOPackage::ServiceProfile sp;
141  ::CORBA::Boolean result;
142  result = CServant->set_service_profile(sp);
143  CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
144  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
145  }
146 
153  {
154  CPPUNIT_ASSERT(CServant);
155 
156  std::string str("add_organization");
157  ::SDOPackage::Organization_ptr org;
158  ::CORBA::Boolean result;
159  result = CServant->add_organization(org);
160  CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
161  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
162  }
163 
171  {
172  CPPUNIT_ASSERT(CServant);
173 
174  std::string str("remove_service_profile");
175  std::string id("Hoge");
176  ::CORBA::Boolean result;
177  result = CServant->remove_service_profile(id.c_str());
178  CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
179  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
180  CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), id);
181  }
182 
190  {
191  CPPUNIT_ASSERT(CServant);
192 
193  std::string str("remove_organization");
194  std::string id("Hoge");
195  ::CORBA::Boolean result;
196  result = CServant->remove_organization(id.c_str());
197  CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
198  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
199  CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), id);
200  }
201 
208  {
209  CPPUNIT_ASSERT(CServant);
210 
211  std::string str("get_configuration_parameters");
212  ::SDOPackage::ParameterList* result;
213  result = CServant->get_configuration_parameters();
214  CPPUNIT_ASSERT_MESSAGE("non-exist", result);
215  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
216  }
217 
224  {
225  CPPUNIT_ASSERT(CServant);
226 
227  std::string str("get_configuration_parameter_values");
228  ::SDOPackage::NVList* result;
229  result = CServant->get_configuration_parameter_values();
230  CPPUNIT_ASSERT_MESSAGE("non-exist", result);
231  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
232  }
233 
240  {
241  CPPUNIT_ASSERT(CServant);
242 
243  std::string str("get_configuration_parameter_value");
244  std::string name("Hoge");
245  ::CORBA::Any* result;
246  result = CServant->get_configuration_parameter_value(name.c_str());
247  CPPUNIT_ASSERT_MESSAGE("non-exist", result);
248  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
249  CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), name);
250  }
251 
259  {
260  CPPUNIT_ASSERT(CServant);
261 
262  std::string str("set_configuration_parameter");
263  std::string name("hoge");
264  ::CORBA::Any value;
265  ::CORBA::Boolean result;
266  result = CServant->set_configuration_parameter(name.c_str(), value);
267  CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
268  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
269  CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), name);
270 // CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), value);
271  }
272 
279  {
280  CPPUNIT_ASSERT(CServant);
281 
282  std::string str("get_configuration_sets");
283  ::SDOPackage::ConfigurationSetList* result;
284  result = CServant->get_configuration_sets();
285  CPPUNIT_ASSERT_MESSAGE("non-exist", result);
286  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
287  }
288 
296  {
297  CPPUNIT_ASSERT(CServant);
298 
299  std::string str("get_configuration_set");
300  std::string config_id("hoge");
301  ::SDOPackage::ConfigurationSet* result;
302  result = CServant->get_configuration_set(config_id.c_str());
303  CPPUNIT_ASSERT_MESSAGE("non-exist", result);
304  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
305  CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), config_id);
306  }
307 
315  {
316  CPPUNIT_ASSERT(CServant);
317 
318  std::string str("set_configuration_set_values");
319  std::string config_id("hoge");
320  ::SDOPackage::ConfigurationSet set;
321  ::CORBA::Boolean result;
322  result = CServant->set_configuration_set_values(config_id.c_str(), set);
323  CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
324  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
325  CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), config_id);
326  }
327 
334  {
335  CPPUNIT_ASSERT(CServant);
336 
337  std::string str("get_active_configuration_set");
338  ::SDOPackage::ConfigurationSet* result;
339  result = CServant->get_active_configuration_set();
340  CPPUNIT_ASSERT_MESSAGE("non-exist", result);
341  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
342  }
343 
351  {
352  CPPUNIT_ASSERT(CServant);
353 
354  std::string str("add_configuration_set");
355  ::SDOPackage::ConfigurationSet set;
356  ::CORBA::Boolean result;
357  result = CServant->add_configuration_set(set);
358  CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
359  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
360  }
361 
369  {
370  CPPUNIT_ASSERT(CServant);
371 
372  std::string str("remove_configuration_set");
373  std::string config_id("hoge");
374  ::CORBA::Boolean result;
375  result = CServant->remove_configuration_set(config_id.c_str());
376  CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
377  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
378  CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), config_id);
379  }
380 
388  {
389  CPPUNIT_ASSERT(CServant);
390 
391  std::string str("activate_configuration_set");
392  std::string str2("hoge");
393  ::CORBA::Boolean result;
394  result = CServant->activate_configuration_set(str2.c_str());
395  CPPUNIT_ASSERT_EQUAL_MESSAGE("not true", true, result);
396  CPPUNIT_ASSERT_EQUAL_MESSAGE("not method name", Log.pop(), str);
397  CPPUNIT_ASSERT_EQUAL_MESSAGE("not argument", Log.pop(), str2);
398  }
399  };
400 }; // namespace ConfigurationServant
401 
402 /*
403  * Register test suite
404  */
406 
407 #ifdef LOCAL_MAIN
408 int main(int argc, char* argv[])
409 {
410  CppUnit::TextUi::TestRunner runner;
411  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
412  CppUnit::Outputter* outputter =
413  new CppUnit::TextOutputter(&runner.result(), std::cout);
414  runner.setOutputter(outputter);
415  bool retcode = runner.run();
416  return !retcode;
417 }
418 #endif // MAIN
419 #endif // ConfigurationServant_cpp
int main(int argc, char **argv)
void test_call_get_configuration_parameter_values()
以下の要件を確認する
void test_call_set_device_profile()
以下の要件を確認する
virtual ServantBase * toServant(doil::ImplBase *lobj)
Getting servant object by impl object.
virtual ReturnCode_t registerFactory(const char *id, doil::ServantNewFunc new_func, doil::ServantDeleteFunc delete_func)
Register servant&#39;s factory.
void test_call_set_service_profile()
以下の要件を確認する
ReturnCode_t
Definition: doil.h:53
std::vector< std::pair< std::string, std::string > > NVList
Definition: IRTC.h:67
void test_call_get_configuration_parameters()
以下の要件を確認する
static CORBAManager & instance()
getting instance
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
void test_call_get_configuration_set()
以下の要件を確認する
::SDOPackage::CORBA::ConfigurationServant * CServant
CPPUNIT_TEST_SUITE(ConfigurationServantTests)
void test_call_get_active_configuration_set()
以下の要件を確認する
doil implementation base class
void test_call_set_configuration_parameter()
以下の要件を確認する
void test_call_remove_organization()
以下の要件を確認する
CORBA manager for doil.
CPPUNIT_TEST(test_call_set_device_profile)
::UnitTest::Servant::ConfigurationImpl * Impl
void test_call_remove_service_profile()
以下の要件を確認する
void test_call_set_configuration_set_values()
以下の要件を確認する
void test_call_remove_configuration_set()
以下の要件を確認する
void test_call_activate_configuration_set()
以下の要件を確認する
Configuration implementation class for ConfigurationServant&#39; unittest.
void test_call_add_organization()
以下の要件を確認する
void test_call_add_configuration_set()
以下の要件を確認する
CPPUNIT_TEST_SUITE_REGISTRATION(ConfigurationServant::ConfigurationServantTests)
virtual ReturnCode_t activateObject(doil::ImplBase *impl)
Activate object.
void test_call_get_configuration_parameter_value()
以下の要件を確認する
std::string pop()
Definition: Logger.cpp:20
void test_call_get_configuration_sets()
以下の要件を確認する


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:42