17 #ifndef CORBAManager_cpp 18 #define CORBAManager_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> 42 std::cout <<
"EchoImpl: " <<
name() <<
" deleted." << std::endl;
44 const char*
id() {
return "EchoSample";}
50 std::cout <<
name() <<
" -> Message is: " << msg << std::endl;
61 public virtual POA_EchoSample
65 :
doil::CORBA::CORBAServantBase(impl)
67 m_impl =
dynamic_cast<EchoImpl*
>(impl);
68 if (m_impl == NULL)
throw std::bad_alloc();
72 std::cout <<
"EchoServant: " <<
name() <<
" deleted." << std::endl;
91 :
public CppUnit::TestFixture
94 CPPUNIT_TEST(test_init);
95 CPPUNIT_TEST(test_instance);
96 CPPUNIT_TEST(test_name);
97 CPPUNIT_TEST(test_case0);
98 CPPUNIT_TEST_SUITE_END();
138 for (
int i(0); i < 1000; ++i)
142 CPPUNIT_ASSERT_MESSAGE(
"CORBAManager's pointer should always be same",
151 for (
int i(0); i < 1000; ++i)
155 CPPUNIT_ASSERT_MESSAGE(
"CORBAManager's pointer should always be same",
162 for (
int i(100); i < 1000; ++i)
165 CPPUNIT_ASSERT_MESSAGE(
"CORBAManager's name should be corba",
176 std::cout << mgr.
name() << std::endl;
182 if (ret ==
doil::OK) std::cout <<
"register: OK" << std::endl;
183 else if (ret ==
doil::NOT_FOUND) std::cout <<
"register: NOT_FOUND" << std::endl;
184 else if (ret ==
doil::UNKNOWN) std::cout <<
"register: UNKNOWN" << std::endl;
185 else std::cout <<
"other error" << std::endl;
190 doil::Delete<EchoServant>);
193 if (ret ==
doil::OK) std::cout <<
"register: OK" << std::endl;
194 else if (ret ==
doil::NOT_FOUND) std::cout <<
"register: NOT_FOUND" << std::endl;
195 else if (ret ==
doil::UNKNOWN) std::cout <<
"register: UNKNOWN" << std::endl;
196 else std::cout <<
"other error" << std::endl;
203 std::cout <<
"servant not found" << std::endl;
209 std::cout <<
"dynamic_cast failed" << std::endl;
212 esvt->
echo(
"daradara");
217 std::cout <<
"ID : " << esvt->
id() << std::endl;
218 std::cout <<
"name: " << esvt->
name() << std::endl;
221 CORBA::ORB_ptr orb = mgr.
getORB();
222 PortableServer::POA_ptr poa = mgr.
getPOA();
224 CORBA::Object_ptr obj = poa->servant_to_reference(esvt);
225 EchoSample_ptr eptr = EchoSample::_narrow(obj);
226 eptr->echo(
"munyamunya");
232 std::cout <<
"not found impl" << std::endl;
237 tmpe->
echo(
"gggggg");
239 printf(
"eimpl 0x%lx\n", (
unsigned long int)eimpl);
240 printf(
"tmpe 0x%lx\n", (
unsigned long int)tmpe);
242 std::cout <<
"objref from eimpl: " << orb->object_to_string(mgr.
toReference(eimpl)) << std::endl;
243 std::cout <<
"objref from obj : " << orb->object_to_string(obj) << std::endl;
249 std::cout <<
"objref from eimpl2:" << orb->object_to_string(mgr.
toReference(eimpl2)) << std::endl;
251 std::string ior0, ior1;
252 ior0 = orb->object_to_string(obj);
253 ior1 = orb->object_to_string(mgr.
toReference(eimpl2));
255 if (ior0 == ior1) std::cout <<
"same!!!!!!!!!!" << std::endl;
256 else std::cout <<
"different" << std::endl;
259 for (
int j(0);
j < 100; ++
j)
261 CORBA::Object_var tobj;
264 tobj = orb->string_to_object(ior0.c_str());
268 tobj = orb->string_to_object(ior1.c_str());
270 EchoSample_var
ec = EchoSample::_narrow(tobj);
275 std::cout <<
"deactivated" << std::endl;
277 std::cout <<
"toImpl" << std::endl;
280 std::cout <<
"not found" << std::endl;
295 int main(
int argc,
char* argv[])
297 CppUnit::TextUi::TestRunner runner;
298 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
299 CppUnit::Outputter* outputter =
300 new CppUnit::TextOutputter(&runner.result(), std::cout);
301 runner.setOutputter(outputter);
306 #endif // CORBAManager_cpp
int main(int argc, char **argv)
virtual const char * name()
Getting ORB's name.
void echo(std::string msg)
::PortableServer::POA_ptr getPOA()
Getting default POA pointer.
virtual ServantBase * toServant(doil::ImplBase *lobj)
Getting servant object by impl object.
virtual const char * name() const
virtual ReturnCode_t registerFactory(const char *id, doil::ServantNewFunc new_func, doil::ServantDeleteFunc delete_func)
Register servant's factory.
::CORBA::ORB_ptr getORB()
Getting ORB pointer.
virtual ImplBase * toImpl(doil::ServantBase *servant)
Getting impl object by servant.
static CORBAManager & instance()
getting instance
CORBAManagerTests()
Constructor.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
EchoServant(doil::ImplBase *impl)
static CORBAManager * init(coil::Properties prop)
initializer
::CORBA::Object_ptr toReference(doil::ImplBase *impl)
Converting Impl object to object reference.
doil implementation base class
~CORBAManagerTests()
Destructor.
def j(str, encoding="cp932")
virtual void setUp()
Test initialization.
Class represents a set of properties.
std::string sprintf(char const *__restrict fmt,...)
Convert it into a format given with an argumen.
CPPUNIT_TEST_SUITE_REGISTRATION(CORBAManager::CORBAManagerTests)
virtual void shutdown()
Shutdown ORB.
virtual const char * id() const
virtual void tearDown()
Test finalization.
void echo(const char *msg)
virtual ReturnCode_t activateObject(doil::ImplBase *impl)
Activate object.