18 #ifndef OutPortCorbaCdrConsumer_cpp 19 #define OutPortCorbaCdrConsumer_cpp 21 #include <cppunit/ui/text/TestRunner.h> 22 #include <cppunit/TextOutputter.h> 23 #include <cppunit/extensions/TestFactoryRegistry.h> 24 #include <cppunit/extensions/HelperMacros.h> 25 #include <cppunit/TestAssert.h> 27 #include <rtm/idl/BasicDataTypeSkel.h> 28 #include <rtm/idl/DataPortSkel.h> 59 const RTC::TimedLong&
data)
61 std::cout <<
"------------------------------" << std::endl;
62 std::cout <<
"Data Listener: " <<
m_name << std::endl;
63 std::cout <<
"Profile::name: " << info.
name << std::endl;
64 std::cout <<
"------------------------------" << std::endl;
82 std::cout <<
"------------------------------" << std::endl;
83 std::cout <<
"Connector Listener: " <<
m_name << std::endl;
84 std::cout <<
"Profile::name: " << info.
name << std::endl;
85 std::cout <<
"------------------------------" << std::endl;
123 :
public CppUnit::TestFixture
127 CPPUNIT_TEST(test_case0);
129 CPPUNIT_TEST_SUITE_END();
145 m_pORB = CORBA::ORB_init(argc, argv);
146 m_pPOA = PortableServer::POA::_narrow(
147 m_pORB->resolve_initial_references(
"RootPOA"));
148 m_pPOA->the_POAManager()->activate();
230 RTC::ConnectorProfile prof;
235 CPPUNIT_ASSERT_EQUAL(
false, ret);
246 CPPUNIT_ASSERT_EQUAL(
true, ret);
248 cdrMemoryStream indata;
249 indata.setByteSwapFlag(
true);
258 retcode = consumer.
get(indata);
263 retcode = consumer.
get(indata);
266 int testdata[8] = { 12,34,56,78,90,23,45,99 };
269 for(
int ic(0);ic<8;++ic)
271 td.data = testdata[ic];
276 retcode = consumer.
get(indata);
279 CORBA::ULong inlen = indata.bufSize();
280 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
284 CPPUNIT_ASSERT_EQUAL((
long)testdata[0], (
long)rtd.data);
286 CPPUNIT_ASSERT(!CORBA::is_nil(consumer.
get_m_objre()));
288 CPPUNIT_ASSERT(CORBA::is_nil(consumer.
get_m_objre()));
292 "dataport.corba_cdr.outport_ior");
295 if (prof.properties[index].value >>= ior)
297 CORBA::Object_ptr var = m_pORB->string_to_object(ior);
298 PortableServer::Servant ser = m_pPOA->reference_to_servant(var);
299 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(ser));
312 int main(
int argc,
char* argv[])
325 std::string arg(argv[i]);
326 std::string next_arg;
327 if (i + 1 < argc) next_arg = argv[i + 1];
330 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
343 ofs.open(fname.c_str());
345 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
346 if ( arg ==
"--cerr" ) { target = 1;
break; }
347 if ( arg ==
"--xsl" )
349 if (next_arg ==
"") xsl =
"default.xsl";
352 if ( arg ==
"--namespace" )
356 std::cerr <<
"no namespace specified" << std::endl;
366 CppUnit::TextUi::TestRunner runner;
368 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
370 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
371 CppUnit::Outputter* outputter = 0;
372 std::ostream* stream = target ? &std::cerr : &std::cout;
376 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
379 std::cout <<
"XML_OUT" << std::endl;
380 outputter =
new CppUnit::XmlOutputter(&runner.result(),
382 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
385 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
388 runner.setOutputter(outputter);
393 #endif // OutPortBase_cpp SDOPackage::NameValue newNV(const char *name, Value value)
Create NameValue.
ConnectorListeners class.
int main(int argc, char **argv)
virtual void tearDown()
Test finalization.
virtual ReturnCode get(cdrMemoryStream &data)
Read data.
RT component logger class.
void addListener(ConnectorDataListener *listener, bool autoclean)
Add the listener.
ConnectorListenerHolder connector_[CONNECTOR_LISTENER_NUM]
ConnectorListenerType listener array The ConnectorListenerType listener is stored.
virtual void operator()(const RTC::ConnectorInfo &info, const RTC::TimedLong &data)
Virtual Callback method.
RTC::ConnectorListeners m_listeners
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
void addListener(ConnectorListener *listener, bool autoclean)
Add the listener.
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
virtual void unsubscribeInterface(const SDOPackage::NVList &properties)
Unsubscribe the data receive notification.
virtual ~OutPortCorbaCdrConsumerMock()
OutPortCorbaCdrConsumer class.
PortableServer::POA_ptr m_pPOA
std::vector< std::string > vstring
const CORBA::Long find_index(const SDOPackage::NVList &nv, const char *name)
Return the index of element specified by name from NVList.
~OutPortCorbaCdrConsumerTests()
Destructor.
ConnectorDataListenerHolder connectorData_[CONNECTOR_DATA_LISTENER_NUM]
ConnectorDataListenerType listener array The ConnectorDataListenerType listener is stored...
OutPortCorbaCdrConsumerTests()
Constructor.
ConnectorDataListenerT class.
DataListener(const char *name)
NameValue and NVList utility functions.
OutPortCorbaCdrConsumerMock(void)
CORBA sequence utility template functions.
std::string name
Connection name.
virtual void operator()(const RTC::ConnectorInfo &info)
Virtual Callback method.
OutPortCorbaCdrConsumer class.
virtual void setListener(ConnectorInfo &info, ConnectorListeners *listeners)
Set the listener.
prop
Organization::get_organization_property ();.
virtual void setBuffer(CdrBufferBase *buffer)
Setting outside buffer's pointer.
virtual bool subscribeInterface(const SDOPackage::NVList &properties)
Subscribe the data receive notification.
Class represents a set of properties.
ConnListener(const char *name)
virtual bool publishInterface(SDOPackage::NVList &properties)
Publish interface information.
CPPUNIT_TEST_SUITE_REGISTRATION(OutPortCorbaCdrConsumer::OutPortCorbaCdrConsumerTests)
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
virtual ReturnCode write(const DataType &value, long int sec=-1, long int nsec=-1)=0
Write data into the buffer.
virtual void setListener(ConnectorInfo &info, ConnectorListeners *listeners)
Set the listener.
CORBA::Object_var get_m_objre()
virtual void setBuffer(CdrBufferBase *buffer)
Setting outside buffer's pointer.
OutPortCorbaCdrProvider class.
BufferBase abstract class.
virtual void setUp()
Test initialization.
Enum
DataPortStatus return codes.
RTC's Port administration class.
virtual void init(coil::Properties &prop)
Initializing configuration.
OutPortCorbaCdrProvider class.