1 /* $Id: test_filter_log.cpp,v 1.6 2005-10-30 17:13:36 adam Exp $
2 Copyright (c) 2005, Index Data.
11 #include "filter_log.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;
42 return package.move();
44 const std::string type() const {
45 return "FilterBounceInit";
50 BOOST_AUTO_TEST_CASE( test_filter_log_1 )
61 BOOST_AUTO_TEST_CASE( test_filter_log_2 )
65 yp2::RouterChain router;
73 // Create package with Z39.50 init request in it
77 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
79 pack.request() = apdu;
80 // Done creating query.
83 pack.router(router).move();
85 // Inspect that we got Z39.50 init response
86 yazpp_1::GDU *gdu = &pack.response();
88 Z_GDU *z_gdu = gdu->get();
91 BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950);
92 BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse);
103 * indent-tabs-mode: nil
104 * c-file-style: "stroustrup"
106 * vim: shiftwidth=4 tabstop=8 expandtab