You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by di...@apache.org on 2011/05/04 10:48:53 UTC
[Lucene.Net] svn commit: r1099375 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g:
src/core/Util/Constants.cs test/core/PartiallyTrustedAppDomain.cs
test/core/TestSupportClass.cs
Author: digy
Date: Wed May 4 08:48:52 2011
New Revision: 1099375
URL: http://svn.apache.org/viewvc?rev=1099375&view=rev
Log:
[LUCENENET-412] [LUCENENET-413] Constants.cs + a new test case
Modified:
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Util/Constants.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Util/Constants.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Util/Constants.cs?rev=1099375&r1=1099374&r2=1099375&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Util/Constants.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Util/Constants.cs Wed May 4 08:48:52 2011
@@ -72,7 +72,7 @@ namespace Lucene.Net.Util
public static readonly System.String LUCENE_MAIN_VERSION = Ident("2.9.4");
- public static System.String LUCENE_VERSION;
+ public static System.String LUCENE_VERSION="8.8.8.8";
static Constants()
{
if (IntPtr.Size == 8)
@@ -84,7 +84,13 @@ namespace Lucene.Net.Util
JRE_IS_64BIT = false;// 32 bit machine
}
- LUCENE_VERSION = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
+ try
+ {
+ LUCENE_VERSION = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
+ }
+ catch (System.Security.SecurityException) //Ignore in medium trust.
+ {
+ }
}
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs?rev=1099375&r1=1099374&r2=1099375&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs Wed May 4 08:48:52 2011
@@ -31,6 +31,7 @@ namespace Lucene.Net.Test
{
public class PartiallyTrustedAppDomain
{
+ public static string TEMPDIR = @"c:\temp\testindex";
/// <summary>
///
/// </summary>
@@ -47,6 +48,7 @@ namespace Lucene.Net.Test
PermissionSet permissions = new PermissionSet(null);
permissions.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
permissions.AddPermission(new ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess));
+ permissions.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, TEMPDIR ));
AppDomain appDomain = AppDomain.CreateDomain("PartiallyTrustedAppDomain", null, setup, permissions);
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs?rev=1099375&r1=1099374&r2=1099375&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs Wed May 4 08:48:52 2011
@@ -1211,6 +1211,44 @@ namespace Lucene.Net._SupportClass
public class TestMediumTrust
{
[Test]
+ public void TestIndexAndSearch()
+ {
+ Lucene.Net.Test.PartiallyTrustedAppDomain.Run(this.GetType(), "TestIndexAndSearch2", null, null);
+ }
+
+ void TestIndexAndSearch2()
+ {
+ Lucene.Net.Store.Directory dir = Lucene.Net.Store.FSDirectory.Open(new System.IO.DirectoryInfo(Lucene.Net.Test.PartiallyTrustedAppDomain.TEMPDIR));
+
+ Lucene.Net.Index.IndexWriter w = new Lucene.Net.Index.IndexWriter(dir, new Lucene.Net.Analysis.Standard.StandardAnalyzer(), true);
+ Lucene.Net.Documents.Field f1 = new Lucene.Net.Documents.Field("field1", "dark side of the moon", Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.TOKENIZED);
+ Lucene.Net.Documents.Field f2 = new Lucene.Net.Documents.Field("field2", "123", Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.UN_TOKENIZED);
+ Lucene.Net.Documents.Document d = new Lucene.Net.Documents.Document();
+ d.Add(f1);
+ d.Add(f2);
+ w.AddDocument(d);
+
+ f1 = new Lucene.Net.Documents.Field("field1", "Fly me to the moon", Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.TOKENIZED);
+ f2 = new Lucene.Net.Documents.Field("field2", "456", Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.UN_TOKENIZED);
+ d = new Lucene.Net.Documents.Document();
+ d.Add(f1);
+ d.Add(f2);
+ w.AddDocument(d);
+
+ w.Close();
+
+ Lucene.Net.Search.IndexSearcher searcher = new IndexSearcher(dir, true);
+
+ Lucene.Net.Search.Sort sort = new Lucene.Net.Search.Sort();
+ sort.SetSort(new Lucene.Net.Search.SortField("field2", Lucene.Net.Search.SortField.STRING));
+ Lucene.Net.Search.Query q = new Lucene.Net.QueryParsers.QueryParser("field1", new Lucene.Net.Analysis.Standard.StandardAnalyzer()).Parse("moon");
+ TopDocs td = searcher.Search(q, null, 100, sort);
+ int resCount = td.ScoreDocs.Length;
+
+ searcher.Close();
+ }
+
+ [Test]
public void Test_Index_Term()
{
//invoke any method