SPRNET-1450
-adjust base class for MvcApplicationContext to WebApplicationContext to acquire proper session scope support
This commit is contained in:
@@ -69,6 +69,14 @@
|
||||
<Project>{5166CE3A-14BE-478A-88DA-729A39DE1E29}</Project>
|
||||
<Name>Spring.Web.Mvc.2010</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\src\Spring\Spring.Web\Spring.Web.2010.csproj">
|
||||
<Project>{BA4789EB-281A-48EA-8763-28B9F0596A18}</Project>
|
||||
<Name>Spring.Web.2010</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Spring.Web.Tests\Spring.Web.Tests.2010.csproj">
|
||||
<Project>{C67E47AA-1ACD-41B4-A465-4D336A2319CA}</Project>
|
||||
<Name>Spring.Web.Tests.2010</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="objects.xml">
|
||||
|
||||
@@ -29,6 +29,7 @@ using Spring.Core.IO;
|
||||
using Spring.Objects.Factory;
|
||||
using Spring.Objects.Factory.Xml;
|
||||
using System.Web.Mvc;
|
||||
using Spring.TestSupport;
|
||||
using Spring.Web.Mvc.Tests.Controllers;
|
||||
using Spring.Context.Support;
|
||||
using System.Reflection;
|
||||
@@ -49,26 +50,29 @@ namespace Spring.Web.Mvc.Tests
|
||||
[SetUp]
|
||||
public void _TestSetup()
|
||||
{
|
||||
ContextRegistry.Clear();
|
||||
_context = new MvcApplicationContext("file://objects.xml");
|
||||
_mvcNamedContext = new MvcApplicationContext("named", false, "file://namedContextObjects.xml");
|
||||
|
||||
ContextRegistry.RegisterContext(_context);
|
||||
ContextRegistry.RegisterContext(_mvcNamedContext);
|
||||
|
||||
_factory = new SpringControllerFactory();
|
||||
|
||||
//due to ridiculous internal methods in DefaultControllerFactory, have to set the ControllerTypeCache using this extension method
|
||||
// see http://stackoverflow.com/questions/727181/asp-net-mvc-system-web-compilation-compilationlock for more info
|
||||
_factory.InitializeWithControllerTypes(new[]
|
||||
using (new VirtualEnvironmentMock("/somedir/some.file", null, null, "/", true))
|
||||
{
|
||||
typeof(FirstContainerRegisteredController),
|
||||
typeof(SecondContainerRegisteredController),
|
||||
typeof(NotInContainerController),
|
||||
typeof(NamedContextController),
|
||||
});
|
||||
ContextRegistry.Clear();
|
||||
_context = new MvcApplicationContext("file://objects.xml");
|
||||
_mvcNamedContext = new MvcApplicationContext("named", false, "file://namedContextObjects.xml");
|
||||
|
||||
SpringControllerFactory.ApplicationContextName = string.Empty;
|
||||
ContextRegistry.RegisterContext(_context);
|
||||
ContextRegistry.RegisterContext(_mvcNamedContext);
|
||||
|
||||
_factory = new SpringControllerFactory();
|
||||
|
||||
//due to ridiculous internal methods in DefaultControllerFactory, have to set the ControllerTypeCache using this extension method
|
||||
// see http://stackoverflow.com/questions/727181/asp-net-mvc-system-web-compilation-compilationlock for more info
|
||||
_factory.InitializeWithControllerTypes(new[]
|
||||
{
|
||||
typeof (FirstContainerRegisteredController),
|
||||
typeof (SecondContainerRegisteredController),
|
||||
typeof (NotInContainerController),
|
||||
typeof (NamedContextController),
|
||||
});
|
||||
|
||||
SpringControllerFactory.ApplicationContextName = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -87,11 +91,13 @@ namespace Spring.Web.Mvc.Tests
|
||||
[Test]
|
||||
public void CanRevertToTypeMatchIfIdMatchUnsuccessful()
|
||||
{
|
||||
MvcApplicationContext context = new MvcApplicationContext("file://objectsMatchByType.xml");
|
||||
|
||||
ContextRegistry.Clear();
|
||||
ContextRegistry.RegisterContext(context);
|
||||
using (new VirtualEnvironmentMock("/somedir/some.file", null, null, "/", true))
|
||||
{
|
||||
MvcApplicationContext context = new MvcApplicationContext("file://objectsMatchByType.xml");
|
||||
|
||||
ContextRegistry.Clear();
|
||||
ContextRegistry.RegisterContext(context);
|
||||
}
|
||||
IController controller = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "FirstContainerRegistered");
|
||||
|
||||
Assert.AreEqual("Should_Be_Matched_By_Type", ((FirstContainerRegisteredController)controller).TestValue);
|
||||
|
||||
Reference in New Issue
Block a user