SPRNET-1126 - XmlMessageConverter/TypeMapper usage should be able to embed fully qualified type name to enable type sharing between producer and subscriber

This commit is contained in:
markpollack
2009-07-22 06:51:33 +00:00
parent 807f100104
commit b3e76a021d
5 changed files with 156 additions and 11 deletions

View File

@@ -0,0 +1,105 @@
#region License
/*
* Copyright <20> 2002-2009 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
using System;
using System.Collections;
using NUnit.Framework;
using Spring.Objects;
namespace Spring.Messaging.Nms.Support.Converter
{
/// <summary>
/// Test the TypeMapper
/// </summary>
/// <author>Mark Pollack</author>
[TestFixture]
public class TypeMapperTests
{
private TypeMapper tm;
[SetUp]
public void SetUp()
{
tm = new TypeMapper();
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void ConfigurationNamespaceTests()
{
tm.DefaultAssemblyName = "Spring.Objects";
tm.AfterPropertiesSet();
}
[Test]
public void FromTypeTestsForDictionary()
{
Assert.AreEqual("Hashtable", tm.FromType(typeof(Hashtable)));
}
[Test]
public void ToTypeForDictionary()
{
Assert.AreEqual(typeof (Hashtable), tm.ToType("Hashtable"));
}
[Test]
public void FromTypeForNonRegisteredType()
{
Assert.AreEqual("TestObject", tm.FromType(typeof(TestObject)));
}
[Test]
public void ToTypeForNonRegisteredTypeSettingDefaults()
{
tm.DefaultNamespace = "Spring.Objects";
tm.DefaultAssemblyName = "Spring.Core.Tests";
Type resolvedTyped = tm.ToType("TestObject");
Assert.AreEqual(typeof(TestObject), resolvedTyped);
}
[Test]
[ExpectedException(typeof(TypeLoadException))]
public void ToTypeForUnresolvableType()
{
tm.ToType("TestObject");
}
[Test]
public void MarhsalUsingAssemblyQualifiedName()
{
tm.UseAssemblyQualifiedName = true;
string typeAsString = tm.FromType(typeof (TestObject));
Type resolvedTyped = tm.ToType(typeAsString);
Assert.AreEqual(typeof(TestObject), resolvedTyped);
}
[Test]
public void UsingTypeMappings()
{
tm.IdTypeMapping.Add("1", typeof (TestObject));
tm.AfterPropertiesSet();
string typeAsString = tm.FromType(typeof (TestObject));
Assert.AreEqual("1", typeAsString);
Type resolvedType = tm.ToType("1");
Assert.AreEqual(typeof(TestObject), resolvedType);
}
}
}

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{FA7A6931-7DBE-4A32-A312-51FAD2E80332}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -110,6 +110,7 @@
<Compile Include="Messaging\Nms\Listener\Adapter\MessageContentsHandler.cs" />
<Compile Include="Messaging\Nms\Listener\Adapter\MessageListenerAdapterTests.cs" />
<Compile Include="Messaging\Nms\StubQueue.cs" />
<Compile Include="Messaging\Nms\Support\Converter\TypeMapperTests.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Messaging\Nms\Integration\SimpleMessageListenerContainerTests.xml" />

View File

@@ -1,7 +1,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>9.0.30729</ProductVersion>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C67E47AA-1ACD-41B4-A465-4D336A2319CA}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -166,7 +166,9 @@
</Content>
<Content Include="Data\Spring\Web\Support\PageHandlerFactoryTests\DisablesSession.aspx" />
<Content Include="Data\Spring\Web\Support\PageHandlerFactoryTests\TransferAfterSetResultSave.aspx" />
<EmbeddedResource Include="Data\Spring\Web\Support\LocalResourceManagerTests\App_LocalResources\WithResources.aspx.resx" />
<EmbeddedResource Include="Data\Spring\Web\Support\LocalResourceManagerTests\App_LocalResources\WithResources.aspx.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Web\Support\ControlInterceptionTests.objects.xml" />
</ItemGroup>
<ItemGroup>