1 /* $Id: test_filter_z3950_client.cpp,v 1.2 2005-10-16 16:09:58 adam Exp $
2 Copyright (c) 2005, Index Data.
11 #include "filter_z3950_client.hpp"
14 #include "session.hpp"
15 #include "package.hpp"
17 #define BOOST_AUTO_TEST_MAIN
18 #include <boost/test/auto_unit_test.hpp>
21 #include <yaz/otherinfo.h>
22 using namespace boost::unit_test;
25 BOOST_AUTO_TEST_CASE( test_filter_z3950_client_1 )
30 yp2::filter::Z3950Client zc;
38 BOOST_AUTO_TEST_CASE( test_filter_z3950_client_2 )
42 yp2::RouterChain router;
44 yp2::filter::Z3950Client zc;
48 // Create package with Z39.50 init request in it
51 ODR odr = odr_createmem(ODR_ENCODE);
52 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
56 pack.request() = apdu;
60 pack.router(router).move();
62 // Inspect that we got Z39.50 init Response - a Z39.50 session
63 // specify a virtual host
64 yazpp_1::GDU *gdu = &pack.response();
66 BOOST_CHECK(pack.session().is_closed());
68 Z_GDU *z_gdu = gdu->get();
71 BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950);
72 BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse);
80 BOOST_AUTO_TEST_CASE( test_filter_z3950_client_3 )
84 yp2::RouterChain router;
86 yp2::filter::Z3950Client zc;
90 // Create package with Z39.50 present request in it
93 ODR odr = odr_createmem(ODR_ENCODE);
94 Z_APDU *apdu = zget_APDU(odr, Z_APDU_presentRequest);
98 pack.request() = apdu;
102 pack.router(router).move();
104 // Inspect that we got Z39.50 close - a Z39.50 session must start
106 yazpp_1::GDU *gdu = &pack.response();
108 BOOST_CHECK(pack.session().is_closed());
110 Z_GDU *z_gdu = gdu->get();
113 BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950);
114 BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_close);
122 BOOST_AUTO_TEST_CASE( test_filter_z3950_client_4 )
126 yp2::RouterChain router;
128 yp2::filter::Z3950Client zc;
132 // Create package with Z39.50 init request in it
135 ODR odr = odr_createmem(ODR_ENCODE);
136 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
138 const char *vhost = "localhost:9999";
140 yaz_oi_set_string_oidval(&apdu->u.initRequest->otherInfo,
141 odr, VAL_PROXY, 1, vhost);
144 pack.request() = apdu;
148 pack.router(router).move();
150 if (pack.session().is_closed())
152 // OK, server was not up!
156 // Inspect that we got Z39.50 init response
157 yazpp_1::GDU *gdu = &pack.response();
158 Z_GDU *z_gdu = gdu->get();
161 BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950);
162 BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse);
175 * indent-tabs-mode: nil
176 * c-file-style: "stroustrup"
178 * vim: shiftwidth=4 tabstop=8 expandtab