From: Andreia Gaita Date: Fri, 13 Nov 2009 21:26:27 +0000 (-0000) Subject: * XmlTextReaderTests.cs: Added ParsingWithNSMgrSubclass test to check X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=88856b11d7704237fffe79f9747d115005773762;p=mono.git * XmlTextReaderTests.cs: Added ParsingWithNSMgrSubclass test to check r146175 fix (chained namespace lookups using XmlNamespaceManager subclasses) svn path=/trunk/mcs/; revision=146179 --- diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog index 00e3f135804..0ea8c18abfe 100644 --- a/mcs/class/System.XML/Test/System.Xml/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml/ChangeLog @@ -1,3 +1,9 @@ +2009-11-13 Andreia Gaita + + * XmlTextReaderTests.cs: Added ParsingWithNSMgrSubclass test to check + r146175 fix (chained namespace lookups using XmlNamespaceManager + subclasses) + 2009-11-11 Atsushi Enomoto * XmlNodeReaderTests.cs : added test for bug #550379. diff --git a/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs index fc868fb373b..21c49abfff6 100644 --- a/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs +++ b/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs @@ -1304,5 +1304,42 @@ namespace MonoTests.System.Xml while (!xtr.EOF) xtr.Read (); } + + [Test] + public void ParsingWithNSMgrSubclass () + { + XmlNamespaceManager nsMgr = new XmlNamespaceManager (new NameTable ()); + nsMgr.AddNamespace ("foo", "bar"); + XmlParserContext inputContext = new XmlParserContext (null, nsMgr, null, XmlSpace.None); + XmlReader xr = XmlReader.Create (new StringReader (""), new XmlReaderSettings (), inputContext); + + XmlNamespaceManager aMgr = new MyNS (xr); + XmlParserContext inputContext2 = new XmlParserContext(null, aMgr, null, XmlSpace.None); + XmlReader xr2 = XmlReader.Create (new StringReader ("namespace test"), new XmlReaderSettings (), inputContext2); + + while (xr2.Read ()) {} + + } + + + // The MyNS subclass chains namespace lookups + class MyNS : XmlNamespaceManager { + private XmlReader xr; + + + public MyNS (XmlReader xr) + : base (xr.NameTable) { + this.xr = xr; + } + + public override string LookupNamespace (string prefix) { + string str = base.LookupNamespace (prefix); + if (!string.IsNullOrEmpty (str)) + return str; + if (xr != null) + return xr.LookupNamespace (prefix); + return String.Empty; + } + } } }