17 #ifndef ORBManager_cpp 18 #define ORBManager_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> 25 #include <coil/DynamicLib.h> 29 #include "EchoCORBASkel.h" 30 #include "EchoIceSkel.h" 42 :
public CppUnit::TestFixture
87 for (
int i(0); i < 100; ++i)
91 CPPUNIT_ASSERT_MESSAGE(
"ORBManager's pointer should always be same",
101 for (
int i(0); i < 100; ++i)
105 CPPUNIT_ASSERT_MESSAGE(
"ORBManager's pointer should always be same",
117 if (dll0.
open(
"../../corba/.libs/libdoilcorba.so",
118 RTLD_LAZY | RTLD_GLOBAL) < 0)
120 std::cout << dll0.
error() << std::endl;
121 CPPUNIT_ASSERT_MESSAGE(
"doilcorba load faild",
false);
125 func0 = dll0.
symbol(
"DoilCORBAInit");
126 CPPUNIT_ASSERT_MESSAGE(
"invalid symbol for corba init", func0 != NULL);
131 std::vector<doil::IORB*> orbs;
133 std::cout <<
"number of ORB: " << orbs.size() << std::endl;
134 for (
int i(0), len(orbs.size()); i < len; ++i)
136 std::cout <<
"ORB name: " << orbs[i]->name() << std::endl;
141 if (dll1.
open(
"../../ice/.libs/libdoilice.so",
142 RTLD_LAZY | RTLD_GLOBAL) < 0)
144 std::cout << dll1.
error() << std::endl;
145 CPPUNIT_ASSERT_MESSAGE(
"doilice load faild",
false);
149 func1 = dll1.
symbol(
"DoilIceInit");
150 CPPUNIT_ASSERT_MESSAGE(
"invalid symbol for ice init", func0 != NULL);
156 std::cout <<
"number of ORB: " << orbs.size() << std::endl;
157 for (
int i(0), len(orbs.size()); i < len; ++i)
159 std::cout <<
"ORB name: " << orbs[i]->name() << std::endl;
164 if (dll2.
open(
".libs/libEchoCORBA.so", RTLD_LAZY | RTLD_GLOBAL) < 0)
166 std::cout << dll2.
error() << std::endl;
167 CPPUNIT_ASSERT_MESSAGE(
"libEchoCORBA load faild",
false);
171 if (init_func2 == NULL)
173 std::cout << dll2.
error() << std::endl;
174 CPPUNIT_ASSERT_MESSAGE(
"symbol not found: EchoCORBAInit",
false);
181 if (dll3.
open(
".libs/libEchoIce.so", RTLD_LAZY | RTLD_GLOBAL) < 0)
183 std::cout << dll3.
error() << std::endl;
184 CPPUNIT_ASSERT_MESSAGE(
"libEchoIce load faild",
false);
188 if (init_func3 == NULL)
190 std::cout << dll3.
error() << std::endl;
191 CPPUNIT_ASSERT_MESSAGE(
"symbol not found: EchoIceInit",
false);
196 if (ie0 == NULL)
throw "ErrorE";
199 for (
int i(0), l(ret.
retcodes_.size()); i < l; ++i)
201 std::cout << i <<
": " << ret.
retcodes_[i].key_ <<
": ";
208 for (
int i(0), l(orbs.size()); i < l; ++i)
210 if (strcmp(orbs[i]->name(),
"corba") == 0)
212 if (strcmp(orbs[i]->name(),
"ice") == 0)
217 EchoCORBA::EchoSample_var ec0 = EchoCORBA::EchoSample::_narrow(obj);
218 if (CORBA::is_nil(ec0))
throw "Objectref is nil";
219 ec0->echo(
"this is corba object");
223 eobj->echo(
"This is Ice object");
225 ie0->
echo(
"hogehoge");
237 int main(
int argc,
char* argv[])
239 CppUnit::TextUi::TestRunner runner;
240 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
241 CppUnit::Outputter* outputter =
242 new CppUnit::TextOutputter(&runner.result(), std::cout);
243 runner.setOutputter(outputter);
248 #endif // ORBManager_cpp
int main(int argc, char **argv)
void echo(std::string msg)
void(* ModuleInitFunc)(coil::Properties &)
::IceInternal::ProxyHandle< ::IceProxy::Demo::EchoSample > EchoSamplePrx
ORBManagerTests()
Constructor.
virtual void setUp()
Test initialization.
CPPUNIT_TEST_SUITE(ORBManagerTests)
void * symbol(const char *symbol_name)
Return an address of the memory where a symbol was loaded.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
::CORBA::Object_ptr toReference(doil::ImplBase *impl)
Converting Impl object to object reference.
static ORBManager & instance()
getting instance
coil::Properties Properties
static const char * return_codes[]
std::vector< NamedReturnCode > retcodes_
::Ice::ObjectPrx toReference(doil::ImplBase *impl)
Converting Impl object to object reference.
CPPUNIT_TEST_SUITE_REGISTRATION(ORBManager::ORBManagerTests)
prop
Organization::get_organization_property ();.
~ORBManagerTests()
Destructor.
Class represents a set of properties.
virtual void tearDown()
Test finalization.
const char * error(void) const
Return the explanation message about the error.
static ORBManager * init(coil::Properties prop)
initializer
virtual ReturnCodes activateObject(ImplBase *impl, const char *orbname="")
Activate object.
virtual int open(const char *dll_name, int open_mode=COIL_DEFAULT_DYNLIB_MODE, int close_handle_on_destruction=1)
Load of the Dynamic link library.
const std::vector< IORB * > getORBs()
Get all the ORBs that are registered in this ORBManager.