Windows: use Boost 1.59, msvc 14.0
[metaproxy-moved-to-github.git] / src / test_filter_record_transform.cpp
1 /* This file is part of Metaproxy.
2    Copyright (C) Index Data
3
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #include "config.hpp"
20 #include "filter_record_transform.hpp"
21
22 #include <metaproxy/router_chain.hpp>
23 #include <metaproxy/package.hpp>
24
25 #define BOOST_AUTO_TEST_MAIN
26 #define BOOST_TEST_DYN_LINK
27 #include <boost/test/auto_unit_test.hpp>
28
29 #include <iostream>
30
31
32 using namespace boost::unit_test;
33
34 namespace mp = metaproxy_1;
35 //using namespace mp::util;
36
37
38
39 BOOST_AUTO_TEST_CASE( test_filter_record_transform_1 )
40 {
41     try
42     {
43         mp::filter::RecordTransform f_rec_trans;
44     }
45     catch ( ... ) {
46         BOOST_CHECK (false);
47     }
48 }
49
50 BOOST_AUTO_TEST_CASE( test_filter_record_transform_2 )
51 {
52     try
53     {
54         mp::RouterChain router;
55
56         mp::filter::RecordTransform f_rec_trans;
57
58         router.append(f_rec_trans);
59
60         //check_sru_to_z3950_init(router);
61         //check_sru_to_z3950_search(router,
62         //                           "@attrset Bib-1 @attr 1=4 the",
63         //                           "@attrset Bib-1 @attr 1=4 the");
64
65     }
66     catch ( ... ) {
67         BOOST_CHECK (false);
68     }
69 }
70
71
72 BOOST_AUTO_TEST_CASE( test_filter_record_transform_3 )
73 {
74
75
76     try
77     {
78         mp::RouterChain router;
79
80
81         std::string xmlconf =
82             "<?xml version='1.0'?>\n"
83             "<filter xmlns='http://indexdata.com/metaproxy'\n"
84             "        id='rec_trans_1' type='record_transform'>\n"
85             "<retrievalinfo>"
86             "<retrieval"
87             " syntax=\"usmarc\""
88             " name=\"marcxml\">"
89             "<backend syntax=\"usmarc\""
90             " name=\"marcxml\""
91             "/>"
92             "</retrieval>"
93             "</retrievalinfo>"
94             "</filter>\n"
95             ;
96
97         //std::cout << xmlconf  << std::endl;
98
99         // reading and parsing XML conf
100         xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(), xmlconf.size());
101         BOOST_CHECK(doc);
102         xmlNode *root_element = xmlDocGetRootElement(doc);
103
104         // creating and configuring filter
105         mp::filter::RecordTransform f_rec_trans;
106         f_rec_trans.configure(root_element, true, 0);
107
108         // remeber to free XML DOM
109         xmlFreeDoc(doc);
110
111         // add only filter to router
112         router.append(f_rec_trans);
113
114         // start testing
115         //check_sru_to_z3950_init(router);
116         //check_sru_to_z3950_search(router,
117         //                           "@attrset Bib-1 @attr 1=4 the",
118         //                           "@attrset Bib-1 @attr 1=4 the");
119
120     }
121
122     catch (std::exception &e) {
123         std::cout << e.what() << "\n";
124         BOOST_CHECK (false);
125     }
126
127     catch ( ... ) {
128         BOOST_CHECK (false);
129     }
130 }
131
132 /*
133  * Local variables:
134  * c-basic-offset: 4
135  * c-file-style: "Stroustrup"
136  * indent-tabs-mode: nil
137  * End:
138  * vim: shiftwidth=4 tabstop=8 expandtab
139  */
140