29 #ifndef CorbaConsumer_cpp 30 #define CorbaConsumer_cpp 32 #include <cppunit/ui/text/TestRunner.h> 33 #include <cppunit/TextOutputter.h> 34 #include <cppunit/extensions/TestFactoryRegistry.h> 35 #include <cppunit/extensions/HelperMacros.h> 36 #include <cppunit/TestAssert.h> 38 #include <rtm/config_rtc.h> 39 #include "HelloSkel.h" 49 :
virtual public POA_hello,
50 virtual public PortableServer::RefCountServantBase
66 :
public CppUnit::TestFixture
69 CPPUNIT_TEST(test_setObject_and__ptr);
70 CPPUNIT_TEST(test_copy_constructor);
71 CPPUNIT_TEST(test_pointer_operator);
72 CPPUNIT_TEST(test_substitute_operator);
73 CPPUNIT_TEST(test_releaseObject);
74 CPPUNIT_TEST_SUITE_END();
90 m_pORB = CORBA::ORB_init(argc, argv);
91 m_pPOA = PortableServer::POA::_narrow(
92 m_pORB->resolve_initial_references(
"RootPOA"));
93 m_pPOA->the_POAManager()->activate();
126 PortableServer::ObjectId_var objId = m_pPOA->activate_object(helloImpl);
130 consumer.
setObject(m_pPOA->id_to_reference(objId));
134 consumer.
_ptr()->hello_world();
137 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(helloImpl));
151 PortableServer::ObjectId_var objId = m_pPOA->activate_object(helloImpl);
155 consumer.
setObject(m_pPOA->id_to_reference(objId));
162 consumerNew.
_ptr()->hello_world();
165 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(helloImpl));
179 PortableServer::ObjectId_var objId = m_pPOA->activate_object(helloImpl);
183 consumer.
setObject(m_pPOA->id_to_reference(objId));
187 consumer->hello_world();
190 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(helloImpl));
198 PortableServer::ObjectId_var objId = m_pPOA->activate_object(helloImpl);
202 consumer.
setObject(m_pPOA->id_to_reference(objId));
209 consumerNew.
_ptr()->hello_world();
212 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(helloImpl));
225 PortableServer::ObjectId_var objId = m_pPOA->activate_object(helloImpl);
229 consumer.
setObject(m_pPOA->id_to_reference(objId));
232 CPPUNIT_ASSERT(! CORBA::is_nil(consumer.
_ptr()));
236 CPPUNIT_ASSERT(CORBA::is_nil(consumer.
_ptr()));
238 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(helloImpl));
251 int main(
int argc,
char* argv[])
264 std::string arg(argv[i]);
265 std::string next_arg;
266 if (i + 1 < argc) next_arg = argv[i + 1];
269 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
282 ofs.open(fname.c_str());
284 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
285 if ( arg ==
"--cerr" ) { target = 1;
break; }
286 if ( arg ==
"--xsl" )
288 if (next_arg ==
"") xsl =
"default.xsl";
291 if ( arg ==
"--namespace" )
295 std::cerr <<
"no namespace specified" << std::endl;
305 CppUnit::TextUi::TestRunner runner;
307 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
309 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
310 CppUnit::Outputter* outputter = 0;
311 std::ostream* stream = target ? &std::cerr : &std::cout;
315 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
318 std::cout <<
"XML_OUT" << std::endl;
319 outputter =
new CppUnit::XmlOutputter(&runner.result(),
321 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
324 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
327 runner.setOutputter(outputter);
332 #endif // CorbaConsumer_cpp
int main(int argc, char **argv)
virtual void releaseObject()
Clear CORBA object setting.
void test_substitute_operator()
CPPUNIT_TEST_SUITE_REGISTRATION(CorbaConsumer::CorbaConsumerTests)
void test_copy_constructor()
コピーコンストラクタのテスト
virtual void tearDown()
Test finalization.
void test_pointer_operator()
ポインタ演算子(operator->())のテスト
virtual bool setObject(CORBA::Object_ptr obj)
Set Object.
PortableServer::POA_ptr m_pPOA
CorbaConsumerTests()
Constructor.
void test_setObject_and__ptr()
setObject()メソッドと_ptr()メソッドのテスト
ObjectTypePtr _ptr()
Get Object reference narrowed as ObjectType.
void test_releaseObject()
releaseObject()メソッドのテスト
virtual void setUp()
Test initialization.
~CorbaConsumerTests()
Destructor.