X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ftest_filter_rewrite.cpp;h=e3802a7531ca597a4054471778271654aac0d033;hb=2bde9b746dfd661553c28a129a667363cc7a1581;hp=d266274baf328ed1fe7860f518717173dcdcb786;hpb=2c08da821832998446e5fe92acf4d1e87fe531d4;p=metaproxy-moved-to-github.git diff --git a/src/test_filter_rewrite.cpp b/src/test_filter_rewrite.cpp index d266274..e3802a7 100644 --- a/src/test_filter_rewrite.cpp +++ b/src/test_filter_rewrite.cpp @@ -38,7 +38,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA using namespace boost::unit_test; namespace mp = metaproxy_1; - +/* + * The global testconfig is commented out, as it won't even compile + * on old Centos5 machines struct TestConfig { TestConfig() { @@ -52,6 +54,7 @@ struct TestConfig { }; BOOST_GLOBAL_FIXTURE( TestConfig ); +*/ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) { @@ -60,27 +63,36 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) std::cout << "Running non-xml config test case" << std::endl; mp::RouterChain router; mp::filter::HttpRewrite fhr; - - //configure the filter - mp::filter::HttpRewrite::spair_vec vec_req; - vec_req.push_back(std::make_pair( - "(?http\\:\\/\\/s?)(?[^\\/?#]+)\\/(?[^\\/]+)" - "\\/(?[^\\/]+)(?.*)", - "${proto}${host}${path}" - )); - vec_req.push_back(std::make_pair( - "(?:Host\\: )(.*)", - "Host: ${host}" - )); - - mp::filter::HttpRewrite::spair_vec vec_res; - vec_res.push_back(std::make_pair( - "(?http\\:\\/\\/s?)(?[^\\/?# \"'>]+)\\/(?[^ \"'>]+)", - "${proto}${pxhost}/${pxpath}/${host}/${path}" - )); - - fhr.configure(vec_req, vec_res); - + + std::string xmlconf = + "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n" + ; + + std::cout << xmlconf; + + // reading and parsing XML conf + xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(), xmlconf.size()); + BOOST_CHECK(doc); + xmlNode *root_element = xmlDocGetRootElement(doc); + fhr.configure(root_element, true, ""); + xmlFreeDoc(doc); + router.append(fhr); // create an http request @@ -179,7 +191,7 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) resp_result = odr_getbuf(enc, &resp_result_len, 0); BOOST_CHECK(resp_result); - BOOST_CHECK_EQUAL(resp_result_len, strlen(resp_expected)); + BOOST_CHECK_EQUAL((size_t) resp_result_len, strlen(resp_expected)); std::cout << "Rewriten result:\n" << resp_result << std::endl; std::cout << "Rewriten result buf len: " << resp_result_len