9 #include "filter_frontend_net.hpp"
11 #define BOOST_AUTO_TEST_MAIN
12 #include <boost/test/auto_unit_test.hpp>
14 using namespace boost::unit_test;
16 class FilterInit: public yp2::Filter {
18 yp2::Package & process(yp2::Package & package) const {
19 ODR odr = odr_createmem(ODR_ENCODE);
20 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse);
22 apdu->u.initResponse->implementationName = "YP2/YAZ";
24 package.response() = apdu;
26 return package.move();
31 BOOST_AUTO_TEST_CASE( test_filter_frontend_net_1 )
36 yp2::FilterFrontendNet nf;
45 BOOST_AUTO_TEST_CASE( test_filter_frontend_net_2 )
50 yp2::RouterChain router;
58 yp2::Package pack_in(session, origin);
60 pack_in.router(router).move();
62 yazpp_1::GDU *gdu = &pack_in.response();
64 BOOST_CHECK_EQUAL(gdu->get()->which, Z_GDU_Z3950);
65 BOOST_CHECK_EQUAL(gdu->get()->u.z3950->which, Z_APDU_initResponse);
74 BOOST_AUTO_TEST_CASE( test_filter_frontend_net_3 )
79 yp2::RouterChain router;
81 yp2::FilterFrontendNet filter_front;
82 filter_front.listen_address() = "unix:socket";
83 filter_front.listen_duration() = 2; // listen a short time only
84 router.rule(filter_front);
86 FilterInit filter_init;
87 router.rule(filter_init);
91 yp2::Package pack_in(session, origin);
93 pack_in.router(router).move();
105 * indent-tabs-mode: nil
107 * vim: shiftwidth=4 tabstop=8 expandtab