You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2014/12/31 22:40:47 UTC

lucenenet git commit: Semi-fixed the test, now throws UnauthorizedAccessException

Repository: lucenenet
Updated Branches:
  refs/heads/master 4128cedfe -> f81d54394


Semi-fixed the test, now throws UnauthorizedAccessException


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

Branch: refs/heads/master
Commit: f81d543948acabaf5876a531458295a09db2a15c
Parents: 4128ced
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Wed Dec 31 23:40:36 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Wed Dec 31 23:40:36 2014 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Core/Store/FSDirectory.cs        |  2 +-
 .../core/Store/TestDirectory.cs                 | 67 ++++++++++----------
 2 files changed, 34 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f81d5439/src/Lucene.Net.Core/Store/FSDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/FSDirectory.cs b/src/Lucene.Net.Core/Store/FSDirectory.cs
index 25c5c1e..4e70822 100644
--- a/src/Lucene.Net.Core/Store/FSDirectory.cs
+++ b/src/Lucene.Net.Core/Store/FSDirectory.cs
@@ -555,7 +555,7 @@ namespace Lucene.Net.Store
         /// <param name="name"></param>
         protected void Fsync(String name, bool isDir = false)
         {
-            IOUtils.Fsync(Path.Combine(directory.FullName, name), false);            
+            IOUtils.Fsync(Path.Combine(directory.FullName, name), isDir);            
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f81d5439/src/Lucene.Net.Tests/core/Store/TestDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Store/TestDirectory.cs b/src/Lucene.Net.Tests/core/Store/TestDirectory.cs
index ac4a4d9..1fa47b6 100644
--- a/src/Lucene.Net.Tests/core/Store/TestDirectory.cs
+++ b/src/Lucene.Net.Tests/core/Store/TestDirectory.cs
@@ -261,7 +261,7 @@ namespace Lucene.Net.Store
         [Test]
         public virtual void TestDontCreate()
         {
-            DirectoryInfo path = new DirectoryInfo(Path.Combine(AppSettings.Get("tmpDir", ""), "doesnotexist"));
+            var path = new DirectoryInfo(Path.Combine(AppSettings.Get("tmpDir", ""), "doesnotexist"));
             try
             {
                 Assert.IsTrue(!path.Exists);
@@ -358,46 +358,45 @@ namespace Lucene.Net.Store
         [Test]
         public virtual void TestFsyncDoesntCreateNewFiles()
         {
-            //File path = CreateTempDir("nocreate");
-            DirectoryInfo path = new DirectoryInfo(Path.Combine(AppSettings.Get("tempDir", ""), "nocreate"));
+            var path = CreateTempDir("nocreate");
             Console.WriteLine(path.FullName);
-            Directory fsdir = new SimpleFSDirectory(path);
 
-            // write a file
-            IndexOutput @out = fsdir.CreateOutput("afile", NewIOContext(Random()));
-            @out.WriteString("boo");
-            @out.Dispose();
-
-            // delete it
-            try
-            {
-                var newDir = new DirectoryInfo(Path.Combine(path.FullName, "afile"));
-                newDir.Create();
-                newDir.Delete();
-            }
-            catch (Exception e)
+            using (Directory fsdir = new SimpleFSDirectory(path))
             {
-                Assert.Fail("Deletion of new Directory should never fail.\nException thrown: {0}", e);
-            }
+                // write a file
+                using (var o = fsdir.CreateOutput("afile", NewIOContext(Random())))
+                {
+                    o.WriteString("boo");
+                }
 
-            // directory is empty
-            Assert.AreEqual(0, fsdir.ListAll().Length);
+                // delete it
+                try
+                {
+                    File.Delete(Path.Combine(path.FullName, "afile"));
+                }
+                catch (Exception e)
+                {
+                    Assert.Fail("Deletion of new Directory should never fail.\nException thrown: {0}", e);
+                }
 
-            // fsync it
-            try
-            {
-                fsdir.Sync(CollectionsHelper.Singleton("afile"));
-                Assert.Fail("didn't get expected exception, instead fsync created new files: " + Arrays.AsList(fsdir.ListAll()));
-            }
-            catch (FileNotFoundException /*| NoSuchFileException*/ expected)
-            {
-                // ok
-            }
+                // directory is empty
+                Assert.AreEqual(0, fsdir.ListAll().Length);
 
-            // directory is still empty
-            Assert.AreEqual(0, fsdir.ListAll().Length);
+                // fsync it
+                try
+                {
+                    fsdir.Sync(CollectionsHelper.Singleton("afile"));
+                    Assert.Fail("didn't get expected exception, instead fsync created new files: " +
+                                Arrays.AsList(fsdir.ListAll()));
+                }
+                catch (FileNotFoundException)
+                {
+                    // ok
+                }
 
-            fsdir.Dispose();
+                // directory is still empty
+                Assert.AreEqual(0, fsdir.ListAll().Length);
+            }
         }
     }
 }
\ No newline at end of file