X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=src%2Ftest_router_flexml.cpp;h=05d7b845ce71c17688a629cc51a2f31631e191fa;hb=48f4e384860829966eacf4881fbf1ccbed38be6a;hp=039eca55aa3519e21666ab46fe68665f765f7b9e;hpb=6ed3503878603e0bae8ab0ee62bf900b3a60f2ca;p=metaproxy-moved-to-github.git diff --git a/src/test_router_flexml.cpp b/src/test_router_flexml.cpp index 039eca5..05d7b84 100644 --- a/src/test_router_flexml.cpp +++ b/src/test_router_flexml.cpp @@ -1,4 +1,4 @@ -/* $Id: test_router_flexml.cpp,v 1.6 2005-12-08 15:34:08 adam Exp $ +/* $Id: test_router_flexml.cpp,v 1.10 2006-01-04 14:15:45 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -10,17 +10,24 @@ #include "filter.hpp" #include "router_flexml.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 ) { @@ -28,28 +35,41 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_1 ) { std::string xmlconf = "\n" "\n" - "\n" - "\n" - "\n" - "210\n" - "\n" - "\n" - "mylog.log\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" + " \n" + " \n" + " \n" + " 210\n" + " \n" + " \n" + " mylog1.log\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " mylog2.log\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" "\n"; - - yp2::RouterFleXML rflexml(xmlconf); + + yp2::FactoryStatic factory; + factory.add_creator("tfilter", filter_creator); + 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); } + BOOST_CHECK(tfilter_destroyed == true); } BOOST_AUTO_UNIT_TEST( test_router_flexml_2 ) @@ -58,15 +78,22 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_2 ) try { std::string xmlconf_invalid = "\n" - "\n" - "\n" - "\n"; - - yp2::RouterFleXML rflexml(xmlconf_invalid); + "\n" + " \n" + " \n" + " \n" + " 210\n"; + + yp2::FilterFactory 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 ( ... ) { ; } @@ -79,24 +106,29 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_3 ) { std::string xmlconf = "\n" "\n" - " \n" - " \n" - " \n" + " \n" + " \n" + " \n" " 210\n" - " \n" - " \n" + " \n" + " \n" " mylog.log\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \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); @@ -104,7 +136,6 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_3 ) } - /* * Local variables: * c-basic-offset: 4