Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/System.XML/Test')
-rw-r--r--mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog14
-rw-r--r--mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaDatatypeTests.cs84
-rw-r--r--mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs27
-rw-r--r--mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTypeTests.cs101
-rw-r--r--mcs/class/System.XML/Test/System.Xml/ChangeLog14
-rw-r--r--mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs40
-rw-r--r--mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog4
-rw-r--r--mcs/class/System.XML/Test/XmlFiles/xsd/datatypesTest.xsd11
8 files changed, 268 insertions, 27 deletions
diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog
index b40a0c2b464..2f486b9cb16 100644
--- a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog
+++ b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog
@@ -1,3 +1,17 @@
+2006-01-10 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlSchemaTypeTests.cs : new file. Test for TypeCode.
+ * XmlSchemaSetTests.cs : added more tests for Add() and marked one as
+ NotWorking (we need info on how consistent this method is).
+
+2006-01-10 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlSchemaDatatypeTests.cs : oops sys.col.generic is NET_2_0.
+
+2006-01-10 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlSchemaDatatypeTests.cs : added test for 2.0 IsDerivedFrom().
+
2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : added AddRollbackIsCompiled(); Add() changes
diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaDatatypeTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaDatatypeTests.cs
index a0d23a0ea61..e7420bf4a67 100644
--- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaDatatypeTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaDatatypeTests.cs
@@ -11,8 +11,16 @@ using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;
+#if NET_2_0
+using System.Collections.Generic;
+#endif
using NUnit.Framework;
+using QName = System.Xml.XmlQualifiedName;
+using SimpleType = System.Xml.Schema.XmlSchemaSimpleType;
+using SimpleRest = System.Xml.Schema.XmlSchemaSimpleTypeRestriction;
+using AssertType = NUnit.Framework.Assert;
+
namespace MonoTests.System.Xml
{
[TestFixture]
@@ -39,6 +47,7 @@ namespace MonoTests.System.Xml
}
[Test]
+ [Category ("NotWorking")] // ContentTypeParticle impl. difference.
public void TestAnyType ()
{
XmlSchema schema = GetSchema ("Test/XmlFiles/xsd/datatypesTest.xsd");
@@ -71,5 +80,80 @@ namespace MonoTests.System.Xml
// AssertDatatype (schema, 6, XmlTokenizedType.NMTOKEN, typeof (string []), "f o o", new string [] {"f", "o", "o"});
}
+#if NET_2_0
+ string [] allTypes = new string [] {
+ "string", "boolean", "float", "double", "decimal",
+ "duration", "dateTime", "time", "date", "gYearMonth",
+ "gYear", "gMonthDay", "gDay", "gMonth", "hexBinary",
+ "base64Binary", "anyURI", "QName", "NOTATION",
+ "normalizedString", "token", "language", "IDREFS",
+ "ENTITIES", "NMTOKEN", "NMTOKENS", "Name", "NCName",
+ "ID", "IDREF", "ENTITY", "integer",
+ "nonPositiveInteger", "negativeInteger", "long",
+ "int", "short", "byte", "nonNegativeInteger",
+ "unsignedLong", "unsignedInt", "unsignedShort",
+ "unsignedByte", "positiveInteger"
+ };
+
+ XmlSchemaSet allWrappers;
+
+ void SetupSimpleTypeWrappers ()
+ {
+ XmlSchema schema = new XmlSchema ();
+ List<QName> qnames = new List<QName> ();
+ foreach (string name in allTypes) {
+ SimpleType st = new SimpleType ();
+ st.Name = "x-" + name;
+ SimpleRest r = new SimpleRest ();
+ st.Content = r;
+ QName qname = new QName (name, XmlSchema.Namespace);
+ r.BaseTypeName = qname;
+ qnames.Add (qname);
+ schema.Items.Add (st);
+ }
+ XmlSchemaSet sset = new XmlSchemaSet ();
+ sset.Add (schema);
+ sset.Compile ();
+ allWrappers = sset;
+ }
+
+ XmlSchemaDatatype GetDatatype (string name)
+ {
+ return (allWrappers.GlobalTypes [new QName ("x-" + name,
+ String.Empty)] as SimpleType).Datatype;
+ }
+
+ string [] GetDerived (string target)
+ {
+ XmlSchemaDatatype strType = GetDatatype (target);
+ List<string> results = new List<string> ();
+ foreach (string name in allTypes) {
+ if (name == target)
+ continue;
+ XmlSchemaDatatype deriv = GetDatatype (name);
+ if (deriv.IsDerivedFrom (strType))
+ results.Add (name);
+ else Console.Error.WriteLine (deriv.GetType () + " is not derived from " + strType.GetType ());
+ }
+ return results.ToArray ();
+ }
+
+ [Test]
+ public void IsDerivedFrom ()
+ {
+ SetupSimpleTypeWrappers ();
+
+ // Funky, but XmlSchemaDatatype.IsDerivedFrom() is
+ // documented to always return false, but actually
+ // matches the same type - which could be guessed that
+ // this method is used only to detect user-defined
+ // simpleType derivation.
+ foreach (string b in allTypes)
+ foreach (string d in allTypes)
+ AssertType.AreEqual (b == d, GetDatatype (d).IsDerivedFrom (GetDatatype (b)), b);
+
+ AssertType.IsFalse (GetDatatype ("string").IsDerivedFrom (null), "null arg");
+ }
+#endif
}
}
diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs
index 56a066c6760..20ad97f68b2 100644
--- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs
@@ -56,9 +56,22 @@ namespace MonoTests.System.Xml
}
[Test]
- [Ignore ("This behavior might be changed, since Add(XmlSchema) does not throw any exceptions, while this does.")]
+ public void AddSchemaThenReader ()
+ {
+ XmlSchemaSet ss = new XmlSchemaSet ();
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' />");
+ XmlSchema xs = new XmlSchema ();
+ xs.TargetNamespace = "ab";
+ ss.Add (xs);
+ ss.Add ("ab", new XmlNodeReader (doc));
+ }
+
+ [Test]
+ [Category ("NotWorking")] // How can we differentiate this
+ // case and the testcase above?
[ExpectedException (typeof (ArgumentException))]
- public void AddTwice ()
+ public void AddReaderTwice ()
{
XmlSchemaSet ss = new XmlSchemaSet ();
XmlDocument doc = new XmlDocument ();
@@ -68,6 +81,16 @@ namespace MonoTests.System.Xml
}
[Test]
+ public void AddSchemaTwice ()
+ {
+ XmlSchemaSet ss = new XmlSchemaSet ();
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:ab' />");
+ ss.Add (XmlSchema.Read (new XmlNodeReader (doc), null));
+ ss.Add (XmlSchema.Read (new XmlNodeReader (doc), null));
+ }
+
+ [Test]
public void CompilationSettings ()
{
Assert.IsNotNull (new XmlSchemaSet ().CompilationSettings);
diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTypeTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTypeTests.cs
new file mode 100644
index 00000000000..f97b6bddc44
--- /dev/null
+++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTypeTests.cs
@@ -0,0 +1,101 @@
+//
+// System.Xml.XmlSchemaSetTests.cs
+//
+// Author:
+// Atsushi Enomoto <atsushi@ximian.com>
+//
+// (C) 2004 Novell Inc.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+using NUnit.Framework;
+
+using QName = System.Xml.XmlQualifiedName;
+using SimpleType = System.Xml.Schema.XmlSchemaSimpleType;
+using SimpleRest = System.Xml.Schema.XmlSchemaSimpleTypeRestriction;
+using AssertType = NUnit.Framework.Assert;
+
+namespace MonoTests.System.Xml
+{
+ [TestFixture]
+ public class XmlSchemaTypeTests
+ {
+#if NET_2_0
+ string [] all_types = new string [] {
+ "string", "boolean", "float", "double", "decimal",
+ "duration", "dateTime", "time", "date", "gYearMonth",
+ "gYear", "gMonthDay", "gDay", "gMonth", "hexBinary",
+ "base64Binary", "anyURI", "QName", "NOTATION",
+ "normalizedString", "token", "language", "IDREFS",
+ "ENTITIES", "NMTOKEN", "NMTOKENS", "Name", "NCName",
+ "ID", "IDREF", "ENTITY", "integer",
+ "nonPositiveInteger", "negativeInteger", "long",
+ "int", "short", "byte", "nonNegativeInteger",
+ "unsignedLong", "unsignedInt", "unsignedShort",
+ "unsignedByte", "positiveInteger"
+ };
+
+ XmlTypeCode [] type_codes = new XmlTypeCode [] {
+ XmlTypeCode.String,
+ XmlTypeCode.Boolean,
+ XmlTypeCode.Float,
+ XmlTypeCode.Double,
+ XmlTypeCode.Decimal,
+ XmlTypeCode.Duration,
+ XmlTypeCode.DateTime,
+ XmlTypeCode.Time,
+ XmlTypeCode.Date,
+ XmlTypeCode.GYearMonth,
+ XmlTypeCode.GYear,
+ XmlTypeCode.GMonthDay,
+ XmlTypeCode.GDay,
+ XmlTypeCode.GMonth,
+ XmlTypeCode.HexBinary,
+ XmlTypeCode.Base64Binary,
+ XmlTypeCode.AnyUri,
+ XmlTypeCode.QName,
+ XmlTypeCode.Notation,
+ XmlTypeCode.NormalizedString,
+ XmlTypeCode.Token,
+ XmlTypeCode.Language,
+ XmlTypeCode.Idref, // IDREFS (LAMESPEC)
+ XmlTypeCode.Entity, // ENTITIES (LAMESPEC)
+ XmlTypeCode.NmToken,
+ XmlTypeCode.NmToken, // NMTOKENS (LAMESPEC)
+ XmlTypeCode.Name,
+ XmlTypeCode.NCName,
+ XmlTypeCode.Id,
+ XmlTypeCode.Idref,
+ XmlTypeCode.Entity,
+ XmlTypeCode.Integer,
+ XmlTypeCode.NonPositiveInteger,
+ XmlTypeCode.NegativeInteger,
+ XmlTypeCode.Long,
+ XmlTypeCode.Int,
+ XmlTypeCode.Short,
+ XmlTypeCode.Byte,
+ XmlTypeCode.NonNegativeInteger,
+ XmlTypeCode.UnsignedLong,
+ XmlTypeCode.UnsignedInt,
+ XmlTypeCode.UnsignedShort,
+ XmlTypeCode.UnsignedByte,
+ XmlTypeCode.PositiveInteger};
+
+ [Test]
+ public void TypeCode ()
+ {
+ for (int i = 0; i < all_types.Length; i++) {
+ string name = all_types [i];
+ QName qname = new QName (name, XmlSchema.Namespace);
+ Assert.AreEqual (type_codes [i],
+ XmlSchemaType.GetBuiltInSimpleType (qname).TypeCode, name);
+ }
+ }
+
+#endif
+ }
+}
diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog
index 441ca9c9bfa..2e69a65947e 100644
--- a/mcs/class/System.XML/Test/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/Test/System.Xml/ChangeLog
@@ -1,3 +1,17 @@
+2006-01-12 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlTextWriterTests.cs : Split AutoCreatePrefixes() and marked as
+ Ignore rather than NotWorking. Also it is not for bug #77086 and
+ #77077 (they were fixed). See bug #77088.
+
+2006-01-12 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlTextWriterTests.cs : re-enabled WriteNmToken_InvalidChars().
+
+2006-01-12 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlTextWriterTests.cs : re-enabled bug #77094 related tests.
+
2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
* XmlWriterTests.cs : added tests for WriteNode(XPathNavigator, bool)
diff --git a/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs
index 90661afd68c..b70e2cce2a1 100644
--- a/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs
@@ -205,29 +205,26 @@ namespace MonoTests.System.Xml
}
[Test]
- [Category ("NotWorking")] // bug #77086, #77087 and #77088
+ [Ignore ("Due to the (silly) dependency on bug #77088, this test will not be fixed. The test could be rewritten but it depends on the original test author.")]
public void AutoCreatePrefixes ()
{
+ xtw.WriteStartElement ("root");
xtw.WriteAttributeString (null, "abc", "http://somenamespace.com", "http://abc.def");
xtw.WriteAttributeString (null, "def", "http://somenamespace.com", "http://def.ghi");
xtw.WriteAttributeString (null, "ghi", "http://othernamespace.com", "http://ghi.jkl");
+ xtw.WriteEndElement ();
-#if NET_2_0
- Assert.AreEqual ("d0p1:abc='http://abc.def' d0p1:def='http://def.ghi'" +
- " d0p2:ghi='http://ghi.jkl'", StringWriterText, "#1");
-#else
- // on 1.x a new prefix is always created when level is 0 ?
- Assert.AreEqual ("d0p1:abc='http://abc.def' d0p2:def='http://def.ghi'" +
- " d0p3:ghi='http://ghi.jkl'", StringWriterText, "#1");
-#endif
-
- sw.GetStringBuilder ().Length = 0;
- CreateXmlTextWriter ();
+ Assert.AreEqual ("<root d1p1:abc='http://abc.def' d1p1:def='http://def.ghi' d1p2:ghi='http://ghi.jkl' xmlns:d1p2='http://othernamespace.com' xmlns:d1p1='http://somenamespace.com' />", StringWriterText, "#1");
+ }
+ [Test]
+ [Ignore ("Due to the (silly) dependency on bug #77088, this test will not be fixed. The test could be rewritten but it depends on the original test author.")]
+ public void AutoCreatePrefixes2 ()
+ {
xtw.WriteStartElement ("person");
- xtw.WriteAttributeString (null, "name", "http://somenamespace.com", "Gates");
- xtw.WriteAttributeString (null, "initials", "http://othernamespace.com", "BG");
- xtw.WriteAttributeString (null, "firstName", "http://somenamespace.com", "Bill");
+ xtw.WriteAttributeString (null, "name", "http://somenamespace.com", "Driesen");
+ xtw.WriteAttributeString (null, "initials", "http://othernamespace.com", "GD");
+ xtw.WriteAttributeString (null, "firstName", "http://somenamespace.com", "Gert");
xtw.WriteStartElement ("address");
xtw.WriteAttributeString (null, "street", "http://somenamespace.com", "Campus");
xtw.WriteAttributeString (null, "number", "http://othernamespace.com", "1");
@@ -238,9 +235,9 @@ namespace MonoTests.System.Xml
Assert.AreEqual (
"<person" +
- " d1p1:name='Gates'" +
- " d1p2:initials='BG'" +
- " d1p1:firstName='Bill'" +
+ " d1p1:name='Driesen'" +
+ " d1p2:initials='GD'" +
+ " d1p1:firstName='Gert'" +
" xmlns:d1p2='http://othernamespace.com'" +
" xmlns:d1p1='http://somenamespace.com'>" +
"<address" +
@@ -525,12 +522,8 @@ namespace MonoTests.System.Xml
}
[Test]
- [Category ("NotWorking")]
public void WriteStartElement_XmlPrefix ()
{
- // uncomment the next code block once bug #77094 has been fixed.
-
- /*
xtw.WriteStartElement ("xml", "something", "http://www.w3.org/XML/1998/namespace");
Assert.AreEqual ("<xml:something", StringWriterText, "#1");
@@ -548,7 +541,6 @@ namespace MonoTests.System.Xml
sw.GetStringBuilder ().Length = 0;
CreateXmlTextWriter ();
- */
}
[Test]
@@ -559,7 +551,6 @@ namespace MonoTests.System.Xml
}
[Test]
- [Category ("NotWorking")] // bug #77094
[ExpectedException (typeof (ArgumentException))]
public void WriteStartElement_XmlPrefix_Invalid2 ()
{
@@ -1536,7 +1527,6 @@ namespace MonoTests.System.Xml
}
[Test]
- [Category ("NotWorking")] // on mono, an XmlException is thrown instead
[ExpectedException (typeof (ArgumentException))]
public void WriteNmToken_InvalidChars ()
{
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog b/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog
index 3fa61cb1cd3..a645e2bff91 100644
--- a/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog
+++ b/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog
@@ -1,3 +1,7 @@
+2006-01-11 Atsushi Enomoto <atsushi@ximian.com>
+
+ * datatypesTest.xsd : missing required file for xsd tests.
+
2005-12-26 Atsushi Enomoto <atsushi@ximian.com>
* multi-schemaLocation.xml,
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/datatypesTest.xsd b/mcs/class/System.XML/Test/XmlFiles/xsd/datatypesTest.xsd
new file mode 100644
index 00000000000..50fb15c3740
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlFiles/xsd/datatypesTest.xsd
@@ -0,0 +1,11 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns="urn:bar" targetNamespace="urn:bar">
+ <xs:element name="e00">
+ <xs:complexType>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="e4" type="xs:string" />
+ <xs:element name="e1" type="xs:normalizedString" />
+ <xs:element name="e2" type="xs:token" />
+ <xs:element name="e3" type="xs:language" />
+</xs:schema>