1 /* $Id: test_router_flexml.cpp,v 1.9 2006-01-04 11:55:32 adam Exp $
2 Copyright (c) 2005, Index Data.
12 #include "router_flexml.hpp"
13 #include "filter_factory.hpp"
15 #define BOOST_AUTO_TEST_MAIN
16 #include <boost/test/auto_unit_test.hpp>
18 using namespace boost::unit_test;
20 class TFilter: public yp2::filter::Base {
22 void process(yp2::Package & package) const {};
26 BOOST_AUTO_UNIT_TEST( test_router_flexml_1 )
30 std::string xmlconf = "<?xml version=\"1.0\"?>\n"
31 "<yp2 xmlns=\"http://indexdata.dk/yp2/config/1\">\n"
32 " <start route=\"start\"/>\n"
34 " <filter id=\"front_default\" type=\"frontend_net\">\n"
37 " <filter id=\"log_cout1\" type=\"log\">\n"
38 " <logfile>mylog1.log</logfile>\n"
40 " <filter id=\"log_cout2\" type=\"log\">\n"
41 " <logfile>mylog2.log</logfile>\n"
45 " <route id=\"start\">\n"
46 " <filter refid=\"front_default\"/>\n"
47 " <filter refid=\"log_cout\"/>\n"
51 yp2::RouterFleXML rflexml(xmlconf);
53 catch ( yp2::RouterFleXML::XMLError &e) {
54 std::cout << "XMLError: " << e.what() << "\n";
57 catch ( yp2::FilterFactoryException &e) {
58 std::cout << "FilterFactoryException: " << e.what() << "\n";
66 BOOST_AUTO_UNIT_TEST( test_router_flexml_2 )
68 bool got_xml_error = false;
71 std::string xmlconf_invalid = "<?xml version=\"1.0\"?>\n"
72 "<y:yp2 xmlns:y=\"http://indexdata.dk/yp2/config/1\">\n"
73 " <start route=\"start\"/>\n"
75 " <filter id=\"front_default\" type=\"frontend_net\">\n"
76 " <port>210</port>\n";
78 yp2::RouterFleXML rflexml(xmlconf_invalid);
80 catch ( yp2::RouterFleXML::XMLError &e) {
86 BOOST_CHECK(got_xml_error);
89 BOOST_AUTO_UNIT_TEST( test_router_flexml_3 )
93 std::string xmlconf = "<?xml version=\"1.0\"?>\n"
94 "<y:yp2 xmlns:y=\"http://indexdata.dk/yp2/config/1\">\n"
95 " <y:start route=\"start\"/>\n"
97 " <y:filter id=\"front_default\" type=\"frontend_net\">\n"
100 " <y:filter id=\"log_cout\" type=\"log\">\n"
101 " <logfile>mylog.log</logfile>\n"
105 " <y:route id=\"start\">\n"
106 " <y:filter refid=\"front_default\"/>\n"
107 " <y:filter refid=\"log_cout\"/>\n"
112 yp2::RouterFleXML rflexml(xmlconf);
123 * indent-tabs-mode: nil
124 * c-file-style: "stroustrup"
126 * vim: shiftwidth=4 tabstop=8 expandtab