1 /* $Id: test_filter_frontend_net.cpp,v 1.18 2007-05-09 21:23:09 adam Exp $
2 Copyright (c) 2005-2007, Index Data.
4 This file is part of Metaproxy.
6 Metaproxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with Metaproxy; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 /* $Id: test_filter_frontend_net.cpp,v 1.18 2007-05-09 21:23:09 adam Exp $
22 Copyright (c) 2005-2007, Index Data.
24 See the LICENSE file for details
32 #include "filter_frontend_net.hpp"
34 #include "router_chain.hpp"
35 #include "session.hpp"
36 #include "package.hpp"
38 #define BOOST_AUTO_TEST_MAIN
39 #include <boost/test/auto_unit_test.hpp>
41 using namespace boost::unit_test;
42 namespace mp = metaproxy_1;
44 class FilterInit: public mp::filter::Base {
46 void process(mp::Package & package) const {
48 if (package.session().is_closed())
50 // std::cout << "Got Close.\n";
53 Z_GDU *gdu = package.request().get();
56 // std::cout << "Got PDU. Sending init response\n";
58 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse);
60 apdu->u.initResponse->implementationName = "YP2/YAZ";
62 package.response() = apdu;
64 return package.move();
69 BOOST_AUTO_UNIT_TEST( test_filter_frontend_net_1 )
74 mp::filter::FrontendNet nf;
82 BOOST_AUTO_UNIT_TEST( test_filter_frontend_net_2 )
87 mp::RouterChain router;
93 // Create package with Z39.50 init request in it
97 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
99 pack.request() = apdu;
100 // Done creating query.
103 pack.router(router).move();
105 // Inspect that we got Z39.50 init response
106 yazpp_1::GDU *gdu = &pack.response();
108 Z_GDU *z_gdu = gdu->get();
111 BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950);
112 BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse);
121 BOOST_AUTO_UNIT_TEST( test_filter_frontend_net_3 )
126 mp::RouterChain router;
128 // put in frontend first
129 mp::filter::FrontendNet filter_front;
131 std::vector <std::string> ports;
132 ports.insert(ports.begin(), "unix:socket");
133 filter_front.ports() = ports;
134 filter_front.listen_duration() = 1; // listen a short time only
135 router.append(filter_front);
138 FilterInit filter_init;
139 router.append(filter_init);
143 pack.router(router).move();
155 * indent-tabs-mode: nil
156 * c-file-style: "stroustrup"
158 * vim: shiftwidth=4 tabstop=8 expandtab