27 #ifndef ManagerConfig_cpp 28 #define ManagerConfig_cpp 30 #include <cppunit/ui/text/TestRunner.h> 31 #include <cppunit/TextOutputter.h> 32 #include <cppunit/extensions/TestFactoryRegistry.h> 33 #include <cppunit/extensions/HelperMacros.h> 34 #include <cppunit/TestAssert.h> 57 ManagerConfig::parseArgs(argc, argv);
62 return ManagerConfig::findConfigFile();
67 ManagerConfig::setSystemInformation(prop);
72 return ManagerConfig::fileExist(filename);
84 :
public CppUnit::TestFixture
87 CPPUNIT_TEST(test_init_and_configure);
88 CPPUNIT_TEST(test_init_default);
89 CPPUNIT_TEST_SUITE_END();
130 CPPUNIT_ASSERT(mgrCfg.
fileExist(
"./rtc.conf"));
134 char* argv[] = {
"command",
"-d",
"./rtc.conf" };
135 int argc =
sizeof(argv) /
sizeof(
char*);
136 mgrCfg.
init(argc, argv);
142 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.COMPONENT.CONF.PATH"),
143 properties.
getProperty(
"rtc.component.conf.path"));
144 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.ARCH"),
146 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.DEBUG.LEVEL"),
147 properties.
getProperty(
"rtc.manager.debug.level"));
148 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.LANGUAGE"),
150 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.NAMESERVER"),
152 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.OPENING_MESSAGE"),
153 properties.
getProperty(
"rtc.manager.opening_message"));
154 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.ORB"),
156 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.ORB.OPTIONS"),
157 properties.
getProperty(
"rtc.manager.orb.options"));
158 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.OS"),
160 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.OS.RELEASE"),
162 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.SUBSYSTEMS"),
164 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.OPENRTM.AUTHOR"),
166 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.OPENRTM.RELEASE"),
168 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.OPENRTM.VENDOR"),
170 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.OPENRTM.VERSION"),
175 CPPUNIT_ASSERT(std::string(
"")
177 CPPUNIT_ASSERT(std::string(
"")
179 CPPUNIT_ASSERT(std::string(
"")
181 CPPUNIT_ASSERT(std::string(
"")
183 CPPUNIT_ASSERT(std::string(
"")
185 CPPUNIT_ASSERT(std::string(
"")
187 CPPUNIT_ASSERT(std::string(
"YES")
193 argc =
sizeof(argv) /
sizeof(
char*);
194 mgrCfg.
init(argc, argv);
196 CPPUNIT_ASSERT_EQUAL(std::string(
"NO"),
201 argv[1] =
"-omanager.is_master:NO";
202 argc =
sizeof(argv) /
sizeof(
char*);
203 mgrCfg.
init(argc, argv);
205 CPPUNIT_ASSERT_EQUAL(std::string(
"NO"),
211 argc =
sizeof(argv) /
sizeof(
char*);
212 mgrCfg.
init(argc, argv);
214 CPPUNIT_ASSERT_EQUAL(std::string(
":9876"),
229 mgrCfg.
init(0, NULL);
235 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.COMPONENT.CONF.PATH"),
236 properties.
getProperty(
"rtc.component.conf.path"));
237 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.ARCH"),
239 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.DEBUG.LEVEL"),
240 properties.
getProperty(
"rtc.manager.debug.level"));
241 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.LANGUAGE"),
243 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.NAMESERVER"),
245 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.OPENING_MESSAGE"),
246 properties.
getProperty(
"rtc.manager.opening_message"));
247 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.ORB"),
249 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.ORB.OPTIONS"),
250 properties.
getProperty(
"rtc.manager.orb.options"));
251 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.OS"),
253 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.OS.RELEASE"),
255 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.MANAGER.SUBSYSTEMS"),
257 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.OPENRTM.AUTHOR"),
259 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.OPENRTM.RELEASE"),
261 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.OPENRTM.VENDOR"),
263 CPPUNIT_ASSERT_EQUAL(std::string(
"DEFAULT.RTC.OPENRTM.VERSION"),
268 CPPUNIT_ASSERT(std::string(
"")
270 CPPUNIT_ASSERT(std::string(
"")
272 CPPUNIT_ASSERT(std::string(
"")
274 CPPUNIT_ASSERT(std::string(
"")
276 CPPUNIT_ASSERT(std::string(
"")
278 CPPUNIT_ASSERT(std::string(
"")
280 CPPUNIT_ASSERT(std::string(
"")
293 int main(
int argc,
char* argv[])
306 std::string arg(argv[i]);
307 std::string next_arg;
308 if (i + 1 < argc) next_arg = argv[i + 1];
311 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
324 ofs.open(fname.c_str());
326 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
327 if ( arg ==
"--cerr" ) { target = 1;
break; }
328 if ( arg ==
"--xsl" )
330 if (next_arg ==
"") xsl =
"default.xsl";
333 if ( arg ==
"--namespace" )
337 std::cerr <<
"no namespace specified" << std::endl;
347 CppUnit::TextUi::TestRunner runner;
349 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
351 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
352 CppUnit::Outputter* outputter = 0;
353 std::ostream* stream = target ? &std::cerr : &std::cout;
357 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
360 std::cout <<
"XML_OUT" << std::endl;
361 outputter =
new CppUnit::XmlOutputter(&runner.result(),
363 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
366 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
369 runner.setOutputter(outputter);
374 #endif // ManagerConfig_cpp int main(int argc, char **argv)
void parseArgs(int argc, char **argv)
Manager configuration class.
void setSystemInformation(coil::Properties &prop)
std::string m_configFile
Manager's configuration file path.
virtual void tearDown()
Test finalization.
RTC manager configuration.
std::vector< std::string > g_argv
void configure(coil::Properties &prop)
Specify the configuration information to the Property.
std::string & configFile()
void test_init_and_configure()
init()メソッドとconfigure()メソッドのテスト
void init(int argc, char **argv)
Initialization.
virtual void setUp()
Test initialization.
ManagerConfigTests()
Constructor.
void test_init_default()
init()メソッドのテスト
~ManagerConfigTests()
Destructor.
CPPUNIT_TEST_SUITE_REGISTRATION(ManagerConfig::ManagerConfigTests)
prop
Organization::get_organization_property ();.
bool fileExist(const std::string &filename)
Class represents a set of properties.
const std::string & getProperty(const std::string &key) const
Search for the property with the specified key in this property.