diff options
author | Sepideh Khoshnood <sekho@microsoft.com> | 2017-04-18 20:26:30 +0300 |
---|---|---|
committer | Dan Moseley <danmose@microsoft.com> | 2017-04-18 20:26:30 +0300 |
commit | cfcbe020b495895029d418aa8cbc0ff8192b3f62 (patch) | |
tree | 16bef0a53a2fe8dd95a87a0f6f654f24486e67aa /src/System.Private.Xml/tests/Xslt | |
parent | b43b4df2e0e2182154bb0f425cb4a61bc1269828 (diff) |
Fix Desktop failures in XSLT tests (#18557)
Diffstat (limited to 'src/System.Private.Xml/tests/Xslt')
6 files changed, 117 insertions, 20 deletions
diff --git a/src/System.Private.Xml/tests/Xslt/TestFiles/TestData/XsltApiV2/sample.xsd b/src/System.Private.Xml/tests/Xslt/TestFiles/TestData/XsltApiV2/sample.xsd new file mode 100644 index 0000000000..002e876183 --- /dev/null +++ b/src/System.Private.Xml/tests/Xslt/TestFiles/TestData/XsltApiV2/sample.xsd @@ -0,0 +1,22 @@ +<?xml version="1.0"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + +<!-- include same schema twice with unique Ids --> + +<xsd:include schemaLocation="addA001av.xsd"/> +<xsd:include schemaLocation="addA001av.xsd"/> + +<xsd:element name="purchaseOrder" type="PurchaseOrderType"/> + +<xsd:element name="comment" type="xsd:string"/> + +<xsd:complexType name="PurchaseOrderType"> + <xsd:sequence> + <xsd:element name="shipTo" type="Address"/> + <xsd:element name="billTo" type="Address"/> + <xsd:element ref="comment" minOccurs="0"/> + </xsd:sequence> + <xsd:attribute name="orderDate" type="xsd:date"/> +</xsd:complexType> + +</xsd:schema> diff --git a/src/System.Private.Xml/tests/Xslt/TestFiles/TestData/XsltApiV2/script.txt b/src/System.Private.Xml/tests/Xslt/TestFiles/TestData/XsltApiV2/script.txt new file mode 100644 index 0000000000..7858901f33 --- /dev/null +++ b/src/System.Private.Xml/tests/Xslt/TestFiles/TestData/XsltApiV2/script.txt @@ -0,0 +1,6 @@ +<ms:script language="C#" implements-prefix="user" xmlns:ms="urn:schemas-microsoft-com:xslt"> +public int add(int i, int j) +{ + return i+j; +} +</ms:script>
\ No newline at end of file diff --git a/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs b/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs index 6199e57de6..89d96f6096 100644 --- a/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs +++ b/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs @@ -4656,6 +4656,7 @@ namespace System.Xml.Tests _output = output; } + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Full framework does support Compiling JScript/CSharp scripts")] //[Variation(id = 1, Desc = "Call Current without MoveNext")] [InlineData()] [Theory] @@ -4671,25 +4672,36 @@ namespace System.Xml.Tests xslArg.AddParam("sourceUri", String.Empty, uriSource.ToString()); xslt.Load(FullFilePath("xsd2cs1.xsl"), new XsltSettings(true, true), new XmlUrlResolver()); + }); + + Assert.Equal("Compiling JScript/CSharp scripts is not supported", e.InnerException.Message); + } + + [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework, "Only full framework supports Compiling JScript/CSharp scripts")] + //[Variation(id = 1, Desc = "Call Current without MoveNext")] + [Fact] + public void NodeIter1_FullFramework() + { + XslCompiledTransform xslt = new XslCompiledTransform(); + + XsltArgumentList xslArg = new XsltArgumentList(); + XmlUrlResolver ur = new XmlUrlResolver(); + Uri uriSource = ur.ResolveUri(null, FullFilePath("sample.xsd")); + xslArg.AddParam("sourceUri", String.Empty, uriSource.ToString()); + + xslt.Load(FullFilePath("xsd2cs1.xsl"), new XsltSettings(true, true), new XmlUrlResolver()); + + Assert.Throws<System.InvalidOperationException>(() => + { XPathDocument doc = new XPathDocument(FullFilePath("sample.xsd")); - StringWriter sw = new StringWriter(); - try + using (StringWriter sw = new StringWriter()) { xslt.Transform(doc, xslArg, sw); - sw.Dispose(); - _output.WriteLine("No exception is thrown when .Current is called before .MoveNext on XPathNodeIterator"); - Assert.True(false); - } - catch (System.InvalidOperationException ex) - { - _output.WriteLine(ex.ToString()); - return; } }); - - Assert.Equal("Compiling JScript/CSharp scripts is not supported", e.InnerException.Message); } + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Full framework does support Compiling JScript/CSharp scripts")] //[Variation(id = 2, Desc = "Call Current after MoveNext")] [InlineData()] [Theory] @@ -4705,15 +4717,30 @@ namespace System.Xml.Tests xslArg.AddParam("sourceUri", String.Empty, uriSource.ToString()); xslt.Load(FullFilePath("xsd2cs2.xsl"), new XsltSettings(true, true), new XmlUrlResolver()); - - XPathDocument doc = new XPathDocument(FullFilePath("sample.xsd")); - StringWriter sw = new StringWriter(); - xslt.Transform(doc, xslArg, sw); - sw.Dispose(); - return; }); Assert.Equal("Compiling JScript/CSharp scripts is not supported", e.InnerException.Message); } + + [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework, "Only full framework supports Compiling JScript/CSharp scripts")] + //[Variation(id = 2, Desc = "Call Current after MoveNext")] + [Fact] + public void NodeIter2_FullFramework() + { + XslCompiledTransform xslt = new XslCompiledTransform(); + + XsltArgumentList xslArg = new XsltArgumentList(); + XmlUrlResolver ur = new XmlUrlResolver(); + Uri uriSource = ur.ResolveUri(null, FullFilePath("sample.xsd")); + xslArg.AddParam("sourceUri", String.Empty, uriSource.ToString()); + + xslt.Load(FullFilePath("xsd2cs2.xsl"), new XsltSettings(true, true), new XmlUrlResolver()); + + XPathDocument doc = new XPathDocument(FullFilePath("sample.xsd")); + using (StringWriter sw = new StringWriter()) + { + xslt.Transform(doc, xslArg, sw); + } + } } } diff --git a/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltSettings.cs b/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltSettings.cs index 69265ea40a..01d7d5519a 100644 --- a/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltSettings.cs +++ b/src/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltSettings.cs @@ -47,6 +47,7 @@ namespace System.Xml.Tests Assert.Equal(actual, expected); } + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Full framework does support Compiling JScript/CSharp scripts")] //[Variation(id = 1, Desc = "Test the script block with EnableScript, should work", Pri = 0, Params = new object[] { "XsltSettings.xml", "XsltSettings1.xsl", false, true })] [InlineData(1, "XsltSettings.xml", "XsltSettings1.xsl", false, true)] //[Variation(id = 4, Desc = "Test the script block with TrustedXslt, should work", Pri = 1, Params = new object[] { "XsltSettings.xml", "XsltSettings1.xsl", true, true })] @@ -62,6 +63,22 @@ namespace System.Xml.Tests Assert.Equal("Compiling JScript/CSharp scripts is not supported", e.InnerException.Message); } + [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework, "Only full framework supports Compiling JScript/CSharp scripts")] + //[Variation(id = 1, Desc = "Test the script block with EnableScript, should work", Pri = 0, Params = new object[] { "XsltSettings.xml", "XsltSettings1.xsl", false, true })] + [InlineData(1, "XsltSettings.xml", "XsltSettings1.xsl", false, true)] + //[Variation(id = 4, Desc = "Test the script block with TrustedXslt, should work", Pri = 1, Params = new object[] { "XsltSettings.xml", "XsltSettings1.xsl", true, true })] + [InlineData(4, "XsltSettings.xml", "XsltSettings1.xsl", true, true)] + //[Variation(id = 9, Desc = "Test the combination of script and document function with TrustedXslt, should work", Pri = 0, Params = new object[] { "XsltSettings.xml", "XsltSettings3.xsl", true, true })] + [InlineData(9, "XsltSettings.xml", "XsltSettings3.xsl", true, true)] + //[Variation(id = 11, Desc = "Test the combination of script and document function with EnableScript, only script should work", Pri = 2, Params = new object[] { "XsltSettings.xml", "XsltSettings3.xsl", false, true })] + [InlineData(11, "XsltSettings.xml", "XsltSettings3.xsl", false, true)] + [Theory] + public void XsltSettings1_1_ContainsScript_FullFramework(object param0, object param1, object param2, object param3, object param4) + { + XsltSettings1_1(param0, param1, param2, param3, param4); + } + + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Full framework does support Compiling JScript/CSharp scripts")] //[Variation(id = 15, Desc = "Test 1 with Default settings, should fail", Pri = 1, Params = new object[] { "XsltSettings.xml", "XsltSettings1.xsl", false, true, false, false })] [InlineData(15, "XsltSettings.xml", "XsltSettings1.xsl", false, true, false, false)] //[Variation(id = 16, Desc = "Test 2 with EnableScript override, should work", Pri = 1, Params = new object[] { "XsltSettings.xml", "XsltSettings1.xsl", false, false, false, true })] @@ -77,6 +94,21 @@ namespace System.Xml.Tests Assert.Equal("Compiling JScript/CSharp scripts is not supported", e.InnerException.Message); } + [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework, "Only full framework supports Compiling JScript/CSharp scripts")] + //[Variation(id = 15, Desc = "Test 1 with Default settings, should fail", Pri = 1, Params = new object[] { "XsltSettings.xml", "XsltSettings1.xsl", false, true, false, false })] + [InlineData(15, "XsltSettings.xml", "XsltSettings1.xsl", false, true, false, false)] + //[Variation(id = 16, Desc = "Test 2 with EnableScript override, should work", Pri = 1, Params = new object[] { "XsltSettings.xml", "XsltSettings1.xsl", false, false, false, true })] + [InlineData(16, "XsltSettings.xml", "XsltSettings1.xsl", false, false, false, true)] + //[Variation(id = 19, Desc = "Test 9 with Default settings override, should fail", Pri = 1, Params = new object[] { "XsltSettings.xml", "XsltSettings3.xsl", true, true, false, false })] + [InlineData(19, "XsltSettings.xml", "XsltSettings3.xsl", true, true, false, false)] + //[Variation(id = 20, Desc = "Test 10 with TrustedXslt override, should work", Pri = 1, Params = new object[] { "XsltSettings.xml", "XsltSettings3.xsl", false, false, true, true })] + [InlineData(20, "XsltSettings.xml", "XsltSettings3.xsl", false, false, true, true)] + [Theory] + public void XsltSettings1_2_ContainsScript_FullFramework(object param0, object param1, object param2, object param3, object param4, object param5, object param6) + { + XsltSettings1_2(param0, param1, param2, param3, param4, param5, param6); + } + //[Variation(id = 5, Desc = "Test the document function with EnableDocumentFunction, should work", Pri = 0, Params = new object[] { "XsltSettings.xml", "XsltSettings2.xsl", true, false })] [InlineData(5, "XsltSettings.xml", "XsltSettings2.xsl", true, false)] //[Variation(id = 8, Desc = "Test the document function with TrustedXslt, should work", Pri = 1, Params = new object[] { "XsltSettings.xml", "XsltSettings2.xsl", true, true })] diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs index 18f83a665e..2048d5bc31 100644 --- a/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs +++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs @@ -1747,7 +1747,10 @@ namespace System.Xml.Tests } catch (System.Xml.Xsl.XsltCompileException e) { - CheckExpectedError(e.InnerException, "system.xml", "Xslt_WrongStylesheetElement", new string[] { "" }); + if (PlatformDetection.IsFullFramework) + CheckExpectedError(e.InnerException, "system.data.sqlxml", "Xslt_WrongStylesheetElement", new string[] { "" }); + else + CheckExpectedError(e.InnerException, "system.xml", "Xslt_WrongStylesheetElement", new string[] { "" }); return; } _output.WriteLine("No exception thrown for a loading a closed reader!"); @@ -1847,7 +1850,11 @@ namespace System.Xml.Tests } catch (System.Xml.Xsl.XsltCompileException e) { - CheckExpectedError(e.InnerException, "system.xml", "Xslt_WrongStylesheetElement", new string[] { "" }); + + if (PlatformDetection.IsFullFramework) + CheckExpectedError(e.InnerException, "system.data.sqlxml", "Xslt_WrongStylesheetElement", new string[] { "" }); + else + CheckExpectedError(e.InnerException, "system.xml", "Xslt_WrongStylesheetElement", new string[] { "" }); } finally { diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/System.Xml.Xsl.XslTransformApi.Tests.csproj b/src/System.Private.Xml/tests/Xslt/XslTransformApi/System.Xml.Xsl.XslTransformApi.Tests.csproj index 1c4fdf0072..37296f055f 100644 --- a/src/System.Private.Xml/tests/Xslt/XslTransformApi/System.Xml.Xsl.XslTransformApi.Tests.csproj +++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/System.Xml.Xsl.XslTransformApi.Tests.csproj @@ -26,6 +26,9 @@ <Link>TestFiles\%(RecursiveDir)%(Filename)%(Extension)</Link> <DestinationDir>TestFiles\%(RecursiveDir)</DestinationDir> </SupplementalTestData> + <Compile Include="$(CommonTestPath)\System\PlatformDetection.cs"> + <Link>CommonTest\System\PlatformDetection.cs</Link> + </Compile> </ItemGroup> <ItemGroup> <ProjectReference Include="$(CommonTestPath)\System\Xml\ModuleCore\ModuleCore.csproj" /> |