automated NH21 integration tests up & running
This commit is contained in:
@@ -189,7 +189,18 @@ namespace Spring
|
||||
/// <see cref="Assembly.GetManifestResourceStream(Type,string)"/>
|
||||
public static string GetAssemblyResourceUri(Type hint, string name)
|
||||
{
|
||||
return "assembly://" + hint.Assembly.FullName.Split(',')[0].Trim() + "/" + hint.Namespace + "/" + name;
|
||||
return "assembly://" + hint.Assembly.FullName.Split(',')[0].Trim() + "/" + hint.Namespace + ((name.IndexOf('/')>-1)?".":"/") + name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns an "assembly://" uri for the specified manifest resource, scoped by the namespace of the specified instance's type.
|
||||
/// ("assembly://hint.assemblyname_without_version/hint.Namespace/name")
|
||||
/// </summary>
|
||||
/// <see cref="Assembly.GetManifestResourceStream(Type,string)"/>
|
||||
public static string GetAssemblyResourceUri(object hint, string name)
|
||||
{
|
||||
Type hintType = hint.GetType();
|
||||
return GetAssemblyResourceUri(hintType, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ CREATE TABLE [Credits](
|
||||
[CreditID] ASC
|
||||
) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
;
|
||||
|
||||
CREATE TABLE [Debits](
|
||||
[DebitID] [int] IDENTITY NOT NULL,
|
||||
@@ -15,4 +16,5 @@ CREATE TABLE [Debits](
|
||||
(
|
||||
[DebitID] ASC
|
||||
) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
;
|
||||
@@ -7,4 +7,4 @@ CREATE TABLE [TestObjects] (
|
||||
(
|
||||
[TestObjectNo] ASC
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -1,7 +1,7 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2007 the original author or authors.
|
||||
* Copyright <20> 2002-2009 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.
|
||||
@@ -18,24 +18,20 @@
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using NHibernate;
|
||||
#if NH_2_1
|
||||
using Spring.Data.NHibernate.Bytecode;
|
||||
#endif
|
||||
using NHibernate.Cfg;
|
||||
using NHibernate.Connection;
|
||||
using NHibernate.Dialect;
|
||||
using NHibernate.Driver;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Spring.Data.Common;
|
||||
#if NH_2_1
|
||||
using Spring.Data.NHibernate.Bytecode;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Spring.Data.NHibernate
|
||||
{
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyTitle("Spring.Data.NHibernate21 Integration Tests")]
|
||||
[assembly: AssemblyDescription("Integration tests for Spring.Data.NHibernate21 assembly")]
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
<db:provider id="targetDbProvider"
|
||||
provider="SqlServer-2.0"
|
||||
connectionString="Data Source=(local);Database=Spring;Trusted_Connection=False"/>
|
||||
connectionString="Data Source=SPRINGQA;Database=Spring;Trusted_Connection=False"/>
|
||||
|
||||
|
||||
<db:provider id="standardDbProvider"
|
||||
provider="SqlServer-2.0"
|
||||
connectionString="Data Source=(local);Database=Spring;Trusted_Connection=False;User ID=springqa;Password=springqa"/>
|
||||
connectionString="Data Source=SPRINGQA;Database=Spring;Trusted_Connection=False;User ID=springqa;Password=springqa"/>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<db:provider id="DbProvider"
|
||||
provider="SqlServer-1.1"
|
||||
connectionString="Data Source=(local);Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"/>
|
||||
connectionString="Data Source=SPRINGQA;Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"/>
|
||||
<!--
|
||||
connectionString="Data Source=MARKT60\SQL2005;Initial Catalog=Spring;User ID=springqa; Password=springqa"/>
|
||||
-->
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'Spring')
|
||||
BEGIN
|
||||
ALTER DATABASE Spring
|
||||
SET SINGLE_USER
|
||||
WITH ROLLBACK IMMEDIATE
|
||||
|
||||
DROP DATABASE Spring
|
||||
END
|
||||
GO
|
||||
|
||||
IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'springqa2')
|
||||
DROP LOGIN [springqa2]
|
||||
GO
|
||||
|
||||
CREATE DATABASE Spring
|
||||
GO
|
||||
|
||||
CREATE LOGIN [springqa2] WITH PASSWORD=N'springqa2', DEFAULT_DATABASE=[Spring], DEFAULT_LANGUAGE=[us_english]
|
||||
GO
|
||||
|
||||
USE Spring
|
||||
CREATE USER [springqa2] FOR LOGIN [springqa2] WITH DEFAULT_SCHEMA=[dbo]
|
||||
EXEC sp_addrolemember 'db_owner', 'springqa2'
|
||||
GO
|
||||
|
||||
-- ALTERNATIVELY JUST DROP ALL TABLES:
|
||||
-- EXEC sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL';
|
||||
-- EXEC sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL';
|
||||
-- EXEC sp_MSForEachTable 'DROP TABLE ?';
|
||||
@@ -0,0 +1,60 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright 2002-2009 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 NUnit.Framework;
|
||||
using Spring.Core.IO;
|
||||
using Spring.Data.Common;
|
||||
using Spring.Data.Core;
|
||||
using Spring.Testing.Ado;
|
||||
|
||||
namespace Spring
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
[SetUpFixture]
|
||||
public class Setup
|
||||
{
|
||||
private const string DBConnection = "Data Source=SPRINGQA;Database=$DATABASE$;Trusted_Connection=False;User ID=springqa;Password=springqa";
|
||||
private readonly IResourceLoader resourceLoader = new ConfigurableResourceLoader();
|
||||
|
||||
private IResource GetResource(object instance, string name)
|
||||
{
|
||||
string resourcePath = TestResourceLoader.GetAssemblyResourceUri(instance, name);
|
||||
return resourceLoader.GetResource(resourcePath);
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void InstallMSSQLDatabase()
|
||||
{
|
||||
IDbProvider dbProvider = DbProviderFactory.GetDbProvider("SqlServer-2.0");
|
||||
AdoTemplate ado = new AdoTemplate(dbProvider);
|
||||
|
||||
// (re-)create database(s)
|
||||
dbProvider.ConnectionString = DBConnection.Replace("$DATABASE$", "master");
|
||||
SimpleAdoTestUtils.ExecuteSqlScript(ado, GetResource(this, "RecreateDatabases.sql"));
|
||||
|
||||
// create tables
|
||||
dbProvider.ConnectionString = DBConnection.Replace("$DATABASE$", "Spring");
|
||||
SimpleAdoTestUtils.ExecuteSqlScript(ado, GetResource(this, "Data.NHibernate/creditdebit.sql"));
|
||||
SimpleAdoTestUtils.ExecuteSqlScript(ado, GetResource(this, "Data.NHibernate/testObject.sql"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,10 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Antlr3.Runtime, Version=3.1.0.39271, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\NHibernate21\net\2.0\Antlr3.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Common.Logging, Version=1.0.2.0, Culture=neutral, PublicKeyToken=af08829b84f0328e">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\Net\2.0\Common.Logging.dll</HintPath>
|
||||
@@ -44,6 +48,14 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\NHibernate21\net\2.0\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate.DomainModel, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\NHibernate21\net\2.0\NHibernate.DomainModel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate.Test, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\NHibernate21\net\2.0\NHibernate.Test.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.4.1.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\Net\2.0\nunit.framework.dll</HintPath>
|
||||
@@ -110,24 +122,20 @@
|
||||
<Compile Include="..\Spring.Data.NHibernate.Integration.Tests\Data\NHibernate\TestObject.cs">
|
||||
<Link>Data\NHibernate\TestObject.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="Setup.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Spring.Data.NHibernate.Integration.Tests\Data\NHibernate\creditdebit.sql">
|
||||
<EmbeddedResource Include="..\Spring.Data.NHibernate.Integration.Tests\Data\NHibernate\creditdebit.sql">
|
||||
<Link>Data\NHibernate\creditdebit.sql</Link>
|
||||
</None>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="RecreateDatabases.sql" />
|
||||
<EmbeddedResource Include="..\Spring.Data.NHibernate.Integration.Tests\Data\NHibernate\testObject.sql">
|
||||
<Link>Data\NHibernate\testObject.sql</Link>
|
||||
</EmbeddedResource>
|
||||
<None Include="Spring.Data.NHibernate21.Integration.Tests.build" />
|
||||
<None Include="Spring.Data.NHibernate21.Integration.Tests.dll.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\..\..\projects\nhibernate\trunk\nhibernate\src\NHibernate.DomainModel\NHibernate.DomainModel.csproj">
|
||||
<Project>{5C649B55-1B3F-4C38-9998-1B043E94A244}</Project>
|
||||
<Name>NHibernate.DomainModel</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\..\..\projects\nhibernate\trunk\nhibernate\src\NHibernate.Test\NHibernate.Test.csproj">
|
||||
<Project>{7AEE5B37-C552-4E59-9B6F-88755BCB5070}</Project>
|
||||
<Name>NHibernate.Test</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\src\Spring\Spring.Aop\Spring.Aop.2008.csproj">
|
||||
<Project>{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}</Project>
|
||||
<Name>Spring.Aop.2008</Name>
|
||||
@@ -144,6 +152,14 @@
|
||||
<Project>{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}</Project>
|
||||
<Name>Spring.Data.2008</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\src\Spring\Spring.Testing.NUnit\Spring.Testing.NUnit.2008.csproj">
|
||||
<Project>{ED204A7B-832F-44C7-BFE3-504AEBE1BCC8}</Project>
|
||||
<Name>Spring.Testing.NUnit.2008</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Spring.Core.Tests\Spring.Core.Tests.2008.csproj">
|
||||
<Project>{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}</Project>
|
||||
<Name>Spring.Core.Tests.2008</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Data\NHibernate\Credit.hbm.xml" />
|
||||
|
||||
@@ -1,57 +1,60 @@
|
||||
<?xml version="1.0" ?>
|
||||
<project name="Spring.Data.NHibernate21.Integration.Tests" default="test" xmlns="http://nant.sf.net/schemas/nant.xsd">
|
||||
<!--
|
||||
Required properties:
|
||||
* current.bin.dir - (path) root level to build to
|
||||
* current.build.debug - (true|false) debug build?
|
||||
* current.build.defines.csc - framework-specific build defines for C# compiler
|
||||
-->
|
||||
<target name="build">
|
||||
|
||||
<!-- build Spring.Data.NHibernate21.Integration.Tests -->
|
||||
<csc target="library" define="${current.build.defines.csc},NH_2_0,NH_2_1"
|
||||
warnaserror="true"
|
||||
debug="${current.build.debug}"
|
||||
output="${current.bin.dir}/${project::get-name()}.dll"
|
||||
doc="${current.bin.dir}/${project::get-name()}.xml">
|
||||
<nowarn>
|
||||
<warning number="${nowarn.numbers.test}" />
|
||||
</nowarn>
|
||||
<sources failonempty="true">
|
||||
<include name="**/*.cs" />
|
||||
<include name="../CommonAssemblyInfo.cs" />
|
||||
</sources>
|
||||
<references basedir="${current.bin.dir}">
|
||||
<lib>
|
||||
<include name="${nh21.lib.dir}"/>
|
||||
</lib>
|
||||
<include name="${nh21.lib.dir}/NHibernate.dll" />
|
||||
<include buildfile="${spring.basedir}/common-project.include" />
|
||||
|
||||
<!--
|
||||
Required properties:
|
||||
* current.bin.dir - (path) root level to build to
|
||||
* current.build.debug - (true|false) debug build?
|
||||
* current.build.defines.csc - framework-specific build defines for C# compiler
|
||||
-->
|
||||
<target name="build">
|
||||
|
||||
<!-- copy nh libs -->
|
||||
<echo message="NH Libs: ${nh21.lib.dir}" />
|
||||
<copy todir="${current.bin.dir}" overwrite="true">
|
||||
<fileset basedir="${nh21.lib.dir}">
|
||||
<include name="**/*.dll" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<!-- build Spring.Data.NHibernate21.Integration.Tests -->
|
||||
<csc target="library" define="${current.build.defines.csc},NH_2_0,NH_2_1"
|
||||
warnaserror="true"
|
||||
debug="${current.build.debug}"
|
||||
output="${current.bin.dir}/${project::get-name()}.dll"
|
||||
doc="${current.bin.dir}/${project::get-name()}.xml">
|
||||
<nowarn>
|
||||
<warning number="${nowarn.numbers.test}" />
|
||||
</nowarn>
|
||||
<sources failonempty="true">
|
||||
<include name="**/*.cs" />
|
||||
<include name="../CommonAssemblyInfo.cs" />
|
||||
</sources>
|
||||
<references basedir="${current.bin.dir}">
|
||||
<include name="System.Data.dll" />
|
||||
<include name="System.EnterpriseServices.dll" />
|
||||
<include name="log4net.dll" />
|
||||
<include name="*.dll" />
|
||||
<exclude name="NHibernate.dll" />
|
||||
<exclude name="${project::get-name()}.dll" />
|
||||
<exclude name="Spring.Data.NHibernate*.dll" />
|
||||
<include name="Spring.Data.NHibernate21.dll" />
|
||||
</references>
|
||||
<resources prefix="Spring" dynamicprefix="true" failonempty="true">
|
||||
<include name="**/*.xml" />
|
||||
</resources>
|
||||
</csc>
|
||||
<include name="Spring.Data.NHibernate21.dll" />
|
||||
<exclude name="Spring.Data.NHibernate.dll" />
|
||||
<exclude name="Spring.Data.NHibernate12*.dll" />
|
||||
<exclude name="Spring.Data.NHibernate20*.dll" />
|
||||
<exclude name="Spring.Data.NHibernate*.Tests.dll" />
|
||||
</references>
|
||||
<resources prefix="Spring" dynamicprefix="true" failonempty="true">
|
||||
<include name="**/*.xml" />
|
||||
</resources>
|
||||
</csc>
|
||||
|
||||
<copy file="${project::get-base-directory()}/${project::get-name()}.dll.config"
|
||||
tofile="${current.bin.dir}/${project::get-name()}.dll.config"/>
|
||||
<copy file="${project::get-base-directory()}/${project::get-name()}.dll.config"
|
||||
tofile="${current.bin.dir}/${project::get-name()}.dll.config"/>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="test" depends="build">
|
||||
<!-- property name="test.assemblyname" value="${project::get-name()}" / -->
|
||||
<call target="common.run-tests" />
|
||||
</target>
|
||||
|
||||
</target>
|
||||
<target name="test" depends="build">
|
||||
<!-- skipping running of tests for now
|
||||
<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>
|
||||
|
||||
@@ -58,15 +58,5 @@
|
||||
<!-- 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"
|
||||
appconfig="${current.bin.dir}/${project::get-name()}.dll.config" />
|
||||
</nunit2outproc>
|
||||
</target>
|
||||
-->
|
||||
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user