From e9ff72d4db1cf37166ebf136b8fd97a4e4124adb Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 16 Sep 2016 23:36:16 +0100 Subject: Remove previous serializer before adding replacement --- icespider/core/irouteHandler.cpp | 1 + icespider/unittests/testApp.cpp | 4 ++-- icespider/unittests/testCompile.cpp | 4 ++-- icespider/unittests/testRoutes.json | 13 +++++++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/icespider/core/irouteHandler.cpp b/icespider/core/irouteHandler.cpp index e096e9c..9d33a6b 100644 --- a/icespider/core/irouteHandler.cpp +++ b/icespider/core/irouteHandler.cpp @@ -43,6 +43,7 @@ namespace IceSpider { void IRouteHandler::addRouteSerializer(const MimeType & ct, StreamSerializerFactoryPtr ssfp) { + routeSerializers.erase(ct); routeSerializers.insert({ ct, ssfp }); } diff --git a/icespider/unittests/testApp.cpp b/icespider/unittests/testApp.cpp index eec91a6..5db7cfd 100644 --- a/icespider/unittests/testApp.cpp +++ b/icespider/unittests/testApp.cpp @@ -26,7 +26,7 @@ void forceEarlyChangeDir() BOOST_AUTO_TEST_CASE( testLoadConfiguration ) { - BOOST_REQUIRE_EQUAL(8, AdHoc::PluginManager::getDefault()->getAll().size()); + BOOST_REQUIRE_EQUAL(9, AdHoc::PluginManager::getDefault()->getAll().size()); } class TestRequest : public IHttpRequest { @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE( testCoreSettings ) BOOST_REQUIRE_EQUAL(6, routes.size()); BOOST_REQUIRE_EQUAL(5, routes[HttpMethod::GET].size()); BOOST_REQUIRE_EQUAL(1, routes[HttpMethod::GET][0].size()); - BOOST_REQUIRE_EQUAL(0, routes[HttpMethod::GET][1].size()); + BOOST_REQUIRE_EQUAL(1, routes[HttpMethod::GET][1].size()); BOOST_REQUIRE_EQUAL(1, routes[HttpMethod::GET][2].size()); BOOST_REQUIRE_EQUAL(2, routes[HttpMethod::GET][3].size()); BOOST_REQUIRE_EQUAL(2, routes[HttpMethod::GET][4].size()); diff --git a/icespider/unittests/testCompile.cpp b/icespider/unittests/testCompile.cpp index 130b762..425821f 100644 --- a/icespider/unittests/testCompile.cpp +++ b/icespider/unittests/testCompile.cpp @@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE( testLoadConfiguration ) rc.applyDefaults(cfg, u); BOOST_REQUIRE_EQUAL("common", cfg->name); - BOOST_REQUIRE_EQUAL(8, cfg->routes.size()); + BOOST_REQUIRE_EQUAL(9, cfg->routes.size()); BOOST_REQUIRE_EQUAL("index", cfg->routes[0]->name); BOOST_REQUIRE_EQUAL("/", cfg->routes[0]->path); @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE( testLoad ) BOOST_TEST_INFO(dlerror()); BOOST_REQUIRE(lib); - BOOST_REQUIRE_EQUAL(8, AdHoc::PluginManager::getDefault()->getAll().size()); + BOOST_REQUIRE_EQUAL(9, AdHoc::PluginManager::getDefault()->getAll().size()); // smoke test (block ensure dlclose dones't cause segfault) { auto route = AdHoc::PluginManager::getDefault()->get("common::index"); diff --git a/icespider/unittests/testRoutes.json b/icespider/unittests/testRoutes.json index a7b3f82..d2d713a 100644 --- a/icespider/unittests/testRoutes.json +++ b/icespider/unittests/testRoutes.json @@ -102,6 +102,19 @@ } } } + }, + { + "name": "override", + "path": "/override", + "method": "GET", + "outputSerializers": [ + { + "contentType": "application/xml", + "serializer": "IceSpider.XsltStreamSerializer", + "params": [ "\"xslt/transform.xslt\"" ] + } + ], + "operation": "TestIceSpider.TestApi.index" } ], "slices": [ -- cgit v1.2.3