Changing from arrays to IList, generify AOP API, change GetObjectsOfType<T> to GetObjects<T> and GetObjectNamesForType<T> to GetObjectNames<T>

This commit is contained in:
Marko Lahma
2012-03-26 08:45:50 +03:00
parent 68b67e3f45
commit 7778994f05
120 changed files with 883 additions and 844 deletions

View File

@@ -20,6 +20,8 @@
#region Imports
using System.Collections.Generic;
using NUnit.Framework;
using Spring.Aop.Framework;
@@ -70,8 +72,8 @@ namespace Spring.Aop.Config
IAdvised advised = testObject as IAdvised;
Assert.IsNotNull(advised);
IAdvisor[] advisors = advised.Advisors;
Assert.IsTrue(advisors.Length > 0, "Advisors should not be empty");
IList<IAdvisor> advisors = advised.Advisors;
Assert.IsTrue(advisors.Count > 0, "Advisors should not be empty");
}

View File

@@ -1,25 +1,26 @@
#region License
/*
* Copyright 2002-2010 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.
/*
* Copyright 2002-2010 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 System.Collections.Generic;
using AopAlliance.Aop;
using NUnit.Framework;
using Spring.Objects.Factory.Config;
@@ -37,7 +38,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
public ArrayList CheckedAdvisors = new ArrayList();
public object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName)
public IList<object> GetAdvicesAndAdvisorsForObject(Type targetType, string targetName)
{
return base.GetAdvicesAndAdvisorsForObject(targetType, targetName, null);
}
@@ -87,8 +88,8 @@ namespace Spring.Aop.Framework.AutoProxy
TestAdvisorAutoProxyCreator apc = new TestAdvisorAutoProxyCreator();
apc.ObjectFactory = of;
object[] advisors = apc.GetAdvicesAndAdvisorsForObject(typeof (object), "dummyTarget");
Assert.AreEqual(1, advisors.Length);
IList<object> advisors = apc.GetAdvicesAndAdvisorsForObject(typeof (object), "dummyTarget");
Assert.AreEqual(1, advisors.Count);
Assert.AreEqual( "RegularAdvisor", ((TestAdvisor)advisors[0]).Name );
Assert.AreEqual(1, apc.CheckedAdvisors.Count);

View File

@@ -1,24 +1,25 @@
#region License
/*
* Copyright 2002-2010 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.
/*
* Copyright 2002-2010 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.Generic;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Proxies;
@@ -120,13 +121,13 @@ namespace Spring.Aop.Framework.AutoProxy
this.ObjectFactory = objectFactory;
}
protected override object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource)
protected override IList<object> GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource)
{
if (typeof(IFactoryObject).IsAssignableFrom(targetType))
{
return DO_NOT_PROXY;
}
return new object[] { NopInterceptor };
return new List<object> { NopInterceptor };
}
}

View File

@@ -21,6 +21,7 @@
#region Imports
using System;
using System.Collections.Generic;
using System.Reflection;
using Common.Logging;
@@ -93,10 +94,10 @@ namespace Spring.Aop.Framework.AutoProxy
_logger.Trace("Created instance");
}
protected override object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource)
protected override IList<object> GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource)
{
_logger.Trace("GetAdvicesAndAdvisorsForObject begin");
object[] advices = base.GetAdvicesAndAdvisorsForObject(targetType, targetName, customTargetSource);
IList<object> advices = base.GetAdvicesAndAdvisorsForObject(targetType, targetName, customTargetSource);
_logger.Trace("GetAdvicesAndAdvisorsForObject end");
return advices;
}

View File

@@ -1,24 +1,25 @@
#region License
/*
* Copyright 2002-2010 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.
/*
* Copyright 2002-2010 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.Generic;
using AopAlliance.Aop;
using NUnit.Framework;
using Spring.Objects.Factory.Config;
@@ -34,7 +35,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
public class TestAdvisorAutoProxyCreator : InfrastructureAdvisorAutoProxyCreator
{
public object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName)
public IList<object> GetAdvicesAndAdvisorsForObject(Type targetType, string targetName)
{
return base.GetAdvicesAndAdvisorsForObject(targetType, targetName, null);
}
@@ -78,8 +79,8 @@ namespace Spring.Aop.Framework.AutoProxy
TestAdvisorAutoProxyCreator apc = new TestAdvisorAutoProxyCreator();
apc.ObjectFactory = of;
object[] advisors = apc.GetAdvicesAndAdvisorsForObject(typeof(object), "dummyTarget");
Assert.AreEqual(1, advisors.Length);
IList<object> advisors = apc.GetAdvicesAndAdvisorsForObject(typeof(object), "dummyTarget");
Assert.AreEqual(1, advisors.Count);
Assert.AreEqual("InfrastructureAdvisor", ((TestAdvisor)advisors[0]).Name);
}
}

View File

@@ -1222,7 +1222,7 @@ namespace Spring.Aop.Framework.DynamicProxy
IAdvised a1 = (IAdvised)p;
IAdvised a2 = (IAdvised)p2;
// Check we can manipulate state of p2
Assert.AreEqual(a1.Advisors.Length, a2.Advisors.Length);
Assert.AreEqual(a1.Advisors.Count, a2.Advisors.Count);
// This should work as SerializablePerson is equal
Assert.AreEqual(p, p2, "Proxies should be equal, even after one was serialized");
@@ -1706,7 +1706,7 @@ namespace Spring.Aop.Framework.DynamicProxy
Assert.AreEqual(2, ni.Count);
IAdvised advised = (IAdvised)ito;
Assert.AreEqual(1, advised.Advisors.Length, "Have 1 advisor");
Assert.AreEqual(1, advised.Advisors.Count, "Have 1 advisor");
Assert.AreEqual(ni, advised.Advisors[0].Advice);
NopInterceptor ni2 = new NopInterceptor();
advised.AddAdvice(1, ni2);
@@ -1750,7 +1750,7 @@ namespace Spring.Aop.Framework.DynamicProxy
// Check it still works: proxy factory state shouldn't have been corrupted
Assert.AreEqual(target.Age, proxied.Age);
Assert.AreEqual(1, ((IAdvised)proxied).Advisors.Length);
Assert.AreEqual(1, ((IAdvised)proxied).Advisors.Count);
}
[Test(Description = "Check that casting to Advised can't get around advice freeze.")]
@@ -1778,7 +1778,7 @@ namespace Spring.Aop.Framework.DynamicProxy
// Check it still works: proxy factory state shouldn't have been corrupted
Assert.AreEqual(target.Age, proxied.Age);
Assert.AreEqual(1, advised.Advisors.Length);
Assert.AreEqual(1, advised.Advisors.Count);
}
[Test]
@@ -1805,13 +1805,13 @@ namespace Spring.Aop.Framework.DynamicProxy
}
// Didn't get removed
Assert.AreEqual(1, advised.Advisors.Length);
Assert.AreEqual(1, advised.Advisors.Count);
pf.IsFrozen = false;
// Can now remove it
advised.RemoveAdvisor(0);
// Check it still works: proxy factory state shouldn't have been corrupted
Assert.AreEqual(target.Age, proxied.Age);
Assert.AreEqual(0, advised.Advisors.Length);
Assert.AreEqual(0, advised.Advisors.Count);
}
[Test(Description = "Check that the string is informative.")]

View File

@@ -154,11 +154,11 @@ namespace Spring.Aop.Framework
IAdvised pc1 = (IAdvised)test1;
IAdvised pc2 = (IAdvised)test1_1;
Assert.AreEqual(pc1.Advisors, pc2.Advisors);
int oldLength = pc1.Advisors.Length;
int oldLength = pc1.Advisors.Count;
NopInterceptor di = new NopInterceptor();
pc1.AddAdvice(1, di);
Assert.AreEqual(pc1.Advisors, pc2.Advisors);
Assert.AreEqual(oldLength + 1, pc2.Advisors.Length, "Now have one more advisor");
Assert.AreEqual(oldLength + 1, pc2.Advisors.Count, "Now have one more advisor");
Assert.AreEqual(di.Count, 0);
test1.Age = (5);
Assert.AreEqual(test1_1.Age, test1.Age);
@@ -224,12 +224,12 @@ namespace Spring.Aop.Framework
string dummy = to.Name;
IAdvised config = (IAdvised)to;
Assert.AreEqual(1, config.Advisors.Length, "Object should have only one advisors");
Assert.AreEqual(1, config.Advisors.Count, "Object should have only one advisors");
Exception ex = new NotSupportedException("Invoke");
// Add evil interceptor to head of list
config.AddAdvice(0, new EvilMethodInterceptor(ex));
Assert.AreEqual(2, config.Advisors.Length, "The advisor count is wrong after adding an advisor programmatically.");
Assert.AreEqual(2, config.Advisors.Count, "The advisor count is wrong after adding an advisor programmatically.");
try
{
@@ -266,16 +266,16 @@ namespace Spring.Aop.Framework
IIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped));
// add to front of introduction chain
int oldCount = config.Introductions.Length;
int oldCount = config.Introductions.Count;
config.AddIntroduction(0, advisor);
Assert.IsTrue(config.Introductions.Length == oldCount + 1);
Assert.IsTrue(config.Introductions.Count == oldCount + 1);
ITimeStamped ts2 = (ITimeStamped)factory.GetObject("test1");
Assert.IsTrue(ts2.TimeStamp == new DateTime(time));
// Can remove
config.RemoveIntroduction(advisor);
Assert.IsTrue(config.Introductions.Length == oldCount);
Assert.IsTrue(config.Introductions.Count == oldCount);
// Existing reference will still work
object o = ts2.TimeStamp;
@@ -292,9 +292,9 @@ namespace Spring.Aop.Framework
}
// Now check non-effect of removing interceptor that isn't there
oldCount = config.Advisors.Length;
oldCount = config.Advisors.Count;
config.RemoveAdvice(new DebugAdvice());
Assert.IsTrue(config.Advisors.Length == oldCount);
Assert.IsTrue(config.Advisors.Count == oldCount);
ITestObject it = (ITestObject)ts2;
DebugAdvice debugInterceptor = new DebugAdvice();
@@ -330,16 +330,16 @@ namespace Spring.Aop.Framework
IIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped));
// add to front of introduction chain
int oldCount = config.Introductions.Length;
int oldCount = config.Introductions.Count;
config.AddIntroduction(0, advisor);
Assert.IsTrue(config.Introductions.Length == oldCount + 1);
Assert.IsTrue(config.Introductions.Count == oldCount + 1);
ITimeStamped ts2 = (ITimeStamped)factory.GetObject("test2");
Assert.IsTrue(ts2.TimeStamp == new DateTime(time));
// Can remove
config.RemoveIntroduction(advisor);
Assert.IsTrue(config.Introductions.Length == oldCount);
Assert.IsTrue(config.Introductions.Count == oldCount);
// Existing reference will still work
object o = ts2.TimeStamp;
@@ -358,9 +358,9 @@ namespace Spring.Aop.Framework
ITestObject it = (ITestObject)factory.GetObject("test2");
config = (IAdvised)it;
oldCount = config.Advisors.Length;
oldCount = config.Advisors.Count;
config.RemoveAdvice(new DebugAdvice());
Assert.IsTrue(config.Advisors.Length == oldCount);
Assert.IsTrue(config.Advisors.Count == oldCount);
DebugAdvice debugInterceptor = new DebugAdvice();
config.AddAdvice(0, debugInterceptor);
@@ -462,10 +462,10 @@ namespace Spring.Aop.Framework
ProxyFactoryObject pfb = (ProxyFactoryObject)factory.GetObject("&validGlobals");
pfb.GetObject(); // for creation
Assert.AreEqual(2, pfb.Advisors.Length, "Proxy should have 1 global and 1 explicit advisor");
Assert.AreEqual(1, pfb.Introductions.Length, "Proxy should have 1 global introduction");
Assert.AreEqual(2, pfb.Advisors.Count, "Proxy should have 1 global and 1 explicit advisor");
Assert.AreEqual(1, pfb.Introductions.Count, "Proxy should have 1 global introduction");
agi.GlobalsAdded = ((IAdvised)agi).Introductions.Length;
agi.GlobalsAdded = ((IAdvised)agi).Introductions.Count;
Assert.IsTrue(agi.GlobalsAdded == 1);
IApplicationEventListener l = (IApplicationEventListener)factory.GetObject("validGlobals");

View File

@@ -399,7 +399,7 @@ namespace Spring.Aop.Framework
advSup.AddAdvisor(advisor1);
advSup.AddAdvisor(advisor1);
Assert.AreEqual(1, advSup.Advisors.Length);
Assert.AreEqual(1, advSup.Advisors.Count);
}
private class AnonymousClassTimeStamped : ITimeStamped
@@ -454,7 +454,7 @@ namespace Spring.Aop.Framework
// Extend to get new interface
TestObjectSubclass raw = new TestObjectSubclass();
ProxyFactory factory = new ProxyFactory(raw);
Assert.AreEqual(8, factory.Interfaces.Length, "Found correct number of interfaces");
Assert.AreEqual(8, factory.Interfaces.Count, "Found correct number of interfaces");
//System.out.println("Proxied interfaces are " + StringUtils.arrayToDelimitedString(factory.getProxiedInterfaces(), ","));
ITestObject tb = (ITestObject)factory.GetProxy();
Assert.IsTrue(tb is IOther, "Picked up secondary interface");
@@ -465,14 +465,14 @@ namespace Spring.Aop.Framework
DateTime t = new DateTime(2004, 8, 1);
TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor(t);
Console.WriteLine(StringUtils.ArrayToDelimitedString(factory.Interfaces, "/"));
Console.WriteLine(StringUtils.CollectionToDelimitedString(factory.Interfaces, "/"));
//factory.addAdvisor(0, new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped)));
factory.AddIntroduction(
new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped))
);
Console.WriteLine(StringUtils.ArrayToDelimitedString(factory.Interfaces, "/"));
Console.WriteLine(StringUtils.CollectionToDelimitedString(factory.Interfaces, "/"));
ITimeStamped ts = (ITimeStamped)factory.GetProxy();
Assert.IsTrue(ts.TimeStamp == t);

View File

@@ -1,9 +1,9 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Diagnostics;
using Common.Logging;
using Common.Logging.Simple;
@@ -44,9 +44,9 @@ namespace Spring.Aspects.Exceptions
System.Diagnostics.Trace.Listeners.Remove(listener);
}
private IList logMessages = new ArrayList();
private IList<string> logMessages = new List<string>();
public IList LogMessages
public IList<string> LogMessages
{
get { return logMessages; }
set { logMessages = value; }

View File

@@ -119,28 +119,27 @@ namespace Spring.Context.Support
return null;
}
public string[] GetObjectNamesForType(Type type)
public IList<string> GetObjectNamesForType(Type type)
{
return null;
}
public string[] GetObjectNamesForType<T>()
public IList<string> GetObjectNames<T>()
{
return null;
}
public string[] GetObjectNamesForType(
Type type, bool includePrototypes, bool includeFactoryObjects)
public IList<string> GetObjectNamesForType(Type type, bool includePrototypes, bool includeFactoryObjects)
{
return null;
}
public string[] GetObjectNamesForType<T>(bool includePrototypes, bool includeFactoryObjects)
public IList<string> GetObjectNames<T>(bool includePrototypes, bool includeFactoryObjects)
{
return null;
}
string[] IListableObjectFactory.GetObjectDefinitionNames()
IList<string> IListableObjectFactory.GetObjectDefinitionNames()
{
return null;
}
@@ -150,7 +149,7 @@ namespace Spring.Context.Support
return null;
}
public IDictionary<string, T> GetObjectsOfType<T>()
public IDictionary<string, T> GetObjects<T>()
{
return null;
}
@@ -160,7 +159,7 @@ namespace Spring.Context.Support
return null;
}
public IDictionary<string, T> GetObjectsOfType<T>(bool includePrototypes, bool includeFactoryObjects)
public IDictionary<string, T> GetObjects<T>(bool includePrototypes, bool includeFactoryObjects)
{
return null;
}
@@ -199,7 +198,7 @@ namespace Spring.Context.Support
return false;
}
public string[] GetAliases(string name)
public IList<string> GetAliases(string name)
{
return null;
}

View File

@@ -21,6 +21,7 @@
#region Imports
using System;
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework;
@@ -75,9 +76,9 @@ namespace Spring.Core.TypeResolution
{
Type[] expected = new Type[] { typeof(IFoo) };
string[] input = new string[] { typeof(IFoo).AssemblyQualifiedName };
Type[] actual = TypeResolutionUtils.ResolveInterfaceArray(input);
IList<Type> actual = TypeResolutionUtils.ResolveInterfaceArray(input);
Assert.IsNotNull(actual);
Assert.AreEqual(expected.Length, actual.Length);
Assert.AreEqual(expected.Length, actual.Count);
Assert.AreEqual(expected[0], actual[0]);
}

View File

@@ -21,6 +21,7 @@
#region Imports
using System;
using System.Collections.Generic;
using NUnit.Framework;
@@ -62,10 +63,10 @@ namespace Spring.Objects.Factory {
protected internal void AssertCount (int count)
{
string [] defnames = ListableObjectFactory.GetObjectDefinitionNames ();
IList<string> defnames = ListableObjectFactory.GetObjectDefinitionNames ();
Assert.IsTrue (
defnames.Length == count,
string.Format ("We should have {0} objects, not {1}.", count, defnames.Length));
defnames.Count == count,
string.Format ("We should have {0} objects, not {1}.", count, defnames.Count));
}
[Test]
@@ -76,19 +77,19 @@ namespace Spring.Objects.Factory {
public virtual void AssertTestObjectCount (int count)
{
string [] defnames =
IList<string> defnames =
ListableObjectFactory.GetObjectNamesForType (typeof (TestObject));
Assert.IsTrue (
defnames.Length == count,
string.Format ("We should have {0} objects for class {1}, not {2}.", count, typeof (TestObject).FullName, defnames.Length));
defnames.Count == count,
string.Format ("We should have {0} objects for class {1}, not {2}.", count, typeof (TestObject).FullName, defnames.Count));
}
[Test]
public virtual void GetDefinitionsForNoSuchClass ()
{
string[] defnames =
IList<string> defnames =
ListableObjectFactory.GetObjectNamesForType (typeof (string));
Assert.IsTrue (defnames.Length == 0, "No string definitions");
Assert.IsTrue (defnames.Count == 0, "No string definitions");
}
/// <summary>
@@ -101,7 +102,7 @@ namespace Spring.Objects.Factory {
{
int count =
ListableObjectFactory.GetObjectNamesForType (
typeof (IFactoryObject)).Length;
typeof (IFactoryObject)).Count;
Assert.IsTrue (
count == 2,
string.Format ("Should have 2 factories, not {0}.", count));

View File

@@ -80,7 +80,7 @@ namespace Spring.Objects.Factory
Assert.IsTrue(-1 < ex.Message.IndexOf("already registered"));
}
Assert.AreEqual(1, of.GetAliases("nAmE").Length);
Assert.AreEqual(1, of.GetAliases("nAmE").Count);
Assert.AreEqual(testObject, of.GetObject("nAmE"));
Assert.AreEqual(testObject, of.GetObject("ALIAS"));
}

View File

@@ -146,7 +146,7 @@ namespace Spring.Objects.Factory
def.FactoryMethodName = "CreateTestObject";
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
lof.RegisterObjectDefinition("factoryObject", def);
IDictionary<string, TestObject> objs = lof.GetObjectsOfType<TestObject>();
IDictionary<string, TestObject> objs = lof.GetObjects<TestObject>();
Assert.AreEqual(1, objs.Count);
}
@@ -160,7 +160,7 @@ namespace Spring.Objects.Factory
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
lof.RegisterObjectDefinition("factoryObject", def);
lof.RegisterObjectDefinition("target", new RootObjectDefinition(typeof(TestObjectCreator)));
IDictionary<string, TestObject> objs = lof.GetObjectsOfType<TestObject>();
IDictionary<string, TestObject> objs = lof.GetObjects<TestObject>();
Assert.AreEqual(1, objs.Count);
}
@@ -404,8 +404,7 @@ namespace Spring.Objects.Factory
#region IInstantiationAwareObjectPostProcessor Members
public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance,
string objectName)
public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, IList<PropertyInfo> pis, object objectInstance, string objectName)
{
return pvs;
}
@@ -455,8 +454,7 @@ namespace Spring.Objects.Factory
#region IInstantiationAwareObjectPostProcessor Members
public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance,
string objectName)
public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, IList<PropertyInfo> pis, object objectInstance, string objectName)
{
return pvs;
}
@@ -532,7 +530,7 @@ namespace Spring.Objects.Factory
{
IListableObjectFactory lof = new DefaultListableObjectFactory();
Assert.IsTrue(lof.GetObjectDefinitionNames() != null, "No objects defined --> array != null");
Assert.IsTrue(lof.GetObjectDefinitionNames().Length == 0, "No objects defined after no arg constructor");
Assert.IsTrue(lof.GetObjectDefinitionNames().Count == 0, "No objects defined after no arg constructor");
Assert.IsTrue(lof.ObjectDefinitionCount == 0, "No objects defined after no arg constructor");
}
@@ -640,7 +638,7 @@ namespace Spring.Objects.Factory
lof.RegisterSingleton("singletonObject", singletonObject);
Assert.IsTrue(lof.ContainsObject("singletonObject"));
Assert.IsTrue(lof.IsSingleton("singletonObject"));
Assert.AreEqual(0, lof.GetAliases("singletonObject").Length);
Assert.AreEqual(0, lof.GetAliases("singletonObject").Count);
DependenciesObject test = (DependenciesObject)lof.GetObject("test");
Assert.AreEqual(singletonObject, lof.GetObject("singletonObject"));
Assert.AreEqual(singletonObject, test.Spouse);
@@ -1751,8 +1749,8 @@ namespace Spring.Objects.Factory
DefaultListableObjectFactory of = new DefaultListableObjectFactory();
of.RegisterObjectDefinition("mod", new RootObjectDefinition(typeof(A)));
string[] names = of.GetObjectNamesForType(typeof (ISerializable), false, false);
Assert.IsNotEmpty(names);
IList<string> names = of.GetObjectNamesForType(typeof (ISerializable), false, false);
Assert.IsNotEmpty((ICollection) names);
Assert.AreEqual("&mod", names[0]);
}

View File

@@ -72,7 +72,7 @@ namespace Spring.Objects.Factory
[Test]
public void ObjectNamesIncludingAncestors()
{
IList names = ObjectFactoryUtils.ObjectNamesIncludingAncestors(_factory);
IList<string> names = ObjectFactoryUtils.ObjectNamesIncludingAncestors(_factory);
Assert.AreEqual(6, names.Count);
}
@@ -89,8 +89,8 @@ namespace Spring.Objects.Factory
mocks.ReplayAll();
string[] names = ObjectFactoryUtils.ObjectNamesIncludingAncestors(of);
Assert.AreEqual(5, names.Length);
IList<string> names = ObjectFactoryUtils.ObjectNamesIncludingAncestors(of);
Assert.AreEqual(5, names.Count);
Assert.AreEqual(new string[] { "objA","objB","objC","obj2A","obj2C" }, names);
mocks.VerifyAll();
@@ -99,7 +99,7 @@ namespace Spring.Objects.Factory
[Test]
public void ObjectNamesForTypeIncludingAncestors()
{
IList names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_factory, typeof (ITestObject));
IList<string> names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_factory, typeof (ITestObject));
// includes 2 TestObjects from IFactoryObjects (DummyFactory definitions)
Assert.AreEqual(4, names.Count);
Assert.IsTrue(names.Contains("test"));
@@ -116,7 +116,7 @@ namespace Spring.Objects.Factory
DefaultListableObjectFactory child = new DefaultListableObjectFactory(root);
child.RegisterObjectDefinition("excludeLocalObject", new RootObjectDefinition(typeof(Hashtable)));
IList names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(child, typeof (ArrayList));
IList<string> names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(child, typeof (ArrayList));
// "excludeLocalObject" matches on the parent, but not the local object definition
Assert.AreEqual(0, names.Count);
@@ -139,8 +139,8 @@ namespace Spring.Objects.Factory
mocks.ReplayAll();
string[] names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE);
Assert.AreEqual(5, names.Length);
IList<string> names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE);
Assert.AreEqual(5, names.Count);
Assert.AreEqual(new string[] { "objA", "objB", "objC", "obj2A", "obj2C" }, names);
mocks.VerifyAll();
@@ -160,8 +160,8 @@ namespace Spring.Objects.Factory
mocks.ReplayAll();
string[] names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE, false, false);
Assert.AreEqual(5, names.Length);
IList<string> names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE, false, false);
Assert.AreEqual(5, names.Count);
Assert.AreEqual(new string[] { "objA", "objB", "objC", "obj2A", "obj2C" }, names);

View File

@@ -65,7 +65,7 @@ namespace Spring.Objects.Factory.Support
"ParentName property not initialized correctly by ctor.");
Assert.IsNotNull(def.PropertyValues,
"PropertyValues must be init'd to a non-null collection if not explicitly supplied.");
Assert.AreEqual(0, def.PropertyValues.PropertyValues.Length,
Assert.AreEqual(0, def.PropertyValues.PropertyValues.Count,
"PropertyValues must be init'd to an empty collection if not explicitly supplied.");
}
}

View File

@@ -44,7 +44,7 @@ namespace Spring.Objects.Factory.Support
typeof (TestObject).FullName, null, AppDomain.CurrentDomain);
Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
Assert.AreEqual(typeof (TestObject), definition.ObjectType);
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length,
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count,
"Must not have any property values as none were passed in.");
Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount,
"Must not have any ctor args as none were passed in.");
@@ -59,7 +59,7 @@ namespace Spring.Objects.Factory.Support
typeof (TestObject).FullName, "Aimee Mann", AppDomain.CurrentDomain);
Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
Assert.AreEqual(typeof (TestObject), definition.ObjectType);
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length,
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count,
"Must not have any property values as none were passed in.");
Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount,
"Must not have any ctor args as none were passed in.");
@@ -74,7 +74,7 @@ namespace Spring.Objects.Factory.Support
typeof (TestObject).FullName, null, null);
Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
Assert.AreEqual(typeof (TestObject).FullName, definition.ObjectTypeName);
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length,
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count,
"Must not have any property values as none were passed in.");
Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount,
"Must not have any ctor args as none were passed in.");

View File

@@ -89,7 +89,7 @@ namespace Spring.Objects.Factory.Support
Assert.AreEqual( "Ohhh", def.ResourceDescription );
Assert.IsTrue( def.HasConstructorArgumentValues );
Assert.AreEqual( other.ConstructorArgumentValues.ArgumentCount, def.ConstructorArgumentValues.ArgumentCount );
Assert.AreEqual( other.PropertyValues.PropertyValues.Length, def.PropertyValues.PropertyValues.Length );
Assert.AreEqual( other.PropertyValues.PropertyValues.Count, def.PropertyValues.PropertyValues.Count );
Assert.AreEqual( other.EventHandlerValues.Events.Count, def.EventHandlerValues.Events.Count );
}
@@ -148,14 +148,14 @@ namespace Spring.Objects.Factory.Support
Assert.AreEqual( "InitChild", rod.InitMethodName );
Assert.AreEqual( "DestroyChild", rod.DestroyMethodName );
Assert.AreEqual( DependencyCheckingMode.None, rod.DependencyCheck );
Assert.AreEqual( 4, rod.DependsOn.Length);
Assert.AreEqual( 4, rod.DependsOn.Count);
Assert.AreEqual( false, rod.IsAbstract );
Assert.AreEqual( false, rod.IsLazyInit );
Assert.AreEqual( "ChildFactoryMethodName", rod.FactoryMethodName );
Assert.AreEqual( "ChildFactoryObjectName", rod.FactoryObjectName );
Assert.AreEqual( "ChildResourceDescription", rod.ResourceDescription );
Assert.AreEqual( 2, rod.ConstructorArgumentValues.ArgumentCount );
Assert.AreEqual( 2, rod.PropertyValues.PropertyValues.Length );
Assert.AreEqual( 2, rod.PropertyValues.PropertyValues.Count );
Assert.AreEqual( "Val1", rod.PropertyValues.GetPropertyValue("Prop1").Value);
Assert.AreEqual( 50, rod.PropertyValues.GetPropertyValue("Age").Value);
Assert.AreEqual( 2, rod.EventHandlerValues.Events.Count );
@@ -183,7 +183,7 @@ namespace Spring.Objects.Factory.Support
"Must be empty if null was passed to the ctor." );
Assert.IsNotNull( def.PropertyValues,
"Must never be null, but rather just empty." );
Assert.AreEqual( 0, def.PropertyValues.PropertyValues.Length,
Assert.AreEqual( 0, def.PropertyValues.PropertyValues.Count,
"Must be empty if null was passed to the ctor." );
}
}

View File

@@ -19,6 +19,8 @@
#endregion
using System;
using System.Collections.Generic;
using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
@@ -109,7 +111,7 @@ namespace Spring.Objects.Factory
get { throw new NotImplementedException(); }
}
public string[] DependsOn
public IList<string> DependsOn
{
get { throw new NotImplementedException(); }
}

View File

@@ -22,6 +22,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
@@ -83,11 +85,11 @@ namespace Spring.Objects.Factory.Xml
protected void SetUp()
{
parent = new DefaultListableObjectFactory();
IDictionary m = new Hashtable();
IDictionary<string, object> m = new Dictionary<string, object>();
m["name"] = "Albert";
parent.RegisterObjectDefinition("father", new RootObjectDefinition(typeof (TestObject), new MutablePropertyValues(m)));
m = new Hashtable();
m["name"] = "Roderick";
m = new Dictionary<string, object>();
m["name"] = "Roderick";
parent.RegisterObjectDefinition("rod", new RootObjectDefinition(typeof (TestObject), new MutablePropertyValues(m)));
// for testing dynamic ctor arguments + parent.GetObject() call propagation

View File

@@ -22,6 +22,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Common.Logging;
@@ -198,12 +199,12 @@ namespace Spring.Objects.Factory.Xml
{
IResource resource = new ReadOnlyXmlTestResource("collections.xml", GetType());
XmlObjectFactory xof = new XmlObjectFactory(resource);
IList objectNames = xof.GetObjectDefinitionNames();
IList<string> objectNames = xof.GetObjectDefinitionNames();
TestObject tb1 = (TestObject) xof.GetObject("aliased");
TestObject alias1 = (TestObject) xof.GetObject("myalias");
Assert.IsTrue(tb1 == alias1);
IList tb1Aliases = xof.GetAliases("aliased");
IList<string> tb1Aliases = xof.GetAliases("aliased");
Assert.AreEqual(1, tb1Aliases.Count);
Assert.IsTrue(tb1Aliases.Contains("myalias"));
Assert.IsTrue(objectNames.Contains("aliased"));
@@ -214,7 +215,7 @@ namespace Spring.Objects.Factory.Xml
TestObject alias3 = (TestObject) xof.GetObject("alias2");
Assert.IsTrue(tb2 == alias2);
Assert.IsTrue(tb2 == alias3);
IList tb2Aliases = xof.GetAliases("multiAliased");
IList<string> tb2Aliases = xof.GetAliases("multiAliased");
Assert.AreEqual(2, tb2Aliases.Count);
Assert.IsTrue(tb2Aliases.Contains("alias1"));
Assert.IsTrue(tb2Aliases.Contains("alias2"));
@@ -228,7 +229,7 @@ namespace Spring.Objects.Factory.Xml
Assert.IsTrue(tb3 == alias4);
Assert.IsTrue(tb3 == alias5);
IList tb3Aliases = xof.GetAliases("aliasWithoutId1");
IList<string> tb3Aliases = xof.GetAliases("aliasWithoutId1");
Assert.AreEqual(2, tb2Aliases.Count);
Assert.IsTrue(tb3Aliases.Contains("aliasWithoutId2"));
Assert.IsTrue(tb3Aliases.Contains("aliasWithoutId3"));

View File

@@ -350,7 +350,7 @@ namespace Spring.Objects.Factory.Xml
Assert.AreEqual(AutoWiringMode.No, od2.AutowireMode);
Assert.AreEqual("init", od2.InitMethodName);
Assert.AreEqual("destroy", od2.DestroyMethodName);
Assert.AreEqual(1, od2.DependsOn.Length);
Assert.AreEqual(1, od2.DependsOn.Count);
Assert.AreEqual("test1", od2.DependsOn[0]);
Assert.AreEqual(DependencyCheckingMode.Simple, od2.DependencyCheck);
}

View File

@@ -459,9 +459,9 @@ namespace Spring.Objects.Factory.Xml
</objects>";
stream = new MemoryStream(Encoding.UTF8.GetBytes(xml));
XmlObjectFactory factory = new XmlObjectFactory(new InputStreamResource(stream, string.Empty));
string[] names = factory.GetObjectDefinitionNames();
IList<string> names = factory.GetObjectDefinitionNames();
// mmm, how is one to test this? I have no idea what the generated name is...
Assert.AreEqual(2, names.Length, "Should have got two object names, one of which is autogenerated.");
Assert.AreEqual(2, names.Count, "Should have got two object names, one of which is autogenerated.");
}
/// <summary>

View File

@@ -20,8 +20,7 @@
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
@@ -70,16 +69,16 @@ namespace Spring.Objects
root.Add (new PropertyValue ("Name", "Fiona Apple"));
root.Add (new PropertyValue ("Age", 24));
MutablePropertyValues props = new MutablePropertyValues (root);
Assert.AreEqual (2, props.PropertyValues.Length);
Assert.AreEqual (2, props.PropertyValues.Count);
}
[Test]
public void InstantiationWithNulls ()
{
MutablePropertyValues props = new MutablePropertyValues ((IDictionary) null);
Assert.AreEqual (0, props.PropertyValues.Length);
MutablePropertyValues props = new MutablePropertyValues ((IDictionary<string, object>) null);
Assert.AreEqual (0, props.PropertyValues.Count);
MutablePropertyValues props2 = new MutablePropertyValues ((IPropertyValues) null);
Assert.AreEqual (0, props2.PropertyValues.Length);
Assert.AreEqual (0, props2.PropertyValues.Count);
}
[Test]
@@ -89,7 +88,7 @@ namespace Spring.Objects
props.AddAll (new PropertyValue [] {
new PropertyValue ("Name", "Fiona Apple"),
new PropertyValue ("Age", 24)});
Assert.AreEqual (2, props.PropertyValues.Length);
Assert.AreEqual (2, props.PropertyValues.Count);
}
[Test]
@@ -98,8 +97,8 @@ namespace Spring.Objects
MutablePropertyValues props = new MutablePropertyValues ();
props.Add (new PropertyValue ("Name", "Fiona Apple"));
props.Add (new PropertyValue ("Age", 24));
props.AddAll ((IList) null);
Assert.AreEqual (2, props.PropertyValues.Length);
props.AddAll ((IList<PropertyValue>) null);
Assert.AreEqual (2, props.PropertyValues.Count);
}
[Test]
@@ -108,9 +107,9 @@ namespace Spring.Objects
MutablePropertyValues props = new MutablePropertyValues ();
props.Add (new PropertyValue ("Name", "Fiona Apple"));
props.Add (new PropertyValue ("Age", 24));
Assert.AreEqual (2, props.PropertyValues.Length);
Assert.AreEqual (2, props.PropertyValues.Count);
props.Remove ("name");
Assert.AreEqual (1, props.PropertyValues.Length);
Assert.AreEqual (1, props.PropertyValues.Count);
}
[Test]
@@ -120,9 +119,9 @@ namespace Spring.Objects
PropertyValue propName = new PropertyValue ("Name", "Fiona Apple");
props.Add (propName);
props.Add (new PropertyValue ("Age", 24));
Assert.AreEqual (2, props.PropertyValues.Length);
Assert.AreEqual (2, props.PropertyValues.Count);
props.Remove (propName);
Assert.AreEqual (1, props.PropertyValues.Length);
Assert.AreEqual (1, props.PropertyValues.Count);
}
[Test]
@@ -139,11 +138,11 @@ namespace Spring.Objects
public void AddAllInMap ()
{
MutablePropertyValues props = new MutablePropertyValues ();
IDictionary map = new Hashtable ();
map.Add ("Name", "Fiona Apple");
IDictionary<string, object> map = new Dictionary<string, object>();
map.Add("Name", "Fiona Apple");
map.Add ("Age", 24);
props.AddAll (map);
Assert.AreEqual (2, props.PropertyValues.Length);
Assert.AreEqual (2, props.PropertyValues.Count);
}
[Test]
@@ -151,15 +150,15 @@ namespace Spring.Objects
{
MutablePropertyValues props = new MutablePropertyValues ();
props.Add (new PropertyValue ("Name", "Fiona Apple"));
props.AddAll ((IDictionary) null);
Assert.AreEqual (1, props.PropertyValues.Length);
props.AddAll ((IDictionary<string, object>) null);
Assert.AreEqual (1, props.PropertyValues.Count);
}
[Test]
public void ChangesSince ()
{
IDictionary map = new Hashtable ();
PropertyValue propName = new PropertyValue ("Name", "Fiona Apple");
IDictionary<string, object> map = new Dictionary<string, object>();
PropertyValue propName = new PropertyValue("Name", "Fiona Apple");
map.Add (propName.Name, propName.Value);
map.Add ("Age", 24);
MutablePropertyValues props = new MutablePropertyValues (map);
@@ -168,13 +167,13 @@ namespace Spring.Objects
// change the name... this is the change we'll be looking for
newProps.SetPropertyValueAt (new PropertyValue (propName.Name, "Naomi Woolf"), 0);
IPropertyValues changes = newProps.ChangesSince (props);
Assert.AreEqual (1, changes.PropertyValues.Length);
Assert.AreEqual (1, changes.PropertyValues.Count);
// the name was changed, so its the name property that should be in the changed list
Assert.IsTrue (changes.Contains ("name"));
newProps.Add (new PropertyValue ("Commentator", "Naomi Woolf"));
changes = newProps.ChangesSince (props);
Assert.AreEqual (2, changes.PropertyValues.Length);
Assert.AreEqual (2, changes.PropertyValues.Count);
// the Commentator was added, so its the Commentator property that should be in the changed list
Assert.IsTrue (changes.Contains ("commentator"));
// the name was changed, so its the name property that should be in the changed list
@@ -184,14 +183,14 @@ namespace Spring.Objects
[Test]
public void ChangesSinceWithSelf ()
{
IDictionary map = new Hashtable ();
map.Add ("Name", "Fiona Apple");
IDictionary<string, object> map = new Dictionary<string, object>();
map.Add("Name", "Fiona Apple");
map.Add ("Age", 24);
MutablePropertyValues props = new MutablePropertyValues (map);
props.Remove ("name");
// get all of the changes between self and self again (there should be none);
IPropertyValues changes = props.ChangesSince (props);
Assert.AreEqual (0, changes.PropertyValues.Length);
Assert.AreEqual (0, changes.PropertyValues.Count);
}
}
}

View File

@@ -62,7 +62,7 @@ namespace Spring.Util
IEventExceptionsCollector exceptions = bru.OnPop( "Iron Brew", eventRaiser );
Assert.AreEqual(1, exceptions.Exceptions.Length);
Assert.AreEqual(1, exceptions.Exceptions.Count);
Assert.IsTrue(firstCall);
Assert.IsTrue(secondCall);
Assert.IsTrue(thirdCall);

View File

@@ -22,6 +22,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
@@ -457,8 +458,8 @@ namespace Spring.Util
public void ToInterfaceArrayFromType()
{
Type[] expected = new Type[] { typeof(IFoo), typeof(IBar) };
Type[] actual = ReflectionUtils.ToInterfaceArray(typeof(IBar));
Assert.AreEqual(expected.Length, actual.Length);
IList<Type> actual = ReflectionUtils.ToInterfaceArray(typeof(IBar));
Assert.AreEqual(expected.Length, actual.Count);
Assert.AreEqual(expected[0], actual[0]);
Assert.AreEqual(expected[1], actual[1]);
}

View File

@@ -21,7 +21,6 @@
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
@@ -121,7 +120,7 @@ namespace Spring.Util
Assert.AreEqual(
":Foo,:Bar", StringUtils.CollectionToCommaDelimitedString(arr));
Assert.AreEqual("null", StringUtils.CollectionToCommaDelimitedString(null));
Assert.AreEqual("null", StringUtils.CollectionToCommaDelimitedString<object>(null));
}
[Test]
@@ -129,8 +128,8 @@ namespace Spring.Util
{
Foo[] arr = new Foo[] {new Foo("Foo"), new Foo("Bar")};
Assert.AreEqual(
":Foo,:Bar", StringUtils.ArrayToCommaDelimitedString(arr));
Assert.AreEqual("null", StringUtils.ArrayToCommaDelimitedString(null));
":Foo,:Bar", StringUtils.CollectionToCommaDelimitedString(arr));
Assert.AreEqual("null", StringUtils.CollectionToCommaDelimitedString<object>(null));
}
[Test]

View File

@@ -92,14 +92,14 @@ namespace Spring.Validation
get { return this.objects.Count; }
}
public string[] GetObjectDefinitionNames()
public IList<string> GetObjectDefinitionNames()
{
return new List<string>(this.objects.Keys).ToArray();
return new List<string>(this.objects.Keys);
}
public IObjectDefinition[] GetObjectDefinitions()
public IList<IObjectDefinition> GetObjectDefinitions()
{
return new List<IObjectDefinition>(this.objects.Values).ToArray();
return new List<IObjectDefinition>(this.objects.Values);
}
public bool ContainsObjectDefinition(string name)
@@ -119,7 +119,7 @@ namespace Spring.Validation
this.objects[name] = definition;
}
public string[] GetAliases(string name)
public IList<string> GetAliases(string name)
{
throw new NotImplementedException();
}

View File

@@ -20,6 +20,7 @@
#region Imports
using System.Collections.Generic;
using System.IO;
using System.Xml;
using NUnit.Framework;
@@ -64,8 +65,8 @@ namespace Spring.Validation
parser.ParseElement(element, parserContext);
}
}
IObjectDefinition[] defs = registry.GetObjectDefinitions();
Assert.AreEqual(9, defs.Length);
IList<IObjectDefinition> defs = registry.GetObjectDefinitions();
Assert.AreEqual(9, defs.Count);
IObjectDefinition def = registry.GetObjectDefinition("destinationAirportValidator");
Assert.IsTrue(def.IsSingleton);

View File

@@ -19,6 +19,7 @@
#endregion
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Threading;
@@ -217,8 +218,8 @@ namespace Spring.Data.Common
//Initialize internal application context. factory
DbProviderFactory.GetDbProvider("SqlServer-2.0");
IApplicationContext ctx = DbProviderFactory.ApplicationContext;
string[] dbProviderNames = ctx.GetObjectNamesForType(typeof(IDbProvider));
Assert.IsTrue(dbProviderNames.Length > 0);
IList<string> dbProviderNames = ctx.GetObjectNamesForType(typeof(IDbProvider));
Assert.IsTrue(dbProviderNames.Count > 0);
}

View File

@@ -73,14 +73,14 @@ namespace Spring.Messaging.Nms.Config
[Test]
public void ObjectsCreated()
{
IDictionary<string, SimpleMessageListenerContainer> containers = ctx.GetObjectsOfType<SimpleMessageListenerContainer>();
IDictionary<string, SimpleMessageListenerContainer> containers = ctx.GetObjects<SimpleMessageListenerContainer>();
Assert.AreEqual(3, containers.Count);
}
[Test]
public void ContainerConfiguration()
{
IDictionary<string, SimpleMessageListenerContainer> containers = ctx.GetObjectsOfType<SimpleMessageListenerContainer>();
IDictionary<string, SimpleMessageListenerContainer> containers = ctx.GetObjects<SimpleMessageListenerContainer>();
IConnectionFactory defaultConnectionFactory = (IConnectionFactory) ctx.GetObject(DEFAULT_CONNECTION_FACTORY);
IConnectionFactory explicitConnectionFactory = (IConnectionFactory) ctx.GetObject(EXPLICIT_CONNECTION_FACTORY);

View File

@@ -49,7 +49,7 @@ namespace Spring.Messaging.Listener.Adapter
{
throw new ListenerExecutionFailedException("Failed to invoke the target method '" + methodName +
"' with arguments " +
StringUtils.ArrayToCommaDelimitedString(arguments));
StringUtils.CollectionToCommaDelimitedString(arguments));
}
try
{
@@ -62,7 +62,7 @@ namespace Spring.Messaging.Listener.Adapter
{
throw new ListenerExecutionFailedException("Failed to invoke the target method '" + methodName +
"' with arguments " +
StringUtils.ArrayToCommaDelimitedString(arguments), e);
StringUtils.CollectionToCommaDelimitedString(arguments), e);
}
}
}

View File

@@ -104,7 +104,7 @@ namespace Spring.ServiceModel.Config
IApplicationContext ctx = new XmlApplicationContext(
ReadOnlyXmlTestResource.GetFilePath("ChannelFactoryObjectDefinitionParserTests.WithoutId.xml", this.GetType()));
IDictionary<string, IContract> channels = ctx.GetObjectsOfType<IContract>();
IDictionary<string, IContract> channels = ctx.GetObjects<IContract>();
Assert.AreEqual(1, channels.Count);
}

View File

@@ -50,7 +50,7 @@ namespace Spring.Objects.Factory.Support
typeof(TestObject).FullName, null, AppDomain.CurrentDomain);
Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
Assert.AreEqual(typeof(TestObject), definition.ObjectType);
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length,
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count,
"Must not have any property values as none were passed in.");
Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount,
"Must not have any ctor args as none were passed in.");
@@ -65,7 +65,7 @@ namespace Spring.Objects.Factory.Support
typeof(TestObject).FullName, "Aimee Mann", AppDomain.CurrentDomain);
Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
Assert.AreEqual(typeof(TestObject), definition.ObjectType);
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length,
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count,
"Must not have any property values as none were passed in.");
Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount,
"Must not have any ctor args as none were passed in.");
@@ -80,7 +80,7 @@ namespace Spring.Objects.Factory.Support
typeof(TestObject).FullName, null, null);
Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
Assert.AreEqual(typeof(TestObject).FullName, definition.ObjectTypeName);
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length,
Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count,
"Must not have any property values as none were passed in.");
Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount,
"Must not have any ctor args as none were passed in.");