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