From: <fab...@us...> - 2009-05-16 06:00:08
|
Revision: 4325 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4325&view=rev Author: fabiomaulo Date: 2009-05-16 06:00:06 +0000 (Sat, 16 May 2009) Log Message: ----------- Fixed some problems in the Example an Performance prjs... btw both are obsolete. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Examples/Blogger/BloggerFixture.cs trunk/nhibernate/src/NHibernate.Examples/Cascades/CascadeFixture.cs trunk/nhibernate/src/NHibernate.Examples/ForumQuestions/T1078029/MemberFixture.cs trunk/nhibernate/src/NHibernate.Examples/ForumQuestions/TestCase.cs trunk/nhibernate/src/NHibernate.Examples/NHibernate.Examples.csproj trunk/nhibernate/src/NHibernate.Examples/QuickStart/UserFixture.cs trunk/nhibernate/src/NHibernate.Test.Performance/PerformanceTest.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate.Examples/TestConfigurationHelper.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Examples/hibernate.cfg.xml Property Changed: ---------------- trunk/nhibernate/src/NHibernate.Examples/ Property changes on: trunk/nhibernate/src/NHibernate.Examples ___________________________________________________________________ Modified: svn:ignore - bin obj .#* *.user *.xsx [Bb]in [Dd]ebug [Rr]elease *.aps *.eto + bin obj .#* *.user *.xsx [Bb]in [Dd]ebug [Rr]elease *.aps *.eto hibernate.cfg.xml Modified: trunk/nhibernate/src/NHibernate.Examples/Blogger/BloggerFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Examples/Blogger/BloggerFixture.cs 2009-05-16 00:59:51 UTC (rev 4324) +++ trunk/nhibernate/src/NHibernate.Examples/Blogger/BloggerFixture.cs 2009-05-16 06:00:06 UTC (rev 4325) @@ -39,7 +39,7 @@ // reload the blog to verify the db has the correct values ISession s = _sessions.OpenSession(); - blog = (Blog) s.Find("from Blog as b where b.Name=:name", "GregBlog", NHibernateUtil.String)[0]; + blog = s.CreateQuery("from Blog as b where b.Name=:name").SetString("name","GregBlog").List<Blog>()[0]; Assert.IsNotNull(blog); Assert.AreEqual(2, blog.Items.Count); @@ -98,7 +98,7 @@ public void Configure() { - Configuration cfg = new Configuration(); + Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); cfg.AddClass(typeof(Blog)); cfg.AddClass(typeof(BlogItem)); _sessions = cfg.BuildSessionFactory(); @@ -106,7 +106,7 @@ public void ExportTables() { - Configuration cfg = new Configuration(); + Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); cfg.AddClass(typeof(Blog)); cfg.AddClass(typeof(BlogItem)); new SchemaExport(cfg).Create(true, true); Modified: trunk/nhibernate/src/NHibernate.Examples/Cascades/CascadeFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Examples/Cascades/CascadeFixture.cs 2009-05-16 00:59:51 UTC (rev 4324) +++ trunk/nhibernate/src/NHibernate.Examples/Cascades/CascadeFixture.cs 2009-05-16 06:00:06 UTC (rev 4325) @@ -19,7 +19,7 @@ [SetUp] public void SetUp() { - cfg = new Configuration(); + cfg = TestConfigurationHelper.GetDefaultConfiguration(); cfg.AddAssembly("NHibernate.Examples"); new SchemaExport(cfg).Create(true, true); Modified: trunk/nhibernate/src/NHibernate.Examples/ForumQuestions/T1078029/MemberFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Examples/ForumQuestions/T1078029/MemberFixture.cs 2009-05-16 00:59:51 UTC (rev 4324) +++ trunk/nhibernate/src/NHibernate.Examples/ForumQuestions/T1078029/MemberFixture.cs 2009-05-16 06:00:06 UTC (rev 4325) @@ -19,7 +19,7 @@ [Test] public void ValidateQuickStart() { - Configuration cfg = new Configuration(); + Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); cfg.AddResource("NHibernate.Examples.ForumQuestions.T1078029.Member.hbm.xml", Assembly.Load("NHibernate.Examples")); ISessionFactory factory = cfg.BuildSessionFactory(); Modified: trunk/nhibernate/src/NHibernate.Examples/ForumQuestions/TestCase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Examples/ForumQuestions/TestCase.cs 2009-05-16 00:59:51 UTC (rev 4324) +++ trunk/nhibernate/src/NHibernate.Examples/ForumQuestions/TestCase.cs 2009-05-16 06:00:06 UTC (rev 4325) @@ -27,7 +27,7 @@ public void ExportSchema(string[] files, bool exportSchema) { - cfg = new Configuration(); + cfg = TestConfigurationHelper.GetDefaultConfiguration(); for (int i = 0; i < files.Length; i++) { Modified: trunk/nhibernate/src/NHibernate.Examples/NHibernate.Examples.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Examples/NHibernate.Examples.csproj 2009-05-16 00:59:51 UTC (rev 4324) +++ trunk/nhibernate/src/NHibernate.Examples/NHibernate.Examples.csproj 2009-05-16 06:00:06 UTC (rev 4325) @@ -154,7 +154,7 @@ <Compile Include="QuickStart\UserFixture.cs"> <SubType>Code</SubType> </Compile> - <Content Include="hibernate.cfg.xml" /> + <Compile Include="TestConfigurationHelper.cs" /> <EmbeddedResource Include="Blogger\Blog.hbm.xml" /> <EmbeddedResource Include="Blogger\BlogItem.hbm.xml" /> <EmbeddedResource Include="Cascades\Alias.hbm.xml" /> @@ -181,9 +181,10 @@ </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <PropertyGroup> - <PreBuildEvent>copy /y "$(ProjectDir)App.config" "$(TargetPath).config" -copy /y "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml"</PreBuildEvent> - <PostBuildEvent> - </PostBuildEvent> + <PreBuildEvent> + </PreBuildEvent> + <PostBuildEvent>copy "$(ProjectDir)App.config" "$(TargetPath).config" +if exist hibernate.cfg.xml (del hibernate.cfg.xml) +if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")</PostBuildEvent> </PropertyGroup> </Project> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Examples/QuickStart/UserFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Examples/QuickStart/UserFixture.cs 2009-05-16 00:59:51 UTC (rev 4324) +++ trunk/nhibernate/src/NHibernate.Examples/QuickStart/UserFixture.cs 2009-05-16 06:00:06 UTC (rev 4325) @@ -16,7 +16,7 @@ [Test] public void ValidateQuickStart() { - Configuration cfg = new Configuration(); + Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); cfg.AddAssembly("NHibernate.Examples"); ISessionFactory factory = cfg.BuildSessionFactory(); Copied: trunk/nhibernate/src/NHibernate.Examples/TestConfigurationHelper.cs (from rev 4323, trunk/nhibernate/src/NHibernate.Test/TestConfigurationHelper.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Examples/TestConfigurationHelper.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Examples/TestConfigurationHelper.cs 2009-05-16 06:00:06 UTC (rev 4325) @@ -0,0 +1,40 @@ +using System; +using System.IO; +using NHibernate.Cfg; + +namespace NHibernate.Examples +{ + public static class TestConfigurationHelper + { + public static readonly string hibernateConfigFile; + + static TestConfigurationHelper() + { + // Verify if hibernate.cfg.xml exists + hibernateConfigFile = GetDefaultConfigurationFilePath(); + } + + public static string GetDefaultConfigurationFilePath() + { + string baseDir = AppDomain.CurrentDomain.BaseDirectory; + string relativeSearchPath = AppDomain.CurrentDomain.RelativeSearchPath; + string binPath = relativeSearchPath == null ? baseDir : Path.Combine(baseDir, relativeSearchPath); + string fullPath = Path.Combine(binPath, Configuration.DefaultHibernateCfgFileName); + return File.Exists(fullPath) ? fullPath : null; + } + + /// <summary> + /// Standar Configuration for tests. + /// </summary> + /// <returns>The configuration using merge between App.Config and hibernate.cfg.xml if present.</returns> + public static Configuration GetDefaultConfiguration() + { + var result = new Configuration(); + if (hibernateConfigFile != null) + { + result.Configure(hibernateConfigFile); + } + return result; + } + } +} \ No newline at end of file Deleted: trunk/nhibernate/src/NHibernate.Examples/hibernate.cfg.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Examples/hibernate.cfg.xml 2009-05-16 00:59:51 UTC (rev 4324) +++ trunk/nhibernate/src/NHibernate.Examples/hibernate.cfg.xml 2009-05-16 06:00:06 UTC (rev 4325) @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > - <session-factory name="NHibernate.Test"> - <!-- properties --> - <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> - <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> - <property name="connection.connection_string">Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI</property> - <property name="show_sql">false</property> - <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property> - <property name="use_outer_join">true</property> - <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property> - <!-- mapping files --> - <mapping assembly="NHibernate.Examples" /> - </session-factory> - -</hibernate-configuration> Modified: trunk/nhibernate/src/NHibernate.Test.Performance/PerformanceTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test.Performance/PerformanceTest.cs 2009-05-16 00:59:51 UTC (rev 4324) +++ trunk/nhibernate/src/NHibernate.Test.Performance/PerformanceTest.cs 2009-05-16 06:00:06 UTC (rev 4325) @@ -62,7 +62,7 @@ driver = (DriverBase) Activator.CreateInstance(System.Type.GetType(driverClass)); - string prepare = (string) cfg.Properties[Environment.PrepareSql] as string; + string prepare = cfg.GetProperty(Environment.PrepareSql); if (prepare == "true") { prepareSql = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |