resolved SPRNET-1079
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using NUnit.Framework;
|
||||
using Spring.Core.IO;
|
||||
using Spring.Objects.Factory.Config;
|
||||
using Spring.Util;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Objects.Factory.Xml
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
[TestFixture]
|
||||
public class NamespaceParserRegistryTests
|
||||
{
|
||||
private class TestNamespaceParser : INamespaceParser
|
||||
{
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
|
||||
public IObjectDefinition ParseElement(XmlElement element, ParserContext parserContext)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public ObjectDefinitionHolder Decorate(XmlNode node, ObjectDefinitionHolder definition, ParserContext parserContext)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
#if !NET_1_0
|
||||
/// <summary>
|
||||
/// This test doesn't work on .NET 1.0 because there are no XmlResolvers for schema loading...
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void CanLoadSchemaImportingOtherSchemaByRelativePath()
|
||||
{
|
||||
string schemaLocation = GetAssemblyResource( this.GetType(), "NamespaceParserRegistryTests_TestSchema.xsd" );
|
||||
NamespaceParserRegistry.RegisterParser(new TestNamespaceParser(), "http://www.example.com/brief", schemaLocation);
|
||||
XmlReader vr = XmlUtils.CreateValidatingReader( new StringResource(
|
||||
@"<?xml version='1.0' encoding='UTF-8' ?>
|
||||
<brief class='foo' />
|
||||
").InputStream, NamespaceParserRegistry.GetSchemas(), null);
|
||||
ConfigXmlDocument newDoc = new ConfigXmlDocument();
|
||||
newDoc.Load(vr);
|
||||
}
|
||||
#endif
|
||||
private string GetAssemblyResource( Type hint, string name)
|
||||
{
|
||||
return "assembly://" + hint.Assembly.FullName.Split(',')[0].Trim() + "/" + hint.Namespace + "/" + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<xsd:schema targetNamespace="http://www.example.com/brief"
|
||||
xmlns:brief="http://www.example.com/brief"
|
||||
xmlns:ex="http://www.example.com/common"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified">
|
||||
|
||||
<xsd:import namespace="http://www.example.com/common" schemaLocation="NamespaceParserRegistryTests_TestSchema_2.xsd"/>
|
||||
|
||||
<xsd:element name="brief">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="kopf" type="xsd:string"/>
|
||||
<xsd:element name="inhalt" type="xsd:string"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attributeGroup ref="ex:CommonAttributes"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
</xsd:schema>
|
||||
@@ -0,0 +1,11 @@
|
||||
<xsd:schema targetNamespace="http://www.example.com/common"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified">
|
||||
|
||||
<xsd:attributeGroup name="CommonAttributes">
|
||||
<xsd:attribute name="class" type="xsd:NMTOKEN" use="optional"/>
|
||||
<xsd:attribute name="id" type="xsd:ID" use="required"/>
|
||||
</xsd:attributeGroup>
|
||||
|
||||
</xsd:schema>
|
||||
@@ -1592,6 +1592,19 @@
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Objects\Factory\Xml\NamespaceParserRegistryTests.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Objects\Factory\Xml\NamespaceParserRegistryTests_TestSchema.xsd"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Objects\Factory\Xml\NamespaceParserRegistryTests_TestSchema_2.xsd"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Objects\Factory\Xml\NullAppender.cs"
|
||||
SubType = "Code"
|
||||
|
||||
@@ -329,7 +329,9 @@
|
||||
<Compile Include="Objects\Factory\Support\ObjectDefinitionBuilderTests.cs" />
|
||||
<Compile Include="Objects\Factory\Xml\ArrayCtorDependencyObject.cs" />
|
||||
<Compile Include="Objects\Factory\Xml\LocaleTests.cs" />
|
||||
<Compile Include="Objects\Factory\Xml\NamespaceParserRegistryTests.cs" />
|
||||
<Compile Include="Objects\Factory\Xml\ObjectFactorySectionHandlerTests.cs" />
|
||||
<Compile Include="Objects\Factory\Xml\ObjectNameGenerationTests.cs" />
|
||||
<Compile Include="Objects\Factory\Xml\SiimpleCtorWiringTests.cs" />
|
||||
<Compile Include="Objects\LazyTestObject.cs" />
|
||||
<Compile Include="Objects\Support\AbstractSharedStateFactoryTests.cs" />
|
||||
@@ -748,6 +750,8 @@
|
||||
<None Include="Context\Support\testobject.xsx">
|
||||
<DependentUpon>testobject.xsd</DependentUpon>
|
||||
</None>
|
||||
<EmbeddedResource Include="Objects\Factory\Xml\NamespaceParserRegistryTests_TestSchema.xsd" />
|
||||
<EmbeddedResource Include="Objects\Factory\Xml\NamespaceParserRegistryTests_TestSchema_2.xsd" />
|
||||
<None Include="Spring.Core.Tests.build" />
|
||||
<EmbeddedResource Include="Context\Support\contextB.xml" />
|
||||
<EmbeddedResource Include="Context\Support\contextC.xml" />
|
||||
@@ -889,4 +893,4 @@
|
||||
xcopy "$(ProjectDir)Data" ..\..\..\..\build\VS.Net.2008\Spring.Core.Tests\$(ConfigurationName)\ /y /s /q /d
|
||||
xcopy "$(ProjectDir)$(TargetFileName).config" ..\..\..\..\build\VS.Net.2008\Spring.Core.Tests\$(ConfigurationName)\ /y /s /q</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user