1 /* $Id: test_filter_frontend_net.cpp,v 1.20 2008-02-20 15:07:53 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.20 2008-02-20 15:07:53 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 #define BOOST_TEST_DYN_LINK
40 #include <boost/test/auto_unit_test.hpp>
42 using namespace boost::unit_test;
43 namespace mp = metaproxy_1;
45 class FilterInit: public mp::filter::Base {
47 void process(mp::Package & package) const {
49 if (package.session().is_closed())
51 // std::cout << "Got Close.\n";
54 Z_GDU *gdu = package.request().get();
57 // std::cout << "Got PDU. Sending init response\n";
59 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse);
61 apdu->u.initResponse->implementationName = "YP2/YAZ";
63 package.response() = apdu;
65 return package.move();
70 BOOST_AUTO_TEST_CASE( test_filter_frontend_net_1 )
75 mp::filter::FrontendNet nf;
83 BOOST_AUTO_TEST_CASE( test_filter_frontend_net_2 )
88 mp::RouterChain router;
94 // Create package with Z39.50 init request in it
98 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
100 pack.request() = apdu;
101 // Done creating query.
104 pack.router(router).move();
106 // Inspect that we got Z39.50 init response
107 yazpp_1::GDU *gdu = &pack.response();
109 Z_GDU *z_gdu = gdu->get();
112 BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950);
113 BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse);
122 BOOST_AUTO_TEST_CASE( test_filter_frontend_net_3 )
127 mp::RouterChain router;
129 // put in frontend first
130 mp::filter::FrontendNet filter_front;
132 std::vector <std::string> ports;
133 ports.insert(ports.begin(), "unix:socket");
134 filter_front.set_ports(ports);
135 filter_front.set_listen_duration(1); // listen a short time only
136 router.append(filter_front);
139 FilterInit filter_init;
140 router.append(filter_init);
144 pack.router(router).move();
156 * indent-tabs-mode: nil
157 * c-file-style: "stroustrup"
159 * vim: shiftwidth=4 tabstop=8 expandtab