Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,239 @@
2009-11-20 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #556619 by
Tor Lillqvist.
2009-04-15 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : test for bug #457065 by Leszek Ciesielski.
2008-12-09 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : test for bug #450797 by Jonathan Anderson.
2008-10-02 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : removed extra NotDotNet.
2008-06-04 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #378239.
2008-06-03 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #316238.
2008-05-22 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #391424.
2008-01-19 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #322551.
2008-01-08 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test from bug #351939.
(by Tor Lillqvist)
2007-12-27 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #349375. (Actually the
previous checkin fixed bug #349375.)
Added another notworking one inspired by the same bug.
2007-12-17 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #349111.
2007-12-17 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #349035.
2007-12-17 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #348786.
2007-09-21 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #325482.
2007-08-21 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #82493.
2007-08-08 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #82357.
2006-04-07 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added CurrentInSelect().
2006-04-07 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added StripSpace().
2006-01-13 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added DocTypeAfterText().
2006-01-13 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : Output_Indent_Xml_DocType() is working now.
2005-12-27 Gert Driesen <drieseng@users.sourceforge.net>
* XslTransformTests.cs: Extended html indentation test (and marked
it NotWorking). Added tests for MS bugs (that have been fixed since).
2005-12-24 Gert Driesen <drieseng@users.sourceforge.net>
* XslTransformTests.cs: Enabled forwards compatible tests.
2005-12-23 Gert Driesen <drieseng@users.sourceforge.net>
* XslTransformTests.cs: Added forwards compatible tests.
2005-12-23 Gert Driesen <drieseng@users.sourceforge.net>
* XslTransformTests.cs: Added working XML/HTML indentation tests.
2005-12-23 Gert Driesen <drieseng@users.sourceforge.net>
* XslTransformTests.cs: Added bug numbers to test cases.
2005-12-17 Gert Driesen <drieseng@users.sourceforge.net>
* XsltCompileExceptionTests.cs: Added tests for ctors.
* XsltExceptionTests.cs: Added tests for ctors.
* XslTransformTests.cs: Added tests for validation of <xsl:output>
attributes.
2005-12-12 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : (LocalParameter) [NotDotNet] should not have
been undone.
2005-12-04 Gert Driesen <drieseng@users.sourceforge.net>
* XslTransformTests.cs: Explictly omit xml declaration, allowing
test to pass on both Mono and MS.NET.
2005-12-04 Gert Driesen <drieseng@users.sourceforge.net>
* XslTransformTests.cs: Undo formatting changes.
2005-12-04 Gert Driesen <drieseng@users.sourceforge.net>
* XslTransformTests.cs: Added test for MS bug, described in KB834667.
2005-12-04 Gert Driesen <drieseng@users.sourceforge.net>
* XslTransformTests.cs: Added test for sorting an empty node set, which
is also a test for omitting XML declaration if no XML is output.
No longer derive from deprecated Assertion class, formatting updates.
2005-11-17 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added WhitespaceHandling ().
2005-10-24 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test for bug #76530.
2005-10-08 Zoltan Varga <vargaz@gmail.com>
* XslTransformTests.cs: Remove test which depends on random GC
behaviour.
2005-09-10 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added testcase for bug #76115.
* MSXslScriptTests.cs : added testcase for bug #76116.
2005-09-10 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added testcase for bug #76046.
2005-08-31 Sebastien Pouliot <sebastien@ximian.com>
* XsltArgumentListCas.cs: New. CAS unit tests for AddExtensionObject.
Note that this is a LinkDemand so it will succeed in 2.0 (as the test
is executed at fulltrust).
* XsltCompileExceptionCas.cs: New. CAS unit tests for exception
serialization.
* XsltExceptionCas.cs: New. CAS unit tests for exception
serialization.
2005-07-29 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added testcase for bug #75663.
2005-05-07 Atsushi Enomoto <atsushi@ximian.com>
* MSXslScriptTests.cs : added testcase for bug #74859.
2005-03-24 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added (extra) test which verifies that
XslTransform.Load() and .Transform() does not hold reference to
stylesheet/instance XPathNavigator inside its internals.
2005-03-23 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test that examines if XSLT rejects
xsl:import incorrectly placed after other contents.
2005-03-22 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added test 1)that examines pattern sanity and
2)that examines if empty element RTF is evaluated as true for bool.
2005-02-28 Atsushi Enomoto <atsushi@ximian.com>
* MsxslScriptTests.cs,
XslTransformTests.cs : set NotWorking for msxsl:script tests (they
premise runnable compilers existence which actually might not exist.)
2005-01-13 Atsushi Enomoto <atsushi@ximian.com>
* MsxslScriptTests.cs : actually it was not testing stylesheet.
* XslTransformTests.cs : marked MSXslNodeSetRejectsNodeSet() as
NotDotNet.
2004-06-06 Atsushi Enomoto <atsushi@ximian.com>
* MsxslScriptTests.cs : Namespace are required (found on fixing
XmlTextReader's namespace bugfix).
2004-05-20 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : Added tests for msxsl:node-set().
2004-03-31 Atsushi Enomoto <atsushi@ximian.com>
* Added MsxslScriptTests.cs.
2004-03-24 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : Added InvalidStylesheet2().
2004-03-13 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : added some tests for invalid stylesheets.
2004-01-03 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformTests.cs : fixed incorrect file path, and output childnode
count.
2003-05-13 Martin Willemoes Hansen <mwh@sysrq.dk>
* XslTransformTests.cs: Inherits from Assertion and Assertion.
prefix removed.
2003-04-12 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* added this file as a new entry.
See ../ChangeLog to find former ChangeLog entries.

View File

@@ -0,0 +1,217 @@
//
// System.Xml.Xsl.MsxslScriptTests.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (C) 2004 Novell Inc.
//
using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
using NUnit.Framework;
namespace MonoTests.System.Xml.Xsl
{
[TestFixture]
public class MsxslScriptTests
{
// PI calc stuff are one of MSDN samples.
static XmlDocument doc;
static MsxslScriptTests ()
{
string inputxml = @"<?xml version='1.0'?>
<data>
<circle>
<radius>12</radius>
</circle>
<circle>
<radius>37.5</radius>
</circle>
</data>";
doc = new XmlDocument ();
doc.LoadXml (inputxml);
}
static string xslstring = @"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:msxsl='urn:schemas-microsoft-com:xslt'
xmlns:user='urn:my-scripts'>
***** rewrite here *****
<xsl:template match='data'>
<circles>
<xsl:for-each select='circle'>
<circle>
<xsl:copy-of select='node()'/>
<circumference>
<!-- xsl:value-of select='user:circumference(radius)'/ -->
TEST:
<xsl:value-of select='user:PadRight(&quot;test-string&quot;, 20)'/>
</circumference>
</circle>
</xsl:for-each>
</circles>
</xsl:template>
</xsl:stylesheet>";
string cs1 = @"<msxsl:script language='C#' implements-prefix='user'>
<![CDATA[
public string PadRight( string str, int padding) {
return str.PadRight(padding);
}
public double circumference(double radius){
double pi = 3.14;
double circ = pi*radius*2;
return circ;
}
]]>
</msxsl:script>";
string vb1 = @"<msxsl:script language='VB' implements-prefix='user'>
<![CDATA[
public function circumference(radius as double) as double
dim pi as double = 3.14
dim circ as double = pi*radius*2
return circ
end function
public function PadRight(str as string, padding as integer) as string
return str.PadRight(padding)
end function
]]>
</msxsl:script>";
string js1 = @"<msxsl:script language='JScript' implements-prefix='user'>
<![CDATA[
function circumference(radius : double) : double {
var pi : double = 3.14;
var circ : double = pi*radius*2;
return circ;
}
function PadRight(str : String, padding : int) {
return str.PadRight(padding);
}
]]>
</msxsl:script>";
XslTransform xslt;
[SetUp]
public void GetReady ()
{
xslt = new XslTransform ();
}
[Test]
[Category ("NotWorking")] // it depends on "mcs" existence
public void TestCSharp ()
{
string style = xslstring.Replace ("***** rewrite here *****", cs1);
XmlTextReader xr = new XmlTextReader (style, XmlNodeType.Document, null);
xslt.Load (xr);
xslt.Transform (doc.CreateNavigator (), null, new XmlTextWriter (new StringWriter ()));
}
[Test]
[Category ("NotWorking")] // it depends on "mbas" existence
public void TestVB ()
{
string style = xslstring.Replace ("***** rewrite here *****", vb1);
XmlTextReader xr = new XmlTextReader (style, XmlNodeType.Document, null);
xslt.Load (xr);
xslt.Transform (doc.CreateNavigator (), null, new XmlTextWriter (new StringWriter ()));
}
[Test]
[Category ("NotWorking")] // it depends on "mjs" existence
public void TestJScript ()
{
string style = xslstring.Replace ("***** rewrite here *****", js1);
XmlTextReader xr = new XmlTextReader (style, XmlNodeType.Document, null);
xslt.Load (xr);
xslt.Transform (doc.CreateNavigator (), null, new XmlTextWriter (new StringWriter ()));
}
[Test]
[Ignore ("Actually it should throw compile exception")]
[ExpectedException (typeof (XsltException))]
public void InvalidScript ()
{
string script = @"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:user='urn:my-scripts'
xmlns:msxsl='urn:schemas-microsoft-com:xslt'>
<!-- -->
<xsl:output method='html' indent='no' />
<!-- -->
<xsl:template match='/project'>
<xsl:if test='user:BadScriptFunction(&apos;test&apos;)'></xsl:if>
</xsl:template>
<!-- -->
<msxsl:script language='C#' implements-prefix='user'>
<![CDATA[
string BadScriptFunction(string test) {
xxx;
}
]]>
</msxsl:script>
<!-- -->
</xsl:stylesheet>";
xslt.Load (new XmlTextReader (script, XmlNodeType.Document, null));
}
[Test]
[Category ("NotWorking")] // it depends on "mcs" existence
public void CompilerWarningsShouldBeIgnored ()
{
string script = @"<xslt:stylesheet xmlns:xslt='http://www.w3.org/1999/XSL/Transform' version='1.0' xmlns:msxsl='urn:schemas-microsoft-com:xslt'
xmlns:stringutils='urn:schemas-sourceforge.net-blah'>
<xslt:output method='text' />
<msxsl:script language='C#' implements-prefix='stringutils'>
<![CDATA[
string PadRight( string str, int padding) {
return str.PadRight(padding);
}
]]>
</msxsl:script>
<xslt:template match='project'>
<xslt:apply-templates select='target[string(@description) != &apos;&apos; ]'>
<xslt:sort select='@name' order='ascending' />
</xslt:apply-templates>
</xslt:template>
<xslt:template match='target'>
<xslt:value-of select='stringutils:PadRight(@name, 20)' />
<xslt:value-of select='@description' />
</xslt:template>
</xslt:stylesheet>";
xslt.Load (new XmlTextReader (script, XmlNodeType.Document, null));
xslt.Transform (doc.CreateNavigator (), null, new XmlTextWriter (TextWriter.Null));
}
[Test]
[Category ("NotWorking")] // it depends on "mcs" existence
public void CompileNoLineInfoSource ()
{
// bug #76116
string xslt = @"<xslt:stylesheet xmlns:xslt='http://www.w3.org/1999/XSL/Transform' version='1.0' xmlns:msxsl='urn:schemas-microsoft-com:xslt' xmlns:stringutils='urn:schemas-sourceforge.net-blah' xmlns:nant='unknown-at-this-time'>
<xslt:output method='text' />
<msxsl:script language='C#' implements-prefix='stringutils'>
<![CDATA[
string PadRight( string str, int padding) {
return str.PadRight(padding);
}
]]>
</msxsl:script>
<xslt:template match='/'>
<foo/>
</xslt:template>
</xslt:stylesheet>";
XmlDocument doc = new XmlDocument ();
doc.LoadXml (xslt);
XslTransform t = new XslTransform ();
t.Load (doc);
}
}
}

View File

@@ -0,0 +1,112 @@
using NUnit.Framework;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
namespace MonoTests.System.Xml.Xsl
{
[TestFixture]
public class XslCompiledTransformTests
{
[Test]
public void GlobalVariableReferencesAnotherGlobalVariable ()
{
string xsl = @"<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:variable name='global2'><xsl:value-of select='root/@attr' /></xsl:variable>
<xsl:variable name='global1'>
<xsl:for-each select='//foo'>
<xsl:if test='@attr = $global2'>
<xsl:value-of select='name(.)' />: <xsl:value-of select='@attr' />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:template match='/'>
<root>
<xsl:value-of select='$global1' />
</root>
</xsl:template>
</xsl:stylesheet>";
StringWriter sw = new StringWriter ();
XslCompiledTransform t = new XslCompiledTransform ();
t.Load (new XPathDocument (new StringReader (xsl)));
t.Transform (new XPathDocument (new XmlTextReader (new StringReader ("<root attr='B'><foo attr='A'/><foo attr='B'/><foo attr='C'/></root>"))), null, sw);
Assert.AreEqual ("<?xml version=\"1.0\" encoding=\"utf-16\"?><root>foo: B</root>", sw.ToString ());
}
[Test]
public void MSXslNodeSetAcceptsNodeSet ()
{
string xsl = @"<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-microsoft-com:xslt'>
<xsl:template match='/'>
<root>
<!-- msxsl:node-set() accepts a node set -->
<xsl:for-each select='msxsl:node-set(root/foo)'>
<xsl:value-of select='name(.)' />: <xsl:value-of select='@attr' />
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>";
StringWriter sw = new StringWriter ();
XslCompiledTransform t = new XslCompiledTransform ();
t.Load (new XPathDocument (new StringReader (xsl)));
// should transform without an exception
t.Transform (new XPathDocument (new XmlTextReader (new StringReader ("<root><foo attr='A'/><foo attr='B'/><foo attr='C'/></root>"))), null, sw);
}
[Test]
public void MSXslNodeSetAcceptsEmptyString ()
{
string xsl = @"<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-microsoft-com:xslt'>
<xsl:template match='/'>
<root>
<!-- msxsl:node-set() accepts an empty string -->
<xsl:variable name='empty'></xsl:variable>
<xsl:for-each select='msxsl:node-set($empty)'>
<xsl:value-of select='name(.)' />: <xsl:value-of select='@attr' />
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>";
StringWriter sw = new StringWriter ();
XslCompiledTransform t = new XslCompiledTransform ();
t.Load (new XPathDocument (new StringReader (xsl)));
// should transform without an exception
t.Transform (new XPathDocument (new XmlTextReader (new StringReader ("<root><foo attr='A'/><foo attr='B'/><foo attr='C'/></root>"))), null, sw);
}
[Test]
public void ValueOfElementWithInsignificantWhitespace ()
{
string xsl = @"<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match='/'>
<root>
<bar>
<xsl:if test='root/@attr'>
<xsl:value-of select='root/@attr'>
</xsl:value-of>
</xsl:if>
</bar>
<baz>
<xsl:for-each select='root/foo'>
<xsl:if test='position() != 1'>
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:value-of select='name(.)' />: <xsl:value-of select='@attr' />
</xsl:for-each>
</baz>
</root>
</xsl:template>
</xsl:stylesheet>";
StringWriter sw = new StringWriter ();
XslCompiledTransform t = new XslCompiledTransform ();
t.Load (new XmlTextReader(new StringReader(xsl)));
t.Transform (new XPathDocument (new XmlTextReader (new StringReader ("<root attr='D'><foo attr='A'/><foo attr='B'/><foo attr='C'/></root>"))), null, sw);
Assert.AreEqual ("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><bar>D</bar><baz>foo: A,foo: B,foo: C</baz></root>", sw.ToString ());
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,83 @@
//
// XmlSchemaExceptionCas.cs
// - CAS unit tests for System.Xml.Schema.XmlSchemaException
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using System;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using System.Xml.Xsl;
namespace MonoCasTests.System.Xml.Xsl {
[TestFixture]
[Category ("CAS")]
public class XsltArgumentListCas {
private MethodInfo addExtensionObject;
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
// this executes at fulltrust
addExtensionObject = typeof (XsltArgumentList).GetMethod ("AddExtensionObject",
new Type[2] { typeof (string), typeof (object) });
}
[Test]
[SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
public void AddExtensionObject ()
{
XsltArgumentList xal = new XsltArgumentList ();
xal.AddExtensionObject ("http://www.go-mono.com", new object ());
}
// we use reflection to call XsltArgumentList as it's AddExtensionObject method
// is protected by a LinkDemand (which will be converted into full demand, i.e.
// a stack walk) when reflection is used (i.e. it gets testable).
[Test]
[SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
#if !NET_2_0
[ExpectedException (typeof (SecurityException))]
#endif
public void AddExtensionObject_LinkDemand ()
{
// requires FullTrust, so denying anything break the requirements
Assert.IsNotNull (addExtensionObject, "AddExtensionObject");
XsltArgumentList xal = new XsltArgumentList ();
addExtensionObject.Invoke (xal, new object[2] { "http://www.go-mono.com", new object () });
}
}
}

View File

@@ -0,0 +1,84 @@
//
// XsltCompileExceptionCas.cs
// - CAS unit tests for System.Xml.Xsl.XsltCompileException
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using System;
using System.Runtime.Serialization;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using System.Xml.Xsl;
namespace MonoCasTests.System.Xml.Xsl {
[TestFixture]
[Category ("CAS")]
public class XsltCompileExceptionCas {
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[ExpectedException (typeof (SecurityException))]
[SecurityPermission (SecurityAction.Deny, SerializationFormatter = true)]
public void DenySerializationFormatter_GetObjectData ()
{
StreamingContext sc = new StreamingContext (StreamingContextStates.All);
XsltCompileException xe = new XsltCompileException (null, String.Empty, 0, 0);
xe.GetObjectData (null, sc);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
[SecurityPermission (SecurityAction.PermitOnly, SerializationFormatter = true)]
public void PermitOnlySerializationFormatter_GetObjectData ()
{
StreamingContext sc = new StreamingContext (StreamingContextStates.All);
XsltCompileException xe = new XsltCompileException (null, String.Empty, 0, 0);
xe.GetObjectData (null, sc);
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void DenyUnrestricted ()
{
// can we call everything without a SecurityException ?
XsltCompileException xe = new XsltCompileException (null, String.Empty, 0, 0);
Assert.AreEqual (0, xe.LineNumber, "LineNumber");
Assert.AreEqual (0, xe.LinePosition, "LinePosition");
Assert.IsNotNull (xe.Message, "Message");
Assert.AreEqual (String.Empty, xe.SourceUri, "SourceUri");
}
}
}

View File

@@ -0,0 +1,273 @@
//
// XsltCompileExceptionTests.cs
// - Unit tests for System.Xml.Xsl.XsltCompileException
//
// Author:
// Gert Driesen <drieseng@users.sourceforge.net>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using System;
using System.Runtime.Serialization;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using System.Xml.Xsl;
namespace MonoCasTests.System.Xml.Xsl
{
[TestFixture]
public class XsltCompileExceptionTests {
#if NET_2_0
[Test]
public void Constructor0 ()
{
XsltCompileException xe = new XsltCompileException ();
Assert.AreEqual (0, xe.LineNumber, "#A1");
Assert.AreEqual (0, xe.LinePosition, "#A2");
Assert.IsNotNull (xe.Message, "#A3");
Assert.AreEqual (string.Empty, xe.Message, "#A4");
Assert.IsNull (xe.SourceUri, "#A5");
Assert.IsNull (xe.InnerException, "#A6");
Assert.IsNull (xe.Source, "#A7");
Assert.IsNull (xe.StackTrace, "#A8");
Assert.IsNull (xe.TargetSite, "#A9");
}
[Test]
public void Constructor1 ()
{
string msg = "mono";
XsltCompileException xe = new XsltCompileException (msg);
Assert.AreEqual (0, xe.LineNumber, "#A1");
Assert.AreEqual (0, xe.LinePosition, "#A2");
Assert.IsNotNull (xe.Message, "#A3");
Assert.AreEqual ("mono", xe.Message, "#A4");
Assert.IsNull (xe.SourceUri, "#A5");
Assert.IsNull (xe.InnerException, "#A6");
Assert.IsNull (xe.Source, "#A7");
Assert.IsNull (xe.StackTrace, "#A8");
Assert.IsNull (xe.TargetSite, "#A9");
}
[Test]
public void Constructor2 ()
{
string msg = "mono";
Exception cause = new ApplicationException ("cause");
XsltCompileException xe = new XsltCompileException (msg, cause);
Assert.AreEqual (0, xe.LineNumber, "#A1");
Assert.AreEqual (0, xe.LinePosition, "#A2");
Assert.IsNotNull (xe.Message, "#A3");
Assert.AreEqual ("mono", xe.Message, "#A4");
Assert.IsNull (xe.SourceUri, "#A5");
Assert.AreSame (cause, xe.InnerException, "#A6");
Assert.IsNull (xe.Source, "#A7");
Assert.IsNull (xe.StackTrace, "#A8");
Assert.IsNull (xe.TargetSite, "#A9");
}
#endif
[Test]
public void Constructor3 ()
{
string sourceUri = "http://local/test.xsl";
Exception cause = new ApplicationException ("cause");
// null uri, line 0, pos 0, innerexception set
XsltCompileException xe = new XsltCompileException (cause, (string) null, 0, 0);
Assert.AreEqual (0, xe.LineNumber, "#A1");
Assert.AreEqual (0, xe.LinePosition, "#A2");
Assert.IsNotNull (xe.Message, "#A3");
Assert.IsTrue (xe.Message.Length > 0, "#A4");
#if NET_2_0
// exact us-english error message
// Assert.AreEqual ("XSLT compile error.", xe.Message, "#A5-US-ENGLISH");
Assert.AreEqual (-1, xe.Message.IndexOf("(0,0) :\n"), "#A5");
#else
Assert.AreEqual ("(0,0) :\n", xe.Message, "#A5");
#endif
Assert.IsNull (xe.SourceUri, "#A6");
Assert.AreSame (cause, xe.InnerException, "#A7");
Assert.IsNull (xe.Source, "#A8");
Assert.IsNull (xe.StackTrace, "#A9");
Assert.IsNull (xe.TargetSite, "#A10");
// null uri, line 1, pos 0, innerexception set
xe = new XsltCompileException (cause, (string) null, 1, 0);
Assert.AreEqual (1, xe.LineNumber, "#B1");
Assert.AreEqual (0, xe.LinePosition, "#B2");
Assert.IsNotNull (xe.Message, "#B3");
Assert.IsTrue (xe.Message.Length > 0, "#B4");
#if NET_2_0
// exact us-english error message
// Assert.AreEqual ("XSLT compile error at (1,0). See InnerException for details.", xe.Message, "#B5-US-ENGLISH");
Assert.IsTrue (xe.Message.IndexOf("(1,0).") != -1, "#B5");
#else
Assert.AreEqual ("(1,0) :\n", xe.Message, "#B5");
#endif
Assert.IsNull (xe.SourceUri, "#B6");
Assert.AreSame (cause, xe.InnerException, "#B7");
Assert.IsNull (xe.Source, "#B8");
Assert.IsNull (xe.StackTrace, "#B9");
Assert.IsNull (xe.TargetSite, "#B10");
// null uri, line 0, pos 1, innerexception set
xe = new XsltCompileException (cause, (string) null, 0, 1);
Assert.AreEqual (0, xe.LineNumber, "#C1");
Assert.AreEqual (1, xe.LinePosition, "#C2");
Assert.IsNotNull (xe.Message, "#C3");
Assert.IsTrue (xe.Message.Length > 0, "#C4");
#if NET_2_0
// exact us-english error message
// Assert.AreEqual ("XSLT compile error.", xe.Message, "#AC-US-ENGLISH");
Assert.AreEqual (-1, xe.Message.IndexOf("(0,1)"), "#C5");
#else
Assert.AreEqual ("(0,1) :\n", xe.Message, "#C5");
#endif
Assert.IsNull (xe.SourceUri, "#C6");
Assert.AreSame (cause, xe.InnerException, "#C7");
Assert.IsNull (xe.Source, "#C8");
Assert.IsNull (xe.StackTrace, "#C9");
Assert.IsNull (xe.TargetSite, "#C10");
// uri set, line 0, pos 0, innerexception set
xe = new XsltCompileException (cause, sourceUri, 0, 0);
Assert.AreEqual (0, xe.LineNumber, "#D1");
Assert.AreEqual (0, xe.LinePosition, "#D2");
Assert.IsNotNull (xe.Message, "#D3");
Assert.IsTrue (xe.Message.Length > 0, "#D4");
#if NET_2_0
// exact us-english error message
// Assert.AreEqual ("XSLT compile error.", xe.Message, "#D5-US-ENGLISH");
Assert.AreEqual (-1, xe.Message.IndexOf("(0,0)"), "#D5");
#else
Assert.AreEqual ("http://local/test.xsl(0,0) :\n", xe.Message, "#D5");
#endif
Assert.AreSame (sourceUri, xe.SourceUri, "#D6");
Assert.AreSame (cause, xe.InnerException, "#D7");
Assert.IsNull (xe.Source, "#D8");
Assert.IsNull (xe.StackTrace, "#D9");
Assert.IsNull (xe.TargetSite, "#D10");
// uri set, line 1, pos 0, innerexception set
xe = new XsltCompileException (cause, sourceUri, 1, 0);
Assert.AreEqual (1, xe.LineNumber, "#E1");
Assert.AreEqual (0, xe.LinePosition, "#E2");
Assert.IsNotNull (xe.Message, "#E3");
Assert.IsTrue (xe.Message.Length > 0, "#E4");
#if NET_2_0
// exact us-english error message
// Assert.AreEqual ("XSLT compile error at http://local/test.xsl(1,0). See InnerException for details.", xe.Message, "#E5-US-ENGLISH");
Assert.IsTrue (xe.Message.IndexOf("http://local/test.xsl(1,0)") != -1, "#E5");
#else
Assert.AreEqual ("http://local/test.xsl(1,0) :\n", xe.Message, "#E5");
#endif
Assert.AreSame (sourceUri, xe.SourceUri, "#E6");
Assert.AreSame (cause, xe.InnerException, "#E7");
Assert.IsNull (xe.Source, "#E8");
Assert.IsNull (xe.StackTrace, "#E9");
Assert.IsNull (xe.TargetSite, "#E10");
// uri set, line 0, pos 1, innerexception set
xe = new XsltCompileException (cause, sourceUri, 0, 1);
Assert.AreEqual (0, xe.LineNumber, "#F1");
Assert.AreEqual (1, xe.LinePosition, "#F2");
Assert.IsNotNull (xe.Message, "#F3");
Assert.IsTrue (xe.Message.Length > 0, "#F4");
#if NET_2_0
// exact us-english error message
// Assert.AreEqual ("XSLT compile error.", xe.Message, "#F5-US-ENGLISH");
Assert.AreEqual (-1, xe.Message.IndexOf("(0,1)"), "#F5");
#else
Assert.AreEqual ("http://local/test.xsl(0,1) :\n", xe.Message, "#F5");
#endif
Assert.AreSame (sourceUri, xe.SourceUri, "#F6");
Assert.AreSame (cause, xe.InnerException, "#F7");
Assert.IsNull (xe.Source, "#F8");
Assert.IsNull (xe.StackTrace, "#F9");
Assert.IsNull (xe.TargetSite, "#F10");
// uri set, line 1, pos 2, innerexception set
xe = new XsltCompileException (cause, sourceUri, 1, 2);
Assert.AreEqual (1, xe.LineNumber, "#G1");
Assert.AreEqual (2, xe.LinePosition, "#G2");
Assert.IsNotNull (xe.Message, "#G3");
Assert.IsTrue (xe.Message.Length > 0, "#G4");
#if NET_2_0
// exact us-english error message
// Assert.AreEqual ("XSLT compile error at http://local/test.xsl(1,2). See InnerException for details.", xe.Message, "#G5-US-ENGLISH");
Assert.IsTrue (xe.Message.IndexOf("http://local/test.xsl(1,2)") != -1, "#G5");
#else
Assert.AreEqual ("http://local/test.xsl(1,2) :\n", xe.Message, "#G5");
#endif
Assert.AreSame (sourceUri, xe.SourceUri, "#G5");
Assert.AreSame (cause, xe.InnerException, "#G6");
Assert.IsNull (xe.Source, "#G7");
Assert.IsNull (xe.StackTrace, "#G8");
Assert.IsNull (xe.TargetSite, "#G9");
// uri set, line 3, pos 4, innerexception null
xe = new XsltCompileException ((Exception) null, sourceUri, 3, 4);
Assert.AreEqual (3, xe.LineNumber, "#H1");
Assert.AreEqual (4, xe.LinePosition, "#H2");
Assert.IsNotNull (xe.Message, "#H3");
Assert.IsTrue (xe.Message.Length > 0, "#H4");
#if NET_2_0
// exact us-english error message
// Assert.AreEqual ("XSLT compile error at http://local/test.xsl(3,4). See InnerException for details.", xe.Message, "#H5-US-ENGLISH");
Assert.IsTrue (xe.Message.IndexOf("http://local/test.xsl(3,4)") != -1, "#H5");
#else
Assert.AreEqual ("http://local/test.xsl(3,4) :\n", xe.Message, "#H5");
#endif
Assert.AreSame (sourceUri, xe.SourceUri, "#H6");
Assert.IsNull (xe.InnerException, "#H7");
Assert.IsNull (xe.Source, "#H8");
Assert.IsNull (xe.StackTrace, "#H9");
Assert.IsNull (xe.TargetSite, "#H10");
// uri set, line 0, pos 0, innerexception null
xe = new XsltCompileException ((Exception) null, sourceUri, 0, 0);
Assert.AreEqual (0, xe.LineNumber, "#I1");
Assert.AreEqual (0, xe.LinePosition, "#I2");
Assert.IsNotNull (xe.Message, "#I3");
Assert.IsTrue (xe.Message.Length > 0, "#I4");
#if NET_2_0
// exact us-english error message
// Assert.AreEqual ("XSLT compile error.", xe.Message, "#I5-US-ENGLISH");
Assert.AreEqual (-1, xe.Message.IndexOf("http://local/test.xsl(0,0) :\n"), "#I5");
#else
Assert.AreEqual ("http://local/test.xsl(0,0) :\n", xe.Message, "#I5");
#endif
Assert.AreSame (sourceUri, xe.SourceUri, "#I6");
Assert.IsNull (xe.InnerException, "#I7");
Assert.IsNull (xe.Source, "#I8");
Assert.IsNull (xe.StackTrace, "#I9");
Assert.IsNull (xe.TargetSite, "#I10");
}
}
}

View File

@@ -0,0 +1,83 @@
//
// XsltExceptionCas.cs - CAS unit tests for System.Xml.Xsl.XsltException
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using System;
using System.Runtime.Serialization;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using System.Xml.Xsl;
namespace MonoCasTests.System.Xml.Xsl {
[TestFixture]
[Category ("CAS")]
public class XsltExceptionCas {
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[ExpectedException (typeof (SecurityException))]
[SecurityPermission (SecurityAction.Deny, SerializationFormatter = true)]
public void DenySerializationFormatter_GetObjectData ()
{
StreamingContext sc = new StreamingContext (StreamingContextStates.All);
XsltException xe = new XsltException (String.Empty, null);
xe.GetObjectData (null, sc);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
[SecurityPermission (SecurityAction.PermitOnly, SerializationFormatter = true)]
public void PermitOnlySerializationFormatter_GetObjectData ()
{
StreamingContext sc = new StreamingContext (StreamingContextStates.All);
XsltException xe = new XsltException (String.Empty, null);
xe.GetObjectData (null, sc);
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void DenyUnrestricted ()
{
// can we call everything without a SecurityException ?
XsltException xe = new XsltException (String.Empty, null);
Assert.AreEqual (0, xe.LineNumber, "LineNumber");
Assert.AreEqual (0, xe.LinePosition, "LinePosition");
Assert.IsNotNull (xe.Message, "Message");
Assert.IsNull (xe.SourceUri, "SourceUri");
}
}
}

View File

@@ -0,0 +1,128 @@
//
// XsltExceptionTests.cs - Unit tests for System.Xml.Xsl.XsltException
//
// Author:
// Gert Driesen <drieseng@users.sourceforge.net>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using System;
using System.Runtime.Serialization;
using System.Xml.Xsl;
namespace MonoCasTests.System.Xml.Xsl {
[TestFixture]
public class XsltExceptionTests
{
#if NET_2_0
[Test]
public void Constructor0 ()
{
XsltException xsltException = new XsltException ();
Assert.AreEqual (0, xsltException.LineNumber, "#1");
Assert.AreEqual (0, xsltException.LinePosition, "#2");
Assert.AreEqual (string.Empty, xsltException.Message, "#3");
Assert.IsNull (xsltException.SourceUri, "#4");
Assert.IsNull (xsltException.InnerException, "#5");
Assert.IsNull (xsltException.Source, "#6");
#if !TARGET_JVM
Assert.IsNull (xsltException.StackTrace, "#7");
Assert.IsNull (xsltException.TargetSite, "#8");
#endif
}
[Test]
public void Constructor1 ()
{
string msg = "mono";
XsltException xsltException = new XsltException (msg);
Assert.AreEqual (0, xsltException.LineNumber, "#1");
Assert.AreEqual (0, xsltException.LinePosition, "#2");
Assert.AreEqual (msg, xsltException.Message, "#3");
Assert.IsNull (xsltException.SourceUri, "#4");
Assert.IsNull (xsltException.InnerException, "#5");
Assert.IsNull (xsltException.Source, "#6");
#if !TARGET_JVM
Assert.IsNull (xsltException.StackTrace, "#7");
Assert.IsNull (xsltException.TargetSite, "#8");
#endif
}
#endif
[Test]
public void Constructor2 ()
{
string msg = "mono";
Exception cause = new ApplicationException ("cause");
XsltException xsltException = new XsltException (msg, cause);
Assert.AreEqual (0, xsltException.LineNumber, "#A1");
Assert.AreEqual (0, xsltException.LinePosition, "#A2");
Assert.AreEqual (msg, xsltException.Message, "#A3");
Assert.IsNull (xsltException.SourceUri, "#A4");
Assert.AreSame (cause, xsltException.InnerException, "#A5");
Assert.IsNull (xsltException.Source, "#A6");
#if !TARGET_JVM
Assert.IsNull (xsltException.StackTrace, "#A7");
Assert.IsNull (xsltException.TargetSite, "#A8");
#endif
xsltException = new XsltException ((string) null, cause);
Assert.AreEqual (0, xsltException.LineNumber, "#B1");
Assert.AreEqual (0, xsltException.LinePosition, "#B2");
Assert.IsNotNull (xsltException.Message, "#B3");
Assert.AreEqual (string.Empty, xsltException.Message, "#B4");
Assert.IsNull (xsltException.SourceUri, "#B5");
Assert.AreSame (cause, xsltException.InnerException, "#B6");
Assert.IsNull (xsltException.Source, "#B7");
#if !TARGET_JVM
Assert.IsNull (xsltException.StackTrace, "#B8");
Assert.IsNull (xsltException.TargetSite, "#B9");
#endif
xsltException = new XsltException (msg, (Exception) null);
Assert.AreEqual (0, xsltException.LineNumber, "#C1");
Assert.AreEqual (0, xsltException.LinePosition, "#C2");
Assert.AreEqual (msg, xsltException.Message, "#C3");
Assert.IsNull (xsltException.SourceUri, "#C4");
Assert.IsNull (xsltException.InnerException, "#C5");
Assert.IsNull (xsltException.Source, "#C6");
#if !TARGET_JVM
Assert.IsNull (xsltException.StackTrace, "#C7");
Assert.IsNull (xsltException.TargetSite, "#C8");
#endif
xsltException = new XsltException ((string) null, (Exception) null);
Assert.AreEqual (0, xsltException.LineNumber, "#D1");
Assert.AreEqual (0, xsltException.LinePosition, "#D2");
Assert.AreEqual (string.Empty, xsltException.Message, "#D3");
Assert.IsNull (xsltException.SourceUri, "#D4");
Assert.IsNull (xsltException.InnerException, "#D5");
Assert.IsNull (xsltException.Source, "#D6");
#if !TARGET_JVM
Assert.IsNull (xsltException.StackTrace, "#D7");
Assert.IsNull (xsltException.TargetSite, "#D8");
#endif
}
}
}