/* * Copyright (C) 2006 Registro.br. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * 1. Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY REGISTRO.BR ``AS IS AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIE OF FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL REGISTRO.BR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ /* $Id: LogoutTest.cpp 536 2006-03-03 15:00:29Z cesar $ */ #include "libepp_nicbr.H" #include "LogoutTest.H" #include "Logout.H" #include "FileUtil.H" #include "IoException.H" #include "XmlException.H" LIBEPP_NICBR_NS_USE CPPUNIT_TEST_SUITE_REGISTRATION(LogoutTest); LogoutTest::LogoutTest() {} LogoutTest::~LogoutTest() {} void LogoutTest::setUp() {} void LogoutTest::tearDown() {} void LogoutTest::xml_validation_test() { bool exception_caught = false; try { string xml_template = FileUtil::read_file("../docs/templates/logout.xml"); Logout logout; logout.get_command()->set_clTRID("ABC-12345"); logout.set_xml_template(xml_template); DomParser parser; parser.enable_validation("../docs/schemas"); parser.parse_command(logout.get_xml()); } catch (const IoException &e) { exception_caught = true; printf("\nIO Exception: code [%d] message [%s]", e.get_code(), e.get_msg().c_str()); } catch (const XmlException &e) { exception_caught = true; printf("\nXml Exception: code [%d] message [%s] low level message [%s]\n", e.get_code(), e.get_msg().c_str(), e.get_low_level_msg().c_str()); } CPPUNIT_ASSERT(!exception_caught); }