From 7844faac6a2693c70da1aef10ee5f2eb160fc8a3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 19 Jun 2016 19:18:23 +0100 Subject: Test call into a real implementation of service --- icespider/core/core.cpp | 7 +++++-- icespider/core/core.h | 2 ++ 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 #include +#include 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 #include #include "irouteHandler.h" +#include 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 #include #include +#include +#include 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(); -- cgit v1.2.3