SPRNET-1561 ASP.NET MVC 5 and WEB API 2 support

* also add .NET 4.5 targets
* fix issues with libs and build targets
This commit is contained in:
Marko Lahma
2013-12-02 19:28:33 +02:00
parent 1466cc9b43
commit fc5fa113bb
185 changed files with 42422 additions and 96 deletions

View File

@@ -29,81 +29,81 @@ namespace Spring.Context.Support
[TestFixture]
public class CodeConfigApplicationContextTests
{
private CodeConfigApplicationContext _context;
private AssemblyObjectDefinitionScanner _scanner;
private CodeConfigApplicationContext context;
private AssemblyObjectDefinitionScanner scanner;
[SetUp]
public void _TestSetup()
{
_context = new CodeConfigApplicationContext();
_scanner = new AssemblyObjectDefinitionScanner();
}
context = new CodeConfigApplicationContext();
scanner = new AssemblyObjectDefinitionScanner();
}
[Test]
public void Can_Filter_For_Assembly_Based_On_Assembly_Metadata()
{
_context.ScanWithAssemblyFilter(a => a.GetName().Name.StartsWith("Spring.Core."));
_context.Refresh();
context.ScanWithAssemblyFilter(a => a.GetName().Name.StartsWith("Spring.Core."));
context.Refresh();
AssertExpectedObjectsAreRegisteredWith(_context, 45);
AssertExpectedObjectsAreRegisteredWith(context, 45);
}
[Test]
public void Can_Filter_For_Assembly_Containing_Specific_Type_But_Having_NO_Definitions()
{
//specifically filter assemblies for one that we *know* will result in NO [Configuration] types in it
_context.ScanWithAssemblyFilter(assy => assy.GetTypes().Any(type => type.FullName.Contains(typeof(Spring.Core.IOrdered).Name)));
_context.Refresh();
context.ScanWithAssemblyFilter(assy => assy.GetTypes().Any(type => type.FullName.Contains(typeof(Spring.Core.IOrdered).Name)));
context.Refresh();
Assert.That(_context.DefaultListableObjectFactory.ObjectDefinitionCount, Is.EqualTo(4));
Assert.That(context.DefaultListableObjectFactory.ObjectDefinitionCount, Is.EqualTo(4));
}
[Test]
public void Can_Filter_For_Assembly_Containing_Specific_Type()
{
_context.ScanWithAssemblyFilter(assy => assy.GetTypes().Any(type => type.FullName.Contains(typeof(MarkerTypeForScannerToFind).Name)));
_context.Refresh();
context.ScanWithAssemblyFilter(assy => assy.GetTypes().Any(type => type.FullName.Contains(typeof(MarkerTypeForScannerToFind).Name)));
context.Refresh();
AssertExpectedObjectsAreRegisteredWith(_context, 45);
AssertExpectedObjectsAreRegisteredWith(context, 45);
}
[Test]
public void Can_Filter_For_Specific_Type()
{
_context.ScanWithTypeFilter(type => type.FullName.Contains(typeof(TheImportedConfigurationClass).Name));
_context.Refresh();
context.ScanWithTypeFilter(type => type.FullName.Contains(typeof(TheImportedConfigurationClass).Name));
context.Refresh();
Assert.That(_context.DefaultListableObjectFactory.ObjectDefinitionCount, Is.EqualTo(8));
Assert.That(context.DefaultListableObjectFactory.ObjectDefinitionCount, Is.EqualTo(8));
}
[Test]
public void Can_Filter_For_Specific_Types_With_Compound_Predicate()
{
_context.ScanWithTypeFilter(type => type.FullName.Contains(typeof(TheImportedConfigurationClass).Name) || type.FullName.Contains(typeof(TheConfigurationClass).Name));
_context.Refresh();
context.ScanWithTypeFilter(type => type.FullName.Contains(typeof(TheImportedConfigurationClass).Name) || type.FullName.Contains(typeof(TheConfigurationClass).Name));
context.Refresh();
AssertExpectedObjectsAreRegisteredWith(_context, 19);
AssertExpectedObjectsAreRegisteredWith(context, 19);
}
[Test]
public void Can_Filter_For_Specific_Types_With_Multiple_Include_Filters()
{
_scanner.WithIncludeFilter(type => type.FullName.Contains(typeof(TheImportedConfigurationClass).Name));
_scanner.WithIncludeFilter(type => type.FullName.Contains(typeof(TheConfigurationClass).Name));
scanner.WithIncludeFilter(type => type.FullName.Contains(typeof(TheImportedConfigurationClass).Name));
scanner.WithIncludeFilter(type => type.FullName.Contains(typeof(TheConfigurationClass).Name));
_context.Scan(_scanner);
_context.Refresh();
context.Scan(scanner);
context.Refresh();
AssertExpectedObjectsAreRegisteredWith(_context, 19);
AssertExpectedObjectsAreRegisteredWith(context, 19);
}
[Test]
public void Can_Perform_Scan_With_No_Filtering()
{
_context.ScanAllAssemblies();
_context.Refresh();
context.ScanAllAssemblies();
context.Refresh();
AssertExpectedObjectsAreRegisteredWith(_context, 45);
AssertExpectedObjectsAreRegisteredWith(context, 45);
}
private void AssertExpectedObjectsAreRegisteredWith(GenericApplicationContext context, int expectedDefinitionCount)

