1 /* $Id: test_filter_frontend_net.cpp,v 1.15 2006-03-16 10:40:59 adam Exp $
2 Copyright (c) 2005-2006, 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;
22 namespace mp = metaproxy_1;
24 class FilterInit: public mp::filter::Base {
26 void process(mp::Package & package) const {
28 if (package.session().is_closed())
30 // std::cout << "Got Close.\n";
33 Z_GDU *gdu = package.request().get();
36 // std::cout << "Got PDU. Sending init response\n";
38 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse);
40 apdu->u.initResponse->implementationName = "YP2/YAZ";
42 package.response() = apdu;
44 return package.move();
49 BOOST_AUTO_UNIT_TEST( test_filter_frontend_net_1 )
54 mp::filter::FrontendNet nf;
62 BOOST_AUTO_UNIT_TEST( test_filter_frontend_net_2 )
67 mp::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);
101 BOOST_AUTO_UNIT_TEST( test_filter_frontend_net_3 )
106 mp::RouterChain router;
108 // put in frontend first
109 mp::filter::FrontendNet filter_front;
111 std::vector <std::string> ports;
112 ports.insert(ports.begin(), "unix:socket");
113 filter_front.ports() = ports;
114 filter_front.listen_duration() = 1; // listen a short time only
115 router.append(filter_front);
118 FilterInit filter_init;
119 router.append(filter_init);
123 pack.router(router).move();
135 * indent-tabs-mode: nil
136 * c-file-style: "stroustrup"
138 * vim: shiftwidth=4 tabstop=8 expandtab