You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ar...@apache.org on 2007/08/11 18:56:44 UTC
svn commit: r564939 [7/8] - in /incubator/lucene.net/trunk/C#/src: ./ Demo/
Demo/DeleteFiles/ Demo/DemoLib/ Demo/IndexFiles/ Demo/IndexHtml/
Demo/SearchFiles/ Lucene.Net/ Lucene.Net/Analysis/Standard/
Lucene.Net/Document/ Lucene.Net/Index/ Lucene.Net/Q...
Added: incubator/lucene.net/trunk/C#/src/Test/Search/TestTermScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestTermScorer.cs?view=auto&rev=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestTermScorer.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestTermScorer.cs Sat Aug 11 09:56:37 2007
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using NUnit.Framework;
+
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using IndexReader = Lucene.Net.Index.IndexReader;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using Term = Lucene.Net.Index.Term;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+
+namespace Lucene.Net.Search
+{
+
+ [TestFixture]
+ public class TestTermScorer
+ {
+ private class AnonymousClassHitCollector : HitCollector
+ {
+ public AnonymousClassHitCollector(System.Collections.IList docs, TestTermScorer enclosingInstance)
+ {
+ InitBlock(docs, enclosingInstance);
+ }
+ private void InitBlock(System.Collections.IList docs, TestTermScorer enclosingInstance)
+ {
+ this.docs = docs;
+ this.enclosingInstance = enclosingInstance;
+ }
+ private System.Collections.IList docs;
+ private TestTermScorer enclosingInstance;
+ public TestTermScorer Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ public override void Collect(int doc, float score)
+ {
+ docs.Add(new TestHit(enclosingInstance, doc, score));
+ Assert.IsTrue(score > 0, "score " + score + " is not greater than 0");
+ Assert.IsTrue(doc == 0 || doc == 5, "Doc: " + doc + " does not equal: " + 0 + " or doc does not equaal: " + 5);
+ }
+ }
+ protected internal RAMDirectory directory;
+ private const System.String FIELD = "field";
+
+ protected internal System.String[] values = new System.String[]{"all", "dogs dogs", "like", "playing", "fetch", "all"};
+ protected internal IndexSearcher indexSearcher;
+ protected internal IndexReader indexReader;
+
+
+ [SetUp]
+ protected internal virtual void SetUp()
+ {
+ directory = new RAMDirectory();
+
+
+ IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true);
+ for (int i = 0; i < values.Length; i++)
+ {
+ Document doc = new Document();
+ doc.Add(new Field(FIELD, values[i], Field.Store.YES, Field.Index.TOKENIZED));
+ writer.AddDocument(doc);
+ }
+ writer.Close();
+ indexSearcher = new IndexSearcher(directory);
+ indexReader = indexSearcher.GetIndexReader();
+ }
+
+ [TearDown]
+ protected internal virtual void TearDown()
+ {
+
+ }
+
+ [Test]
+ public virtual void Test()
+ {
+
+ Term allTerm = new Term(FIELD, "all");
+ TermQuery termQuery = new TermQuery(allTerm);
+
+ Weight weight = termQuery.Weight(indexSearcher);
+
+ Lucene.Net.Search.TermScorer ts = new Lucene.Net.Search.TermScorer(weight, indexReader.TermDocs(allTerm), indexSearcher.GetSimilarity(), indexReader.Norms(FIELD));
+ Assert.IsTrue(ts != null, "ts is null and it shouldn't be");
+ //we have 2 documents with the term all in them, one document for all the other values
+ System.Collections.IList docs = new System.Collections.ArrayList();
+ //must call next first
+
+
+ ts.Score(new AnonymousClassHitCollector(docs, this));
+ Assert.IsTrue(docs.Count == 2, "docs Size: " + docs.Count + " is not: " + 2);
+ TestHit doc0 = (TestHit) docs[0];
+ TestHit doc5 = (TestHit) docs[1];
+ //The scores should be the same
+ Assert.IsTrue(doc0.score == doc5.score, doc0.score + " does not equal: " + doc5.score);
+ /*
+ Score should be (based on Default Sim.:
+ All floats are approximate
+ tf = 1
+ numDocs = 6
+ docFreq(all) = 2
+ idf = ln(6/3) + 1 = 1.693147
+ idf ^ 2 = 2.8667
+ boost = 1
+ lengthNorm = 1 //there is 1 term in every document
+ coord = 1
+ sumOfSquaredWeights = (idf * boost) ^ 2 = 1.693147 ^ 2 = 2.8667
+ queryNorm = 1 / (sumOfSquaredWeights)^0.5 = 1 /(1.693147) = 0.590
+
+ score = 1 * 2.8667 * 1 * 1 * 0.590 = 1.69
+
+ */
+ Assert.IsTrue(doc0.score == 1.6931472f, doc0.score + " does not equal: " + 1.6931472f);
+ }
+
+ [Test]
+ public virtual void TestNext()
+ {
+
+ Term allTerm = new Term(FIELD, "all");
+ TermQuery termQuery = new TermQuery(allTerm);
+
+ Weight weight = termQuery.Weight(indexSearcher);
+
+ TermScorer ts = new TermScorer(weight, indexReader.TermDocs(allTerm), indexSearcher.GetSimilarity(), indexReader.Norms(FIELD));
+ Assert.IsTrue(ts != null, "ts is null and it shouldn't be");
+ Assert.IsTrue(ts.Next() == true, "next did not return a doc");
+ Assert.IsTrue(ts.Score() == 1.6931472f, "score is not correct");
+ Assert.IsTrue(ts.Next() == true, "next did not return a doc");
+ Assert.IsTrue(ts.Score() == 1.6931472f, "score is not correct");
+ Assert.IsTrue(ts.Next() == false, "next returned a doc and it should not have");
+ }
+
+ [Test]
+ public virtual void TestSkipTo()
+ {
+
+ Term allTerm = new Term(FIELD, "all");
+ TermQuery termQuery = new TermQuery(allTerm);
+
+ Weight weight = termQuery.Weight(indexSearcher);
+
+ TermScorer ts = new TermScorer(weight, indexReader.TermDocs(allTerm), indexSearcher.GetSimilarity(), indexReader.Norms(FIELD));
+ Assert.IsTrue(ts != null, "ts is null and it shouldn't be");
+ Assert.IsTrue(ts.SkipTo(3) == true, "Didn't skip");
+ //The next doc should be doc 5
+ Assert.IsTrue(ts.Doc() == 5, "doc should be number 5");
+ }
+
+ [Test]
+ public virtual void TestExplain()
+ {
+ Term allTerm = new Term(FIELD, "all");
+ TermQuery termQuery = new TermQuery(allTerm);
+
+ Weight weight = termQuery.Weight(indexSearcher);
+
+ TermScorer ts = new TermScorer(weight, indexReader.TermDocs(allTerm), indexSearcher.GetSimilarity(), indexReader.Norms(FIELD));
+ Assert.IsTrue(ts != null, "ts is null and it shouldn't be");
+ Explanation explanation = ts.Explain(0);
+ Assert.IsTrue(explanation != null, "explanation is null and it shouldn't be");
+ //System.out.println("Explanation: " + explanation.toString());
+ //All this Explain does is return the term frequency
+ Assert.IsTrue(explanation.GetValue() == 1, "term frq is not 1");
+ explanation = ts.Explain(1);
+ Assert.IsTrue(explanation != null, "explanation is null and it shouldn't be");
+ //System.out.println("Explanation: " + explanation.toString());
+ //All this Explain does is return the term frequency
+ Assert.IsTrue(explanation.GetValue() == 0, "term frq is not 0");
+
+ Term dogsTerm = new Term(FIELD, "dogs");
+ termQuery = new TermQuery(dogsTerm);
+ weight = termQuery.Weight(indexSearcher);
+
+ ts = new TermScorer(weight, indexReader.TermDocs(dogsTerm), indexSearcher.GetSimilarity(), indexReader.Norms(FIELD));
+ Assert.IsTrue(ts != null, "ts is null and it shouldn't be");
+ explanation = ts.Explain(1);
+ Assert.IsTrue(explanation != null, "explanation is null and it shouldn't be");
+ //System.out.println("Explanation: " + explanation.toString());
+ //All this Explain does is return the term frequency
+ //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
+ float sqrtTwo = (float) System.Math.Sqrt(2.0f);
+ Assert.IsTrue(explanation.GetValue() == sqrtTwo, "term frq: " + explanation.GetValue() + " is not the square root of 2");
+
+ explanation = ts.Explain(10); //try a doc out of range
+ Assert.IsTrue(explanation != null, "explanation is null and it shouldn't be");
+ //System.out.println("Explanation: " + explanation.toString());
+ //All this Explain does is return the term frequency
+
+ Assert.IsTrue(explanation.GetValue() == 0, "term frq: " + explanation.GetValue() + " is not 0");
+ }
+
+ private class TestHit
+ {
+ private void InitBlock(TestTermScorer enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private TestTermScorer enclosingInstance;
+ public TestTermScorer Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ public int doc;
+ public float score;
+
+ public TestHit(TestTermScorer enclosingInstance, int doc, float score)
+ {
+ InitBlock(enclosingInstance);
+ this.doc = doc;
+ this.score = score;
+ }
+
+ public override System.String ToString()
+ {
+ return "TestHit{" + "doc=" + doc + ", score=" + score + "}";
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestTermVectors.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestTermVectors.cs?view=diff&rev=564939&r1=564938&r2=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestTermVectors.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestTermVectors.cs Sat Aug 11 09:56:37 2007
@@ -16,7 +16,9 @@
*/
using System;
+
using NUnit.Framework;
+
using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
using Document = Lucene.Net.Documents.Document;
using Field = Lucene.Net.Documents.Field;
Added: incubator/lucene.net/trunk/C#/src/Test/Search/TestThreadSafe.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestThreadSafe.cs?view=auto&rev=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestThreadSafe.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestThreadSafe.cs Sat Aug 11 09:56:37 2007
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using NUnit.Framework;
+
+using Directory = Lucene.Net.Store.Directory;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using IndexReader = Lucene.Net.Index.IndexReader;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+using Lucene.Net.Documents;
+
+namespace Lucene.Net.Search
+{
+
+ /// <author> yonik
+ /// </author>
+ /// <version> $Id: TestThreadSafe.java 472959 2006-11-09 16:21:50Z yonik $
+ /// </version>
+ [TestFixture]
+ public class TestThreadSafe
+ {
+ internal System.Random r = new System.Random();
+ internal Directory dir1;
+ internal Directory dir2;
+
+ internal IndexReader ir1;
+ internal IndexReader ir2;
+
+ internal System.String failure = null;
+
+
+ internal class Thr : SupportClass.ThreadClass
+ {
+ private class AnonymousClassFieldSelector : FieldSelector
+ {
+ public AnonymousClassFieldSelector(Thr enclosingInstance)
+ {
+ InitBlock(enclosingInstance);
+ }
+ private void InitBlock(Thr enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private Thr enclosingInstance;
+ public Thr Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ public virtual FieldSelectorResult Accept(System.String fieldName)
+ {
+ switch (Enclosing_Instance.rand.Next(2))
+ {
+
+ case 0: return FieldSelectorResult.LAZY_LOAD;
+
+ case 1: return FieldSelectorResult.LOAD;
+ // TODO: add other options
+
+ default: return FieldSelectorResult.LOAD;
+
+ }
+ }
+ }
+ private void InitBlock(TestThreadSafe enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private TestThreadSafe enclosingInstance;
+ public TestThreadSafe Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ internal int iter;
+ internal System.Random rand;
+ // pass in random in case we want to make things reproducable
+ public Thr(TestThreadSafe enclosingInstance, int iter, System.Random rand, int level)
+ {
+ InitBlock(enclosingInstance);
+ this.iter = iter;
+ this.rand = rand;
+ }
+
+ override public void Run()
+ {
+ try
+ {
+ for (int i = 0; i < iter; i++)
+ {
+ /*** future
+ // pick a random index reader... a shared one, or create your own
+ IndexReader ir;
+ ***/
+
+ switch (rand.Next(1))
+ {
+
+ case 0: LoadDoc(Enclosing_Instance.ir1); break;
+ }
+ }
+ }
+ catch (System.Exception th)
+ {
+ Enclosing_Instance.failure = th.ToString();
+ TestCase.Fail(Enclosing_Instance.failure);
+ }
+ }
+
+
+ internal virtual void LoadDoc(IndexReader ir)
+ {
+ // beware of deleted docs in the future
+ Document doc = ir.Document(rand.Next(ir.MaxDoc()), new AnonymousClassFieldSelector(this));
+
+ System.Collections.IList fields = doc.GetFields();
+ for (int i = 0; i < fields.Count; i++)
+ {
+ Fieldable f = (Fieldable) fields[i];
+ Enclosing_Instance.ValidateField(f);
+ }
+ }
+ }
+
+
+ internal virtual void ValidateField(Fieldable f)
+ {
+ System.String val = f.StringValue();
+ if (!val.StartsWith("^") || !val.EndsWith("$"))
+ {
+ throw new System.SystemException("Invalid field:" + f.ToString() + " val=" + val);
+ }
+ }
+
+ internal System.String[] words = "now is the time for all good men to come to the aid of their country".Split(' ');
+
+ internal virtual void BuildDir(Directory dir, int nDocs, int maxFields, int maxFieldLen)
+ {
+ IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
+ iw.SetMaxBufferedDocs(10);
+ for (int j = 0; j < nDocs; j++)
+ {
+ Document d = new Document();
+ int nFields = r.Next(maxFields);
+ for (int i = 0; i < nFields; i++)
+ {
+ int flen = r.Next(maxFieldLen);
+ System.Text.StringBuilder sb = new System.Text.StringBuilder("^ ");
+ while (sb.Length < flen)
+ sb.Append(" " + words[r.Next(words.Length)]);
+ sb.Append(" $");
+ Field.Store store = Field.Store.YES; // make random later
+ Field.Index index = Field.Index.TOKENIZED; // make random later
+ d.Add(new Field("f" + i, sb.ToString(), store, index));
+ }
+ iw.AddDocument(d);
+ }
+ iw.Close();
+ }
+
+
+ internal virtual void DoTest(int iter, int nThreads)
+ {
+ Thr[] tarr = new Thr[nThreads];
+ for (int i = 0; i < nThreads; i++)
+ {
+ tarr[i] = new Thr(this, iter, new System.Random(), 1);
+ tarr[i].Start();
+ }
+ for (int i = 0; i < nThreads; i++)
+ {
+ tarr[i].Join();
+ }
+ if (failure != null)
+ {
+ TestCase.Fail(failure);
+ }
+ }
+
+ [Test]
+ public virtual void TestLazyLoadThreadSafety()
+ {
+ dir1 = new RAMDirectory();
+ // test w/ field sizes bigger than the buffer of an index input
+ BuildDir(dir1, 15, 5, 2000);
+
+ // do many small tests so the thread locals go away inbetween
+ for (int i = 0; i < 100; i++)
+ {
+ ir1 = IndexReader.Open(dir1);
+ DoTest(10, 100);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestWildcard.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestWildcard.cs?view=diff&rev=564939&r1=564938&r2=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestWildcard.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestWildcard.cs Sat Aug 11 09:56:37 2007
@@ -16,7 +16,9 @@
*/
using System;
+
using NUnit.Framework;
+
using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
using Document = Lucene.Net.Documents.Document;
using Field = Lucene.Net.Documents.Field;
@@ -59,7 +61,23 @@
Assert.IsFalse(fq.Equals(wq1));
}
- /// <summary> Tests Wildcard queries with an asterisk.</summary>
+ /// <summary> Tests if a WildcardQuery that has no wildcard in the term is rewritten to a single
+ /// TermQuery.
+ /// </summary>
+ [Test]
+ public virtual void TestTermWithoutWildcard()
+ {
+ RAMDirectory indexStore = GetIndexStore("field", new System.String[]{"nowildcard", "nowildcardx"});
+ IndexSearcher searcher = new IndexSearcher(indexStore);
+
+ Query wq = new WildcardQuery(new Term("field", "nowildcard"));
+ AssertMatches(searcher, wq, 1);
+
+ wq = searcher.Rewrite(wq);
+ Assert.IsTrue(wq is TermQuery);
+ }
+
+ /// <summary> Tests Wildcard queries with an asterisk.</summary>
[Test]
public virtual void TestAsterisk()
{
Modified: incubator/lucene.net/trunk/C#/src/Test/SearchTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/SearchTest.cs?view=diff&rev=564939&r1=564938&r2=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/SearchTest.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/SearchTest.cs Sat Aug 11 09:56:37 2007
@@ -16,13 +16,14 @@
*/
using System;
-using Lucene.Net.Analysis;
+
+using Lucene.Net.Store;
using Lucene.Net.Documents;
+using Lucene.Net.Analysis;
using Lucene.Net.Index;
-using Lucene.Net.QueryParsers;
using Lucene.Net.Search;
using Searchable = Lucene.Net.Search.Searchable;
-using Lucene.Net.Store;
+using Lucene.Net.QueryParsers;
namespace Lucene.Net
{
Modified: incubator/lucene.net/trunk/C#/src/Test/SearchTestForDuplicates.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/SearchTestForDuplicates.cs?view=diff&rev=564939&r1=564938&r2=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/SearchTestForDuplicates.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/SearchTestForDuplicates.cs Sat Aug 11 09:56:37 2007
@@ -16,13 +16,14 @@
*/
using System;
-using Lucene.Net.Analysis;
+
+using Lucene.Net.Store;
using Lucene.Net.Documents;
+using Lucene.Net.Analysis;
using Lucene.Net.Index;
-using Lucene.Net.QueryParsers;
using Lucene.Net.Search;
using Searchable = Lucene.Net.Search.Searchable;
-using Lucene.Net.Store;
+using Lucene.Net.QueryParsers;
namespace Lucene.Net
{
Added: incubator/lucene.net/trunk/C#/src/Test/Store/MockRAMDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Store/MockRAMDirectory.cs?view=auto&rev=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/MockRAMDirectory.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/MockRAMDirectory.cs Sat Aug 11 09:56:37 2007
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Store
+{
+
+ /// <summary> This is a subclass of RAMDirectory that adds methods
+ /// intented to be used only by unit tests.
+ /// </summary>
+ /// <version> $Id: RAMDirectory.java 437897 2006-08-29 01:13:10Z yonik $
+ /// </version>
+
+ [Serializable]
+ public class MockRAMDirectory : RAMDirectory
+ {
+ internal long maxSize;
+
+ // Max actual bytes used. This is set by MockRAMOutputStream:
+ internal long maxUsedSize;
+ internal double randomIOExceptionRate;
+ internal System.Random randomState;
+
+ public MockRAMDirectory() : base()
+ {
+ }
+ public MockRAMDirectory(System.String dir) : base(dir)
+ {
+ }
+ public MockRAMDirectory(Directory dir) : base(dir)
+ {
+ }
+ public MockRAMDirectory(System.IO.FileInfo dir) : base(dir)
+ {
+ }
+
+ virtual public long GetMaxSizeInBytes()
+ {
+ return this.maxSize;
+ }
+
+ virtual public void SetMaxSizeInBytes(long maxSize)
+ {
+ this.maxSize = maxSize;
+ }
+
+ /// <summary> Returns the peek actual storage used (bytes) in this
+ /// directory.
+ /// </summary>
+ virtual public long GetMaxUsedSizeInBytes()
+ {
+ return this.maxUsedSize;
+ }
+
+ public virtual void ResetMaxUsedSizeInBytes()
+ {
+ this.maxUsedSize = GetRecomputedActualSizeInBytes();
+ }
+
+ /// <summary> If 0.0, no exceptions will be thrown. Else this should
+ /// be a double 0.0 - 1.0. We will randomly throw an
+ /// IOException on the first write to an OutputStream based
+ /// on this probability.
+ /// </summary>
+ public virtual void SetRandomIOExceptionRate(double rate, long seed)
+ {
+ randomIOExceptionRate = rate;
+ // seed so we have deterministic behaviour:
+ randomState = new System.Random((System.Int32) seed);
+ }
+
+ public virtual double GetRandomIOExceptionRate()
+ {
+ return randomIOExceptionRate;
+ }
+
+ internal virtual void MaybeThrowIOException()
+ {
+ if (randomIOExceptionRate > 0.0)
+ {
+ int number = System.Math.Abs(randomState.Next() % 1000);
+ if (number < randomIOExceptionRate * 1000)
+ {
+ throw new System.IO.IOException("a random IOException");
+ }
+ }
+ }
+
+ public override IndexOutput CreateOutput(System.String name)
+ {
+ RAMFile file = new RAMFile(this);
+ lock (this)
+ {
+ RAMFile existing = (RAMFile) fileMap_ForNUnitTest[name];
+ if (existing != null)
+ {
+ sizeInBytes_ForNUnitTest -= existing.sizeInBytes_ForNUnitTest;
+ existing.directory_ForNUnitTest = null;
+ }
+ fileMap_ForNUnitTest[name] = file;
+ }
+
+ return new MockRAMOutputStream(this, file);
+ }
+
+ /// <summary>Provided for testing purposes. Use sizeInBytes() instead. </summary>
+ virtual internal long GetRecomputedSizeInBytes()
+ {
+ lock (this)
+ {
+ long size = 0;
+ System.Collections.IEnumerator it = fileMap_ForNUnitTest.Values.GetEnumerator();
+ while (it.MoveNext())
+ {
+ size += ((RAMFile) it.Current).GetSizeInBytes_ForNUnitTest();
+ }
+ return size;
+ }
+ }
+
+ /// <summary>Like getRecomputedSizeInBytes(), but, uses actual file
+ /// lengths rather than buffer allocations (which are
+ /// quantized up to nearest
+ /// BufferedIndexOutput.BUFFER_SIZE (now 1024) bytes.
+ /// </summary>
+ virtual internal long GetRecomputedActualSizeInBytes()
+ {
+ long size = 0;
+ System.Collections.IEnumerator it = fileMap_ForNUnitTest.Values.GetEnumerator();
+ while (it.MoveNext())
+ {
+ size += ((RAMFile) it.Current).length_ForNUnitTest;
+ }
+ return size;
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/trunk/C#/src/Test/Store/MockRAMOutputStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Store/MockRAMOutputStream.cs?view=auto&rev=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/MockRAMOutputStream.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/MockRAMOutputStream.cs Sat Aug 11 09:56:37 2007
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Store
+{
+
+ /// <summary> Used by MockRAMDirectory to create an output stream that
+ /// will throw an IOException on fake disk full, track max
+ /// disk space actually used, and maybe throw random
+ /// IOExceptions.
+ /// </summary>
+
+ public class MockRAMOutputStream : RAMOutputStream
+ {
+ private MockRAMDirectory dir;
+ private bool first = true;
+
+ /// <summary>Construct an empty output buffer. </summary>
+ public MockRAMOutputStream(MockRAMDirectory dir, RAMFile f) : base(f)
+ {
+ this.dir = dir;
+ }
+
+ public virtual void Close()
+ {
+ base.Close();
+
+ // Now compute actual disk usage & track the maxUsedSize
+ // in the MockRAMDirectory:
+ long size = dir.GetRecomputedActualSizeInBytes();
+ if (size > dir.maxUsedSize)
+ {
+ dir.maxUsedSize = size;
+ }
+ }
+
+ public override void FlushBuffer(byte[] src, int len)
+ {
+ long freeSpace = dir.maxSize - dir.SizeInBytes();
+ long realUsage = 0;
+
+ // Enforce disk full:
+ if (dir.maxSize != 0 && freeSpace <= len)
+ {
+ // Compute the real disk free. This will greatly slow
+ // down our test but makes it more accurate:
+ realUsage = dir.GetRecomputedActualSizeInBytes();
+ freeSpace = dir.maxSize - realUsage;
+ }
+
+ if (dir.maxSize != 0 && freeSpace <= len)
+ {
+ if (freeSpace > 0 && freeSpace < len)
+ {
+ realUsage += freeSpace;
+ base.FlushBuffer(src, (int) freeSpace);
+ }
+ if (realUsage > dir.maxUsedSize)
+ {
+ dir.maxUsedSize = realUsage;
+ }
+ throw new System.IO.IOException("fake disk full at " + dir.SizeInBytes() + " bytes");
+ }
+ else
+ {
+ base.FlushBuffer(src, len);
+ }
+
+ if (first)
+ {
+ // Maybe throw random exception; only do this on first
+ // write to a new file:
+ first = false;
+ dir.MaybeThrowIOException();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/trunk/C#/src/Test/Store/TestBufferedIndexInput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Store/TestBufferedIndexInput.cs?view=auto&rev=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/TestBufferedIndexInput.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/TestBufferedIndexInput.cs Sat Aug 11 09:56:37 2007
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using NUnit.Framework;
+
+namespace Lucene.Net.Store
+{
+ [TestFixture]
+ public class TestBufferedIndexInput
+ {
+ // Call readByte() repeatedly, past the buffer boundary, and see that it
+ // is working as expected.
+ // Our input comes from a dynamically generated/ "file" - see
+ // MyBufferedIndexInput below.
+ [Test]
+ public virtual void TestReadByte()
+ {
+ MyBufferedIndexInput input = new MyBufferedIndexInput();
+ for (int i = 0; i < BufferedIndexInput.BUFFER_SIZE_ForNUnitTest * 10; i++)
+ {
+ Assert.AreEqual(input.ReadByte(), Byten(i));
+ }
+ }
+
+ // Call readBytes() repeatedly, with various chunk sizes (from 1 byte to
+ // larger than the buffer size), and see that it returns the bytes we expect.
+ // Our input comes from a dynamically generated "file" -
+ // see MyBufferedIndexInput below.
+ [Test]
+ public virtual void TestReadBytes()
+ {
+ MyBufferedIndexInput input = new MyBufferedIndexInput();
+ int pos = 0;
+ // gradually increasing size:
+ for (int size = 1; size < BufferedIndexInput.BUFFER_SIZE_ForNUnitTest * 10; size = size + size / 200 + 1)
+ {
+ CheckReadBytes(input, size, pos);
+ pos += size;
+ }
+ // wildly fluctuating size:
+ for (long i = 0; i < 1000; i++)
+ {
+ // The following function generates a fluctuating (but repeatable)
+ // size, sometimes small (<100) but sometimes large (>10000)
+ int size1 = (int) (i % 7 + 7 * (i % 5) + 7 * 5 * (i % 3) + 5 * 5 * 3 * (i % 2));
+ int size2 = (int) (i % 11 + 11 * (i % 7) + 11 * 7 * (i % 5) + 11 * 7 * 5 * (i % 3) + 11 * 7 * 5 * 3 * (i % 2));
+ int size = (i % 3 == 0)?size2 * 10:size1;
+ CheckReadBytes(input, size, pos);
+ pos += size;
+ }
+ // constant small size (7 bytes):
+ for (int i = 0; i < BufferedIndexInput.BUFFER_SIZE_ForNUnitTest; i++)
+ {
+ CheckReadBytes(input, 7, pos);
+ pos += 7;
+ }
+ }
+ private void CheckReadBytes(BufferedIndexInput input, int size, int pos)
+ {
+ // Just to see that "offset" is treated properly in readBytes(), we
+ // add an arbitrary offset at the beginning of the array
+ int offset = size % 10; // arbitrary
+ byte[] b = new byte[offset + size];
+ input.ReadBytes(b, offset, size);
+ for (int i = 0; i < size; i++)
+ {
+ Assert.AreEqual(b[offset + i], Byten(pos + i));
+ }
+ }
+
+ // This tests that attempts to readBytes() past an EOF will fail, while
+ // reads up to the EOF will succeed. The EOF is determined by the
+ // BufferedIndexInput's arbitrary length() value.
+ [Test]
+ public virtual void TestEOF()
+ {
+ MyBufferedIndexInput input = new MyBufferedIndexInput(1024);
+ // see that we can read all the bytes at one go:
+ CheckReadBytes(input, (int) input.Length(), 0);
+ // go back and see that we can't read more than that, for small and
+ // large overflows:
+ int pos = (int) input.Length() - 10;
+ input.Seek(pos);
+ CheckReadBytes(input, 10, pos);
+ input.Seek(pos);
+ try
+ {
+ CheckReadBytes(input, 11, pos);
+ Assert.Fail("Block read past end of file");
+ }
+ catch (System.IO.IOException e)
+ {
+ /* success */
+ }
+ input.Seek(pos);
+ try
+ {
+ CheckReadBytes(input, 50, pos);
+ Assert.Fail("Block read past end of file");
+ }
+ catch (System.IO.IOException e)
+ {
+ /* success */
+ }
+ input.Seek(pos);
+ try
+ {
+ CheckReadBytes(input, 100000, pos);
+ Assert.Fail("Block read past end of file");
+ }
+ catch (System.IO.IOException e)
+ {
+ /* success */
+ }
+ }
+
+ // byten emulates a file - Byten(n) returns the n'th byte in that file.
+ // MyBufferedIndexInput reads this "file".
+ private static byte Byten(long n)
+ {
+ return (byte) (n * n % 256);
+ }
+
+ private class MyBufferedIndexInput : BufferedIndexInput
+ {
+ private long pos;
+ private long len;
+ public MyBufferedIndexInput(long len)
+ {
+ this.len = len;
+ this.pos = 0;
+ }
+ public MyBufferedIndexInput() : this(System.Int64.MaxValue)
+ {
+ }
+
+ public override void ReadInternal(byte[] b, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ b[i] = Lucene.Net.Store.TestBufferedIndexInput.Byten(pos++);
+ }
+
+ public override void SeekInternal(long pos)
+ {
+ this.pos = pos;
+ }
+
+ public override void Close()
+ {
+ }
+
+ public override long Length()
+ {
+ return len;
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: 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?view=diff&rev=564939&r1=564938&r2=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/TestLock.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/TestLock.cs Sat Aug 11 09:56:37 2007
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
/* ====================================================================
* The Apache Software License, Version 1.1
*
@@ -53,6 +70,7 @@
*/
using System;
+
using NUnit.Framework;
namespace Lucene.Net.store
Added: incubator/lucene.net/trunk/C#/src/Test/Store/TestLockFactory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Store/TestLockFactory.cs?view=auto&rev=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/TestLockFactory.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/TestLockFactory.cs Sat Aug 11 09:56:37 2007
@@ -0,0 +1,717 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using NUnit.Framework;
+
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using IndexReader = Lucene.Net.Index.IndexReader;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using IndexSearcher = Lucene.Net.Search.IndexSearcher;
+using Query = Lucene.Net.Search.Query;
+using Term = Lucene.Net.Index.Term;
+using TermQuery = Lucene.Net.Search.TermQuery;
+using Hits = Lucene.Net.Search.Hits;
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+
+namespace Lucene.Net.Store
+{
+
+ [TestFixture]
+ public class TestLockFactory
+ {
+
+ // Verify: we can provide our own LockFactory implementation, the right
+ // methods are called at the right time, locks are created, etc.
+ [Test]
+ public virtual void TestCustomLockFactory()
+ {
+ Directory dir = new RAMDirectory();
+ MockLockFactory lf = new MockLockFactory(this);
+ dir.SetLockFactory(lf);
+
+ // Lock prefix should have been set:
+ Assert.IsTrue(lf.lockPrefixSet, "lock prefix was not set by the RAMDirectory");
+
+ IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
+
+ // add 100 documents (so that commit lock is used)
+ for (int i = 0; i < 100; i++)
+ {
+ AddDoc(writer);
+ }
+
+ // Both write lock and commit lock should have been created:
+ Assert.AreEqual(1, lf.locksCreated.Count, "# of unique locks created (after instantiating IndexWriter)");
+ Assert.IsTrue(lf.makeLockCount >= 1, "# calls to makeLock is 0 (after instantiating IndexWriter)");
+
+ for (System.Collections.IEnumerator e = lf.locksCreated.Keys.GetEnumerator(); e.MoveNext(); )
+ {
+ System.String lockName = (System.String) e.Current;
+ MockLockFactory.MockLock lock_Renamed = (MockLockFactory.MockLock) lf.locksCreated[lockName];
+ Assert.IsTrue(lock_Renamed.lockAttempts > 0, "# calls to Lock.obtain is 0 (after instantiating IndexWriter)");
+ }
+
+ writer.Close();
+ }
+
+ // Verify: we can use the NoLockFactory with RAMDirectory w/ no
+ // exceptions raised:
+ // Verify: NoLockFactory allows two IndexWriters
+ [Test]
+ public virtual void TestRAMDirectoryNoLocking()
+ {
+ Directory dir = new RAMDirectory();
+ dir.SetLockFactory(NoLockFactory.GetNoLockFactory());
+
+ Assert.IsTrue(typeof(NoLockFactory).IsInstanceOfType(dir.GetLockFactory()), "RAMDirectory.setLockFactory did not take");
+
+ IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
+
+ // Create a 2nd IndexWriter. This is normally not allowed but it should run through since we're not
+ // using any locks:
+ IndexWriter writer2 = null;
+ try
+ {
+ writer2 = new IndexWriter(dir, new WhitespaceAnalyzer(), false);
+ }
+ catch (System.Exception e)
+ {
+ System.Console.Out.WriteLine(e.StackTrace);
+ Assert.Fail("Should not have hit an IOException with no locking");
+ }
+
+ writer.Close();
+ if (writer2 != null)
+ {
+ writer2.Close();
+ }
+ }
+
+ // Verify: SingleInstanceLockFactory is the default lock for RAMDirectory
+ // Verify: RAMDirectory does basic locking correctly (can't create two IndexWriters)
+ [Test]
+ public virtual void TestDefaultRAMDirectory()
+ {
+ Directory dir = new RAMDirectory();
+
+ Assert.IsTrue(typeof(SingleInstanceLockFactory).IsInstanceOfType(dir.GetLockFactory()), "RAMDirectory did not use correct LockFactory: got " + dir.GetLockFactory());
+
+ IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
+
+ // Create a 2nd IndexWriter. This should fail:
+ IndexWriter writer2 = null;
+ try
+ {
+ writer2 = new IndexWriter(dir, new WhitespaceAnalyzer(), false);
+ Assert.Fail("Should have hit an IOException with two IndexWriters on default SingleInstanceLockFactory");
+ }
+ catch (System.IO.IOException e)
+ {
+ }
+
+ writer.Close();
+ if (writer2 != null)
+ {
+ writer2.Close();
+ }
+ }
+
+ // Verify: SimpleFSLockFactory is the default for FSDirectory
+ // Verify: FSDirectory does basic locking correctly
+ [Test]
+ public virtual void TestDefaultFSDirectory()
+ {
+ System.String indexDirName = "index.TestLockFactory1";
+
+ IndexWriter writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true);
+
+ Assert.IsTrue(typeof(SimpleFSLockFactory).IsInstanceOfType(writer.GetDirectory().GetLockFactory()) || typeof(NativeFSLockFactory).IsInstanceOfType(writer.GetDirectory().GetLockFactory()), "FSDirectory did not use correct LockFactory: got " + writer.GetDirectory().GetLockFactory());
+
+ IndexWriter writer2 = null;
+
+ // Create a 2nd IndexWriter. This should fail:
+ try
+ {
+ writer2 = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), false);
+ Assert.Fail("Should have hit an IOException with two IndexWriters on default SimpleFSLockFactory");
+ }
+ catch (System.IO.IOException e)
+ {
+ }
+
+ writer.Close();
+ if (writer2 != null)
+ {
+ writer2.Close();
+ }
+
+ // Cleanup
+ RmDir(indexDirName);
+ }
+
+ // Verify: FSDirectory's default lockFactory clears all locks correctly
+ [Test]
+ public virtual void TestFSDirectoryTwoCreates()
+ {
+ System.String indexDirName = "index.TestLockFactory2";
+
+ IndexWriter writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true);
+
+ Assert.IsTrue(typeof(SimpleFSLockFactory).IsInstanceOfType(writer.GetDirectory().GetLockFactory()) || typeof(NativeFSLockFactory).IsInstanceOfType(writer.GetDirectory().GetLockFactory()), "FSDirectory did not use correct LockFactory: got " + writer.GetDirectory().GetLockFactory());
+
+ // Intentionally do not close the first writer here.
+ // The goal is to "simulate" a crashed writer and
+ // ensure the second writer, with create=true, is
+ // able to remove the lock files. This works OK
+ // with SimpleFSLockFactory as the locking
+ // implementation. Note, however, that this test
+ // will not work on WIN32 when we switch to
+ // NativeFSLockFactory as the default locking for
+ // FSDirectory because the second IndexWriter cannot
+ // remove those lock files since they are held open
+ // by the first writer. This is because leaving the
+ // first IndexWriter open is not really a good way
+ // to simulate a crashed writer.
+
+ // Create a 2nd IndexWriter. This should not fail:
+ IndexWriter writer2 = null;
+ try
+ {
+ writer2 = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true);
+ }
+ catch (System.IO.IOException e)
+ {
+ System.Console.Error.WriteLine(e.StackTrace);
+ Assert.Fail("Should not have hit an IOException with two IndexWriters with create=true, on default SimpleFSLockFactory");
+ }
+
+ writer.Close();
+ if (writer2 != null)
+ {
+ writer2.Close();
+ }
+
+ // Cleanup
+ RmDir(indexDirName);
+ }
+
+
+ // Verify: setting custom lock factory class (as system property) works:
+ // Verify: FSDirectory does basic locking correctly
+ [Test]
+ public virtual void TestLockClassProperty()
+ {
+ Assert.Fail("TestLockClassProperty() needs conversion to C#");
+
+ /*
+ System.String indexDirName = "index.TestLockFactory3";
+
+ System_Renamed.setProperty("Lucene.Net.Store.FSDirectoryLockFactoryClass", "Lucene.Net.Store.NoLockFactory");
+
+ IndexWriter writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true);
+
+ Assert.IsTrue(typeof(NoLockFactory).IsInstanceOfType(writer.GetDirectory().GetLockFactory()), "FSDirectory did not use correct LockFactory: got " + writer.GetDirectory().GetLockFactory());
+
+ // Put back to the correct default for subsequent tests:
+ // System.clearProperty("Lucene.Net.Store.FSDirectoryLockFactoryClass");
+ System_Renamed.setProperty("Lucene.Net.Store.FSDirectoryLockFactoryClass", "");
+
+ writer.Close();
+ // Cleanup
+ RmDir(indexDirName);
+ */
+ }
+
+ // Verify: setDisableLocks works
+ [Test]
+ public virtual void TestDisableLocks()
+ {
+ System.String indexDirName = "index.TestLockFactory4";
+
+ Assert.IsTrue(!FSDirectory.GetDisableLocks(), "Locks are already disabled");
+ FSDirectory.SetDisableLocks(true);
+
+ IndexWriter writer = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), true);
+
+ Assert.IsTrue(typeof(NoLockFactory).IsInstanceOfType(writer.GetDirectory().GetLockFactory()), "FSDirectory did not use correct default LockFactory: got " + writer.GetDirectory().GetLockFactory());
+
+ // Should be no error since locking is disabled:
+ IndexWriter writer2 = null;
+ try
+ {
+ writer2 = new IndexWriter(indexDirName, new WhitespaceAnalyzer(), false);
+ }
+ catch (System.IO.IOException e)
+ {
+ System.Console.Error.WriteLine(e.StackTrace);
+ Assert.Fail("Should not have hit an IOException with locking disabled");
+ }
+
+ FSDirectory.SetDisableLocks(false);
+ writer.Close();
+ if (writer2 != null)
+ {
+ writer2.Close();
+ }
+ // Cleanup
+ RmDir(indexDirName);
+ }
+
+ // Verify: if I try to getDirectory() with two different locking implementations, I get an IOException
+ [Test]
+ public virtual void TestFSDirectoryDifferentLockFactory()
+ {
+ System.String indexDirName = "index.TestLockFactory5";
+
+ LockFactory lf = new SingleInstanceLockFactory();
+ FSDirectory fs1 = FSDirectory.GetDirectory(indexDirName, lf);
+
+ // Different lock factory instance should hit IOException:
+ try
+ {
+ FSDirectory fs2 = FSDirectory.GetDirectory(indexDirName, new SingleInstanceLockFactory());
+ Assert.Fail("Should have hit an IOException because LockFactory instances differ");
+ }
+ catch (System.IO.IOException e)
+ {
+ }
+
+ FSDirectory fs3 = null;
+
+ // Same lock factory instance should not:
+ try
+ {
+ fs3 = FSDirectory.GetDirectory(indexDirName, lf);
+ }
+ catch (System.IO.IOException e)
+ {
+ System.Console.Error.WriteLine(e.StackTrace);
+ Assert.Fail("Should not have hit an IOException because LockFactory instances are the same");
+ }
+
+ fs1.Close();
+ if (fs3 != null)
+ {
+ fs3.Close();
+ }
+ // Cleanup
+ RmDir(indexDirName);
+ }
+
+ // Verify: do stress test, by opening IndexReaders and
+ // IndexWriters over & over in 2 threads and making sure
+ // no unexpected exceptions are raised:
+ [Test]
+ public virtual void TestStressLocks()
+ {
+ _TestStressLocks(null, "index.TestLockFactory6");
+ }
+
+ // Verify: do stress test, by opening IndexReaders and
+ // IndexWriters over & over in 2 threads and making sure
+ // no unexpected exceptions are raised, but use
+ // NativeFSLockFactory:
+ public virtual void testStressLocksNativeFSLockFactory()
+ {
+ _TestStressLocks(new NativeFSLockFactory("index.TestLockFactory7"), "index.TestLockFactory7");
+ }
+
+ public virtual void _TestStressLocks(LockFactory lockFactory, System.String indexDirName)
+ {
+ FSDirectory fs1 = FSDirectory.GetDirectory(indexDirName, lockFactory);
+
+ // First create a 1 doc index:
+ IndexWriter w = new IndexWriter(fs1, new WhitespaceAnalyzer(), true);
+ AddDoc(w);
+ w.Close();
+
+ WriterThread writer = new WriterThread(this, 100, fs1);
+ SearcherThread searcher = new SearcherThread(this, 100, fs1);
+ writer.Start();
+ searcher.Start();
+
+ while (writer.IsAlive || searcher.IsAlive)
+ {
+ try
+ {
+ System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 1000));
+ }
+ catch (System.Threading.ThreadInterruptedException e)
+ {
+ }
+ }
+
+ Assert.IsTrue(!writer.hitException, "IndexWriter hit unexpected exceptions");
+ Assert.IsTrue(!searcher.hitException, "IndexSearcher hit unexpected exceptions");
+
+ // Cleanup
+ RmDir(indexDirName);
+ }
+
+ // Verify: NativeFSLockFactory works correctly
+ [Test]
+ public virtual void TestNativeFSLockFactory()
+ {
+ Assert.Fail("TestLockClassProperty() needs conversion to C#");
+
+ NativeFSLockFactory f = new NativeFSLockFactory(SupportClass.AppSettings.Get("tempDir", ""));
+
+ //UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
+ NativeFSLockFactory f2 = new NativeFSLockFactory(SupportClass.AppSettings.Get("tempDir", ""));
+
+ f.SetLockPrefix("test");
+ Lock l = f.MakeLock("commit");
+ Lock l2 = f.MakeLock("commit");
+
+ Assert.IsTrue(l.Obtain(), "failed to obtain lock");
+ Assert.IsTrue(!l2.Obtain(), "succeeded in obtaining lock twice");
+ l.Release();
+
+ Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed");
+ l2.Release();
+
+ // Make sure we can obtain first one again:
+ Assert.IsTrue(l.Obtain(), "failed to obtain lock");
+ l.Release();
+ }
+
+ // Verify: NativeFSLockFactory assigns different lock
+ // prefixes to different directories:
+ [Test]
+ public virtual void TestNativeFSLockFactoryPrefix()
+ {
+
+ // Make sure we get identical instances:
+ Directory dir1 = FSDirectory.GetDirectory("TestLockFactory.8", new NativeFSLockFactory("TestLockFactory.8"));
+ Directory dir2 = FSDirectory.GetDirectory("TestLockFactory.9", new NativeFSLockFactory("TestLockFactory.9"));
+
+ System.String prefix1 = dir1.GetLockFactory().GetLockPrefix();
+ System.String prefix2 = dir2.GetLockFactory().GetLockPrefix();
+
+ Assert.IsTrue(!prefix1.Equals(prefix2), "Native Lock Factories are incorrectly shared: dir1 and dir2 have same lock prefix '" + prefix1 + "'; they should be different");
+ RmDir("TestLockFactory.8");
+ RmDir("TestLockFactory.9");
+ }
+
+ // Verify: default LockFactory has no prefix (ie
+ // write.lock is stored in index):
+ [Test]
+ public virtual void TestDefaultFSLockFactoryPrefix()
+ {
+
+ // Make sure we get null prefix:
+ Directory dir = FSDirectory.GetDirectory("TestLockFactory.10");
+
+ System.String prefix = dir.GetLockFactory().GetLockPrefix();
+
+ Assert.IsTrue(null == prefix, "Default lock prefix should be null");
+
+ RmDir("TestLockFactory.10");
+ }
+
+ private class WriterThread : SupportClass.ThreadClass
+ {
+ private void InitBlock(TestLockFactory enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private TestLockFactory enclosingInstance;
+ public TestLockFactory Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ private Directory dir;
+ private int numIteration;
+ public bool hitException = false;
+ public WriterThread(TestLockFactory enclosingInstance, int numIteration, Directory dir)
+ {
+ InitBlock(enclosingInstance);
+ this.numIteration = numIteration;
+ this.dir = dir;
+ }
+ override public void Run()
+ {
+ WhitespaceAnalyzer analyzer = new WhitespaceAnalyzer();
+ IndexWriter writer = null;
+ for (int i = 0; i < this.numIteration; i++)
+ {
+ try
+ {
+ writer = new IndexWriter(dir, analyzer, false);
+ }
+ catch (System.IO.IOException e)
+ {
+ if (e.ToString().IndexOf(" timed out:") == - 1)
+ {
+ hitException = true;
+ }
+ else
+ {
+ // lock obtain timed out
+ // NOTE: we should at some point
+ // consider this a failure? The lock
+ // obtains, across IndexReader &
+ // IndexWriters should be "fair" (ie
+ // FIFO).
+ }
+ }
+ catch (System.Exception e)
+ {
+ hitException = true;
+ System.Console.Out.WriteLine("Stress Test Index Writer: creation hit unexpected exception: " + e.ToString());
+ System.Console.Error.WriteLine(e.StackTrace);
+ break;
+ }
+ if (writer != null)
+ {
+ try
+ {
+ Enclosing_Instance.AddDoc(writer);
+ }
+ catch (System.IO.IOException e)
+ {
+ hitException = true;
+ System.Console.Out.WriteLine("Stress Test Index Writer: AddDoc hit unexpected exception: " + e.ToString());
+ System.Console.Error.WriteLine(e.StackTrace);
+ break;
+ }
+ try
+ {
+ writer.Close();
+ }
+ catch (System.IO.IOException e)
+ {
+ hitException = true;
+ System.Console.Out.WriteLine("Stress Test Index Writer: close hit unexpected exception: " + e.ToString());
+ System.Console.Error.WriteLine(e.StackTrace);
+ break;
+ }
+ writer = null;
+ }
+ }
+ }
+ }
+
+ private class SearcherThread : SupportClass.ThreadClass
+ {
+ private void InitBlock(TestLockFactory enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private TestLockFactory enclosingInstance;
+ public TestLockFactory Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ private Directory dir;
+ private int numIteration;
+ public bool hitException = false;
+ public SearcherThread(TestLockFactory enclosingInstance, int numIteration, Directory dir)
+ {
+ InitBlock(enclosingInstance);
+ this.numIteration = numIteration;
+ this.dir = dir;
+ }
+ override public void Run()
+ {
+ IndexSearcher searcher = null;
+ WhitespaceAnalyzer analyzer = new WhitespaceAnalyzer();
+ Query query = new TermQuery(new Term("content", "aaa"));
+ for (int i = 0; i < this.numIteration; i++)
+ {
+ try
+ {
+ searcher = new IndexSearcher(dir);
+ }
+ catch (System.Exception e)
+ {
+ hitException = true;
+ System.Console.Out.WriteLine("Stress Test Index Searcher: create hit unexpected exception: " + e.ToString());
+ System.Console.Error.WriteLine(e.StackTrace);
+ break;
+ }
+ if (searcher != null)
+ {
+ Hits hits = null;
+ try
+ {
+ hits = searcher.Search(query);
+ }
+ catch (System.IO.IOException e)
+ {
+ hitException = true;
+ System.Console.Out.WriteLine("Stress Test Index Searcher: search hit unexpected exception: " + e.ToString());
+ System.Console.Error.WriteLine(e.StackTrace);
+ break;
+ }
+ // System.out.println(hits.length() + " total results");
+ try
+ {
+ searcher.Close();
+ }
+ catch (System.IO.IOException e)
+ {
+ hitException = true;
+ System.Console.Out.WriteLine("Stress Test Index Searcher: close hit unexpected exception: " + e.ToString());
+ System.Console.Out.WriteLine(e.StackTrace);
+ break;
+ }
+ searcher = null;
+ }
+ }
+ }
+ }
+
+ public class MockLockFactory : LockFactory
+ {
+ public MockLockFactory(TestLockFactory enclosingInstance)
+ {
+ InitBlock(enclosingInstance);
+ }
+ private void InitBlock(TestLockFactory enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private TestLockFactory enclosingInstance;
+ public TestLockFactory Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+
+ public bool lockPrefixSet;
+ public System.Collections.Hashtable locksCreated = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
+ public int makeLockCount = 0;
+
+ public override void SetLockPrefix(System.String lockPrefix)
+ {
+ base.SetLockPrefix(lockPrefix);
+ lockPrefixSet = true;
+ }
+
+ public override Lock MakeLock(System.String lockName)
+ {
+ lock (this)
+ {
+ Lock lock_Renamed = new MockLock(this);
+ locksCreated[lockName] = lock_Renamed;
+ makeLockCount++;
+ return lock_Renamed;
+ }
+ }
+
+ public override void ClearLock(System.String specificLockName)
+ {
+ }
+
+ public class MockLock : Lock
+ {
+ public MockLock(MockLockFactory enclosingInstance)
+ {
+ InitBlock(enclosingInstance);
+ }
+ private void InitBlock(MockLockFactory enclosingInstance)
+ {
+ this.enclosingInstance = enclosingInstance;
+ }
+ private MockLockFactory enclosingInstance;
+ public MockLockFactory Enclosing_Instance
+ {
+ get
+ {
+ return enclosingInstance;
+ }
+
+ }
+ public int lockAttempts;
+
+ public override bool Obtain()
+ {
+ lockAttempts++;
+ return true;
+ }
+ public override void Release()
+ {
+ // do nothing
+ }
+ public override bool IsLocked()
+ {
+ return false;
+ }
+ }
+ }
+
+ private void AddDoc(IndexWriter writer)
+ {
+ Document doc = new Document();
+ doc.Add(new Field("content", "aaa", Field.Store.NO, Field.Index.TOKENIZED));
+ writer.AddDocument(doc);
+ }
+
+ private void RmDir(System.String dirName)
+ {
+ System.IO.FileInfo dir = new System.IO.FileInfo(dirName);
+ System.String[] files = System.IO.Directory.GetFileSystemEntries(dir.FullName); // clear old files
+ for (int i = 0; i < files.Length; i++)
+ {
+ System.IO.FileInfo file = new System.IO.FileInfo(dir.FullName + "\\" + files[i]);
+ bool tmpBool;
+ if (System.IO.File.Exists(file.FullName))
+ {
+ System.IO.File.Delete(file.FullName);
+ tmpBool = true;
+ }
+ else if (System.IO.Directory.Exists(file.FullName))
+ {
+ System.IO.Directory.Delete(file.FullName);
+ tmpBool = true;
+ }
+ else
+ tmpBool = false;
+ bool generatedAux = tmpBool;
+ }
+ bool tmpBool2;
+ if (System.IO.File.Exists(dir.FullName))
+ {
+ System.IO.File.Delete(dir.FullName);
+ tmpBool2 = true;
+ }
+ else if (System.IO.Directory.Exists(dir.FullName))
+ {
+ System.IO.Directory.Delete(dir.FullName);
+ tmpBool2 = true;
+ }
+ else
+ tmpBool2 = false;
+ bool generatedAux2 = tmpBool2;
+ }
+ }
+}
\ No newline at end of file
Added: incubator/lucene.net/trunk/C#/src/Test/Store/TestWindowsMMap.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Store/TestWindowsMMap.cs?view=auto&rev=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/TestWindowsMMap.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/TestWindowsMMap.cs Sat Aug 11 09:56:37 2007
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using NUnit.Framework;
+
+using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using IndexSearcher = Lucene.Net.Search.IndexSearcher;
+
+namespace Lucene.Net.Store
+{
+
+ [TestFixture]
+ public class TestWindowsMMap
+ {
+
+ private const System.String alphabet = "abcdefghijklmnopqrstuvwzyz";
+ private System.Random random;
+
+ [SetUp]
+ public virtual void SetUp()
+ {
+ random = new System.Random();
+ SupportClass.AppSettings.Get("Lucene.Net.FSDirectory.class", "Lucene.Net.Store.MMapDirectory");
+ }
+
+ private System.String RandomToken()
+ {
+ int tl = 1 + random.Next(7);
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ for (int cx = 0; cx < tl; cx++)
+ {
+ int c = random.Next(25);
+ sb.Append(alphabet.Substring(c, (c + 1) - (c)));
+ }
+ return sb.ToString();
+ }
+
+ private System.String RandomField()
+ {
+ int fl = 1 + random.Next(3);
+ System.Text.StringBuilder fb = new System.Text.StringBuilder();
+ for (int fx = 0; fx < fl; fx++)
+ {
+ fb.Append(RandomToken());
+ fb.Append(" ");
+ }
+ return fb.ToString();
+ }
+
+ private const System.String storePathname = "testLuceneMmap";
+
+ [Test]
+ public virtual void TestMmapIndex()
+ {
+ FSDirectory storeDirectory;
+ storeDirectory = FSDirectory.GetDirectory(storePathname);
+
+ // plan to add a set of useful stopwords, consider changing some of the
+ // interior filters.
+ StandardAnalyzer analyzer = new StandardAnalyzer(new System.Collections.Hashtable());
+ // TODO: something about lock timeouts and leftover locks.
+ IndexWriter writer = new IndexWriter(storeDirectory, analyzer, true);
+ IndexSearcher searcher = new IndexSearcher(storePathname);
+
+ for (int dx = 0; dx < 1000; dx++)
+ {
+ System.String f = RandomField();
+ Document doc = new Document();
+ doc.Add(new Field("data", f, Field.Store.YES, Field.Index.TOKENIZED));
+ writer.AddDocument(doc);
+ }
+
+ searcher.Close();
+ writer.Close();
+ RmDir(new System.IO.FileInfo(storePathname));
+ }
+
+ private void RmDir(System.IO.FileInfo dir)
+ {
+ System.IO.FileInfo[] files = SupportClass.FileSupport.GetFiles(dir);
+ for (int i = 0; i < files.Length; i++)
+ {
+ bool tmpBool;
+ if (System.IO.File.Exists(files[i].FullName))
+ {
+ System.IO.File.Delete(files[i].FullName);
+ tmpBool = true;
+ }
+ else if (System.IO.Directory.Exists(files[i].FullName))
+ {
+ System.IO.Directory.Delete(files[i].FullName);
+ tmpBool = true;
+ }
+ else
+ tmpBool = false;
+ bool generatedAux = tmpBool;
+ }
+ bool tmpBool2;
+ if (System.IO.File.Exists(dir.FullName))
+ {
+ System.IO.File.Delete(dir.FullName);
+ tmpBool2 = true;
+ }
+ else if (System.IO.Directory.Exists(dir.FullName))
+ {
+ System.IO.Directory.Delete(dir.FullName);
+ tmpBool2 = true;
+ }
+ else
+ tmpBool2 = false;
+ bool generatedAux2 = tmpBool2;
+ }
+ }
+}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/C#/src/Test/Store/_TestHelper.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Store/_TestHelper.cs?view=diff&rev=564939&r1=564938&r2=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/_TestHelper.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/_TestHelper.cs Sat Aug 11 09:56:37 2007
@@ -41,7 +41,7 @@
{
if (IsFSIndexInput(is_Renamed))
{
- return ((FSIndexInput) is_Renamed).IsClone;
+ return ((FSIndexInput) is_Renamed).isClone_ForNUnitTest;
}
else
{
Modified: incubator/lucene.net/trunk/C#/src/Test/StoreTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/StoreTest.cs?view=diff&rev=564939&r1=564938&r2=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/StoreTest.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/StoreTest.cs Sat Aug 11 09:56:37 2007
@@ -16,11 +16,13 @@
*/
using System;
+
using Directory = Lucene.Net.Store.Directory;
-using FSDirectory = Lucene.Net.Store.FSDirectory;
using IndexInput = Lucene.Net.Store.IndexInput;
using IndexOutput = Lucene.Net.Store.IndexOutput;
+using FSDirectory = Lucene.Net.Store.FSDirectory;
using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using _TestUtil = Lucene.Net.Util._TestUtil;
namespace Lucene.Net
{
@@ -52,7 +54,11 @@
if (ram)
store = new RAMDirectory();
else
- store = FSDirectory.GetDirectory("test.store", true);
+ {
+ System.String dirName = "test.store";
+ _TestUtil.RmDir(dirName);
+ store = FSDirectory.GetDirectory(dirName);
+ }
int LENGTH_MASK = 0xFFF;
@@ -94,7 +100,7 @@
start = System.DateTime.Now;
if (!ram)
- store = FSDirectory.GetDirectory("test.store", false);
+ store = FSDirectory.GetDirectory("test.store");
for (i = 0; i < count; i++)
{
Added: incubator/lucene.net/trunk/C#/src/Test/Test-VS2005.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Test-VS2005.csproj?view=auto&rev=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Test-VS2005.csproj (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Test-VS2005.csproj Sat Aug 11 09:56:37 2007
@@ -0,0 +1,509 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectType>Local</ProjectType>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{AAF68BCF-F781-45FC-98B3-2B9CEE411E01}</ProjectGuid>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ApplicationIcon>
+ </ApplicationIcon>
+ <AssemblyKeyContainerName>
+ </AssemblyKeyContainerName>
+ <AssemblyName>Lucene.Net.Test</AssemblyName>
+ <AssemblyOriginatorKeyFile>
+ </AssemblyOriginatorKeyFile>
+ <DefaultClientScript>JScript</DefaultClientScript>
+ <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
+ <DefaultTargetSchema>IE50</DefaultTargetSchema>
+ <DelaySign>false</DelaySign>
+ <OutputType>Library</OutputType>
+ <RootNamespace>Lucene.Net.Test</RootNamespace>
+ <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+ <StartupObject>
+ </StartupObject>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <OutputPath>bin\Debug\</OutputPath>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <BaseAddress>285212672</BaseAddress>
+ <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+ <ConfigurationOverrideFile>
+ </ConfigurationOverrideFile>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DocumentationFile>
+ </DocumentationFile>
+ <DebugSymbols>true</DebugSymbols>
+ <FileAlignment>4096</FileAlignment>
+ <NoStdLib>false</NoStdLib>
+ <NoWarn>
+ </NoWarn>
+ <Optimize>false</Optimize>
+ <RegisterForComInterop>false</RegisterForComInterop>
+ <RemoveIntegerChecks>false</RemoveIntegerChecks>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <WarningLevel>4</WarningLevel>
+ <DebugType>full</DebugType>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <OutputPath>bin\Release\</OutputPath>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <BaseAddress>285212672</BaseAddress>
+ <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+ <ConfigurationOverrideFile>
+ </ConfigurationOverrideFile>
+ <DefineConstants>TRACE</DefineConstants>
+ <DocumentationFile>
+ </DocumentationFile>
+ <DebugSymbols>false</DebugSymbols>
+ <FileAlignment>4096</FileAlignment>
+ <NoStdLib>false</NoStdLib>
+ <NoWarn>
+ </NoWarn>
+ <Optimize>true</Optimize>
+ <RegisterForComInterop>false</RegisterForComInterop>
+ <RemoveIntegerChecks>false</RemoveIntegerChecks>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <WarningLevel>4</WarningLevel>
+ <DebugType>none</DebugType>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="DemoLib">
+ <Name>DemoLib</Name>
+ <HintPath>..\Demo\DemoLib\bin\Debug\DemoLib.dll</HintPath>
+ </Reference>
+ <Reference Include="Lucene.Net">
+ <Name>Lucene.Net</Name>
+ <HintPath>..\Lucene.Net\bin\Debug\Lucene.Net.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.core">
+ <Name>nunit.core</Name>
+ <HintPath>D:\DEVS\NUnit\bin\nunit.core.dll</HintPath>
+ <AssemblyFolderKey>hklm\dn\nunit.framework</AssemblyFolderKey>
+ </Reference>
+ <Reference Include="nunit.framework">
+ <Name>nunit.framework</Name>
+ <HintPath>D:\DEVS\NUnit\bin\nunit.framework.dll</HintPath>
+ <AssemblyFolderKey>hklm\dn\nunit.framework</AssemblyFolderKey>
+ </Reference>
+ <Reference Include="System">
+ <Name>System</Name>
+ </Reference>
+ <Reference Include="System.Data">
+ <Name>System.Data</Name>
+ </Reference>
+ <Reference Include="System.Runtime.Remoting">
+ <Name>system.runtime.remoting</Name>
+ </Reference>
+ <Reference Include="System.Xml">
+ <Name>System.XML</Name>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AnalysisTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Analysis\TestAnalyzers.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Analysis\TestISOLatin1AccentFilter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Analysis\TestKeywordAnalyzer.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Analysis\TestLengthFilter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Analysis\TestPerFieldAnalzyerWrapper.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Analysis\TestStandardAnalyzer.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Analysis\TestStopAnalyzer.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Analysis\TestStopFilter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="AssemblyInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Document\TestBinaryDocument.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Document\TestDateTools.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Document\TestDocument.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Document\TestNumberTools.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IndexTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\DocHelper.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\MockIndexInput.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\Store\TestRAMDirectory.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestAddIndexesNoOptimize.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestBackwardsCompatibility.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestCompoundFile.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestDoc.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestDocumentWriter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestFieldInfos.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestFieldsReader.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestFilterIndexReader.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestIndexFileDeleter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestIndexInput.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestIndexModifier.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestIndexReader.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestIndexWriter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestIndexWriterDelete.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestIndexWriterLockRelease.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestIndexWriterMergePolicy.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestIndexWriterMerging.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestLazyBug.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestLazyProxSkipping.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestMultiReader.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestNorms.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestParallelReader.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestParallelTermEnum.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestSegmentMerger.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestSegmentReader.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestSegmentTermDocs.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestSegmentTermEnum.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestStressIndexing.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestTermdocPerf.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestTermVectorsReader.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestTermVectorsWriter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Index\TestWordlistLoader.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="QueryParser\TestMultiAnalyzer.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="QueryParser\TestMultiFieldQueryParser.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="QueryParser\TestQueryParser.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="SearchTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="SearchTestForDuplicates.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\BaseTestRangeFilter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\CheckHits.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\MockFilter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\QueryUtils.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\SampleComparable.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\SingleDocTestFilter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\Spans\TestBasics.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\Spans\TestNearSpansOrdered.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\Spans\TestSpanExplanations.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\Spans\TestSpanExplanationsOfNonMatches.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\Spans\TestSpans.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\Spans\TestSpansAdvanced.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\Spans\TestSpansAdvanced2.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestBoolean2.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestBooleanMinShouldMatch.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestBooleanOr.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestBooleanPrefixQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestBooleanQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestBooleanScorer.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestCachingWrapperFilter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestComplexExplanations.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestComplexExplanationsOfNonMatches.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestConstantScoreRangeQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestCustomSearcherSort.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestDateFilter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestDisjunctionMaxQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestDocBoost.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestExplanations.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestFilteredQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestFuzzyQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestMatchAllDocsQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestMultiPhraseQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestMultiSearcher.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestMultiSearcherRanking.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestMultiThreadTermVectors.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestNot.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestParallelMultiSearcher.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestPhrasePrefixQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestPhraseQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestPositionIncrement.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestPrefixFilter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestPrefixQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestQueryTermVector.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestRangeFilter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestRangeQuery.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestRemoteSearchable.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestScorerPerf.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestSetNorm.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestSimilarity.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestSimpleExplanations.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestSimpleExplanationsOfNonMatches.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestSort.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestTermScorer.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestTermVectors.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestThreadSafe.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Search\TestWildcard.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="StoreTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\MockRAMDirectory.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\MockRAMOutputStream.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\TestBufferedIndexInput.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\TestLock.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\TestLockFactory.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\TestWindowsMMap.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\_TestHelper.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="TestDemo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="TestHitIterator.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="TestSearch.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="TestSearchForDuplicates.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="ThreadSafetyTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Util\English.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Util\TestBitVector.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Util\TestPriorityQueue.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Util\TestSmallFloat.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Util\TestStringHelper.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Util\_TestUtil.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <None Include="Index\index.prelockless.cfs.zip" />
+ <None Include="Index\index.prelockless.nocfs.zip" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <PreBuildEvent>
+ </PreBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
Added: incubator/lucene.net/trunk/C#/src/Test/Test-VS2005.sln
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Test-VS2005.sln?view=auto&rev=564939
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Test-VS2005.sln (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Test-VS2005.sln Sat Aug 11 09:56:37 2007
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test-VS2005", "Test-VS2005.csproj", "{AAF68BCF-F781-45FC-98B3-2B9CEE411E01}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AAF68BCF-F781-45FC-98B3-2B9CEE411E01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AAF68BCF-F781-45FC-98B3-2B9CEE411E01}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AAF68BCF-F781-45FC-98B3-2B9CEE411E01}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AAF68BCF-F781-45FC-98B3-2B9CEE411E01}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal