// uncomment to enable VLD leak detection - will automatically link to required libs
//#include "vld.h"
//#include "vldapi.h"
#include <string>
#include <boost/test/minimal.hpp>
#include <RCF/Idl.hpp>
#include <RCF/InitDeinit.hpp>
#include <RCF/RcfServer.hpp>
#include <RCF/InitDeinit.hpp>
#include <RCF/test/EndpointFactories.hpp>
#include <RCF/test/TransportFactories.hpp>
#include <RCF/util/CommandLine.hpp>
class Echo
{
public:
std::string echo(const std::string &s)
{
sLog = s;
return s;
}
static std::string sLog;
};
std::string Echo::sLog;
RCF_BEGIN(I_Echo, "I_Echo")
RCF_METHOD_R1(std::string, echo, const std::string &)
RCF_END(I_Echo)
int test_main(int argc, char **argv)
{
util::CommandLine::getSingleton().parse(argc, argv);
RCF::deinit();
for (unsigned int i=0; i<RCF::getTransportFactories().size(); ++i)
{
RCF::init();
{
RCF::TransportFactoryPtr transportFactoryPtr = RCF::getTransportFactories()[i];
std::pair<RCF::ServerTransportPtr, RCF::ClientTransportAutoPtrPtr> transports = transportFactoryPtr->createTransports();
RCF::ServerTransportPtr serverTransportPtr( transports.first );
RCF::ClientTransportAutoPtr clientTransportAutoPtr( *transports.second );
RCF::writeTransportTypes(std::cout, *serverTransportPtr, *clientTransportAutoPtr);
std::string s0 = "something special";
Echo echo;
RCF::RcfServer server( boost::dynamic_pointer_cast<RCF::I_Service>(serverTransportPtr) );
server.start();
server.bind<I_Echo>(echo);
std::string s = RcfClient<I_Echo>( clientTransportAutoPtr->clone() ).echo(s0);
BOOST_CHECK(s0 == s);
}
RCF::deinit();
}
RCF::init();
RCF::init();
RCF::deinit();
RCF::deinit();
return boost::exit_success;
}