diff --git a/src/Spring/Spring.Core/Spring.Core.2010.csproj b/src/Spring/Spring.Core/Spring.Core.2010.csproj index 45f7572e..3f55abba 100644 --- a/src/Spring/Spring.Core/Spring.Core.2010.csproj +++ b/src/Spring/Spring.Core/Spring.Core.2010.csproj @@ -696,7 +696,7 @@ - + diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorInstantiationInfo.cs b/src/Spring/Spring.Core/Util/ConstructorInstantiationInfo.cs similarity index 95% rename from src/Spring/Spring.Core/Objects/Factory/Support/ConstructorInstantiationInfo.cs rename to src/Spring/Spring.Core/Util/ConstructorInstantiationInfo.cs index 2eb85091..fb3fe70f 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorInstantiationInfo.cs +++ b/src/Spring/Spring.Core/Util/ConstructorInstantiationInfo.cs @@ -20,7 +20,7 @@ using System.Reflection; -namespace Spring.Objects.Factory.Support +namespace Spring.Util { /// /// Collects information on the constructor to use to create the instance and the argument instances to pass into the diff --git a/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/ctor-args.xml b/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/ctor-args.xml index b44d63f1..f189ebdb 100644 --- a/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/ctor-args.xml +++ b/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/ctor-args.xml @@ -3,9 +3,6 @@ Tests for list and map handling in an XML object definition file. - - - diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs index 7c00612b..720ed766 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs @@ -32,6 +32,7 @@ using Spring.Core.IO; using Spring.Expressions; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; +using Spring.Util; #endregion @@ -56,7 +57,7 @@ namespace Spring.Objects.Factory.Xml } [Test] - public void WalkThrough() + public void CanApplyConstructorArgsToAbstractType() { IResource resource = new ReadOnlyXmlTestResource("ctor-args.xml", GetType()); XmlObjectFactory xof = new XmlObjectFactory(resource); @@ -66,6 +67,7 @@ namespace Spring.Objects.Factory.Xml RootObjectDefinition def = (RootObjectDefinition) xof.GetObjectDefinition("rod"); ConstructorResolver resolver = new ConstructorResolver(xof, xof, new SimpleInstantiationStrategy(), new ObjectDefinitionValueResolver(xof)); + ConstructorInstantiationInfo ci = resolver.GetConstructorInstantiationInfo("rod", def, null, null); AbstractObjectDefinition objDef = (AbstractObjectDefinition)xof.GetObjectDefinition("foo"); diff --git a/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs b/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs index 5fcbebea..118d2b8e 100644 --- a/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs +++ b/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs @@ -131,27 +131,6 @@ namespace Spring.Proxy "Custom attribute not applied to member method."); } - [Test] - [Ignore] - // SPRNET-1262 - public void AppliesSpecificTypeAttributeWithNoPropertySettersToTargetType() - { - IProxyTypeBuilder builder = GetProxyBuilder(); - builder.TargetType = typeof(ClassWithFakeServiceKnownTypeAttribute); - builder.TypeAttributes.Add(new FakeServiceKnownTypeAttribute(typeof(TestObject))); - - Type proxy = builder.BuildProxyType(); - Assert.IsNotNull(proxy, "The proxy generated by a (valid) call to BuildProxy() was null."); - - object[] attrs = proxy.GetCustomAttributes(false); - Assert.IsNotNull(attrs, "Should have had 1 attribute applied to the target type."); - Assert.AreEqual(1, attrs.Length, "Should have had 1 attribute applied to the target type."); - Assert.AreEqual(typeof(FakeServiceKnownTypeAttribute), attrs[0].GetType(), "Wrong System.Type of Attribute applied to the target type."); - - FakeServiceKnownTypeAttribute fgsta = attrs[0] as FakeServiceKnownTypeAttribute; - Assert.AreEqual(typeof(TestObject), fgsta.Type, "Property 'Type' on Target Attribute not set!"); - } - [Test] // SPRNET-1262 public void AppliesSpecificTypeAttributeWithNoPropertySettersToTargetTypeUsingCustomAttributeBuilder() diff --git a/test/Spring/Spring.Services.Tests/ServiceModel/ServiceExporterTests.cs b/test/Spring/Spring.Services.Tests/ServiceModel/ServiceExporterTests.cs index 5b3444e6..b0581767 100644 --- a/test/Spring/Spring.Services.Tests/ServiceModel/ServiceExporterTests.cs +++ b/test/Spring/Spring.Services.Tests/ServiceModel/ServiceExporterTests.cs @@ -34,6 +34,7 @@ using Spring.ServiceModel; using Spring.Core.IO; using Spring.Objects.Factory; using Spring.Objects.Factory.Xml; +using System.Collections.Generic; #endregion @@ -53,16 +54,73 @@ namespace Spring.ServiceModel { const string xml = @" - - - - -"; - Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); - IObjectFactory objectFactory = new XmlObjectFactory(new InputStreamResource(stream, string.Empty)); + + + + + "; - se = new ServiceExporter(); - se.ObjectFactory = objectFactory; + using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(xml))) + { + IObjectFactory objectFactory = new XmlObjectFactory(new InputStreamResource(stream, string.Empty)); + se = new ServiceExporter(); + se.ObjectFactory = objectFactory; + } + + + + + + + + } + + + [Test] + //SPRNET-1262 + public void ProxiesDeclarativeAttributeWithConstructorArguments() + { + XmlObjectFactory objectFactory = null; + + const string xml = + @" + + + + + + + + + + + + + "; + + + using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(xml))) + { + objectFactory = new XmlObjectFactory(new InputStreamResource(stream, string.Empty)); + } + + Type proxyType = (Type)objectFactory.GetObject("service"); + object[] attrs = proxyType.GetCustomAttributes(false); + + ServiceKnownTypeAttribute attrib = null; + + //loop thru all retreived attributes, attempting to find the one that is of the expected type + for (int i = 0; i < attrs.Length; i++) + { + attrib = attrs[i] as ServiceKnownTypeAttribute; + + //break out of the loop once we find the one we want + if (attrib != null) + break; + } + + Assert.NotNull(attrib, String.Format("No attributes of the expecte type {0} were found.", typeof(ServiceKnownTypeAttribute))); + Assert.AreEqual(typeof(List), attrib.Type, "Property 'Type' on Target Attribute not set!"); } [Test] diff --git a/test/Spring/Spring.Services.Tests/Spring.Services.Tests.2010.csproj b/test/Spring/Spring.Services.Tests/Spring.Services.Tests.2010.csproj index 148df31b..8cf0bb84 100644 --- a/test/Spring/Spring.Services.Tests/Spring.Services.Tests.2010.csproj +++ b/test/Spring/Spring.Services.Tests/Spring.Services.Tests.2010.csproj @@ -214,6 +214,9 @@ Always + + + Always