X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Ftest_router_flexml.cpp;h=5cefd7a4b637627563f28dcbbf6e4ff9a919d2fb;hb=14d0e634d5061208301502d813d488d1e82f190b;hp=e6ee8fc0d8443f4794eccda91f1ef32cc38ad2a8;hpb=63ea8aedbfd7dc56ab28dbc82c38b4458dcecb68;p=metaproxy-moved-to-github.git diff --git a/src/test_router_flexml.cpp b/src/test_router_flexml.cpp index e6ee8fc..5cefd7a 100644 --- a/src/test_router_flexml.cpp +++ b/src/test_router_flexml.cpp @@ -1,4 +1,4 @@ -/* $Id: test_router_flexml.cpp,v 1.8 2006-01-04 11:19:04 adam Exp $ +/* $Id: test_router_flexml.cpp,v 1.11 2006-01-04 14:30:51 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -10,18 +10,24 @@ #include "filter.hpp" #include "router_flexml.hpp" -#include "filter_factory.hpp" +#include "factory_static.hpp" #define BOOST_AUTO_TEST_MAIN #include using namespace boost::unit_test; +static bool tfilter_destroyed = false; class TFilter: public yp2::filter::Base { public: void process(yp2::Package & package) const {}; + ~TFilter() { tfilter_destroyed = true; }; }; - + +static yp2::filter::Base* filter_creator() +{ + return new TFilter; +} BOOST_AUTO_UNIT_TEST( test_router_flexml_1 ) { @@ -34,8 +40,14 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_1 ) " \n" " 210\n" " \n" - " \n" - " mylog.log\n" + " \n" + " mylog1.log\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " mylog2.log\n" " \n" " \n" " \n" @@ -45,19 +57,19 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_1 ) " \n" " \n" "\n"; - yp2::RouterFleXML rflexml(xmlconf); - } - catch ( yp2::RouterFleXML::XMLError &e) { - std::cout << "XMLError: " << e.what() << "\n"; - BOOST_CHECK (false); + + yp2::FactoryStatic factory; + factory.add_creator("tfilter", filter_creator); + yp2::RouterFleXML rflexml(xmlconf, factory); } - catch ( yp2::FilterFactoryException &e) { - std::cout << "FilterFactoryException: " << e.what() << "\n"; + catch ( std::runtime_error &e) { + std::cout << "std::runtime error: " << e.what() << "\n"; BOOST_CHECK (false); } catch ( ... ) { BOOST_CHECK (false); } + BOOST_CHECK(tfilter_destroyed == true); } BOOST_AUTO_UNIT_TEST( test_router_flexml_2 ) @@ -72,11 +84,16 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_2 ) " \n" " 210\n"; - yp2::RouterFleXML rflexml(xmlconf_invalid); + yp2::FactoryFilter factory; + yp2::RouterFleXML rflexml(xmlconf_invalid, factory); } catch ( yp2::RouterFleXML::XMLError &e) { got_xml_error = true; } + catch ( std::runtime_error &e) { + std::cout << "std::runtime error: " << e.what() << "\n"; + BOOST_CHECK (false); + } catch ( ... ) { ; } @@ -106,7 +123,12 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_3 ) " \n" "\n"; - yp2::RouterFleXML rflexml(xmlconf); + yp2::FactoryStatic factory; + yp2::RouterFleXML rflexml(xmlconf, factory); + } + catch ( std::runtime_error &e) { + std::cout << "std::runtime error: " << e.what() << "\n"; + BOOST_CHECK (false); } catch ( ... ) { BOOST_CHECK (false);