/* * 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: DomParserTest.cpp 531 2006-03-01 22:15:55Z koji $ */ #include #include #include "libepp_nicbr.H" #include "XmlException.H" #include "StrUtil.H" #include "DomParserTest.H" using std::auto_ptr; using std::map; LIBEPP_NICBR_NS_USE CPPUNIT_TEST_SUITE_REGISTRATION(DomParserTest); DomParserTest::DomParserTest(): _parser(0) { try { _parser = new DomParser(); } catch (...) { } } DomParserTest::~DomParserTest() { if (_parser) { delete _parser; } } void DomParserTest::setUp() {} void DomParserTest::tearDown() {} void DomParserTest::enable_validation_test() { bool exception_caught = false; _parser->enable_validation("../docs/schemas"); string xml_payload = "Greeting"; try { auto_ptr greeting(new Greeting()); _parser->parse_greeting(xml_payload, greeting.get()); } catch (const XmlException &e) { exception_caught = true; } CPPUNIT_ASSERT(exception_caught); } void DomParserTest::disable_validation_test() { bool exception_caught = false; _parser->disable_validation(); string xml_payload = "Greeting"; try { auto_ptr greeting(new Greeting()); _parser->parse_greeting(xml_payload, greeting.get()); } catch (const XmlException &e) { exception_caught = true; } CPPUNIT_ASSERT(!exception_caught); } void DomParserTest::parse_command_test() { bool exception_caught = false; _parser->enable_validation("../docs/schemas/"); string xml_payload = "" "" "" "Nic.BR Server" "2006-01-27T15:48:00.0Z" "" "1.0" "pt" "en" "sp" "urn:ietf:params:xml:ns:contact" "urn:ietf:params:xml:ns:domain" "urn:ietf:params:xml:ns:organization" "" "http://registro.br/contactext-1.0" "http://registro.br/domainext-1.0" "http://registro.br/organizationext-1.0" "" "" "" "" "" "" "" "" "Provedor de Serviços" "" "" "" "" "" "" "2008-01-01T00:00:00.0Z" "" "" "" ""; try { _parser->parse_command(xml_payload); } catch (const XmlException &e) { exception_caught = true; } CPPUNIT_ASSERT(!exception_caught); }