projects
/
metaproxy-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Further work on filter registration in RouterFleXML
[metaproxy-moved-to-github.git]
/
src
/
test_router_flexml.cpp
diff --git
a/src/test_router_flexml.cpp
b/src/test_router_flexml.cpp
index
000ee0b
..
05d7b84
100644
(file)
--- a/
src/test_router_flexml.cpp
+++ b/
src/test_router_flexml.cpp
@@
-1,4
+1,4
@@
-/* $Id: test_router_flexml.cpp,v 1.7 2005-12-08 22:32:58 adam Exp $
+/* $Id: test_router_flexml.cpp,v 1.10 2006-01-04 14:15:45 adam Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
Copyright (c) 2005, Index Data.
%LICENSE%
@@
-10,17
+10,24
@@
#include "filter.hpp"
#include "router_flexml.hpp"
#include "filter.hpp"
#include "router_flexml.hpp"
+#include "factory_static.hpp"
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
using namespace boost::unit_test;
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
using namespace boost::unit_test;
+static bool tfilter_destroyed = false;
class TFilter: public yp2::filter::Base {
public:
void process(yp2::Package & package) const {};
class TFilter: public yp2::filter::Base {
public:
void process(yp2::Package & package) const {};
+ ~TFilter() { tfilter_destroyed = true; };
};
};
-
+
+static yp2::filter::Base* filter_creator()
+{
+ return new TFilter;
+}
BOOST_AUTO_UNIT_TEST( test_router_flexml_1 )
{
BOOST_AUTO_UNIT_TEST( test_router_flexml_1 )
{
@@
-30,11
+37,17
@@
BOOST_AUTO_UNIT_TEST( test_router_flexml_1 )
"<yp2 xmlns=\"http://indexdata.dk/yp2/config/1\">\n"
" <start route=\"start\"/>\n"
" <filters>\n"
"<yp2 xmlns=\"http://indexdata.dk/yp2/config/1\">\n"
" <start route=\"start\"/>\n"
" <filters>\n"
- " <filter id=\"front_default\" type=\"frontend-net\">\n"
+ " <filter id=\"front_default\" type=\"frontend_net\">\n"
" <port>210</port>\n"
" </filter>\n"
" <port>210</port>\n"
" </filter>\n"
- " <filter id=\"log_cout\" type=\"log\">\n"
- " <logfile>mylog.log</logfile>\n"
+ " <filter id=\"log_cout1\" type=\"log\">\n"
+ " <logfile>mylog1.log</logfile>\n"
+ " </filter>\n"
+ " <filter id=\"tfilter_id\" type=\"tfilter\">\n"
+ " <someelement/>\n"
+ " </filter>\n"
+ " <filter id=\"log_cout2\" type=\"log\">\n"
+ " <logfile>mylog2.log</logfile>\n"
" </filter>\n"
" </filters>\n"
" <routes>\n"
" </filter>\n"
" </filters>\n"
" <routes>\n"
@@
-44,11
+57,19
@@
BOOST_AUTO_UNIT_TEST( test_router_flexml_1 )
" </route>\n"
" </routes>\n"
"</yp2>\n";
" </route>\n"
" </routes>\n"
"</yp2>\n";
- yp2::RouterFleXML rflexml(xmlconf);
+
+ yp2::FactoryStatic factory;
+ factory.add_creator("tfilter", filter_creator);
+ yp2::RouterFleXML rflexml(xmlconf, factory);
+ }
+ catch ( std::runtime_error &e) {
+ std::cout << "std::runtime error: " << e.what() << "\n";
+ BOOST_CHECK (false);
}
catch ( ... ) {
BOOST_CHECK (false);
}
}
catch ( ... ) {
BOOST_CHECK (false);
}
+ BOOST_CHECK(tfilter_destroyed == true);
}
BOOST_AUTO_UNIT_TEST( test_router_flexml_2 )
}
BOOST_AUTO_UNIT_TEST( test_router_flexml_2 )
@@
-60,14
+81,19
@@
BOOST_AUTO_UNIT_TEST( test_router_flexml_2 )
"<y:yp2 xmlns:y=\"http://indexdata.dk/yp2/config/1\">\n"
" <start route=\"start\"/>\n"
" <filters>\n"
"<y:yp2 xmlns:y=\"http://indexdata.dk/yp2/config/1\">\n"
" <start route=\"start\"/>\n"
" <filters>\n"
- " <filter id=\"front_default\" type=\"frontend-net\">\n"
+ " <filter id=\"front_default\" type=\"frontend_net\">\n"
" <port>210</port>\n";
" <port>210</port>\n";
- yp2::RouterFleXML rflexml(xmlconf_invalid);
+ yp2::FilterFactory factory;
+ yp2::RouterFleXML rflexml(xmlconf_invalid, factory);
}
catch ( yp2::RouterFleXML::XMLError &e) {
got_xml_error = true;
}
}
catch ( yp2::RouterFleXML::XMLError &e) {
got_xml_error = true;
}
+ catch ( std::runtime_error &e) {
+ std::cout << "std::runtime error: " << e.what() << "\n";
+ BOOST_CHECK (false);
+ }
catch ( ... ) {
;
}
catch ( ... ) {
;
}
@@
-82,7
+108,7
@@
BOOST_AUTO_UNIT_TEST( test_router_flexml_3 )
"<y:yp2 xmlns:y=\"http://indexdata.dk/yp2/config/1\">\n"
" <y:start route=\"start\"/>\n"
" <y:filters>\n"
"<y:yp2 xmlns:y=\"http://indexdata.dk/yp2/config/1\">\n"
" <y:start route=\"start\"/>\n"
" <y:filters>\n"
- " <y:filter id=\"front_default\" type=\"frontend-net\">\n"
+ " <y:filter id=\"front_default\" type=\"frontend_net\">\n"
" <port>210</port>\n"
" </y:filter>\n"
" <y:filter id=\"log_cout\" type=\"log\">\n"
" <port>210</port>\n"
" </y:filter>\n"
" <y:filter id=\"log_cout\" type=\"log\">\n"
@@
-97,7
+123,12
@@
BOOST_AUTO_UNIT_TEST( test_router_flexml_3 )
" </y:routes>\n"
"</y:yp2>\n";
" </y:routes>\n"
"</y:yp2>\n";
- yp2::RouterFleXML rflexml(xmlconf);
+ yp2::FactoryStatic factory;
+ yp2::RouterFleXML rflexml(xmlconf, factory);
+ }
+ catch ( std::runtime_error &e) {
+ std::cout << "std::runtime error: " << e.what() << "\n";
+ BOOST_CHECK (false);
}
catch ( ... ) {
BOOST_CHECK (false);
}
catch ( ... ) {
BOOST_CHECK (false);