View File

@@ -41,6 +41,7 @@
<include name="System.Core.dll"/>
<include name="${current.bin.dir}/*.dll" />
<exclude name="${current.bin.dir}/${project::get-name()}.dll" />
<exclude name="${current.bin.dir}/System.Net.Http*.dll" />
</references>
</csc>

View File

@@ -36,7 +36,7 @@
<include name="System.dll"/>
<include name="System.Core.dll"/>
<include name="${vs-net.mstest.bin.dir.current}\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll" />
<include name="*.dll" />
<include name="${current.bin.dir}/*.dll" />
<exclude name="${current.bin.dir}/${project::get-name()}.dll" />
<exclude name="${current.bin.dir}/CloverRuntime.dll" />
</references>

View File

@@ -59,10 +59,10 @@
<exclude name="${current.bin.dir}/${project::get-name()}.dll" />
<include name="${lib.dir}/nunit.core.interfaces.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc.Tests.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc4.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc4.Tests.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc5.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc5.Tests.dll" />
</references>
</csc>
<copy todir="${current.bin.dir}">

View File

@@ -67,10 +67,10 @@
<include name="${lib.dir}/nunit.core.interfaces.dll" />
<exclude name="${current.bin.dir}/System.Web.Extensions.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc.Tests.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc3.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc3.Tests.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc5.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc5.Tests.dll" />
</references>
</csc>
<copy todir="${current.bin.dir}">

View File

