From: Oleg T. <he...@us...> - 2004-10-26 19:29:30
|
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11487/v1/test Modified Files: Elliotte_Rusty_HaroldTests.cs EntryPoint.cs XIncludeReaderTests.cs Log Message: Working on bugs. Index: EntryPoint.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/EntryPoint.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- EntryPoint.cs 25 Oct 2004 19:32:39 -0000 1.6 +++ EntryPoint.cs 26 Oct 2004 19:28:43 -0000 1.7 @@ -9,13 +9,13 @@ { public static void Main() { - XIncludeReaderTests rt = new XIncludeReaderTests(); + //XIncludeReaderTests rt = new XIncludeReaderTests(); //EdUniTests rt = new EdUniTests(); //NistTests rt = new NistTests(); - //Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); + Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); try { - rt.OuterXmlTest(); + rt.harold_90(); } catch (Exception e) { Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- XIncludeReaderTests.cs 25 Oct 2004 19:32:39 -0000 1.7 +++ XIncludeReaderTests.cs 26 Oct 2004 19:28:43 -0000 1.8 @@ -22,15 +22,24 @@ Debug.Listeners.Add(new TextWriterTraceListener(Console.Error)); } - + /// <summary> /// Utility method for running tests. /// </summary> public static void RunAndCompare(string source, string result) + { + RunAndCompare(source, result, false); + } + + /// <summary> + /// Utility method for running tests. + /// </summary> + public static void RunAndCompare(string source, string result, bool textAsCDATA) { XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; XIncludingReader xir = new XIncludingReader(source); + xir.ExposeTextInclusionsAsCDATA = textAsCDATA; try { doc.Load(xir); @@ -66,7 +75,7 @@ Assert.AreEqual(r1.Value, r2.Value); break; case XmlNodeType.CDATA: - Assert.AreEqual(r2.NodeType, XmlNodeType.CDATA); + Assert.IsTrue(r2.NodeType == XmlNodeType.CDATA || r2.NodeType == XmlNodeType.Text); Assert.AreEqual(r1.Value, r2.Value); break; case XmlNodeType.Comment: @@ -113,7 +122,7 @@ Assert.AreEqual(r1.Value, r2.Value); break; case XmlNodeType.Text: - Assert.AreEqual(r2.NodeType, XmlNodeType.Text); + Assert.IsTrue(r2.NodeType == XmlNodeType.CDATA || r2.NodeType == XmlNodeType.Text); Assert.AreEqual(r1.Value, r2.Value); break; default: Index: Elliotte_Rusty_HaroldTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/Elliotte_Rusty_HaroldTests.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Elliotte_Rusty_HaroldTests.cs 19 Oct 2004 16:24:56 -0000 1.1 +++ Elliotte_Rusty_HaroldTests.cs 26 Oct 2004 19:28:43 -0000 1.2 @@ -25,9 +25,17 @@ /// </summary> public static void RunAndCompare(string source, string result) { + RunAndCompare(source, result, false); + } + + /// <summary> + /// Utility method for running tests. + /// </summary> + public static void RunAndCompare(string source, string result, bool textAsCDATA) + { XIncludeReaderTests.RunAndCompare( "../../XInclude-Test-Suite/Harold/test/" + source, - "../../XInclude-Test-Suite/Harold/test/" + result); + "../../XInclude-Test-Suite/Harold/test/" + result, textAsCDATA); } @@ -177,8 +185,15 @@ /// <summary> /// Syntactically incorrect IRI is a fatal error (Eitehr I'm missing something or the spec needs to state this prinicple more clearly.) /// </summary> + /// <remarks> + /// As per spec: + /// "A value that results in a syntactically invalid URI or IRI should be + /// reported as a fatal error, but some implementations may find it + /// impractical to distinguish this case from a resource error." + /// We do treat it as a resource error. + /// </remarks> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(DirectoryNotFoundException))] public void harold_13() { RunAndCompare("badiri.xml", ""); @@ -189,8 +204,15 @@ /// <summary> /// Syntactically incorrect IRI with an unrecognized scheme is a fatal error /// </summary> + /// <remarks> + /// As per spec: + /// "A value that results in a syntactically invalid URI or IRI should be + /// reported as a fatal error, but some implementations may find it + /// impractical to distinguish this case from a resource error." + /// We do treat it as a resource error. + /// </remarks> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(DirectoryNotFoundException))] public void harold_14() { RunAndCompare("badiri2.xml", ""); @@ -213,7 +235,7 @@ /// accept attribute contains carriage-return/linefeed pair /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(InvalidAcceptHTTPHeaderValue))] public void harold_16() { RunAndCompare("badaccept1.xml", ""); @@ -225,7 +247,7 @@ /// accept attribute contains Latin-1 character (non-breaking space) /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(InvalidAcceptHTTPHeaderValue))] public void harold_17() { RunAndCompare("badaccept2.xml", ""); @@ -283,7 +305,7 @@ [Test] public void harold_22() { - RunAndCompare("metafallbacktest2.xml", "../result/metafallbacktest2.xml"); + RunAndCompare("metafallbacktest2.xml", "../result/metafallbacktest2.xml", true); } @@ -292,7 +314,7 @@ /// A fallback element in an included document contains an include element with a parse attribute with an illegal value. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(UnknownParseAttributeValueException))] public void harold_23() { RunAndCompare("metafallbacktest3.xml", ""); @@ -304,7 +326,7 @@ /// A fallback element in an included document contains an include element with neither an xpointer nor an href attribute. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(MissingHrefAndXpointerException))] public void harold_24() { RunAndCompare("metafallbacktest4.xml", ""); @@ -317,7 +339,7 @@ /// A fallback element in an included document contains an include element whose href attribute has a fragment ID. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] public void harold_25() { RunAndCompare("metafallbacktestwithfragmentid.xml", ""); @@ -329,7 +351,7 @@ /// The XPointer does not select anything in the acquired infoset, but does select something in the source infoset. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_26() { RunAndCompare("metafallbacktest5.xml", ""); @@ -377,7 +399,7 @@ /// then fails to find a resource, which is a fatal error if there's no fallback. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_30() { RunAndCompare("metamissingfallbacktestwithxpointer.xml", ""); @@ -390,7 +412,7 @@ /// then fails to find a resource, but it has a fallback, which itself has an include child, which then throws a fatal error. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_31() { RunAndCompare("metafallbackwithbadxpointertest.xml", ""); @@ -412,8 +434,8 @@ /// <summary> /// An include element points to a document that includes it, using an xpointer to select part of that document. /// </summary> - [Test] - [ExpectedException(typeof(Exception))] + [Test] + [ExpectedException(typeof(CircularInclusionException))] public void harold_33() { RunAndCompare("legalcircle.xml", ""); @@ -458,7 +480,7 @@ /// Detect an inclusion loop when an include element refers to itself /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(CircularInclusionException))] public void harold_37() { RunAndCompare("internalcircular.xml", ""); @@ -471,7 +493,7 @@ /// in the same document /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(CircularInclusionException))] public void harold_38() { RunAndCompare("internalcircularviaancestor.xml", ""); @@ -528,7 +550,7 @@ /// testIncludeElementsCannotHaveIncludeChildren /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_43() { RunAndCompare("nestedxinclude.xml", ""); @@ -540,7 +562,7 @@ /// Include elements cannot have children from the xinclude namespace except for fallback. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_44() { RunAndCompare("nestedxincludenamespace.xml", ""); @@ -552,7 +574,7 @@ /// Fallback can only be a child of xinclude element /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_45() { RunAndCompare("nakedfallback.xml", ""); @@ -564,7 +586,7 @@ /// A fallback element cannot have a fallback child element. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_46() { RunAndCompare("fallbackcontainsfallback.xml", ""); @@ -578,7 +600,7 @@ /// In this test the fallback is activated. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_47() { RunAndCompare("multiplefallbacks.xml", ""); @@ -592,7 +614,7 @@ /// In this test the fallback is not activated. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_48() { RunAndCompare("multiplefallbacks2.xml", ""); @@ -604,7 +626,7 @@ /// A document cannot include itself /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(CircularInclusionException))] public void harold_49() { RunAndCompare("circle1.xml", ""); @@ -616,7 +638,7 @@ /// Document A includes document B which includes document A /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(CircularInclusionException))] public void harold_50() { RunAndCompare("circle2a.xml", ""); @@ -628,7 +650,7 @@ /// Include element is missing an href and xpointer attribute /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(MissingHrefAndXpointerException))] public void harold_51() { RunAndCompare("missinghref.xml", ""); @@ -640,7 +662,7 @@ /// parse attribute must have value xml or text /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(UnknownParseAttributeValueException))] public void harold_52() { RunAndCompare("badparseattribute.xml", ""); @@ -652,7 +674,7 @@ /// Missing resource is fatal when there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_53() { RunAndCompare("missingfile.xml", ""); @@ -708,7 +730,7 @@ /// XPointer that selects nothing is a resource error, and fatal because there's no fallback. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_58() { RunAndCompare("xptridtest2.xml", ""); @@ -743,7 +765,7 @@ /// the second XPointer part is still a fatal error. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_61() { RunAndCompare("laterfailure.xml", ""); @@ -756,7 +778,7 @@ /// the second XPointer part is still a fatal error. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_62() { RunAndCompare("laterfailure2.xml", ""); @@ -843,7 +865,7 @@ /// An XPointer that doesn't point to anything is a resource error; and fatal because there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_69() { RunAndCompare("xptrtumblertest2.xml", ""); @@ -855,7 +877,7 @@ /// Syntax error in an XPointer is a resource error; and fatal because there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_70() { RunAndCompare("badxptr.xml", ""); @@ -867,7 +889,7 @@ /// Syntax error in an XPointer is a resource error; and fatal because there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] public void harold_71() { RunAndCompare("badxptr2.xml", ""); @@ -967,7 +989,7 @@ /// Syntax error in an XPointer is a resource error; and fatal becaue there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_80() { RunAndCompare("badxptr3.xml", ""); @@ -979,7 +1001,7 @@ /// Syntax error in an XPointer is a resource error; and fatal becaue there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_81() { RunAndCompare("badxptr4.xml", ""); @@ -991,7 +1013,7 @@ /// Circular references via xpointer are fatal /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(CircularInclusionException))] public void harold_82() { RunAndCompare("circlepointer1.xml", ""); @@ -1003,7 +1025,7 @@ /// href attribute with fragment ID is a fatal error even when there's an xpointer attribute /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] public void harold_83() { RunAndCompare("xpointeroverridesfragmentid.xml", ""); @@ -1015,7 +1037,7 @@ /// href attribute with fragment ID is a fatal error /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] public void harold_84() { RunAndCompare("ignoresfragmentid.xml", ""); @@ -1039,7 +1061,7 @@ /// syntax of fragment IDs from RFC 2396. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] public void harold_86() { RunAndCompare("meaninglessfragmentid.xml", ""); @@ -1098,7 +1120,7 @@ [Test] public void harold_90() { - RunAndCompare("accepthtml.xml", "../result/accepthtml.xml"); + RunAndCompare("accepthtml.xml", "../result/accepthtml.xml", true); } @@ -1107,7 +1129,7 @@ /// Unrecognized scheme in XPointer is a fatal error if there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_91() { RunAndCompare("unrecognizedscheme.xml", ""); @@ -1141,7 +1163,7 @@ /// Included document has an include element with neither href nor xpointer attribute /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(MissingHrefAndXpointerException))] public void harold_94() { RunAndCompare("toplevel.xml", ""); |