diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-07-12 22:04:17 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-07-12 22:04:17 +0100 |
commit | 2a4d99cc48cf4dea21bbd31a69760ddad0fcf994 (patch) | |
tree | a6ec9c1002006eb9921898777a6b2177c2432acb | |
parent | Roll up testOptions into a single lib for an empty, but otherwise realistic t... (diff) | |
download | icetray-2a4d99cc48cf4dea21bbd31a69760ddad0fcf994.tar.bz2 icetray-2a4d99cc48cf4dea21bbd31a69760ddad0fcf994.tar.xz icetray-2a4d99cc48cf4dea21bbd31a69760ddad0fcf994.zip |
Service creation refactor
Move service create into Service class
Move assertions from DryIce runtime into explicit icebox interface test
-rw-r--r-- | icetray/dryice/Jamfile.jam | 1 | ||||
-rw-r--r-- | icetray/dryice/dryice.cpp | 9 | ||||
-rw-r--r-- | icetray/icetray/icetrayService.cpp | 10 | ||||
-rw-r--r-- | icetray/icetray/icetrayService.h | 1 | ||||
-rw-r--r-- | icetray/unittests/Jamfile.jam | 9 | ||||
-rw-r--r-- | icetray/unittests/testIceBoxInterface.cpp | 19 |
6 files changed, 38 insertions, 11 deletions
diff --git a/icetray/dryice/Jamfile.jam b/icetray/dryice/Jamfile.jam index 6df0569..0be9092 100644 --- a/icetray/dryice/Jamfile.jam +++ b/icetray/dryice/Jamfile.jam @@ -12,7 +12,6 @@ lib dryice : <library>..//pthread <library>..//boost_system <library>..//boost_thread - <library>..//dl <implicit-dependency>../icetray//icetray : : <include>. diff --git a/icetray/dryice/dryice.cpp b/icetray/dryice/dryice.cpp index 744e0a6..5223ca6 100644 --- a/icetray/dryice/dryice.cpp +++ b/icetray/dryice/dryice.cpp @@ -1,22 +1,15 @@ #include "dryice.h" #include <boost/assert.hpp> -#include <dlfcn.h> #include <factory.h> #include <Ice/Initialize.h> #include <Ice/ObjectAdapter.h> namespace IceTray { - typedef IceTray::Service *(* SetupFunction)(Ice::CommunicatorPtr); - DryIce * DryIce::currentDryIce = nullptr; DryIce::DryIce(const Ice::StringSeq & cmdline) { BOOST_ASSERT(!currentDryIce); - void * i = dlsym(NULL, "createIceTrayService"); - BOOST_VERIFY(i); - auto sf = (SetupFunction)i; - BOOST_VERIFY(sf); Ice::StringSeq args; Ice::InitializationData id; id.properties = Ice::createProperties(); @@ -24,7 +17,7 @@ namespace IceTray { id.properties->setProperty("DryIce.PoolProvider", "MockPool"); id.properties->parseCommandLineOptions("", cmdline); ic = Ice::initialize(args, id); - s = sf(nullptr); + s = Service::create(ic); s->start("DryIce", ic, {}); currentDryIce = this; } diff --git a/icetray/icetray/icetrayService.cpp b/icetray/icetray/icetrayService.cpp index d785632..d206c57 100644 --- a/icetray/icetray/icetrayService.cpp +++ b/icetray/icetray/icetrayService.cpp @@ -26,6 +26,12 @@ namespace IceTray { return current; } + Service * + Service::create(Ice::CommunicatorPtr) + { + return IceTray::ServiceFactory::createNew("default"); + } + void Service::start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq & args) { adp = ic->createObjectAdapter(name); @@ -80,9 +86,9 @@ namespace IceTray { extern "C" { DLL_PUBLIC IceBox::Service * - createIceTrayService(Ice::CommunicatorPtr) + createIceTrayService(Ice::CommunicatorPtr ic) { - return IceTray::ServiceFactory::createNew("default"); + return IceTray::Service::create(ic); } } diff --git a/icetray/icetray/icetrayService.h b/icetray/icetray/icetrayService.h index 63ccd7e..228d198 100644 --- a/icetray/icetray/icetrayService.h +++ b/icetray/icetray/icetrayService.h @@ -23,6 +23,7 @@ namespace IceTray { DatabasePoolPtr getConnectionPool(const Ice::CommunicatorPtr & ic, const std::string & type, const std::string & prefix); static Service * getCurrent(); + static Service * create(Ice::CommunicatorPtr); private: void configureLoggers(const Ice::ObjectAdapterPtr &, const Ice::PropertiesPtr &); diff --git a/icetray/unittests/Jamfile.jam b/icetray/unittests/Jamfile.jam index 8fd034a..ea78320 100644 --- a/icetray/unittests/Jamfile.jam +++ b/icetray/unittests/Jamfile.jam @@ -56,10 +56,19 @@ run <library>testCommon <library>boost_filesystem <library>dbpp-postgresql + <library>..//dl : testIceTray ; run + testIceBoxInterface.cpp + : : : + <library>testCommon + <library>testService + <library>..//dl + ; + +run testIceTrayReplace.cpp testIceTrayService.ice testIceTrayServiceI.cpp diff --git a/icetray/unittests/testIceBoxInterface.cpp b/icetray/unittests/testIceBoxInterface.cpp new file mode 100644 index 0000000..13febe0 --- /dev/null +++ b/icetray/unittests/testIceBoxInterface.cpp @@ -0,0 +1,19 @@ +#define BOOST_TEST_MODULE TestIceBoxInterface +#include <boost/test/unit_test.hpp> + +#include <dlfcn.h> +#include <icetrayService.h> + +BOOST_AUTO_TEST_CASE( IceBoxInterface ) +{ + typedef IceTray::Service *(* SetupFunction)(Ice::CommunicatorPtr); + + void * i = dlsym(NULL, "createIceTrayService"); + BOOST_REQUIRE(i); + auto sf = (SetupFunction)i; + BOOST_REQUIRE(sf); + auto service = sf(nullptr); + BOOST_REQUIRE(service); + delete service; +} + |