From: <dar...@us...> - 2009-07-01 17:44:16
|
Revision: 4552 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4552&view=rev Author: darioquintana Date: 2009-07-01 17:43:35 +0000 (Wed, 01 Jul 2009) Log Message: ----------- NH-645 reopened: not working with AST-Hql. Tests rewritten Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs 2009-07-01 16:31:18 UTC (rev 4551) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs 2009-07-01 17:43:35 UTC (rev 4552) @@ -1,16 +1,38 @@ using System; using System.Collections; +using Antlr.Runtime.Tree; using NHibernate.Cfg; using NHibernate.Dialect; using NHibernate.Dialect.Function; +using NHibernate.Hql.Ast.ANTLR; +using NHibernate.Hql.Classic; using NUnit.Framework; using Environment=NHibernate.Cfg.Environment; namespace NHibernate.Test.NHSpecificTest.NH645 { [TestFixture] - public class HQLFunctionFixture : TestCase + public class HqlFunctionWithClassicParser : HQLFunctionFixtureBase { + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); + configuration.SetProperty(Environment.QueryTranslator, typeof (ClassicQueryTranslatorFactory).AssemblyQualifiedName); + } + } + + [TestFixture, Ignore("Not fixed yet in the AST-HQL parser")] + public class HqlFunctionWithAstHqlParser : HQLFunctionFixtureBase + { + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); + configuration.SetProperty(Environment.QueryTranslator, typeof (ASTQueryTranslatorFactory).AssemblyQualifiedName); + } + } + + public class HQLFunctionFixtureBase : TestCase + { private bool appliesToThisDialect = true; protected override string MappingsAssembly @@ -18,14 +40,14 @@ get { return "NHibernate.Test"; } } - protected override bool AppliesTo(Dialect.Dialect dialect) + protected override IList Mappings { - return appliesToThisDialect; + get { return new[] {"HQL.Animal.hbm.xml", "HQL.MaterialResource.hbm.xml"}; } } - protected override IList Mappings + protected override bool AppliesTo(Dialect.Dialect dialect) { - get { return new[] {"HQL.Animal.hbm.xml", "HQL.MaterialResource.hbm.xml"}; } + return appliesToThisDialect; } protected override void Configure(Configuration configuration) @@ -36,10 +58,31 @@ appliesToThisDialect = false; } + public void Run(string hql) + { + using (ISession s = OpenSession()) + try + { + s.CreateQuery(hql).List(); + } + catch (Exception ex) + { + if (IsClassicParser) + { + if (ex is QueryException) + Assert.Fail("The parser think that 'freetext' is a boolean function"); + } + else //Hql-Parser + { + if (ex is RewriteEmptyStreamException || ex is InvalidCastException) + Assert.Fail("The parser think that 'freetext' is a boolean function"); + } + } + } + /// <summary> /// Just test the parser can compile, and SqlException is expected. /// </summary> - [Test] public void SimpleWhere() { @@ -57,21 +100,6 @@ { Run("from Animal a where freetext(a.Description, 'hey apple car') AND a.Description <> 'foo'"); } - - - public void Run(string hql) - { - using(ISession s = OpenSession()) - try - { - s.CreateQuery(hql).List(); - } - catch (Exception ex) - { - if (ex is QueryException) - Assert.Fail("The parser think that 'freetext' is a boolean function"); - } - } } public class CustomDialect : MsSql2005Dialect This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |