lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [10/18] lucenenet git commit: Some more work on tests
Date Tue, 06 Jan 2015 03:46:26 GMT
Some more work on tests


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

Branch: refs/heads/master
Commit: ca7e09b2e490749a315820e32af10768c0783d40
Parents: 8a999e1
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Mon Jan 5 17:48:09 2015 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Mon Jan 5 17:48:09 2015 +0200

----------------------------------------------------------------------
 .../core/Store/TestBufferedIndexInput.cs        | 98 +++++++++-----------
 .../core/Store/TestMultiMMap.cs                 |  1 +
 2 files changed, 46 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ca7e09b2/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 0cfa402..731bcc5 100644
--- a/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs
+++ b/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs
@@ -268,74 +268,66 @@ namespace Lucene.Net.Store
         [Test]
         public virtual void TestSetBufferSize()
         {
-            //File indexDir = CreateTempDir("testSetBufferSize");
-            var indexDir = new DirectoryInfo(Path.Combine(AppSettings.Get("tempDir", ""),
"testSetBufferSize"));
-            try
+            var indexDir = CreateTempDir("testSetBufferSize");
+            using (var dir = new MockFSDirectory(indexDir, Random()))
             {
-                using (MockFSDirectory dir = new MockFSDirectory(indexDir, Random()))
+                using (var writer = new IndexWriter(dir,
+                    (new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()))).SetOpenMode(
+                        IndexWriterConfig.OpenMode_e.CREATE).SetMergePolicy(NewLogMergePolicy(false))))
                 {
-                    using (IndexWriter 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++)
+                    {
+                        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))
                     {
-                        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();
+                        searcher = NewSearcher(reader);
+                        hits = searcher.Search(new TermQuery(bbb), null, 1000).ScoreDocs;
                         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);
-                        }
+                        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();
-                        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);
-                        }
+                        Assert.AreEqual(35, hits.Length);
                     }
                 }
             }
-            finally
-            {
-                System.IO.Directory.Delete(indexDir.FullName, true);
-            }
         }
 
         private class MockFSDirectory : BaseDirectory
         {
-            internal IList<IndexInput> AllIndexInputs = new List<IndexInput>();
+            internal readonly IList<IndexInput> AllIndexInputs = new List<IndexInput>();
 
-            internal Random Rand;
+            private Random Rand;
 
-            internal Directory Dir;
+            private Directory Dir;
 
             public MockFSDirectory(DirectoryInfo path, Random rand)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ca7e09b2/src/Lucene.Net.Tests/core/Store/TestMultiMMap.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Store/TestMultiMMap.cs b/src/Lucene.Net.Tests/core/Store/TestMultiMMap.cs
index aa7807c..3ec109f 100644
--- a/src/Lucene.Net.Tests/core/Store/TestMultiMMap.cs
+++ b/src/Lucene.Net.Tests/core/Store/TestMultiMMap.cs
@@ -47,6 +47,7 @@ namespace Lucene.Net.Store
         public override void SetUp()
         {
             base.SetUp();
+            // LUCENENET TODO: what?!?!?!?!?!
             AssumeTrue("test requires a jre that supports unmapping", MMapDirectory.UNMAP_SUPPORTED);
         }
 


Mime
View raw message