X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ftest_filter_frontend_net.cpp;h=1c9b8c26d2fa279fc46fc8a474376f4e0f0f84bd;hb=d50228aa34df04bcef967019f584437d058368d2;hp=a8e51163ebb69e3c824e1c54f538c67169d4fb28;hpb=834e7cda28e6f15fb39e0f58ce51268ef8b36ac4;p=metaproxy-moved-to-github.git diff --git a/src/test_filter_frontend_net.cpp b/src/test_filter_frontend_net.cpp index a8e5116..1c9b8c2 100644 --- a/src/test_filter_frontend_net.cpp +++ b/src/test_filter_frontend_net.cpp @@ -16,14 +16,14 @@ using namespace boost::unit_test; class FilterInit: public yp2::Filter { public: - yp2::Package & process(yp2::Package & package) const { + void process(yp2::Package & package) const { - Z_GDU *gdu = package.request().get(); if (package.session().is_closed()) { - // std::cout << "Got Close. Sending nothing\n"; + // std::cout << "Got Close.\n"; } + Z_GDU *gdu = package.request().get(); if (gdu) { // std::cout << "Got PDU. Sending init response\n"; @@ -47,7 +47,6 @@ BOOST_AUTO_TEST_CASE( test_filter_frontend_net_1 ) { yp2::FilterFrontendNet nf; } - BOOST_CHECK(true); } catch ( ... ) { BOOST_CHECK (false); @@ -66,22 +65,20 @@ BOOST_AUTO_TEST_CASE( test_filter_frontend_net_2 ) router.rule(tf); // Create package with Z39.50 init request in it - yp2::Session session; - yp2::Origin origin; - yp2::Package pack_in(session, origin); + yp2::Package pack; ODR odr = odr_createmem(ODR_ENCODE); Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); - pack_in.request() = apdu; + pack.request() = apdu; odr_destroy(odr); // Done creating query. // Put it in router - pack_in.router(router).move(); + pack.router(router).move(); // Inspect that we got Z39.50 init response - yazpp_1::GDU *gdu = &pack_in.response(); + yazpp_1::GDU *gdu = &pack.response(); Z_GDU *z_gdu = gdu->get(); BOOST_CHECK(z_gdu); @@ -90,7 +87,6 @@ BOOST_AUTO_TEST_CASE( test_filter_frontend_net_2 ) BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse); } } - BOOST_CHECK(true); } catch ( ... ) { BOOST_CHECK (false); @@ -103,19 +99,20 @@ BOOST_AUTO_TEST_CASE( test_filter_frontend_net_3 ) { { yp2::RouterChain router; + + // put in frontend first yp2::FilterFrontendNet filter_front; filter_front.listen_address() = "unix:socket"; - filter_front.listen_duration() = 2; // listen a short time only + filter_front.listen_duration() = 1; // listen a short time only router.rule(filter_front); + // put in a backend FilterInit filter_init; router.rule(filter_init); - yp2::Session session; - yp2::Origin origin; - yp2::Package pack_in(session, origin); + yp2::Package pack; - pack_in.router(router).move(); + pack.router(router).move(); } BOOST_CHECK(true); }