lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [2/3] lucenenet git commit: put back the test to match what Lucene is doing
Date Sat, 02 May 2015 17:37:24 GMT
put back the test to match what Lucene is doing


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/ff6f2426
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/ff6f2426
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/ff6f2426

Branch: refs/heads/master
Commit: ff6f2426cb96a74f5573350ee0e1b56bcc9dbcd9
Parents: 19f506c
Author: Laimonas Simutis <laimis@gmail.com>
Authored: Fri May 1 20:30:59 2015 -0400
Committer: Laimonas Simutis <laimis@gmail.com>
Committed: Fri May 1 20:30:59 2015 -0400

----------------------------------------------------------------------
 .../core/Store/TestBufferedIndexInput.cs        | 98 +++++++++++---------
 1 file changed, 52 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ff6f2426/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs b/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs
index 731bcc5..86335f0 100644
--- a/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs
+++ b/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs
@@ -269,55 +269,61 @@ namespace Lucene.Net.Store
         public virtual void TestSetBufferSize()
         {
             var indexDir = CreateTempDir("testSetBufferSize");
-            using (var dir = new MockFSDirectory(indexDir, Random()))
+            var dir = new MockFSDirectory(indexDir, Random());
+            try
             {
-                using (var writer = new IndexWriter(dir,
-                    (new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()))).SetOpenMode(
-                        IndexWriterConfig.OpenMode_e.CREATE).SetMergePolicy(NewLogMergePolicy(false))))
+                var writer = new IndexWriter(
+                    dir,
+                    new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()))
+                        .SetOpenMode(IndexWriterConfig.OpenMode_e.CREATE)
+                        .SetMergePolicy(NewLogMergePolicy(false)));
+                    
+                for (int i = 0; i < 37; i++)
                 {
-                    for (int i = 0; i < 37; i++)
-                    {
-                        var doc = new Document();
-                        doc.Add(NewTextField("content", "aaa bbb ccc ddd" + i, Field.Store.YES));
-                        doc.Add(NewTextField("id", "" + i, Field.Store.YES));
-                        writer.AddDocument(doc);
-                    }
-
-                    dir.AllIndexInputs.Clear();
-                    dir.TweakBufferSizes();
-                    writer.DeleteDocuments(new Term("id", "0"));
-
-                    var aaa = new Term("content", "aaa");
-                    var bbb = new Term("content", "bbb");
-
-                    IndexSearcher searcher;
-                    ScoreDoc[] hits;
-                    using (var reader = DirectoryReader.Open(writer, true))
-                    {
-                        searcher = NewSearcher(reader);
-                        hits = searcher.Search(new TermQuery(bbb), null, 1000).ScoreDocs;
-                        dir.TweakBufferSizes();
-                        Assert.AreEqual(36, hits.Length);
-                    }
-
-                    dir.TweakBufferSizes();
-                    writer.DeleteDocuments(new Term("id", "4"));
-                    using (var reader = DirectoryReader.Open(writer, true))
-                    {
-                        searcher = NewSearcher(reader);
-
-                        hits = searcher.Search(new TermQuery(bbb), null, 1000).ScoreDocs;
-                        dir.TweakBufferSizes();
-                        Assert.AreEqual(35, hits.Length);
-                        dir.TweakBufferSizes();
-                        hits = searcher.Search(new TermQuery(new Term("id", "33")), null,
1000).ScoreDocs;
-                        dir.TweakBufferSizes();
-                        Assert.AreEqual(1, hits.Length);
-                        hits = searcher.Search(new TermQuery(aaa), null, 1000).ScoreDocs;
-                        dir.TweakBufferSizes();
-                        Assert.AreEqual(35, hits.Length);
-                    }
+                    var doc = new Document();
+                    doc.Add(NewTextField("content", "aaa bbb ccc ddd" + i, Field.Store.YES));
+                    doc.Add(NewTextField("id", "" + i, Field.Store.YES));
+                    writer.AddDocument(doc);
                 }
+
+                dir.AllIndexInputs.Clear();
+
+                IndexReader reader = DirectoryReader.Open(writer, true);
+                var aaa = new Term("content", "aaa");
+                var bbb = new Term("content", "bbb");
+                reader.Dispose();
+
+                dir.TweakBufferSizes();
+                writer.DeleteDocuments(new Term("id", "0"));
+                reader = DirectoryReader.Open(writer, true);
+                var searcher = NewSearcher(reader);
+                var hits = searcher.Search(new TermQuery(bbb), null, 1000).ScoreDocs;
+                dir.TweakBufferSizes();
+                Assert.AreEqual(36, hits.Length);
+
+                reader.Dispose();
+
+                dir.TweakBufferSizes();
+                writer.DeleteDocuments(new Term("id", "4"));
+                reader = DirectoryReader.Open(writer, true);
+                searcher = NewSearcher(reader);
+
+                hits = searcher.Search(new TermQuery(bbb), null, 1000).ScoreDocs;
+                dir.TweakBufferSizes();
+                Assert.AreEqual(35, hits.Length);
+                dir.TweakBufferSizes();
+                hits = searcher.Search(new TermQuery(new Term("id", "33")), null, 1000).ScoreDocs;
+                dir.TweakBufferSizes();
+                Assert.AreEqual(1, hits.Length);
+                hits = searcher.Search(new TermQuery(aaa), null, 1000).ScoreDocs;
+                dir.TweakBufferSizes();
+                Assert.AreEqual(35, hits.Length);
+                writer.Dispose();
+                reader.Dispose();
+            }
+            finally
+            {
+                indexDir.Delete(true);
             }
         }
 


Mime
View raw message