X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ftest_filter_query_rewrite.cpp;h=042a2709bef026709078dc29e48480da62bbb532;hb=0264192f26c10308aad161983ea29568c96521a6;hp=4badebe4989f9f13d8c2559b9d0cc3d520711a77;hpb=d4659f09509fea809cf32542b7a3cde662639ba9;p=metaproxy-moved-to-github.git diff --git a/src/test_filter_query_rewrite.cpp b/src/test_filter_query_rewrite.cpp index 4badebe..042a270 100644 --- a/src/test_filter_query_rewrite.cpp +++ b/src/test_filter_query_rewrite.cpp @@ -1,7 +1,22 @@ -/* $Id: test_filter_query_rewrite.cpp,v 1.8 2006-01-23 08:23:37 mike Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter_query_rewrite.cpp,v 1.14 2007-11-02 17:47:41 adam Exp $ + Copyright (c) 2005-2007, Index Data. -%LICENSE% +This file is part of Metaproxy. + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Metaproxy; see the file LICENSE. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ #include "config.hpp" @@ -15,14 +30,17 @@ #include "package.hpp" #define BOOST_AUTO_TEST_MAIN +#define BOOST_TEST_DYN_LINK #include using namespace boost::unit_test; -using namespace yp2::util; -class FilterBounceZ3950: public yp2::filter::Base { +namespace mp = metaproxy_1; +using namespace mp::util; + +class FilterBounceZ3950: public mp::filter::Base { public: - void process(yp2::Package & package) const { + void process(mp::Package & package) const { if (package.session().is_closed()) { @@ -61,14 +79,14 @@ public: }; }; -void check_query_rewrite_init(yp2::RouterChain &router) +void check_query_rewrite_init(mp::RouterChain &router) { //std::cout << "QUERY REWRITE INIT\n"; // Create package with Z39.50 init request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); pack.request() = apdu; @@ -91,7 +109,7 @@ void check_query_rewrite_init(yp2::RouterChain &router) } } -void check_query_rewrite_search(yp2::RouterChain &router, +void check_query_rewrite_search(mp::RouterChain &router, std::string query_in, std::string query_expect) { @@ -99,13 +117,13 @@ void check_query_rewrite_search(yp2::RouterChain &router, // << query_in << " " << query_expect << "\n"; // Create package with Z39.50 search request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_searchRequest); // create package PQF query here - yp2::util::pqf(odr, apdu, query_in); + mp::util::pqf(odr, apdu, query_in); // create package PDF database info (needed!) apdu->u.searchRequest->num_databaseNames = 1; @@ -139,24 +157,24 @@ void check_query_rewrite_search(yp2::RouterChain &router, } -BOOST_AUTO_UNIT_TEST( test_filter_query_rewrite_1 ) +BOOST_AUTO_TEST_CASE( test_filter_query_rewrite_1 ) { try { - yp2::filter::QueryRewrite f_query_rewrite; + mp::filter::QueryRewrite f_query_rewrite; } catch ( ... ) { BOOST_CHECK (false); } } -BOOST_AUTO_UNIT_TEST( test_filter_query_rewrite2 ) +BOOST_AUTO_TEST_CASE( test_filter_query_rewrite2 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::QueryRewrite f_query_rewrite; + mp::filter::QueryRewrite f_query_rewrite; //FilterBounceZ3950 f_bounce_z3950; router.append(f_query_rewrite); @@ -174,47 +192,19 @@ BOOST_AUTO_UNIT_TEST( test_filter_query_rewrite2 ) } -BOOST_AUTO_UNIT_TEST( test_filter_query_rewrite3 ) +BOOST_AUTO_TEST_CASE( test_filter_query_rewrite3 ) { try { - yp2::RouterChain router; + mp::RouterChain router; std::string xmlconf = "\n" - "\n" - " \n" - " @attrset XYZ\n" - " @attrset Bib-1\n" - " \n" - " \n" - " @attr 1=4\n" - " @attr 1=4 @attr 4=2\n" - " \n" - " \n" - " fish\n" - " cat\n" - " \n" - " \n" - " @attr 1=4\n" - " @attr 1=5 @attr 4=1\n" - " \n" - " \n" - " fish\n" - " mouse\n" - " \n" - " \n" - " ^\n" - " @and @attr1=9999 vdb\n" - " \n" - " \n" - " @attr 1=4 foo\n" - " @attr 1=1034 fish\n" - " \n" "\n" ; @@ -226,7 +216,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_query_rewrite3 ) xmlNode *root_element = xmlDocGetRootElement(doc); // creating and configuring filter - yp2::filter::QueryRewrite f_query_rewrite; + mp::filter::QueryRewrite f_query_rewrite; f_query_rewrite.configure(root_element); // remeber to free XML DOM