17 #ifndef ExecutionContextProxy_cpp 18 #define ExecutionContextProxy_cpp 20 #include <cppunit/ui/text/TestRunner.h> 21 #include <cppunit/TextOutputter.h> 22 #include <cppunit/extensions/TestFactoryRegistry.h> 23 #include <cppunit/extensions/HelperMacros.h> 24 #include <cppunit/TestAssert.h> 28 #include <idl/RTCSkel.h> 29 #include <ExecutionContextProxy.h> 45 void log(
const std::string& msg)
53 for (
int i = 0; i < (int)
m_log.size(); ++i)
55 if (
m_log[i] == msg) ++count;
70 :
public virtual ::POA_RTC::LightweightRTObject,
75 : ::
doil::CORBA::CORBAServantBase(impl)
87 virtual ::CORBA::Boolean
is_alive(::RTC::ExecutionContext_ptr exec_context)
143 ::SDOPackage::Local::ISDOSystemElement*
m_impl;
158 const char*
id() {
return "ILightweightRTObjectMock";}
159 const char*
name() {
return "ILightweightRTObjectMock";}
178 virtual bool is_alive(const ::RTC::Local::IExecutionContext* exec_context)
271 :
public virtual ::POA_RTC::ExecutionContext
318 if (m_logger != NULL)
320 m_logger->log(
"get_rate");
322 return (CORBA::Double)3.14159;
331 if (m_logger != NULL)
333 m_logger->log(
"set_rate");
334 ::std::ostringstream os;
336 m_logger->log(os.str());
391 if (m_logger != NULL)
393 m_logger->log(
"add_component");
427 :
public CppUnit::TestFixture
431 CPPUNIT_TEST(test_get_rate);
432 CPPUNIT_TEST(test_set_rate);
433 CPPUNIT_TEST(test_add_component);
434 CPPUNIT_TEST_SUITE_END();
449 m_pORB = CORBA::ORB_init(argc, argv);
450 m_pPOA = PortableServer::POA::_narrow(
451 m_pORB->resolve_initial_references(
"RootPOA"));
452 m_pPOA->the_POAManager()->activate();
485 ::CORBA::Object_ptr ref = obj->_this();
486 if(::CORBA::is_nil(ref))
488 std::cout<<
"ref is nil.Abort test."<<std::endl;
491 ::RTC::CORBA::ExecutionContextProxy* ap
492 = new ::RTC::CORBA::ExecutionContextProxy(ref);
498 CPPUNIT_ASSERT_EQUAL(0, logger.
countLog(
"get_rate"));
499 ret = ap->get_rate();
500 CPPUNIT_ASSERT_EQUAL(1, logger.
countLog(
"get_rate"));
501 CPPUNIT_ASSERT_EQUAL(3.14159, ret);
517 ::CORBA::Object_ptr ref = obj->_this();
518 if(::CORBA::is_nil(ref))
520 std::cout<<
"ref is nil.Abort test."<<std::endl;
523 ::RTC::CORBA::ExecutionContextProxy* ap
524 = new ::RTC::CORBA::ExecutionContextProxy(ref);
529 double dbuf = 2.71828;
531 CPPUNIT_ASSERT_EQUAL(0, logger.
countLog(
"2.71828"));
532 CPPUNIT_ASSERT_EQUAL(0, logger.
countLog(
"set_rate"));
533 ret = ap->set_rate(dbuf);
534 CPPUNIT_ASSERT_EQUAL(1, logger.
countLog(
"set_rate"));
536 CPPUNIT_ASSERT_EQUAL(1, logger.
countLog(
"2.71828"));
551 std::cout <<
"Manager Name==>"<< mgr.
name() << std::endl;
555 ::CORBA::Object_ptr ref = obj->_this();
556 if(::CORBA::is_nil(ref))
558 std::cout<<
"ref is nil.Abort test."<<std::endl;
561 ::RTC::CORBA::ExecutionContextProxy* ap
562 = new ::RTC::CORBA::ExecutionContextProxy(ref);
570 doil::New<LightweightRTObjectServantMock>,
571 doil::Delete<LightweightRTObjectServantMock>);
573 CPPUNIT_ASSERT_EQUAL(0, logger.
countLog(
"add_component"));
574 ret = ap->add_component(comp);
575 CPPUNIT_ASSERT_EQUAL(1, logger.
countLog(
"add_component"));
595 int main(
int argc,
char* argv[])
597 CppUnit::TextUi::TestRunner runner;
598 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
599 CppUnit::Outputter* outputter =
600 new CppUnit::TextOutputter(&runner.result(), std::cout);
601 runner.setOutputter(outputter);
606 #endif // ExecutionContextProxy_cpp virtual ~LightweightRTObjectServantMock()
::RTC::ReturnCode_t add_component(::RTC::LightweightRTObject_ptr comp)
virtual ::RTC::ExecutionContext_ptr get_context(::RTC::ExecutionContextHandle_t exec_handle)
virtual ::RTC::Local::ReturnCode_t on_finalize()
int main(int argc, char **argv)
virtual const char * name()
Getting ORB's name.
virtual ~ExecutionContextRtmMock()
EXECUTION_HANDLE_TYPE_NATIVE ExecutionContextHandle_t
std::vector< std::string > m_log
::RTC::LifeCycleState get_component_state(::RTC::LightweightRTObject_ptr comp)
virtual ::RTC::ExecutionContextList * get_owned_contexts()
virtual ::RTC::Local::ReturnCode_t on_initialize()
virtual ::RTC::ExecutionContextHandle_t attach_context(::RTC::ExecutionContext_ptr exec_context)
virtual bool is_alive(const ::RTC::Local::IExecutionContext *exec_context)
virtual ReturnCode_t registerFactory(const char *id, doil::ServantNewFunc new_func, doil::ServantDeleteFunc delete_func)
Register servant's factory.
virtual ::RTC::Local::IExecutionContext * get_context(::RTC::Local::ExecutionContextHandle_t exec_handle)
::RTC::ReturnCode_t start()
static CORBAManager & instance()
getting instance
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
PortableServer::POA_ptr m_pPOA
::RTC::ReturnCode_t activate_component(::RTC::LightweightRTObject_ptr comp)
virtual ::RTC::ExecutionContextList * get_participating_contexts()
virtual ::RTC::ReturnCode_t initialize()
::CORBA::Double get_rate()
CPPUNIT_TEST_SUITE_REGISTRATION(ExecutionContextProxy::ExecutionContextProxyTests)
virtual ::RTC::Local::ReturnCode_t on_activated(::RTC::Local::ExecutionContextHandle_t exec_handle)
~ExecutionContextProxyTests()
Destructor.
virtual ::RTC::Local::ReturnCode_t exit()
virtual ::RTC::ReturnCode_t detach_context(::RTC::ExecutionContextHandle_t exec_handle)
void setLogger(Logger *logger)
virtual ::RTC::ExecutionContextHandle_t get_context_handle(::RTC::ExecutionContext_ptr cxt)
virtual ::RTC::Local::ExecutionContextHandle_t get_context_handle(const ::RTC::Local::IExecutionContext *cxt)
virtual ::RTC::Local::ReturnCode_t initialize()
::RTC::ReturnCode_t stop()
virtual ::RTC::Local::ExecutionContextHandle_t attach_context(const ::RTC::Local::IExecutionContext *exec_context)
std::vector< ExecutionContext * > ExecutionContextList
int countLog(const std::string &msg)
virtual ::RTC::Local::ReturnCode_t on_shutdown(::RTC::Local::ExecutionContextHandle_t exec_handle)
virtual ::RTC::ReturnCode_t on_initialize()
virtual ::CORBA::Boolean is_alive(::RTC::ExecutionContext_ptr exec_context)
virtual ::RTC::Local::ReturnCode_t on_deactivated(::RTC::Local::ExecutionContextHandle_t exec_handle)
virtual void setUp()
Test initialization.
virtual ::RTC::Local::ReturnCode_t detach_context(::RTC::Local::ExecutionContextHandle_t exec_handle)
ILightweightRTObjectMock()
virtual ::RTC::ReturnCode_t on_aborting(::RTC::ExecutionContextHandle_t exec_handle)
void log(const std::string &msg)
::RTC::ExecutionKind get_kind()
virtual ~ILightweightRTObjectMock()
void test_add_component()
::CORBA::Boolean is_running()
virtual ::RTC::ReturnCode_t on_startup(::RTC::ExecutionContextHandle_t exec_handle)
virtual ::RTC::Local::ReturnCode_t on_aborting(::RTC::Local::ExecutionContextHandle_t exec_handle)
::RTC::ReturnCode_t reset_component(::RTC::LightweightRTObject_ptr comp)
virtual void tearDown()
Test finalization.
::SDOPackage::Local::ISDOSystemElement * m_impl
virtual ::RTC::Local::ReturnCode_t on_error(::RTC::Local::ExecutionContextHandle_t exec_handle)
ExecutionContextProxyTests()
Constructor.
virtual ::RTC::ReturnCode_t on_reset(::RTC::ExecutionContextHandle_t exec_handle)
virtual ::RTC::Local::ReturnCode_t on_reset(::RTC::Local::ExecutionContextHandle_t exec_handle)
virtual ::RTC::Local::ExecutionContextList get_owned_contexts()
virtual ::RTC::ReturnCode_t on_activated(::RTC::ExecutionContextHandle_t exec_handle)
std::vector< std::string > m_log
::RTC::ReturnCode_t set_rate(::CORBA::Double rate)
::RTC::ReturnCode_t deactivate_component(::RTC::LightweightRTObject_ptr comp)
virtual ::RTC::Local::ReturnCode_t finalize()
virtual ::RTC::ReturnCode_t on_error(::RTC::ExecutionContextHandle_t exec_handle)
virtual ::RTC::ReturnCode_t on_finalize()
virtual ::RTC::ReturnCode_t exit()
::OutPortBase::Logger logger
ILightweightRTObject interface class.
virtual ::RTC::Local::ExecutionContextList get_participating_contexts()
virtual ::RTC::ReturnCode_t on_shutdown(::RTC::ExecutionContextHandle_t exec_handle)
ILightweightRTObject interface class.
virtual ::RTC::Local::ReturnCode_t on_startup(::RTC::Local::ExecutionContextHandle_t exec_handle)
virtual ReturnCode_t activateObject(doil::ImplBase *impl)
Activate object.
::RTC::ReturnCode_t remove_component(::RTC::LightweightRTObject_ptr comp)
LightweightRTObjectServantMock(doil::ImplBase *impl)
virtual ::RTC::ReturnCode_t on_deactivated(::RTC::ExecutionContextHandle_t exec_handle)
ExecutionContextRtmMock()
virtual ::RTC::ReturnCode_t finalize()