X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ftest_filter_virt_db.cpp;h=db30cb76f46e5d1fd5f80bac1bc029aa42c4b1ef;hb=586d78659d671683f33ec55f4a7d32b28e345ccd;hp=8d5994d2b6393bf8ee0170a62052f48aeba6340f;hpb=637a685d61a9ff0e3f398a59da426979815c4d68;p=metaproxy-moved-to-github.git diff --git a/src/test_filter_virt_db.cpp b/src/test_filter_virt_db.cpp index 8d5994d..db30cb7 100644 --- a/src/test_filter_virt_db.cpp +++ b/src/test_filter_virt_db.cpp @@ -1,7 +1,5 @@ -/* $Id: test_filter_virt_db.cpp,v 1.17 2007-05-09 21:23:09 adam Exp $ - Copyright (c) 2005-2007, Index Data. - -This file is part of Metaproxy. +/* This file is part of Metaproxy. + Copyright (C) Index Data 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 @@ -14,25 +12,24 @@ 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. - */ +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include "config.hpp" #include #include -#include "util.hpp" +#include #include "filter_virt_db.hpp" #include "filter_backend_test.hpp" #include "filter_log.hpp" -#include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include +#include #define BOOST_AUTO_TEST_MAIN +#define BOOST_TEST_DYN_LINK #include #include @@ -42,9 +39,9 @@ using namespace boost::unit_test; namespace mp = metaproxy_1; -BOOST_AUTO_UNIT_TEST( test_filter_virt_db_1 ) +BOOST_AUTO_TEST_CASE( test_filter_virt_db_1 ) { - try + try { mp::filter::VirtualDB vdb; } @@ -53,36 +50,36 @@ BOOST_AUTO_UNIT_TEST( test_filter_virt_db_1 ) } } -BOOST_AUTO_UNIT_TEST( test_filter_virt_db_2 ) +BOOST_AUTO_TEST_CASE( test_filter_virt_db_2 ) { - try + try { mp::RouterChain router; - + mp::filter::VirtualDB vdb; - + router.append(vdb); - + // Create package with Z39.50 init request in it // Since there is not vhost given, the virt will make its // own init response (regardless of backend) mp::Package pack; - + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); - + BOOST_CHECK(apdu); - + pack.request() = apdu; - + // Put it in router - pack.router(router).move(); - + pack.router(router).move(); + // Inspect that we got Z39.50 init Response OK. yazpp_1::GDU *gdu = &pack.response(); - - BOOST_CHECK(!pack.session().is_closed()); - + + BOOST_CHECK(!pack.session().is_closed()); + Z_GDU *z_gdu = gdu->get(); BOOST_CHECK(z_gdu); if (z_gdu) { @@ -101,21 +98,21 @@ static void init(mp::Package &pack, mp::Router &router) // Create package with Z39.50 init request in it mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); - + BOOST_CHECK(apdu); if (!apdu) return; - + pack.request() = apdu; - + // Put it in router - pack.router(router).move(); - + pack.router(router).move(); + // Inspect that we got Z39.50 init response yazpp_1::GDU *gdu = &pack.response(); - - BOOST_CHECK(!pack.session().is_closed()); - + + BOOST_CHECK(!pack.session().is_closed()); + Z_GDU *z_gdu = gdu->get(); BOOST_CHECK(z_gdu); if (!z_gdu) @@ -123,42 +120,42 @@ static void init(mp::Package &pack, mp::Router &router) BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950); BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse); } - + static void search(mp::Package &pack, mp::Router &router, const std::string &query, const char *db, const char *setname) { // Create package with Z39.50 search request in it - + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_searchRequest); mp::util::pqf(odr, apdu, query); apdu->u.searchRequest->resultSetName = odr_strdup(odr, setname); - + apdu->u.searchRequest->num_databaseNames = 1; apdu->u.searchRequest->databaseNames = (char**) odr_malloc(odr, sizeof(char *)); apdu->u.searchRequest->databaseNames[0] = odr_strdup(odr, db); - + BOOST_CHECK(apdu); if (!apdu) return; - + pack.request() = apdu; - + Z_GDU *gdu_test = pack.request().get(); BOOST_CHECK(gdu_test); - + // Put it in router - pack.router(router).move(); - + pack.router(router).move(); + // Inspect that we got Z39.50 search response yazpp_1::GDU *gdu = &pack.response(); - - BOOST_CHECK(!pack.session().is_closed()); - + + BOOST_CHECK(!pack.session().is_closed()); + Z_GDU *z_gdu = gdu->get(); BOOST_CHECK(z_gdu); if (!z_gdu) @@ -172,10 +169,10 @@ static void present(mp::Package &pack, mp::Router &router, const char *setname) { // Create package with Z39.50 present request in it - + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_presentRequest); - + apdu->u.presentRequest->resultSetId = odr_strdup(odr, setname); *apdu->u.presentRequest->resultSetStartPoint = start; *apdu->u.presentRequest->numberOfRecordsRequested = number; @@ -183,20 +180,20 @@ static void present(mp::Package &pack, mp::Router &router, BOOST_CHECK(apdu); if (!apdu) return; - + pack.request() = apdu; - + Z_GDU *gdu_test = pack.request().get(); BOOST_CHECK(gdu_test); - + // Put it in router - pack.router(router).move(); - + pack.router(router).move(); + // Inspect that we got Z39.50 present response yazpp_1::GDU *gdu = &pack.response(); - - BOOST_CHECK(!pack.session().is_closed()); - + + BOOST_CHECK(!pack.session().is_closed()); + Z_GDU *z_gdu = gdu->get(); BOOST_CHECK(z_gdu); if (!z_gdu) @@ -205,9 +202,9 @@ static void present(mp::Package &pack, mp::Router &router, BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_presentResponse); } -BOOST_AUTO_UNIT_TEST( test_filter_virt_db_3 ) +BOOST_AUTO_TEST_CASE( test_filter_virt_db_3 ) { - try + try { mp::RouterChain router; @@ -215,8 +212,8 @@ BOOST_AUTO_UNIT_TEST( test_filter_virt_db_3 ) #if 0 router.append(filter_log1); #endif - - mp::filter::VirtualDB vdb; + + mp::filter::VirtualDB vdb; router.append(vdb); vdb.add_map_db2target("Default", "localhost:210", ""); mp::filter::Log filter_log2("BACK"); @@ -228,7 +225,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_virt_db_3 ) mp::Session session1; mp::Origin origin1; - + { mp::Package pack(session1, origin1); init(pack, router); @@ -258,8 +255,9 @@ BOOST_AUTO_UNIT_TEST( test_filter_virt_db_3 ) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil - * c-file-style: "stroustrup" * End: * vim: shiftwidth=4 tabstop=8 expandtab */ +