lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aro...@apache.org
Subject svn commit: r432239 [8/8] - in /incubator/lucene.net/trunk/C#/src: ./ Demo/DeleteFiles/ Demo/DemoLib/ Demo/DemoLib/HTML/ Demo/IndexFiles/ Demo/IndexHtml/ Demo/SearchFiles/ Lucene.Net/ Lucene.Net/Analysis/ Lucene.Net/Analysis/Standard/ Lucene.Net/Docume...
Date Thu, 17 Aug 2006 13:49:32 GMT
Added: incubator/lucene.net/trunk/C#/src/Test/Store/TestLock.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Store/TestLock.cs?rev=432239&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/TestLock.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/TestLock.cs Thu Aug 17 06:49:26 2006
@@ -0,0 +1,118 @@
+/* ====================================================================
+* The Apache Software License, Version 1.1
+*
+* Copyright (c) 2001,2004 The Apache Software Foundation.  All rights
+* reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in
+*    the documentation and/or other materials provided with the
+*    distribution.
+*
+* 3. The end-user documentation included with the redistribution,
+*    if any, must include the following acknowledgment:
+*       "This product includes software developed by the
+*        Apache Software Foundation (http://www.apache.org/)."
+*    Alternately, this acknowledgment may appear in the software itself,
+*    if and wherever such third-party acknowledgments normally appear.
+*
+* 4. The names "Apache" and "Apache Software Foundation" and
+*    "Apache Lucene" must not be used to endorse or promote products
+*    derived from this software without prior written permission. For
+*    written permission, please contact apache@apache.org.
+*
+* 5. Products derived from this software may not be called "Apache",
+*    "Apache Lucene", nor may "Apache" appear in their name, without
+*    prior written permission of the Apache Software Foundation.
+*
+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+* SUCH DAMAGE.
+* ====================================================================
+*
+* This software consists of voluntary contributions made by many
+* individuals on behalf of the Apache Software Foundation.  For more
+* information on the Apache Software Foundation, please see
+* <http://www.apache.org/>.
+*/
+
+using System;
+using NUnit.Framework;
+
+namespace Lucene.Net.store
+{
+	
+    [TestFixture]
+    public class TestLock
+    {
+		
+        [Test]
+        public virtual void  TestObtain()
+        {
+            LockMock lock_Renamed = new LockMock(this);
+            Lucene.Net.Store.Lock.LOCK_POLL_INTERVAL = 10;
+			
+            try
+            {
+                lock_Renamed.Obtain(Lucene.Net.Store.Lock.LOCK_POLL_INTERVAL);
+                Assert.Fail("Should have failed to obtain lock");
+            }
+            catch (System.IO.IOException e)
+            {
+                Assert.AreEqual(lock_Renamed.lockAttempts, 2, "should attempt to lock more
than once");
+            }
+        }
+		
+        private class LockMock : Lucene.Net.Store.Lock
+        {
+            public LockMock(TestLock enclosingInstance)
+            {
+                InitBlock(enclosingInstance);
+            }
+            private void  InitBlock(TestLock enclosingInstance)
+            {
+                this.enclosingInstance = enclosingInstance;
+            }
+            private TestLock enclosingInstance;
+            override public bool IsLocked()
+            {
+                return false;
+            }
+            public TestLock Enclosing_Instance
+            {
+                get
+                {
+                    return enclosingInstance;
+                }
+				
+            }
+            public int lockAttempts;
+			
+            public override bool Obtain()
+            {
+                lockAttempts++;
+                return false;
+            }
+            public override void  Release()
+            {
+                // do nothing
+            }
+        }
+    }
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Test.csproj?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Test.csproj (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Test.csproj Thu Aug 17 06:49:26 2006
@@ -90,22 +90,22 @@
                     HintPath = "..\Demo\DemoLib\bin\Debug\DemoLib.dll"
                 />
                 <Reference
-                    Name = "Lucene.Net"
-                    AssemblyName = "Lucene.Net"
-                    HintPath = "..\Lucene.Net\bin\Debug\Lucene.Net.dll"
-                />
-                <Reference
                     Name = "nunit.core"
                     AssemblyName = "nunit.core"
-                    HintPath = ".\NUnit\bin\nunit.core.dll"
+                    HintPath = "D:\DEVS\NUnit\bin\nunit.core.dll"
                     AssemblyFolderKey = "hklm\dn\nunit.framework"
                 />
                 <Reference
                     Name = "nunit.framework"
                     AssemblyName = "nunit.framework"
-                    HintPath = ".\NUnit\bin\nunit.framework.dll"
+                    HintPath = "D:\DEVS\NUnit\bin\nunit.framework.dll"
                     AssemblyFolderKey = "hklm\dn\nunit.framework"
                 />
+                <Reference
+                    Name = "Lucene.Net"
+                    AssemblyName = "Lucene.Net"
+                    HintPath = "..\Lucene.Net\bin\Debug\Lucene.Net.dll"
+                />
             </References>
         </Build>
         <Files>
@@ -286,6 +286,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "Index\TestIndexWriterMerging.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Index\TestMultiReader.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -331,7 +336,7 @@
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Index\Store\TestFSDirectory.cs"
+                    RelPath = "Index\Store\_delete_TestFSDirectory.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
@@ -381,6 +386,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "Search\SingleDocTestFilter.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Search\TestBoolean2.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -551,12 +561,12 @@
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Search\Regex\TestRegexQuery.cs"
+                    RelPath = "Search\Regex\_delete_TestRegexQuery.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Search\Regex\TestSpanRegexQuery.cs"
+                    RelPath = "Search\Regex\_delete_TestSpanRegexQuery.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
@@ -582,6 +592,11 @@
                 />
                 <File
                     RelPath = "Store\_TestHelper.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Store\TestLock.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />

Modified: incubator/lucene.net/trunk/C#/src/Test/TestDemo.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/TestDemo.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/TestDemo.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/TestDemo.cs Thu Aug 17 06:49:26 2006
@@ -63,8 +63,9 @@
 			// Now search the index:
 			IndexSearcher isearcher = new IndexSearcher(directory);
 			// Parse a simple query that searches for "text":
-			Query query = Lucene.Net.QueryParsers.QueryParser.Parse("text", "fieldname", analyzer);
-			Hits hits = isearcher.Search(query);
+            Lucene.Net.QueryParsers.QueryParser parser = new Lucene.Net.QueryParsers.QueryParser("fieldname",
analyzer);
+            Lucene.Net.Search.Query query = parser.Parse("text");
+            Hits hits = isearcher.Search(query);
 			Assert.AreEqual(1, hits.Length());
 			// Iterate through the results:
 			for (int i = 0; i < hits.Length(); i++)

Modified: incubator/lucene.net/trunk/C#/src/Test/ThreadSafetyTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/ThreadSafetyTest.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/ThreadSafetyTest.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/ThreadSafetyTest.cs Thu Aug 17 06:49:26 2006
@@ -69,7 +69,7 @@
 						Lucene.Net.Documents.Document d = new Lucene.Net.Documents.Document();
 						int n = Lucene.Net.ThreadSafetyTest.RANDOM.Next();
 						d.Add(new Field("id", System.Convert.ToString(n), Field.Store.YES, Field.Index.UN_TOKENIZED));
-						d.Add(new Field("contents", English.IntToEnglish(n), Field.Store.NO, Field.Index.TOKENIZED));
+						d.Add(new Field("contents", Lucene.Net.Util.English.IntToEnglish(n), Field.Store.NO,
Field.Index.TOKENIZED));
 						System.Console.Out.WriteLine("Adding " + n);
 						
 						// Switch between single and multiple file segments
@@ -96,7 +96,7 @@
 			}
 		}
 		
-		private class SearcherThread:SupportClass.ThreadClass
+		private class SearcherThread : SupportClass.ThreadClass
 		{
 			private void  InitBlock()
 			{
@@ -143,8 +143,9 @@
 			private void  searchFor(int n, Searcher searcher)
 			{
 				System.Console.Out.WriteLine("Searching for " + n);
-				Hits hits = searcher.Search(Lucene.Net.QueryParsers.QueryParser.Parse(English.IntToEnglish(n),
"contents", Lucene.Net.ThreadSafetyTest.ANALYZER));
-				System.Console.Out.WriteLine("Search for " + n + ": total=" + hits.Length());
+                Lucene.Net.QueryParsers.QueryParser parser = new Lucene.Net.QueryParsers.QueryParser("contents",
Lucene.Net.ThreadSafetyTest.ANALYZER);
+                Lucene.Net.Search.Hits hits = searcher.Search(parser.Parse(Lucene.Net.Util.English.IntToEnglish(n)));
+                System.Console.Out.WriteLine("Search for " + n + ": total=" + hits.Length());
 				for (int j = 0; j < System.Math.Min(3, hits.Length()); j++)
 				{
 					System.Console.Out.WriteLine("Hit for " + n + ": " + hits.Doc(j).Get("id"));



Mime
View raw message