added xml ressources - most notably the LOC marc21-toXYZ stylesheets
[metaproxy-moved-to-github.git] / src / test_filter_record_transform.cpp
1 /* $Id: test_filter_record_transform.cpp,v 1.2 2006-10-04 11:21:47 marc Exp $
2    Copyright (c) 2005-2006, 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.dk/yp2/config/1'\n"
76             "        id='rec_trans_1' type='record_transform'>\n"
77             "<retrievalinfo>"
78             "<retrieval" 
79             " syntax=\"usmarc\""
80             " name=\"marcxml\""
81             " backendsyntax=\"usmarc\""
82             " backendname=\"marcxml\""
83             " identifier=\"info:srw/schema/1/marcxml-v1.1\""
84             ">"
85             "<convert/>"
86             "</retrieval>"
87             "</retrievalinfo>"
88             "</filter>\n"
89             ;
90          
91         //std::cout << xmlconf  << std::endl;
92
93         // reading and parsing XML conf
94         xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(), xmlconf.size());
95         BOOST_CHECK(doc);
96         xmlNode *root_element = xmlDocGetRootElement(doc);
97
98         // creating and configuring filter
99         mp::filter::RecordTransform f_rec_trans;
100         f_rec_trans.configure(root_element);
101         
102         // remeber to free XML DOM
103         xmlFreeDoc(doc);
104         
105         // add only filter to router
106         router.append(f_rec_trans);
107
108         // start testing
109         //check_sru_to_z3950_init(router);
110         //check_sru_to_z3950_search(router, 
111         //                           "@attrset Bib-1 @attr 1=4 the", 
112         //                           "@attrset Bib-1 @attr 1=4 the");
113
114     }
115
116     catch (std::exception &e) {
117         std::cout << e.what() << "\n";
118         BOOST_CHECK (false);
119     }
120
121     catch ( ... ) {
122         BOOST_CHECK (false);
123     }
124 }
125
126 /*
127  * Local variables:
128  * c-basic-offset: 4
129  * indent-tabs-mode: nil
130  * c-file-style: "stroustrup"
131  * End:
132  * vim: shiftwidth=4 tabstop=8 expandtab
133  */