All filters declare a yp2_filter_struct - used for both static and
[metaproxy-moved-to-github.git] / src / test_filter_virt_db.cpp
index 56e82ed..4ec8efc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: test_filter_virt_db.cpp,v 1.5 2005-10-26 10:21:03 marc Exp $
+/* $Id: test_filter_virt_db.cpp,v 1.9 2005-12-02 12:21:07 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -8,7 +8,7 @@
 #include <iostream>
 #include <stdexcept>
 
-#include "test_util.hpp"
+#include "util.hpp"
 #include "filter_virt_db.hpp"
 #include "filter_backend_test.hpp"
 #include "filter_log.hpp"
@@ -26,7 +26,7 @@
 using namespace boost::unit_test;
 
 
-BOOST_AUTO_TEST_CASE( test_filter_virt_db_1 )
+BOOST_AUTO_UNIT_TEST( test_filter_virt_db_1 )
 {
     try 
     {
@@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE( test_filter_virt_db_1 )
     }
 }
 
-BOOST_AUTO_TEST_CASE( test_filter_virt_db_2 )
+BOOST_AUTO_UNIT_TEST( test_filter_virt_db_2 )
 {
     try 
     {
@@ -45,20 +45,19 @@ BOOST_AUTO_TEST_CASE( test_filter_virt_db_2 )
         
         yp2::filter::Virt_db vdb;
         
-        router.rule(vdb);
+        router.append(vdb);
         
         // Create package with Z39.50 init request in it
         // Since there is not vhost given, the virt will make its
         // own init response (regardless of backend)
         yp2::Package pack;
         
-        ODR odr = odr_createmem(ODR_ENCODE);
+        yp2::odr odr;
         Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
         
         BOOST_CHECK(apdu);
         
         pack.request() = apdu;
-        odr_destroy(odr);
         
         // Put it in router
         pack.router(router).move(); 
@@ -84,7 +83,7 @@ BOOST_AUTO_TEST_CASE( test_filter_virt_db_2 )
 static void init(yp2::Package &pack, yp2::Router &router)
 {
     // Create package with Z39.50 init request in it
-    ODR odr = odr_createmem(ODR_ENCODE);
+    yp2::odr odr;
     Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
     
     BOOST_CHECK(apdu);
@@ -92,7 +91,6 @@ static void init(yp2::Package &pack, yp2::Router &router)
         return;
     
     pack.request() = apdu;
-    odr_destroy(odr);
     
     // Put it in router
     pack.router(router).move(); 
@@ -116,7 +114,7 @@ static void search(yp2::Package &pack, yp2::Router &router,
 {
     // Create package with Z39.50 search request in it
             
-    ODR odr = odr_createmem(ODR_ENCODE);
+    yp2::odr odr;
     Z_APDU *apdu = zget_APDU(odr, Z_APDU_searchRequest);
 
     yp2::util::pqf(odr, apdu, query);
@@ -134,8 +132,6 @@ static void search(yp2::Package &pack, yp2::Router &router,
     
     pack.request() = apdu;
     
-    odr_destroy(odr);
-    
     Z_GDU *gdu_test = pack.request().get();
     BOOST_CHECK(gdu_test);
     
@@ -161,7 +157,7 @@ static void present(yp2::Package &pack, yp2::Router &router,
 {
     // Create package with Z39.50 present request in it
             
-    ODR odr = odr_createmem(ODR_ENCODE);
+    yp2::odr odr;
     Z_APDU *apdu = zget_APDU(odr, Z_APDU_presentRequest);
     
     apdu->u.presentRequest->resultSetId  = odr_strdup(odr, setname);
@@ -174,8 +170,6 @@ static void present(yp2::Package &pack, yp2::Router &router,
     
     pack.request() = apdu;
     
-    odr_destroy(odr);
-    
     Z_GDU *gdu_test = pack.request().get();
     BOOST_CHECK(gdu_test);
     
@@ -195,7 +189,7 @@ static void present(yp2::Package &pack, yp2::Router &router,
     BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_presentResponse);
 }
 
-BOOST_AUTO_TEST_CASE( test_filter_virt_db_3 )
+BOOST_AUTO_UNIT_TEST( test_filter_virt_db_3 )
 {
     try 
     {
@@ -203,18 +197,18 @@ BOOST_AUTO_TEST_CASE( test_filter_virt_db_3 )
 
         yp2::filter::Log filter_log1("FRONT");
 #if 0
-        router.rule(filter_log1);
+        router.append(filter_log1);
 #endif
    
         yp2::filter::Virt_db vdb;        
-        router.rule(vdb);
+        router.append(vdb);
         vdb.add_map_db2vhost("Default", "localhost:210");
         yp2::filter::Log filter_log2("BACK");
 #if 0
-        router.rule(filter_log2);
+        router.append(filter_log2);
 #endif
         yp2::filter::Backend_test btest;
-        router.rule(btest);
+        router.append(btest);
 
         yp2::Session session1;
         yp2::Origin origin1;