Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backported NHibernate 1.2, changed other files only where necessary t…
…o ensure compile/working tests SVN: branches/1.2.x@3119
- Loading branch information
Showing
102 changed files
with
12,889 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,100 @@ | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<configuration> | |||
<configSections> | |||
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> | |||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> | |||
</configSections> | |||
|
|||
<connectionStrings> | |||
<add name="TestConnectionString" connectionString="TestConnectionString-TestConnectionString" /> | |||
</connectionStrings> | |||
<runtime> | |||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" | |||
applies-to="v1.1.4322"> | |||
<qualifyAssembly partialName="System.Web" | |||
fullName="System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> | |||
</assemblyBinding> | |||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" | |||
applies-to="v2.0.50727"> | |||
<qualifyAssembly partialName="System.Web" | |||
fullName="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> | |||
</assemblyBinding> | |||
</runtime> | |||
|
|||
<nhibernate> | |||
<add key="hibernate.connection.provider" value="NHibernate.Test.DebugConnectionProvider, NHibernate.Test" /> | |||
<add key="hibernate.connection.isolation" value="ReadCommitted" /> | |||
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" /> | |||
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" /> | |||
<add key="hibernate.connection.connection_string" value="Server=(local);initial catalog=nhibernate;Integrated Security=SSPI" /> | |||
<add key="hibernate.query.substitutions" value="true 1, false 0, yes 'Y', no 'N'" /> | |||
<add key="hibernate.adonet.batch_size" value="10" /> | |||
<add key="hibernate.prepare_sql" value="false" /> | |||
<add key="hibernate.cache.provider_class" value="NHibernate.Cache.HashtableCacheProvider, NHibernate" /> | |||
<add key="hibernate.cache.use_query_cache" value="true" /> | |||
</nhibernate> | |||
|
|||
<!-- This section contains the log4net configuration settings --> | |||
<log4net debug="false"> | |||
|
|||
<!-- Define some output appenders --> | |||
<appender name="trace" | |||
type="log4net.Appender.TraceAppender, log4net"> | |||
<layout type="log4net.Layout.PatternLayout,log4net"> | |||
<param name="ConversionPattern" | |||
value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" /> | |||
</layout> | |||
</appender> | |||
|
|||
<appender name="console" | |||
type="log4net.Appender.ConsoleAppender, log4net"> | |||
<layout type="log4net.Layout.PatternLayout,log4net"> | |||
<param name="ConversionPattern" | |||
value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" /> | |||
</layout> | |||
</appender> | |||
|
|||
<appender name="rollingFile" | |||
type="log4net.Appender.RollingFileAppender,log4net" > | |||
|
|||
<param name="File" | |||
value="log.txt" /> | |||
<param name="AppendToFile" | |||
value="false" /> | |||
<param name="RollingStyle" | |||
value="Date" /> | |||
<param name="DatePattern" | |||
value="yyyy.MM.dd" /> | |||
<param name="StaticLogFileName" | |||
value="true" /> | |||
|
|||
<layout type="log4net.Layout.PatternLayout,log4net"> | |||
<param name="ConversionPattern" | |||
value="%d [%t] %-5p %c - %m%n" /> | |||
</layout> | |||
</appender> | |||
|
|||
<!-- Setup the root category, add the appenders and set the default priority --> | |||
|
|||
<root> | |||
<priority value="WARN" /> | |||
<appender-ref ref="console" /> | |||
</root> | |||
|
|||
<logger name="NHibernate.Bytecode.CodeDom"> | |||
<priority value="OFF" /> | |||
</logger> | |||
|
|||
<logger name="NHibernate.SQL"> | |||
<level value="OFF" /> | |||
</logger> | |||
|
|||
<logger name="NHibernate.Tool.hbm2ddl.SchemaExport"> | |||
<level value="WARN" /> | |||
</logger> | |||
</log4net> | |||
|
|||
|
|||
</configuration> | |||
|
|||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,144 @@ | |||
using System; | |||
using System.Collections; | |||
using Lucene.Net.Analysis; | |||
using Lucene.Net.Analysis.Standard; | |||
using Lucene.Net.QueryParsers; | |||
using Lucene.Net.Search; | |||
using NHibernate.Cfg; | |||
using NUnit.Framework; | |||
|
|||
namespace NHibernate.Search.Tests.Bridge | |||
{ | |||
[TestFixture] | |||
public class BridgeTest : SearchTestCase | |||
{ | |||
[Test] | |||
public void DefaultAndNullBridges() | |||
{ | |||
Cloud cloud = new Cloud(); | |||
cloud.DateTime = null; | |||
cloud.Double1 = (null); | |||
cloud.Double2 = (2.1d); | |||
cloud.Int1 = (null); | |||
cloud.Int2 = (2); | |||
cloud.Float1 = (null); | |||
cloud.Float2 = (2.1f); | |||
cloud.Long1 = (null); | |||
cloud.Long2 = (2L); | |||
cloud.String1 = (null); | |||
cloud.Type = (CloudType.Dog); | |||
cloud.Storm = (false); | |||
ISession s = OpenSession(); | |||
ITransaction tx = s.BeginTransaction(); | |||
s.Save(cloud); | |||
s.Flush(); | |||
tx.Commit(); | |||
|
|||
tx = s.BeginTransaction(); | |||
IFullTextSession session = Search.CreateFullTextSession(s); | |||
QueryParser parser = new QueryParser("id", new StandardAnalyzer()); | |||
Query query; | |||
IList result; | |||
|
|||
query = parser.Parse("Double2:[2 TO 2.1] AND Float2:[2 TO 2.1] " + | |||
"AND Int2:[2 TO 2.1] AND Long2:[2 TO 2.1] AND Type:\"Dog\" AND Storm:false"); | |||
|
|||
result = session.CreateFullTextQuery(query).List(); | |||
Assert.AreEqual(1, result.Count, "find primitives and do not fail on null"); | |||
|
|||
query = parser.Parse("Double1:[2 TO 2.1] OR Float1:[2 TO 2.1] OR Int1:[2 TO 2.1] OR Long1:[2 TO 2.1]"); | |||
result = session.CreateFullTextQuery(query).List(); | |||
Assert.AreEqual(0, result.Count, "null elements should not be stored"); //the query is dumb because restrictive | |||
|
|||
s.Delete(s.Get(typeof(Cloud), cloud.Id)); | |||
tx.Commit(); | |||
s.Close(); | |||
} | |||
|
|||
[Test] | |||
public void CustomBridges() | |||
{ | |||
Cloud cloud = new Cloud(); | |||
cloud.CustomFieldBridge = ("This is divided by 2"); | |||
cloud.CustomStringBridge = ("This is div by 4"); | |||
ISession s = OpenSession(); | |||
ITransaction tx = s.BeginTransaction(); | |||
s.Save(cloud); | |||
s.Flush(); | |||
tx.Commit(); | |||
|
|||
tx = s.BeginTransaction(); | |||
IFullTextSession session = Search.CreateFullTextSession(s); | |||
QueryParser parser = new QueryParser("id", new SimpleAnalyzer()); | |||
Query query; | |||
IList result; | |||
|
|||
query = parser.Parse("CustomFieldBridge:This AND CustomStringBridge:This"); | |||
result = session.CreateFullTextQuery(query).List(); | |||
Assert.AreEqual(1, result.Count, "Properties not mapped"); | |||
|
|||
query = parser.Parse("CustomFieldBridge:by AND CustomStringBridge:is"); | |||
result = session.CreateFullTextQuery(query).List(); | |||
Assert.AreEqual(0, result.Count, "Custom types not taken into account"); | |||
|
|||
s.Delete(s.Get(typeof(Cloud), cloud.Id)); | |||
tx.Commit(); | |||
s.Close(); | |||
} | |||
|
|||
[Test] | |||
public void DateTimeBridge() | |||
{ | |||
Cloud cloud = new Cloud(); | |||
|
|||
|
|||
DateTime date = new DateTime(2000, 12, 15, 3, 43, 2); | |||
cloud.DateTime = (date); //5 millisecond | |||
cloud.DateTimeDay = (date); | |||
cloud.DateTimeHour = (date); | |||
cloud.DateTimeMillisecond = (date); | |||
cloud.DateTimeMinute = (date); | |||
cloud.DateTimeMonth = (date); | |||
cloud.DateTimeSecond = (date); | |||
cloud.DateTimeYear = (date); | |||
ISession s = OpenSession(); | |||
ITransaction tx = s.BeginTransaction(); | |||
s.Save(cloud); | |||
s.Flush(); | |||
tx.Commit(); | |||
|
|||
tx = s.BeginTransaction(); | |||
IFullTextSession session = Search.CreateFullTextSession(s); | |||
QueryParser parser = new QueryParser("id", new StandardAnalyzer()); | |||
Query query; | |||
IList result; | |||
|
|||
query = parser.Parse("DateTime:[19900101 TO 20060101]" | |||
+ " AND DateTimeDay:[20001214 TO 2000121501]" | |||
+ " AND DateTimeMonth:[200012 TO 20001201]" | |||
+ " AND DateTimeYear:[2000 TO 200001]" | |||
+ " AND DateTimeHour:[20001214 TO 2000121503]" | |||
+ " AND DateTimeMinute:[20001214 TO 200012150343]" | |||
+ " AND DateTimeSecond:[20001214 TO 20001215034302]" | |||
+ " AND DateTimeMillisecond:[20001214 TO 20001215034302005]" | |||
); | |||
result = session.CreateFullTextQuery(query).List(); | |||
Assert.AreEqual(1, result.Count, "DateTime not found or not property truncated"); | |||
|
|||
s.Delete(s.Get(typeof(Cloud), cloud.Id)); | |||
tx.Commit(); | |||
s.Close(); | |||
} | |||
|
|||
protected override void Configure(Configuration configuration) | |||
{ | |||
base.Configure(configuration); | |||
configuration.SetProperty(Environment.AnalyzerClass, typeof(SimpleAnalyzer).AssemblyQualifiedName); | |||
} | |||
|
|||
protected override IList Mappings | |||
{ | |||
get { return new string[] { "Bridge.Cloud.hbm.xml" }; } | |||
} | |||
} | |||
} |
Oops, something went wrong.