1 /* $Id: test_filter_frontend_net.cpp,v 1.13 2005-10-31 09:40:18 marc Exp $
2 Copyright (c) 2005, Index Data.
12 #include "filter_frontend_net.hpp"
14 #include "router_chain.hpp"
15 #include "session.hpp"
16 #include "package.hpp"
18 #define BOOST_AUTO_TEST_MAIN
19 #include <boost/test/auto_unit_test.hpp>
21 using namespace boost::unit_test;
23 class FilterInit: public yp2::filter::Base {
25 void process(yp2::Package & package) const {
27 if (package.session().is_closed())
29 // std::cout << "Got Close.\n";
32 Z_GDU *gdu = package.request().get();
35 // std::cout << "Got PDU. Sending init response\n";
37 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse);
39 apdu->u.initResponse->implementationName = "YP2/YAZ";
41 package.response() = apdu;
43 return package.move();
48 BOOST_AUTO_TEST_CASE( test_filter_frontend_net_1 )
53 yp2::filter::FrontendNet nf;
61 BOOST_AUTO_TEST_CASE( test_filter_frontend_net_2 )
66 yp2::RouterChain router;
72 // Create package with Z39.50 init request in it
76 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
78 pack.request() = apdu;
79 // Done creating query.
82 pack.router(router).move();
84 // Inspect that we got Z39.50 init response
85 yazpp_1::GDU *gdu = &pack.response();
87 Z_GDU *z_gdu = gdu->get();
90 BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950);
91 BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse);
100 BOOST_AUTO_TEST_CASE( test_filter_frontend_net_3 )
105 yp2::RouterChain router;
107 // put in frontend first
108 yp2::filter::FrontendNet filter_front;
110 std::vector <std::string> ports;
111 ports.insert(ports.begin(), "unix:socket");
112 filter_front.ports() = ports;
113 filter_front.listen_duration() = 1; // listen a short time only
114 router.append(filter_front);
117 FilterInit filter_init;
118 router.append(filter_init);
122 pack.router(router).move();
134 * indent-tabs-mode: nil
135 * c-file-style: "stroustrup"
137 * vim: shiftwidth=4 tabstop=8 expandtab