1 /* $Id: test_filter_multi.cpp,v 1.1 2006-01-15 20:03:14 adam Exp $
2 Copyright (c) 2005, Index Data.
11 #include "filter_multi.hpp"
13 #include "router_chain.hpp"
14 #include "session.hpp"
15 #include "package.hpp"
17 #define BOOST_AUTO_TEST_MAIN
18 #include <boost/test/auto_unit_test.hpp>
20 using namespace boost::unit_test;
22 class FilterBounceInit: public yp2::filter::Base {
24 void process(yp2::Package & package) const {
26 if (package.session().is_closed())
28 // std::cout << "Got Close.\n";
31 Z_GDU *gdu = package.request().get();
34 // std::cout << "Got PDU. Sending init response\n";
36 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse);
38 apdu->u.initResponse->implementationName = "YP2/YAZ";
40 package.response() = apdu;
47 BOOST_AUTO_UNIT_TEST( test_filter_multi_1 )
51 yp2::filter::Multi lf;
58 BOOST_AUTO_UNIT_TEST( test_filter_multi_2 )
62 yp2::RouterChain router;
64 yp2::filter::Multi multi;
65 FilterBounceInit bounce;
68 router.append(bounce);
70 // Create package with Z39.50 init request in it
74 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
76 pack.request() = apdu;
77 // Done creating query.
80 pack.router(router).move();
82 // Inspect that we got Z39.50 init response
83 yazpp_1::GDU *gdu = &pack.response();
85 Z_GDU *z_gdu = gdu->get();
88 BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950);
89 BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse);
100 * indent-tabs-mode: nil
101 * c-file-style: "stroustrup"
103 * vim: shiftwidth=4 tabstop=8 expandtab