diff options
-rw-r--r-- | icespider/core/core.cpp | 7 | ||||
-rw-r--r-- | icespider/core/core.h | 2 | ||||
-rw-r--r-- | icespider/unittests/testApp.cpp | 35 |
3 files changed, 42 insertions, 2 deletions
diff --git a/icespider/core/core.cpp b/icespider/core/core.cpp index 7c501c5..933fdc1 100644 --- a/icespider/core/core.cpp +++ b/icespider/core/core.cpp @@ -1,6 +1,7 @@ #include "core.h" #include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/classification.hpp> +#include <Ice/Initialize.h> namespace ba = boost::algorithm; @@ -18,10 +19,13 @@ namespace IceSpider { } mroutes[r->pathElementCount()].push_back(r); } + + communicator = Ice::initialize({}); } Core::~Core() { + if (communicator) communicator->destroy(); } void @@ -62,8 +66,7 @@ namespace IceSpider { Ice::ObjectPrx Core::getProxy(const char * type) const { - fprintf(stderr, "request for proxy type %s\n", type); - return NULL; + return communicator->propertyToProxy(type); } } diff --git a/icespider/core/core.h b/icespider/core/core.h index afca336..2f0a9a3 100644 --- a/icespider/core/core.h +++ b/icespider/core/core.h @@ -4,6 +4,7 @@ #include <visibility.h> #include <vector> #include "irouteHandler.h" +#include <Ice/Communicator.h> namespace IceSpider { class DLL_PUBLIC Core { @@ -21,6 +22,7 @@ namespace IceSpider { Ice::ObjectPrx getProxy(const char * type) const; MethodRoutes routes; + Ice::CommunicatorPtr communicator; }; } diff --git a/icespider/unittests/testApp.cpp b/icespider/unittests/testApp.cpp index 2c4e1b2..08c03b4 100644 --- a/icespider/unittests/testApp.cpp +++ b/icespider/unittests/testApp.cpp @@ -4,6 +4,8 @@ #include <plugins.h> #include <irouteHandler.h> #include <core.h> +#include <test-api.h> +#include <Ice/ObjectAdapter.h> using namespace UserIceSpider; @@ -86,4 +88,37 @@ BOOST_AUTO_TEST_CASE( testFindRoutes ) BOOST_REQUIRE(findRoute(&requestDeleteThing)); } +class TestSerice : public TestIceSpider::TestApi { + public: + TestIceSpider::SomeModelPtr index(const Ice::Current &) override + { + return NULL; + } + + TestIceSpider::SomeModelPtr withParams(const std::string &, Ice::Int, const Ice::Current &) override + { + return NULL; + } + + void returnNothing(const std::string &, const Ice::Current &) override + { + } + + void complexParam(const std::string &, const TestIceSpider::SomeModelPtr &, const Ice::Current &) override + { + } +}; + +BOOST_AUTO_TEST_CASE( testGetIndex ) +{ + auto adp = communicator->createObjectAdapterWithEndpoints("test", "default"); + auto obj = adp->addWithUUID(new TestSerice()); + adp->activate(); + TestRequest requestGetIndex(this, HttpMethod::GET, "/"); + fprintf(stderr, "%s\n", obj->ice_id().c_str()); + communicator->getProperties()->setProperty("N13TestIceSpider7TestApiE", communicator->proxyToString(obj)); + process(&requestGetIndex); + adp->deactivate(); +} + BOOST_AUTO_TEST_SUITE_END(); |