X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ftest_filter_rewrite.cpp;h=0050b4012716e005ed27a8dd05b42e4655986457;hb=61eac1ac42c75e21780707bf238a6d8a19068f05;hp=90c17d666d66da7480cd893edd07b21704e29278;hpb=df9b11da1202e8af0eb10633a44405e45c94800e;p=metaproxy-moved-to-github.git diff --git a/src/test_filter_rewrite.cpp b/src/test_filter_rewrite.cpp index 90c17d6..0050b40 100644 --- a/src/test_filter_rewrite.cpp +++ b/src/test_filter_rewrite.cpp @@ -42,14 +42,14 @@ namespace mp = metaproxy_1; * The global testconfig is commented out, as it won't even compile * on old Centos5 machines struct TestConfig { - TestConfig() + TestConfig() { - std::cout << "global setup\n"; + std::cout << "global setup\n"; yaz_log_init_level(YLOG_ALL); } - ~TestConfig() - { - std::cout << "global teardown\n"; + ~TestConfig() + { + std::cout << "global teardown\n"; } }; @@ -63,23 +63,44 @@ 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; - + std::string xmlconf = "\n" "\n" - " \n" - " https?://)(?<pxhost>[^ /?#]+)/(?<pxpath>[^ /]+)" "/(?<host>[^ /]+)(?<path>[^ ]*)'\n" " to='${proto}${host}${path}' />\n" - " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" " \n" - " \n" - " \n" + " \n" + " \n" + " to='${proto}${pxhost}/${pxpath}/${host}/${path}' />\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" " \n" "\n" ; @@ -92,14 +113,14 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) xmlNode *root_element = xmlDocGetRootElement(doc); fhr.configure(root_element, true, ""); xmlFreeDoc(doc); - + router.append(fhr); // create an http request mp::Package pack; mp::odr odr; - Z_GDU *gdu_req = z_get_HTTP_Request_uri(odr, + Z_GDU *gdu_req = z_get_HTTP_Request_uri(odr, "http://proxyhost/proxypath/targetsite/page1.html", 0, 1); pack.request() = gdu_req; @@ -120,20 +141,24 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) "}" "" "" - "" + "" "" "

Welcome to our website. It doesn't make it easy to get pro" "xified" "" " An absolute link" - "" " An absolute link" - "\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 - mp::Package pack; - - mp::odr odr; - Z_GDU *gdu_req = z_get_HTTP_Request_uri(odr, - "http://proxyhost/proxypath/targetsite/page1.html", 0, 1); - - pack.request() = gdu_req; - - //create the http response - - const char *resp_buf = - "HTTP/1.1 200 OK\r\n" - "Content-Length: 50\r\n" - "Content-Type: text/html\r\n" - "Link: ; rel=absolute\r\n" - "Link: ; rel=relative\r\n" - "\r\n" - "Hello proxy!" - "" - "" - "" - "" - "

Welcome to our website. It doesn't make it easy to get pro" - "xified" - "" - " An absolute link" - "" - "" - "" - "" - "

Welcome to our website. It doesn't make it easy to get pro" - "xified" - "" - " An absolute link" - "