@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B9590252-6D58-4587-950C-475AB61FDBCF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Spring.Web.Mvc5.Tests</RootNamespace>
<AssemblyName>Spring.Web.Mvc5.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\build\VS.Net.2010\Spring.Web.Mvc5.Tests\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET_3_5;NET_4_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\..\lib\Net\2.0\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.AspNet.Mvc.5.0.0\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.AspNet.Razor.3.0.0\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.Routing" />
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CommonAssemblyInfo.cs">
<Link>CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Spring.Web.Mvc3.Tests\ControllerFactoryTestExtension.cs">
<Link>ControllerFactoryTestExtension.cs</Link>
</Compile>
<Compile Include="..\Spring.Web.Mvc3.Tests\Controllers\FirstContainerRegisteredController.cs">
<Link>Controllers\FirstContainerRegisteredController.cs</Link>
</Compile>
<Compile Include="..\Spring.Web.Mvc3.Tests\Controllers\NamedContextController.cs">
<Link>Controllers\NamedContextController.cs</Link>
</Compile>
<Compile Include="..\Spring.Web.Mvc3.Tests\Controllers\NotInContainerController.cs">
<Link>Controllers\NotInContainerController.cs</Link>
</Compile>
<Compile Include="..\Spring.Web.Mvc3.Tests\Controllers\SecondContainerRegisteredController.cs">
<Link>Controllers\SecondContainerRegisteredController.cs</Link>
</Compile>
<Compile Include="..\Spring.Web.Mvc4.Tests\SpringMvcDependencyResolverTests.cs">
<Link>SpringMvcDependencyResolverTests.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Spring\Spring.Core\Spring.Core.2010.csproj">
<Project>{710961A3-0DF4-49E4-A26E-F5B9C044AC84}</Project>
<Name>Spring.Core.2010</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\src\Spring\Spring.Web.Mvc5\Spring.Web.Mvc5.2010.csproj">
<Project>{39aad7ea-2ed0-4e50-8d4d-c666ea9cbfe4}</Project>
<Name>Spring.Web.Mvc5.2010</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Content Include="..\Spring.Web.Mvc3.Tests\namedContextObjectsMvc.xml">
<Link>namedContextObjectsMvc.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="..\Spring.Web.Mvc3.Tests\objectsMvc.xml">
<Link>objectsMvc.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,106 @@
<?xml version="1.0" ?>
<project name="Spring.Web.Mvc5.Tests" default="test" xmlns="http://nant.sf.net/schemas/nant.xsd">
<include buildfile="${spring.basedir}/common-project.include" />
<!--
Required properties:
* current.bin.dir - (path) root level to build to
* build.debug - (true|false) debug build?
* current.build.defines.csc - framework-specific build defines
* lib.dir - framework-specific assembly references
-->
<target name="build">
<!-- build Spring.Web.Mvc -->
<csc target="library" define="${current.build.defines.csc}"
warnaserror="true"
optimize="${build.optimize}"
debug="${current.build.debug}"
output="${current.bin.dir}/${project::get-name()}.dll"
doc="${current.bin.dir}/${project::get-name()}.xml"
nostdlib="true"
noconfig="true"
>
<nowarn>
<warning number="${nowarn.numbers.test}" /> <!-- 1701 -->
<warning number="${nowarn.numbers.test},1587"/>
</nowarn>
<sources failonempty="true">
<include name="**/*.cs" />
<include name="../CommonAssemblyInfo.cs" />
<include name="../Spring.Web.Mvc3.Tests/**/*.cs" />
<include name="../Spring.Web.Mvc4.Tests/**/*.cs" />
<include name="../Spring.Web.Mvc5.Tests/**/*.cs" />
<exclude name="../Spring.Web.Mvc3.Tests/**/SpringMvcDependencyResolverTests.cs" />
</sources>
<resources prefix="Spring" dynamicprefix="true" failonempty="true">
<include name="../Spring.Web.Mvc3.Tests/**/*.resx" />
<include name="../Spring.Web.Mvc3.Tests/**/*.xsd" />
<include name="../Spring.Web.Mvc3.Tests/**/*.txt" />
<include name="../Spring.Web.Mvc3.Tests/**/*.xml" />
<exclude name="../Spring.Web.Mvc3.Tests/Data/**/*" />
<exclude name="../Spring.Web.Mvc3.Tests/obj/**/*" />
<exclude name="../Spring.Web.Mvc3.Tests/bin/**/*" />
</resources>
<references>
<include name="mscorlib.dll"/>
<include name="Microsoft.CSharp.dll"/>
<include name="System.dll"/>
<include name="System.Core.dll"/>
<include name="System.Configuration.dll" />
<include name="System.Data.dll" />
<include name="System.Drawing.dll" />
<include name="System.Xml.dll" />
<include name="System.Web.dll" />
<include name="System.Web.Abstractions.dll"/>
<include name="System.Web.ApplicationServices.dll" />
<include name="System.Web.Routing.dll"/>
<include name="System.Web.Services.dll" />
<include name="${spring.basedir}/packages/Microsoft.AspNet.Mvc.5.0.0/lib/net45/System.Web.Mvc.dll" />
<include name="${spring.basedir}/packages/Microsoft.AspNet.WebApi.Core.5.0.0/lib/net45/System.Web.Http.dll" />
<include name="${spring.basedir}/packages/Microsoft.AspNet.WebApi.WebHost.5.0.0/lib/net45/System.Web.Http.WebHost.dll" />
<include name="${current.bin.dir}/*.dll" />
<include name="${current.bin.dir}/Spring.Web.Mvc5.dll" />
<exclude name="${current.bin.dir}/${project::get-name()}.dll" />
<include name="${lib.dir}/nunit.core.interfaces.dll" />
<exclude name="${current.bin.dir}/System.Web.Extensions.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc3.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc3.Tests.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc4.dll" />
<exclude name="${current.bin.dir}/Spring.Web.Mvc4.Tests.dll" />
</references>
</csc>
<copy todir="${current.bin.dir}">
<fileset basedir="${project::get-base-directory()}/Data">
<include name="**/*.*" />
</fileset>
</copy>
<copy todir="${current.bin.dir}">
<fileset basedir="${project::get-base-directory()}">
<include name="**/*.xml" />
</fileset>
</copy>
<copy todir="${current.bin.dir}" flatten="true">
<fileset basedir="${spring.basedir}/packages/">
<include name="Microsoft.AspNet.*.5.0.0/**/*.dll" />
</fileset>
</copy>
</target>
<target name="test" depends="build">
<!-- property name="test.assemblyname" value="${project::get-name()}" / -->
<call target="common.run-tests" />
</target>
<!--
<target name="test" depends="build">
<nunit2outproc>
<formatter type="Plain" />
<formatter type="Xml" usefile="true" extension=".xml" outputdir="${current.bin.dir}/results" />
<test assemblyname="${current.bin.dir}/${project::get-name()}.dll" />
</nunit2outproc>
</target>
-->
</project>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
</packages>