28 #ifndef OutPortProvider_cpp 29 #define OutPortProvider_cpp 31 #include <cppunit/ui/text/TestRunner.h> 32 #include <cppunit/TextOutputter.h> 33 #include <cppunit/extensions/TestFactoryRegistry.h> 34 #include <cppunit/extensions/HelperMacros.h> 35 #include <cppunit/TestAssert.h> 115 const int maxsize = 256;
118 return std::string(buf);
142 const std::string& portType,
143 const std::string& dataType,
144 const std::string& interfaceType,
145 const std::string& dataFlowType,
146 const std::string& subscriptionType)
148 setPortType(portType.c_str());
149 setDataType(dataType.c_str());
150 setInterfaceType(interfaceType.c_str());
151 setDataFlowType(dataFlowType.c_str());
152 setSubscriptionType(subscriptionType.c_str());
179 :
public CppUnit::TestFixture
182 CPPUNIT_TEST(test_publishInterfaceProfile);
183 CPPUNIT_TEST(test_publishInterfaceProfile2);
184 CPPUNIT_TEST(test_publishInterface);
185 CPPUNIT_TEST_SUITE_END();
195 for (
int i = 0; i <
g_argc; i++) {
196 argv[i] = (
char *)g_argv[i].c_str();
199 CORBA::ORB_var orb = CORBA::ORB_init(g_argc, argv);
233 std::auto_ptr<RTC::OutPortProvider>
provider(
235 "DATA_FLOW_TYPE",
"SUBSCRIPTION_TYPE"));
238 provider->publishInterfaceProfile(prop);
245 CPPUNIT_FAIL(
"dataport.data_type fialure.");
247 catch(std::string ex) {
250 CPPUNIT_FAIL(
"dataport.data_type failure.");
257 NVUtil::find(prop,
"dataport.interface_type") >>= value;
258 CPPUNIT_ASSERT_EQUAL(std::string(
"INTERFACE_TYPE"), std::string(value));
266 CPPUNIT_FAIL(
"dataport.dataflow_type failure.");
268 catch(std::string ex) {
271 CPPUNIT_FAIL(
"dataport.dataflow_type failure.");
279 NVUtil::find(prop,
"dataport.subscription_type") >>= value;
280 CPPUNIT_FAIL(
"dataport.subscription_type failure.");
282 catch(std::string ex) {
285 CPPUNIT_FAIL(
"dataport.subscription_type failure.");
300 std::auto_ptr<OutPortProviderMock>
provider(
302 "DATA_FLOW_TYPE",
"SUBSCRIPTION_TYPE"));
305 provider->publishInterfaceProfile(prop);
309 for (CORBA::ULong i(0); i < prop_dummy.length(); ++i)
311 if (std::string(prop_dummy[i].name) == std::string(
"dataport.interface_type"))
314 prop_dummy[i].value <<=
"DUMMY";
319 provider->setDummydataInProperties();
321 provider->publishInterface(prop_dummy);
324 CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1),
NVUtil::find_index(prop_dummy,
"PROPERTY_NAME1"));
325 CPPUNIT_ASSERT_EQUAL(CORBA::Long(-1),
NVUtil::find_index(prop_dummy,
"PROPERTY_NAME2"));
328 provider->publishInterface(prop);
333 CPPUNIT_ASSERT(CORBA::Long(-1) != index1);
334 CPPUNIT_ASSERT(CORBA::Long(-1) != index2);
337 prop[index1].value >>= value1;
338 CPPUNIT_ASSERT_EQUAL(std::string(
"PROPERTY_VALUE1"), std::string(value1));
341 prop[index2].value >>= value2;
342 CPPUNIT_ASSERT_EQUAL(std::string(
"PROPERTY_VALUE2"), std::string(value2));
351 std::auto_ptr<OutPortProviderMock>
provider(
353 "DATA_FLOW_TYPE",
"SUBSCRIPTION_TYPE"));
357 provider->setDummydataInProperties();
360 provider->publishInterfaceProfile(prop);
364 CPPUNIT_ASSERT(CORBA::Long(-1) != index1);
365 CPPUNIT_ASSERT(CORBA::Long(-1) != index2);
368 prop[index1].value >>= value1;
369 CPPUNIT_ASSERT_EQUAL(std::string(
"PROPERTY_VALUE1"), std::string(value1));
372 prop[index2].value >>= value2;
373 CPPUNIT_ASSERT_EQUAL(std::string(
"PROPERTY_VALUE2"), std::string(value2));
386 int main(
int argc,
char* argv[])
399 std::string arg(argv[i]);
400 std::string next_arg;
401 if (i + 1 < argc) next_arg = argv[i + 1];
404 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
417 ofs.open(fname.c_str());
419 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
420 if ( arg ==
"--cerr" ) { target = 1;
break; }
421 if ( arg ==
"--xsl" )
423 if (next_arg ==
"") xsl =
"default.xsl";
426 if ( arg ==
"--namespace" )
430 std::cerr <<
"no namespace specified" << std::endl;
440 CppUnit::TextUi::TestRunner runner;
442 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
444 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
445 CppUnit::Outputter* outputter = 0;
446 std::ostream* stream = target ? &std::cerr : &std::cout;
450 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
453 std::cout <<
"XML_OUT" << std::endl;
454 outputter =
new CppUnit::XmlOutputter(&runner.result(),
456 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
459 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
462 runner.setOutputter(outputter);
467 #endif // OutPortProvider_cpp void setDateFormat(const char *format)
Set date/time format for adding the header.
ConnectorListeners class.
virtual ~Logger(void)
Virtual destructor.
int main(int argc, char **argv)
virtual void header(int level)
Message prefix appender function.
void test_publishInterface()
publishInterface()メソッドのテスト
OutPortConnector base class.
LogStreamBuf m_logStreamBuf
virtual void setUp()
Test initialization.
virtual void tearDown()
Test finalization.
void setConnector(RTC::OutPortConnector *connector)
set Connector
::coil::LogStreamBuffer LogStreamBuf
bool appendStringValue(SDOPackage::NVList &nv, const char *name, const char *value)
Append the specified string to element of NVList.
std::vector< std::pair< std::string, std::string > > NVList
void setName(const char *name)
Set suffix of date/time string of header.
log_stream< char > LogStream
CPPUNIT_TEST_SUITE_REGISTRATION(OutPortProvider::OutPortProviderTests)
void setBuffer(RTC::CdrBufferBase *buffer)
Setting outside buffer's pointer.
const CORBA::Long find_index(const SDOPackage::NVList &nv, const char *name)
Return the index of element specified by name from NVList.
void test_publishInterfaceProfile2()
publishInterfaceProfile()メソッドのテスト
const CORBA::Any & find(const SDOPackage::NVList &nv, const char *name)
Return the value specified by name from NVList.
OutPortProviderMock(const std::string &portType, const std::string &dataType, const std::string &interfaceType, const std::string &dataFlowType, const std::string &subscriptionType)
bool setLevel(const char *level)
Set log level by string.
prop
Organization::get_organization_property ();.
ostream_type & level(int level)
Acquire log stream.
std::vector< std::string > g_argv
void setDummydataInProperties(void)
void test_publishInterfaceProfile()
publishInterfaceProfile()メソッドのテスト。
void setListener(RTC::ConnectorInfo &info, RTC::ConnectorListeners *listeners)
Set the listener.
Logger(const char *name="")
Constructor.
~OutPortProviderTests()
Destructor.
int strToLevel(const char *level)
Set the log level Set the log level corresponding to the given string.
static const char * m_levelString[]
OutPortProviderTests()
Constructor.
BufferBase abstract class.
std::string getDate(void)
Get the current formatted date/time string Get the current datetime described by specified format...