diff options
author | Mohammed Abdul Azeem <azeemmysore@gmail.com> | 2016-07-18 13:17:19 +0530 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2016-07-19 14:17:15 +0000 |
commit | 3aa52d36824d11b8774de15708fdfcbb93cd9dc3 (patch) | |
tree | da30a99082cdb0d774e5a452344a976abf6a4bb5 /sax/qa/cppunit | |
parent | 495cfa27c173741caa233575438c18746272b4aa (diff) |
GSOC - Handling namespace declaration missing case:
initialization parameter to FastParser will turn off
the namespace declaration missing exception. Test cases
have also been given to verify the same.
Change-Id: I4c3e02c7ad92d50e279f895ced53c78fc8f49b91
Reviewed-on: https://gerrit.libreoffice.org/27278
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sax/qa/cppunit')
-rw-r--r-- | sax/qa/cppunit/xmlimport.cxx | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/sax/qa/cppunit/xmlimport.cxx b/sax/qa/cppunit/xmlimport.cxx index c0320fc00351..f7fcd739d4c3 100644 --- a/sax/qa/cppunit/xmlimport.cxx +++ b/sax/qa/cppunit/xmlimport.cxx @@ -278,10 +278,12 @@ public: XMLImportTest() : BootstrapFixture(true, false) {} void parse(); + void testMissingNamespaceDeclaration(); void testIllegalNamespaceUse(); CPPUNIT_TEST_SUITE( XMLImportTest ); CPPUNIT_TEST( parse ); + CPPUNIT_TEST( testMissingNamespaceDeclaration ); CPPUNIT_TEST( testIllegalNamespaceUse ); CPPUNIT_TEST_SUITE_END(); }; @@ -317,11 +319,11 @@ void XMLImportTest::parse() source.aInputStream = createStreamFromFile( m_sDirPath + fileNames[i] ); m_xParser->parseStream(source); - const OUString& rParserStr = m_xDocumentHandler->getString(); + const OUString rParserStr = m_xDocumentHandler->getString(); source.aInputStream = createStreamFromFile( m_sDirPath + fileNames[i] ); m_xLegacyFastParser->parseStream(source); - const OUString& rLegacyFastParserStr = m_xDocumentHandler->getString(); + const OUString rLegacyFastParserStr = m_xDocumentHandler->getString(); CPPUNIT_ASSERT_EQUAL( rParserStr, rLegacyFastParserStr ); // OString o = OUStringToOString( Str, RTL_TEXTENCODING_ASCII_US ); @@ -329,6 +331,33 @@ void XMLImportTest::parse() } } +void XMLImportTest::testMissingNamespaceDeclaration() +{ + OUString fileNames[] = { "manifestwithnsdecl.xml", "manifestwithoutnsdecl.xml" }; + + uno::Reference<lang::XInitialization> const xInit(m_xLegacyFastParser, + uno::UNO_QUERY_THROW); + uno::Sequence<uno::Any> args(1); + args[0] <<= OUString("IgnoreMissingNSDecl"); + xInit->initialize( args ); + + for (sal_uInt16 i = 0; i < sizeof( fileNames ) / sizeof( OUString ); i++) + { + InputSource source; + source.sSystemId = "internal"; + + source.aInputStream = createStreamFromFile( m_sDirPath + fileNames[i] ); + m_xParser->parseStream(source); + const OUString rParserStr = m_xDocumentHandler->getString(); + + source.aInputStream = createStreamFromFile( m_sDirPath + fileNames[i] ); + m_xLegacyFastParser->parseStream(source); + const OUString rLegacyFastParserStr = m_xDocumentHandler->getString(); + + CPPUNIT_ASSERT_EQUAL( rParserStr, rLegacyFastParserStr ); + } +} + void XMLImportTest::testIllegalNamespaceUse() { rtl::Reference< NSDocumentHandler > m_xNSDocumentHandler; |