1 /* $Id: test_router_flexml.cpp,v 1.8 2006-01-04 11:19:04 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_cout\" type=\"log\">\n"
38 " <logfile>mylog.log</logfile>\n"
42 " <route id=\"start\">\n"
43 " <filter refid=\"front_default\"/>\n"
44 " <filter refid=\"log_cout\"/>\n"
48 yp2::RouterFleXML rflexml(xmlconf);
50 catch ( yp2::RouterFleXML::XMLError &e) {
51 std::cout << "XMLError: " << e.what() << "\n";
54 catch ( yp2::FilterFactoryException &e) {
55 std::cout << "FilterFactoryException: " << e.what() << "\n";
63 BOOST_AUTO_UNIT_TEST( test_router_flexml_2 )
65 bool got_xml_error = false;
68 std::string xmlconf_invalid = "<?xml version=\"1.0\"?>\n"
69 "<y:yp2 xmlns:y=\"http://indexdata.dk/yp2/config/1\">\n"
70 " <start route=\"start\"/>\n"
72 " <filter id=\"front_default\" type=\"frontend_net\">\n"
73 " <port>210</port>\n";
75 yp2::RouterFleXML rflexml(xmlconf_invalid);
77 catch ( yp2::RouterFleXML::XMLError &e) {
83 BOOST_CHECK(got_xml_error);
86 BOOST_AUTO_UNIT_TEST( test_router_flexml_3 )
90 std::string xmlconf = "<?xml version=\"1.0\"?>\n"
91 "<y:yp2 xmlns:y=\"http://indexdata.dk/yp2/config/1\">\n"
92 " <y:start route=\"start\"/>\n"
94 " <y:filter id=\"front_default\" type=\"frontend_net\">\n"
97 " <y:filter id=\"log_cout\" type=\"log\">\n"
98 " <logfile>mylog.log</logfile>\n"
102 " <y:route id=\"start\">\n"
103 " <y:filter refid=\"front_default\"/>\n"
104 " <y:filter refid=\"log_cout\"/>\n"
109 yp2::RouterFleXML rflexml(xmlconf);
120 * indent-tabs-mode: nil
121 * c-file-style: "stroustrup"
123 * vim: shiftwidth=4 tabstop=8 expandtab