17 #ifndef IceManager_cpp 18 #define IceManager_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;
65 :
doil::Ice::IceServantBase(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;
74 virtual void echo(
const std::string& msg,
const Ice::Current&)
76 std::cout <<
"servant" <<
name() <<
"::echo() was called" << std::endl;
92 :
public CppUnit::TestFixture
95 CPPUNIT_TEST(test_init);
96 CPPUNIT_TEST(test_instance);
97 CPPUNIT_TEST(test_name);
98 CPPUNIT_TEST(test_case0);
99 CPPUNIT_TEST_SUITE_END();
139 for (
int i(0); i < 1000; ++i)
143 CPPUNIT_ASSERT_MESSAGE(
"IceManager's pointer should always be same",
152 for (
int i(0); i < 1000; ++i)
156 CPPUNIT_ASSERT_MESSAGE(
"IceManager's pointer should always be same",
164 for (
int i(100); i < 1000; ++i)
167 CPPUNIT_ASSERT_MESSAGE(
"IceManager's name should be corba",
179 std::cout << mgr.
name() << std::endl;
185 if (ret ==
doil::OK) std::cout <<
"register: OK" << std::endl;
186 else if (ret ==
doil::NOT_FOUND) std::cout <<
"register: NOT_FOUND" << std::endl;
187 else if (ret ==
doil::UNKNOWN) std::cout <<
"register: UNKNOWN" << std::endl;
188 else std::cout <<
"other error" << std::endl;
193 doil::Delete<EchoServant>);
196 if (ret ==
doil::OK) std::cout <<
"register: OK" << std::endl;
197 else if (ret ==
doil::NOT_FOUND) std::cout <<
"register: NOT_FOUND" << std::endl;
198 else if (ret ==
doil::UNKNOWN) std::cout <<
"register: UNKNOWN" << std::endl;
199 else std::cout <<
"other error" << std::endl;
206 std::cout <<
"servant not found" << std::endl;
212 std::cout <<
"dynamic_cast failed" << std::endl;
220 std::cout <<
"ID : " << esvt->
id() << std::endl;
221 std::cout <<
"name: " << esvt->
name() << std::endl;
224 Ice::CommunicatorPtr orb = mgr.
getORB();
225 Ice::ObjectAdapterPtr adapter = mgr.
getAdapter();
227 Ice::ObjectPrx base = mgr.
getORB()->stringToProxy(
"EchoSample0:default -p 10000");
228 std::cout <<
"Proxy base was created" << std::endl;
230 std::cout <<
"base was casted to EchoSample proxy" << std::endl;
233 std::cout <<
"Invalud Object reference" << std::endl;
234 throw "Invalid Proxy!";
236 eobj->echo(
"munyamunya");
243 std::cout <<
"not found impl" << std::endl;
248 tmpe->
echo(
"gggggg");
250 printf(
"eimpl 0x%lx\n", (
unsigned long int)eimpl);
251 printf(
"tmpe 0x%lx\n", (
unsigned long int)tmpe);
257 base = mgr.
getORB()->stringToProxy(
"EchoSample1:default -p 10000");
258 eobj = Demo::EchoSamplePrx::checkedCast(base);
259 eobj->echo(
"hogehogehoge");
272 int main(
int argc,
char* argv[])
274 CppUnit::TextUi::TestRunner runner;
275 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
276 CppUnit::Outputter* outputter =
277 new CppUnit::TextOutputter(&runner.result(), std::cout);
278 runner.setOutputter(outputter);
283 #endif // IceManager_cpp
int main(int argc, char **argv)
virtual ImplBase * toImpl(doil::ServantBase *servant)
Getting impl object by servant.
void echo(std::string msg)
::IceInternal::ProxyHandle< ::IceProxy::Demo::EchoSample > EchoSamplePrx
virtual const char * name() const
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
IceManagerTests()
Constructor.
EchoServant(doil::ImplBase *impl)
CPPUNIT_TEST_SUITE_REGISTRATION(IceManager::IceManagerTests)
virtual void tearDown()
Test finalization.
doil implementation base class
virtual const char * id() const
virtual ReturnCode_t registerFactory(const char *id, doil::ServantNewFunc new_func, doil::ServantDeleteFunc delete_func)
Register servant's factory.
Doil Ice servant base class.
virtual void echo(const std::string &msg, const Ice::Current &)
::Ice::CommunicatorPtr getORB()
Getting ORB pointer.
virtual void shutdown()
Shutdown ORB.
Class represents a set of properties.
::Ice::ObjectAdapterPtr getAdapter()
Getting default POA pointer.
virtual ServantBase * toServant(doil::ImplBase *lobj)
Getting servant object by impl object.
std::string sprintf(char const *__restrict fmt,...)
Convert it into a format given with an argumen.
static IceManager * init(coil::Properties prop)
initializer
virtual void setUp()
Test initialization.
~IceManagerTests()
Destructor.
virtual const char * name()
Getting ORB's name.
static IceManager & instance()
getting instance
virtual ReturnCode_t activateObject(doil::ImplBase *impl)
Activate object.