The configure method takes test_only flag so we can avoid
[metaproxy-moved-to-github.git] / src / test_filter_record_transform.cpp
1 /* $Id: test_filter_record_transform.cpp,v 1.8 2008-02-20 15:07:53 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 #define BOOST_TEST_DYN_LINK
35 #include <boost/test/auto_unit_test.hpp>
36
37 #include <iostream>
38
39
40 using namespace boost::unit_test;
41
42 namespace mp = metaproxy_1;
43 //using namespace mp::util;
44
45
46
47 BOOST_AUTO_TEST_CASE( test_filter_record_transform_1 )
48 {
49     try 
50     {
51         mp::filter::RecordTransform f_rec_trans;
52     }
53     catch ( ... ) {
54         BOOST_CHECK (false);
55     }
56 }
57
58 BOOST_AUTO_TEST_CASE( test_filter_record_transform_2 )
59 {
60     try 
61     {
62         mp::RouterChain router;
63         
64         mp::filter::RecordTransform f_rec_trans;
65         
66         router.append(f_rec_trans);
67
68         //check_sru_to_z3950_init(router);
69         //check_sru_to_z3950_search(router, 
70         //                           "@attrset Bib-1 @attr 1=4 the", 
71         //                           "@attrset Bib-1 @attr 1=4 the");
72
73     }
74     catch ( ... ) {
75         BOOST_CHECK (false);
76     }
77 }
78
79
80 BOOST_AUTO_TEST_CASE( test_filter_record_transform_3 )
81 {
82     
83
84     try 
85     {
86         mp::RouterChain router;
87         
88
89         std::string xmlconf = 
90             "<?xml version='1.0'?>\n"
91             "<filter xmlns='http://indexdata.com/metaproxy'\n"
92             "        id='rec_trans_1' type='record_transform'>\n"
93             "<retrievalinfo>"
94             "<retrieval" 
95             " syntax=\"usmarc\""
96             " name=\"marcxml\">"
97             "<backend syntax=\"usmarc\""
98             " name=\"marcxml\""
99             "/>"
100             "</retrieval>"
101             "</retrievalinfo>"
102             "</filter>\n"
103             ;
104          
105         //std::cout << xmlconf  << std::endl;
106
107         // reading and parsing XML conf
108         xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(), xmlconf.size());
109         BOOST_CHECK(doc);
110         xmlNode *root_element = xmlDocGetRootElement(doc);
111
112         // creating and configuring filter
113         mp::filter::RecordTransform f_rec_trans;
114         f_rec_trans.configure(root_element, true);
115         
116         // remeber to free XML DOM
117         xmlFreeDoc(doc);
118         
119         // add only filter to router
120         router.append(f_rec_trans);
121
122         // start testing
123         //check_sru_to_z3950_init(router);
124         //check_sru_to_z3950_search(router, 
125         //                           "@attrset Bib-1 @attr 1=4 the", 
126         //                           "@attrset Bib-1 @attr 1=4 the");
127
128     }
129
130     catch (std::exception &e) {
131         std::cout << e.what() << "\n";
132         BOOST_CHECK (false);
133     }
134
135     catch ( ... ) {
136         BOOST_CHECK (false);
137     }
138 }
139
140 /*
141  * Local variables:
142  * c-basic-offset: 4
143  * indent-tabs-mode: nil
144  * c-file-style: "stroustrup"
145  * End:
146  * vim: shiftwidth=4 tabstop=8 expandtab
147  */