GPL v2.
[metaproxy-moved-to-github.git] / src / test_filter_record_transform.cpp
1 /* $Id: test_filter_record_transform.cpp,v 1.6 2007-05-09 21:23:09 adam Exp $
2    Copyright (c) 2005-2007, Index Data.
3
4 This file is part of Metaproxy.
5
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
9 version.
10
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
14 for more details.
15
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
19 02111-1307, USA.
20  */
21
22 #include "config.hpp"
23 #include "filter_record_transform.hpp"
24 //#include "util.hpp"
25 //#include "sru_util.hpp"
26 #include "router_chain.hpp"
27 #include "session.hpp"
28 #include "package.hpp"
29
30 //#include <iostream>
31 //#include <stdexcept>
32
33 #define BOOST_AUTO_TEST_MAIN
34 #include <boost/test/auto_unit_test.hpp>
35
36 #include <iostream>
37
38
39 using namespace boost::unit_test;
40
41 namespace mp = metaproxy_1;
42 //using namespace mp::util;
43
44
45
46 BOOST_AUTO_UNIT_TEST( test_filter_record_transform_1 )
47 {
48     try 
49     {
50         mp::filter::RecordTransform f_rec_trans;
51     }
52     catch ( ... ) {
53         BOOST_CHECK (false);
54     }
55 }
56
57 BOOST_AUTO_UNIT_TEST( test_filter_record_transform_2 )
58 {
59     try 
60     {
61         mp::RouterChain router;
62         
63         mp::filter::RecordTransform f_rec_trans;
64         
65         router.append(f_rec_trans);
66
67         //check_sru_to_z3950_init(router);
68         //check_sru_to_z3950_search(router, 
69         //                           "@attrset Bib-1 @attr 1=4 the", 
70         //                           "@attrset Bib-1 @attr 1=4 the");
71
72     }
73     catch ( ... ) {
74         BOOST_CHECK (false);
75     }
76 }
77
78
79 BOOST_AUTO_UNIT_TEST( test_filter_record_transform_3 )
80 {
81     
82
83     try 
84     {
85         mp::RouterChain router;
86         
87
88         std::string xmlconf = 
89             "<?xml version='1.0'?>\n"
90             "<filter xmlns='http://indexdata.com/metaproxy'\n"
91             "        id='rec_trans_1' type='record_transform'>\n"
92             "<retrievalinfo>"
93             "<retrieval" 
94             " syntax=\"usmarc\""
95             " name=\"marcxml\">"
96             "<backend syntax=\"usmarc\""
97             " name=\"marcxml\""
98             "/>"
99             "</retrieval>"
100             "</retrievalinfo>"
101             "</filter>\n"
102             ;
103          
104         //std::cout << xmlconf  << std::endl;
105
106         // reading and parsing XML conf
107         xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(), xmlconf.size());
108         BOOST_CHECK(doc);
109         xmlNode *root_element = xmlDocGetRootElement(doc);
110
111         // creating and configuring filter
112         mp::filter::RecordTransform f_rec_trans;
113         f_rec_trans.configure(root_element);
114         
115         // remeber to free XML DOM
116         xmlFreeDoc(doc);
117         
118         // add only filter to router
119         router.append(f_rec_trans);
120
121         // start testing
122         //check_sru_to_z3950_init(router);
123         //check_sru_to_z3950_search(router, 
124         //                           "@attrset Bib-1 @attr 1=4 the", 
125         //                           "@attrset Bib-1 @attr 1=4 the");
126
127     }
128
129     catch (std::exception &e) {
130         std::cout << e.what() << "\n";
131         BOOST_CHECK (false);
132     }
133
134     catch ( ... ) {
135         BOOST_CHECK (false);
136     }
137 }
138
139 /*
140  * Local variables:
141  * c-basic-offset: 4
142  * indent-tabs-mode: nil
143  * c-file-style: "stroustrup"
144  * End:
145  * vim: shiftwidth=4 tabstop=8 expandtab
146  */