xml tests fix

This commit is contained in:
Marian Krivos
2011-09-14 16:13:26 +00:00
parent d589a60abe
commit 87f604a743
8 changed files with 872 additions and 347 deletions

View File

@@ -320,8 +320,18 @@ void SAXParserTest::testCharacters()
void SAXParserTest::testParseMemory()
{
SAXParser parser;
std::string xml = parseMemory(parser, XMLWriter::CANONICAL, ATTRIBUTES);
assert (xml == ATTRIBUTES);
std::string xml = parseMemory(parser, XMLWriter::CANONICAL | XMLWriter::PRETTY_PRINT, WSDL);
assert (xml == WSDL);
}
void SAXParserTest::testParsePartialReads()
{
SAXParser parser;
parser.setFeature("http://www.appinf.com/features/enable-partial-reads", true);
std::string xml = parse(parser, XMLWriter::CANONICAL | XMLWriter::PRETTY_PRINT, WSDL);
assert (xml == WSDL);
}
@@ -340,6 +350,7 @@ std::string SAXParserTest::parse(XMLReader& reader, int options, const std::stri
std::istringstream istr(data);
std::ostringstream ostr;
XMLWriter writer(ostr, options);
writer.setNewLine(XMLWriter::NEWLINE_LF);
reader.setContentHandler(&writer);
reader.setDTDHandler(&writer);
reader.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER, static_cast<Poco::XML::LexicalHandler*>(&writer));
@@ -351,9 +362,10 @@ std::string SAXParserTest::parse(XMLReader& reader, int options, const std::stri
std::string SAXParserTest::parseMemory(XMLReader& reader, int options, const std::string& data)
{
std::istringstream istr(data);
std::ostringstream ostr;
XMLWriter writer(ostr, options);
std::istringstream istr(data);
std::ostringstream ostr;
XMLWriter writer(ostr, options);
writer.setNewLine(XMLWriter::NEWLINE_LF);
reader.setContentHandler(&writer);
reader.setDTDHandler(&writer);
reader.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER, static_cast<Poco::XML::LexicalHandler*>(&writer));
@@ -383,13 +395,14 @@ CppUnit::Test* SAXParserTest::suite()
CppUnit_addTest(pSuite, SAXParserTest, testNoNamespaces);
CppUnit_addTest(pSuite, SAXParserTest, testUndeclaredNamespace);
CppUnit_addTest(pSuite, SAXParserTest, testUndeclaredNamespaceNoPrefixes);
CppUnit_addTest(pSuite, SAXParserTest, testUndeclaredNoNamespace);
CppUnit_addTest(pSuite, SAXParserTest, testRSS);
CppUnit_addTest(pSuite, SAXParserTest, testEncoding);
CppUnit_addTest(pSuite, SAXParserTest, testParseMemory);
CppUnit_addTest(pSuite, SAXParserTest, testCharacters);
CppUnit_addTest(pSuite, SAXParserTest, testUndeclaredNoNamespace);
CppUnit_addTest(pSuite, SAXParserTest, testRSS);
CppUnit_addTest(pSuite, SAXParserTest, testEncoding);
CppUnit_addTest(pSuite, SAXParserTest, testCharacters);
CppUnit_addTest(pSuite, SAXParserTest, testParseMemory);
CppUnit_addTest(pSuite, SAXParserTest, testParsePartialReads);
return pSuite;
return pSuite;
}
@@ -1034,3 +1047,148 @@ const std::string SAXParserTest::RSS =
const std::string SAXParserTest::ENCODING =
"<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>"
"<euro-sign>\244</euro-sign>";
const std::string SAXParserTest::WSDL =
"<!-- WSDL description of the Google Web APIs.\n"
" The Google Web APIs are in beta release. All interfaces are subject to\n"
" change as we refine and extend our APIs. Please see the terms of use\n"
" for more information. -->\n"
"<!-- Revision 2002-08-16 -->\n"
"<ns1:definitions name=\"GoogleSearch\" targetNamespace=\"urn:GoogleSearch\" xmlns:ns1=\"http://schemas.xmlsoap.org/wsdl/\">\n"
"\t<!-- Types for search - result elements, directory categories -->\n"
"\t<ns1:types>\n"
"\t\t<ns2:schema targetNamespace=\"urn:GoogleSearch\" xmlns:ns2=\"http://www.w3.org/2001/XMLSchema\">\n"
"\t\t\t<ns2:complexType name=\"GoogleSearchResult\">\n"
"\t\t\t\t<ns2:all>\n"
"\t\t\t\t\t<ns2:element name=\"documentFiltering\" type=\"xsd:boolean\"/>\n"
"\t\t\t\t\t<ns2:element name=\"searchComments\" type=\"xsd:string\"/>\n"
"\t\t\t\t\t<ns2:element name=\"estimatedTotalResultsCount\" type=\"xsd:int\"/>\n"
"\t\t\t\t\t<ns2:element name=\"estimateIsExact\" type=\"xsd:boolean\"/>\n"
"\t\t\t\t\t<ns2:element name=\"resultElements\" type=\"typens:ResultElementArray\"/>\n"
"\t\t\t\t\t<ns2:element name=\"searchQuery\" type=\"xsd:string\"/>\n"
"\t\t\t\t\t<ns2:element name=\"startIndex\" type=\"xsd:int\"/>\n"
"\t\t\t\t\t<ns2:element name=\"endIndex\" type=\"xsd:int\"/>\n"
"\t\t\t\t\t<ns2:element name=\"searchTips\" type=\"xsd:string\"/>\n"
"\t\t\t\t\t<ns2:element name=\"directoryCategories\" type=\"typens:DirectoryCategoryArray\"/>\n"
"\t\t\t\t\t<ns2:element name=\"searchTime\" type=\"xsd:double\"/>\n"
"\t\t\t\t</ns2:all>\n"
"\t\t\t</ns2:complexType>\n"
"\t\t\t<ns2:complexType name=\"ResultElement\">\n"
"\t\t\t\t<ns2:all>\n"
"\t\t\t\t\t<ns2:element name=\"summary\" type=\"xsd:string\"/>\n"
"\t\t\t\t\t<ns2:element name=\"URL\" type=\"xsd:string\"/>\n"
"\t\t\t\t\t<ns2:element name=\"snippet\" type=\"xsd:string\"/>\n"
"\t\t\t\t\t<ns2:element name=\"title\" type=\"xsd:string\"/>\n"
"\t\t\t\t\t<ns2:element name=\"cachedSize\" type=\"xsd:string\"/>\n"
"\t\t\t\t\t<ns2:element name=\"relatedInformationPresent\" type=\"xsd:boolean\"/>\n"
"\t\t\t\t\t<ns2:element name=\"hostName\" type=\"xsd:string\"/>\n"
"\t\t\t\t\t<ns2:element name=\"directoryCategory\" type=\"typens:DirectoryCategory\"/>\n"
"\t\t\t\t\t<ns2:element name=\"directoryTitle\" type=\"xsd:string\"/>\n"
"\t\t\t\t</ns2:all>\n"
"\t\t\t</ns2:complexType>\n"
"\t\t\t<ns2:complexType name=\"ResultElementArray\">\n"
"\t\t\t\t<ns2:complexContent>\n"
"\t\t\t\t\t<ns2:restriction base=\"soapenc:Array\">\n"
"\t\t\t\t\t\t<ns2:attribute ns1:arrayType=\"typens:ResultElement[]\" ref=\"soapenc:arrayType\"/>\n"
"\t\t\t\t\t</ns2:restriction>\n"
"\t\t\t\t</ns2:complexContent>\n"
"\t\t\t</ns2:complexType>\n"
"\t\t\t<ns2:complexType name=\"DirectoryCategoryArray\">\n"
"\t\t\t\t<ns2:complexContent>\n"
"\t\t\t\t\t<ns2:restriction base=\"soapenc:Array\">\n"
"\t\t\t\t\t\t<ns2:attribute ns1:arrayType=\"typens:DirectoryCategory[]\" ref=\"soapenc:arrayType\"/>\n"
"\t\t\t\t\t</ns2:restriction>\n"
"\t\t\t\t</ns2:complexContent>\n"
"\t\t\t</ns2:complexType>\n"
"\t\t\t<ns2:complexType name=\"DirectoryCategory\">\n"
"\t\t\t\t<ns2:all>\n"
"\t\t\t\t\t<ns2:element name=\"fullViewableName\" type=\"xsd:string\"/>\n"
"\t\t\t\t\t<ns2:element name=\"specialEncoding\" type=\"xsd:string\"/>\n"
"\t\t\t\t</ns2:all>\n"
"\t\t\t</ns2:complexType>\n"
"\t\t</ns2:schema>\n"
"\t</ns1:types>\n"
"\t<!-- Messages for Google Web APIs - cached page, search, spelling. -->\n"
"\t<ns1:message name=\"doGetCachedPage\">\n"
"\t\t<ns1:part name=\"key\" type=\"xsd:string\"/>\n"
"\t\t<ns1:part name=\"url\" type=\"xsd:string\"/>\n"
"\t</ns1:message>\n"
"\t<ns1:message name=\"doGetCachedPageResponse\">\n"
"\t\t<ns1:part name=\"return\" type=\"xsd:base64Binary\"/>\n"
"\t</ns1:message>\n"
"\t<ns1:message name=\"doSpellingSuggestion\">\n"
"\t\t<ns1:part name=\"key\" type=\"xsd:string\"/>\n"
"\t\t<ns1:part name=\"phrase\" type=\"xsd:string\"/>\n"
"\t</ns1:message>\n"
"\t<ns1:message name=\"doSpellingSuggestionResponse\">\n"
"\t\t<ns1:part name=\"return\" type=\"xsd:string\"/>\n"
"\t</ns1:message>\n"
"\t<!-- note, ie and oe are ignored by server; all traffic is UTF-8. -->\n"
"\t<ns1:message name=\"doGoogleSearch\">\n"
"\t\t<ns1:part name=\"key\" type=\"xsd:string\"/>\n"
"\t\t<ns1:part name=\"q\" type=\"xsd:string\"/>\n"
"\t\t<ns1:part name=\"start\" type=\"xsd:int\"/>\n"
"\t\t<ns1:part name=\"maxResults\" type=\"xsd:int\"/>\n"
"\t\t<ns1:part name=\"filter\" type=\"xsd:boolean\"/>\n"
"\t\t<ns1:part name=\"restrict\" type=\"xsd:string\"/>\n"
"\t\t<ns1:part name=\"safeSearch\" type=\"xsd:boolean\"/>\n"
"\t\t<ns1:part name=\"lr\" type=\"xsd:string\"/>\n"
"\t\t<ns1:part name=\"ie\" type=\"xsd:string\"/>\n"
"\t\t<ns1:part name=\"oe\" type=\"xsd:string\"/>\n"
"\t</ns1:message>\n"
"\t<ns1:message name=\"doGoogleSearchResponse\">\n"
"\t\t<ns1:part name=\"return\" type=\"typens:GoogleSearchResult\"/>\n"
"\t</ns1:message>\n"
"\t<!-- Port for Google Web APIs, \"GoogleSearch\" -->\n"
"\t<ns1:portType name=\"GoogleSearchPort\">\n"
"\t\t<ns1:operation name=\"doGetCachedPage\">\n"
"\t\t\t<ns1:input message=\"typens:doGetCachedPage\"/>\n"
"\t\t\t<ns1:output message=\"typens:doGetCachedPageResponse\"/>\n"
"\t\t</ns1:operation>\n"
"\t\t<ns1:operation name=\"doSpellingSuggestion\">\n"
"\t\t\t<ns1:input message=\"typens:doSpellingSuggestion\"/>\n"
"\t\t\t<ns1:output message=\"typens:doSpellingSuggestionResponse\"/>\n"
"\t\t</ns1:operation>\n"
"\t\t<ns1:operation name=\"doGoogleSearch\">\n"
"\t\t\t<ns1:input message=\"typens:doGoogleSearch\"/>\n"
"\t\t\t<ns1:output message=\"typens:doGoogleSearchResponse\"/>\n"
"\t\t</ns1:operation>\n"
"\t</ns1:portType>\n"
"\t<!-- Binding for Google Web APIs - RPC, SOAP over HTTP -->\n"
"\t<ns1:binding name=\"GoogleSearchBinding\" type=\"typens:GoogleSearchPort\">\n"
"\t\t<ns3:binding style=\"rpc\" transport=\"http://schemas.xmlsoap.org/soap/http\" xmlns:ns3=\"http://schemas.xmlsoap.org/wsdl/soap/\"/>\n"
"\t\t<ns1:operation name=\"doGetCachedPage\" xmlns:ns3=\"http://schemas.xmlsoap.org/wsdl/soap/\">\n"
"\t\t\t<ns3:operation soapAction=\"urn:GoogleSearchAction\"/>\n"
"\t\t\t<ns1:input>\n"
"\t\t\t\t<ns3:body encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" namespace=\"urn:GoogleSearch\" use=\"encoded\"/>\n"
"\t\t\t</ns1:input>\n"
"\t\t\t<ns1:output>\n"
"\t\t\t\t<ns3:body encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" namespace=\"urn:GoogleSearch\" use=\"encoded\"/>\n"
"\t\t\t</ns1:output>\n"
"\t\t</ns1:operation>\n"
"\t\t<ns1:operation name=\"doSpellingSuggestion\" xmlns:ns3=\"http://schemas.xmlsoap.org/wsdl/soap/\">\n"
"\t\t\t<ns3:operation soapAction=\"urn:GoogleSearchAction\"/>\n"
"\t\t\t<ns1:input>\n"
"\t\t\t\t<ns3:body encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" namespace=\"urn:GoogleSearch\" use=\"encoded\"/>\n"
"\t\t\t</ns1:input>\n"
"\t\t\t<ns1:output>\n"
"\t\t\t\t<ns3:body encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" namespace=\"urn:GoogleSearch\" use=\"encoded\"/>\n"
"\t\t\t</ns1:output>\n"
"\t\t</ns1:operation>\n"
"\t\t<ns1:operation name=\"doGoogleSearch\" xmlns:ns3=\"http://schemas.xmlsoap.org/wsdl/soap/\">\n"
"\t\t\t<ns3:operation soapAction=\"urn:GoogleSearchAction\"/>\n"
"\t\t\t<ns1:input>\n"
"\t\t\t\t<ns3:body encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" namespace=\"urn:GoogleSearch\" use=\"encoded\"/>\n"
"\t\t\t</ns1:input>\n"
"\t\t\t<ns1:output>\n"
"\t\t\t\t<ns3:body encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" namespace=\"urn:GoogleSearch\" use=\"encoded\"/>\n"
"\t\t\t</ns1:output>\n"
"\t\t</ns1:operation>\n"
"\t</ns1:binding>\n"
"\t<!-- Endpoint for Google Web APIs -->\n"
"\t<ns1:service name=\"GoogleSearchService\">\n"
"\t\t<ns1:port binding=\"typens:GoogleSearchBinding\" name=\"GoogleSearchPort\">\n"
"\t\t\t<ns4:address location=\"http://api.google.com/search/beta2\" xmlns:ns4=\"http://schemas.xmlsoap.org/wsdl/soap/\"/>\n"
"\t\t</ns1:port>\n"
"\t</ns1:service>\n"
"</ns1:definitions>\n";