18 #ifndef InPortCorbaCdrConsumer_cpp 19 #define InPortCorbaCdrConsumer_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> 58 const RTC::TimedLong&
data)
60 std::cout <<
"------------------------------" << std::endl;
61 std::cout <<
"Data Listener: " <<
m_name << std::endl;
62 std::cout <<
"Profile::name: " << info.
name << std::endl;
63 std::cout <<
"------------------------------" << std::endl;
81 std::cout <<
"------------------------------" << std::endl;
82 std::cout <<
"Connector Listener: " <<
m_name << std::endl;
83 std::cout <<
"Profile::name: " << info.
name << std::endl;
84 std::cout <<
"------------------------------" << std::endl;
121 :
public CppUnit::TestFixture
125 CPPUNIT_TEST(test_case0);
127 CPPUNIT_TEST_SUITE_END();
144 m_pORB = CORBA::ORB_init(argc, argv);
145 m_pPOA = PortableServer::POA::_narrow(
146 m_pORB->resolve_initial_references(
"RootPOA"));
147 m_pPOA->the_POAManager()->activate();
223 RTC::ConnectorProfile prof;
225 int testdata[8] = { 12,34,56,78,90,23,45,99 };
230 CPPUNIT_ASSERT_EQUAL(
false, ret);
242 CPPUNIT_ASSERT_EQUAL(
true, ret);
244 cdrMemoryStream indata;
245 indata.setByteSwapFlag(
true);
248 for(
int ic(0);ic<8;++ic)
251 td.data = testdata[ic];
256 retcode = consumer.
put(indata);
266 std::cout <<
"ERROR: PushConnector creation failed." << std::endl;
270 for(
int ic(0);ic<8;++ic)
272 retcode = consumer.
put(indata);
277 retcode = consumer.
put(indata);
280 for(
int icc(0);icc<8;++icc)
285 CORBA::ULong inlen = cdr.bufSize();
286 CPPUNIT_ASSERT_EQUAL(96,(
int)inlen);
289 CPPUNIT_ASSERT_EQUAL(testdata[0], (
int)rtd.data);
292 CPPUNIT_ASSERT(!CORBA::is_nil(consumer.
get_m_objre()));
294 CPPUNIT_ASSERT(CORBA::is_nil(consumer.
get_m_objre()));
298 "dataport.corba_cdr.inport_ior");
300 if (prof.properties[index].value >>= ior)
302 CORBA::Object_ptr var = m_pORB->string_to_object(ior);
303 PortableServer::Servant ser = m_pPOA->reference_to_servant(var);
304 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(ser));
320 int main(
int argc,
char* argv[])
333 std::string arg(argv[i]);
334 std::string next_arg;
335 if (i + 1 < argc) next_arg = argv[i + 1];
338 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
351 ofs.open(fname.c_str());
353 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
354 if ( arg ==
"--cerr" ) { target = 1;
break; }
355 if ( arg ==
"--xsl" )
357 if (next_arg ==
"") xsl =
"default.xsl";
360 if ( arg ==
"--namespace" )
364 std::cerr <<
"no namespace specified" << std::endl;
374 CppUnit::TextUi::TestRunner runner;
376 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
378 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
379 CppUnit::Outputter* outputter = 0;
380 std::ostream* stream = target ? &std::cerr : &std::cout;
384 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
387 std::cout <<
"XML_OUT" << std::endl;
388 outputter =
new CppUnit::XmlOutputter(&runner.result(),
390 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
393 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
396 runner.setOutputter(outputter);
401 #endif // OutPortBase_cpp SDOPackage::NameValue newNV(const char *name, Value value)
Create NameValue.
InPortPushConnector class.
ConnectorListeners class.
virtual bool subscribeInterface(const SDOPackage::NVList &properties)
Subscribe to the data sending notification.
int main(int argc, char **argv)
InPortConnector base class.
InPortCorbaCdrConsumer class.
void addListener(ConnectorDataListener *listener, bool autoclean)
Add the listener.
ConnectorListenerHolder connector_[CONNECTOR_LISTENER_NUM]
ConnectorListenerType listener array The ConnectorListenerType listener is stored.
DataListener(const char *name)
ConnListener(const char *name)
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
virtual void unsubscribeInterface(const SDOPackage::NVList &properties)
Unsubscribe the data send notification.
virtual ReturnCode put(const cdrMemoryStream &data)
Send data to the destination port.
void addListener(ConnectorListener *listener, bool autoclean)
Add the listener.
virtual void operator()(const RTC::ConnectorInfo &info, const RTC::TimedLong &data)
Virtual Callback method.
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
CORBA::Object_var get_m_objre()
~InPortCorbaCdrConsumerTests()
Destructor.
InPortCorbaCdrProvider class.
RTC::InPortConnector * connector
std::vector< std::string > vstring
virtual void setListener(ConnectorInfo &info, ConnectorListeners *listeners)
Set the listener.
const CORBA::Long find_index(const SDOPackage::NVList &nv, const char *name)
Return the index of element specified by name from NVList.
PortableServer::POA_ptr m_pPOA
ConnectorDataListenerHolder connectorData_[CONNECTOR_DATA_LISTENER_NUM]
ConnectorDataListenerType listener array The ConnectorDataListenerType listener is stored...
InPortCorbaCdrProvider class.
virtual void setConnector(InPortConnector *connector)
set Connector
ConnectorDataListenerT class.
NameValue and NVList utility functions.
CORBA sequence utility template functions.
Push type connector class.
virtual void setUp()
Test initialization.
std::string name
Connection name.
virtual void tearDown()
Test finalization.
prop
Organization::get_organization_property ();.
virtual ReturnCode read(DataType &value, long int sec=-1, long int nsec=-1)=0
Read data from the buffer.
virtual void operator()(const RTC::ConnectorInfo &info)
Virtual Callback method.
Class represents a set of properties.
RTC::ConnectorListeners m_listeners
virtual void setBuffer(BufferBase< cdrMemoryStream > *buffer)
Setting outside buffer's pointer.
InPortCorbaCdrConsumer class.
virtual bool publishInterface(SDOPackage::NVList &properties)
Publish interface information.
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
BufferBase abstract class.
virtual ~InPortCorbaCdrConsumerMock()
CPPUNIT_TEST_SUITE_REGISTRATION(InPortCorbaCdrConsumer::InPortCorbaCdrConsumerTests)
Enum
DataPortStatus return codes.
RTC's Port administration class.
InPortCorbaCdrConsumerTests()
Constructor.
virtual void init(coil::Properties &prop)
Initializing configuration.
virtual void publishInterfaceProfile(SDOPackage::NVList &properties)
Publish InterfaceProfile information.
InPortCorbaCdrConsumerMock(void)