diff options
author | Gert Driesen <drieseng@users.sourceforge.net> | 2006-02-28 22:18:36 +0300 |
---|---|---|
committer | Gert Driesen <drieseng@users.sourceforge.net> | 2006-02-28 22:18:36 +0300 |
commit | 181d10350c45a24acf0e79dabdaeb3acd03fc1aa (patch) | |
tree | 08e7f938e95ceedff14c3f1270a5fb511298da9f /mcs/class/System.XML/Test/System.Xml.Schema | |
parent | c0fea8c79efa5b43f1afa52290f75411ac923ac9 (diff) |
* XmlSchema.cs: Do not define namespace for zero-length TargetNamespace
and report XmlSchemaException when compiling XmlSchema with
zero-length TargetNamespace. Fixes bug #77391.
* XmlSchemaTests.cs: Added test for writing XmlSchema with
zero-length TargetNamespace. Added test for compiling XmlSchema
with zero-length TargetNamespace. Replaced Console.WriteLine with
AssertEquals.
svn path=/trunk/mcs/; revision=57415
Diffstat (limited to 'mcs/class/System.XML/Test/System.Xml.Schema')
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog | 7 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs | 27 |
2 files changed, 32 insertions, 2 deletions
diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog index fd3032e8ad0..74cc73333c9 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog @@ -1,3 +1,10 @@ +2006-02-28 Gert Driesen <drieseng@users.sourceforge.net> + + * XmlSchemaTests.cs: Added test for writing XmlSchema with + zero-length TargetNamespace. Added test for compiling XmlSchema + with zero-length TargetNamespace. Replaced Console.WriteLine with + AssertEquals. + 2006-02-06 Atsushi Enomoto <atsushi@ximian.com> * XmlSchemaDatatypeTests.cs: (TestAnyType) NotDotNet -> Ignore. diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs index cf2e11bf26b..ceb0c971933 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs @@ -132,11 +132,24 @@ namespace MonoTests.System.Xml [Test] [ExpectedException (typeof (XmlSchemaException))] + public void TestCompile_ZeroLength_TargetNamespace () + { + XmlSchema schema = new XmlSchema (); + schema.TargetNamespace = string.Empty; + Assert (!schema.IsCompiled); + + // MS.NET 1.x: The Namespace '' is an invalid URI. + // MS.NET 2.0: The targetNamespace attribute cannot have empty string as its value. + schema.Compile (null); + } + + [Test] + [ExpectedException (typeof (XmlSchemaException))] public void TestCompileNonSchema () { XmlTextReader xtr = new XmlTextReader ("<root/>", XmlNodeType.Document, null); XmlSchema schema = XmlSchema.Read (xtr, null); - xtr.Close ();
+ xtr.Close (); } [Test] @@ -200,7 +213,17 @@ namespace MonoTests.System.Xml xw = new XmlTextWriter (sw); xs.TargetNamespace = "urn:foo"; xs.Write (xw); - Console.WriteLine ("#2", "<xs:schema xmlns:tns=\"urn:foo\" targetNamespace=\"urn:foo\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" />", doc.DocumentElement.OuterXml); + doc.LoadXml (sw.ToString ()); + AssertEquals ("#2", "<xs:schema xmlns:tns=\"urn:foo\" targetNamespace=\"urn:foo\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" />", doc.DocumentElement.OuterXml); + + // Zero-length TargetNamespace + xs = new XmlSchema (); + sw = new StringWriter (); + xw = new XmlTextWriter (sw); + xs.TargetNamespace = string.Empty; + xs.Write (xw); + doc.LoadXml (sw.ToString ()); + AssertEquals ("#2b", "<xs:schema targetNamespace=\"\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" />", doc.DocumentElement.OuterXml); // XmlSerializerNamespaces xs = new XmlSchema (); |