Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Context/Support
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv23865/test/Spring/Spring.Core.Tests/Context/Support
Modified Files:
ContextRegistryTests.cs
Log Message:
fixed SPRNET-394
fixed SPRNET-886
Index: ContextRegistryTests.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Context/Support/ContextRegistryTests.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ContextRegistryTests.cs 7 Oct 2006 14:51:23 -0000 1.8
--- ContextRegistryTests.cs 21 Mar 2008 10:49:38 -0000 1.9
***************
*** 22,25 ****
--- 22,26 ----
using System;
+ using System.Xml;
using NUnit.Framework;
***************
*** 42,45 ****
--- 43,76 ----
}
+
+ /// <summary>
+ /// This handler simulates calls to ContextRegistry during context creation
+ /// </summary>
+ private static object GetContextRecursive(object parent, object context, XmlNode section)
+ {
+ return ContextRegistry.GetContext(); // this must fail!
+ }
+
+ [Test]
+ public void ThrowsInvalidOperationExceptionOnRecursiveCallsToGetContext()
+ {
+ HookableContextHandler.CreateContextFromSectionHandler prevInst = HookableContextHandler.SetSectionHandler(
+ new HookableContextHandler.CreateContextFromSectionHandler(GetContextRecursive));
+ try
+ {
+ ContextRegistry.GetContext("somename");
+ }
+ catch(Exception ex)
+ {
+ InvalidOperationException rootCause = ex.GetBaseException() as InvalidOperationException;
+ Assert.IsNotNull(rootCause);
+ Assert.AreEqual("root context is currently in creation.", rootCause.Message.Substring(0, 38));
+ }
+ finally
+ {
+ HookableContextHandler.SetSectionHandler(prevInst);
+ }
+ }
+
[Test]
public void RegisterRootContext()
|