Example #1
0
        public virtual void TestNotDirectory()
        {
            DirectoryInfo path  = CreateTempDir("testnotdir");
            Directory     fsDir = new SimpleFSDirectory(path, null);

            try
            {
                IndexOutput @out = fsDir.CreateOutput("afile", NewIOContext(Random()));
                @out.Dispose();
                Assert.IsTrue(SlowFileExists(fsDir, "afile"));
                try
                {
                    var d = new SimpleFSDirectory(new DirectoryInfo(Path.Combine(path.FullName, "afile")), null);
                    Assert.Fail("did not hit expected exception");
                }
#pragma warning disable 168
                catch (DirectoryNotFoundException nsde)
#pragma warning restore 168
                {
                    // Expected
                }
            }
            finally
            {
                fsDir.Dispose();
                System.IO.Directory.Delete(path.FullName, true);
            }
        }
Example #2
0
        public virtual void TestNotDirectory()
        {
            //File path = CreateTempDir("testnotdir");
            DirectoryInfo path  = new DirectoryInfo(Path.Combine(AppSettings.Get("tempDir", ""), "testnotdir"));
            Directory     fsDir = new SimpleFSDirectory(path, null);

            try
            {
                IndexOutput @out = fsDir.CreateOutput("afile", NewIOContext(Random()));
                @out.Dispose();
                Assert.IsTrue(SlowFileExists(fsDir, "afile"));
                try
                {
                    new SimpleFSDirectory(new DirectoryInfo(Path.Combine(path.FullName, "afile")), null);
                    Assert.Fail("did not hit expected exception");
                }
                catch (NoSuchDirectoryException nsde)
                {
                    // Expected
                }
            }
            finally
            {
                fsDir.Dispose();
                System.IO.Directory.Delete(path.FullName, true);
            }
        }
Example #3
0
        public virtual void TestDontCreate()
        {
            var path = new DirectoryInfo(Path.Combine(AppSettings.Get("tmpDir", ""), "doesnotexist"));

            try
            {
                Assert.IsTrue(!path.Exists);
                Directory dir = new SimpleFSDirectory(path, null);
                Assert.IsTrue(!path.Exists);
                dir.Dispose();
            }
            finally
            {
                System.IO.Directory.Delete(path.FullName, true);
            }
        }
Example #4
0
        public virtual void TestFsyncDoesntCreateNewFiles()
        {
            //File path = CreateTempDir("nocreate");
            DirectoryInfo path = new DirectoryInfo(Path.Combine(AppSettings.Get("tempDir", ""), "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)
            {
                Assert.Fail("Deletion of new Directory should never fail.");
            }

            // directory is 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 /*| NoSuchFileException*/ expected)
            {
                // ok
            }

            // directory is still empty
            Assert.AreEqual(0, fsdir.ListAll().Length);

            fsdir.Dispose();
        }
Example #5
0
        public virtual void TestDontCreate()
        {
            var parentFolder = CreateTempDir(this.GetType().Name.ToLowerInvariant());
            var path         = new DirectoryInfo(Path.Combine(parentFolder.FullName, "doesnotexist"));

            try
            {
                Assert.IsTrue(!path.Exists);
                Directory dir = new SimpleFSDirectory(path, null);
                Assert.IsTrue(!path.Exists);
                dir.Dispose();
            }
            finally
            {
                if (path.Exists)
                {
                    System.IO.Directory.Delete(path.FullName, true);
                }
            }
        }
Example #6
0
        public virtual void TestDefaultFSLockFactoryPrefix()
        {
            // Make sure we get null prefix, which wont happen if setLockFactory is ever called.
            DirectoryInfo dirName = CreateTempDir("TestLockFactory.10");

            Directory dir = new SimpleFSDirectory(dirName);

            Assert.IsNull(dir.LockFactory.LockPrefix, "Default lock prefix should be null");
            dir.Dispose();

            dir = new MMapDirectory(dirName);
            Assert.IsNull(dir.LockFactory.LockPrefix, "Default lock prefix should be null");
            dir.Dispose();

            dir = new NIOFSDirectory(dirName);
            Assert.IsNull(dir.LockFactory.LockPrefix, "Default lock prefix should be null");
            dir.Dispose();

            System.IO.Directory.Delete(dirName.FullName, true);
        }
Example #7
0
        public virtual void TestDefaultFSLockFactoryPrefix()
        {
            // Make sure we get null prefix, which wont happen if setLockFactory is ever called.
            DirectoryInfo dirName = CreateTempDir("TestLockFactory.10");

            Directory dir = new SimpleFSDirectory(dirName);
            Assert.IsNull(dir.LockFactory.LockPrefix, "Default lock prefix should be null");
            dir.Dispose();

            dir = new MMapDirectory(dirName);
            Assert.IsNull(dir.LockFactory.LockPrefix, "Default lock prefix should be null");
            dir.Dispose();

            dir = new NIOFSDirectory(dirName);
            Assert.IsNull(dir.LockFactory.LockPrefix, "Default lock prefix should be null");
            dir.Dispose();

            System.IO.Directory.Delete(dirName.FullName, true);
        }
 public virtual void TestNotDirectory()
 {
     DirectoryInfo path = CreateTempDir("testnotdir");
     Directory fsDir = new SimpleFSDirectory(path, null);
     try
     {
         IndexOutput @out = fsDir.CreateOutput("afile", NewIOContext(Random()));
         @out.Dispose();
         Assert.IsTrue(SlowFileExists(fsDir, "afile"));
         try
         {
             var d = new SimpleFSDirectory(new DirectoryInfo(Path.Combine(path.FullName, "afile")), null);
             Assert.Fail("did not hit expected exception");
         }
         catch (NoSuchDirectoryException nsde)
         {
             // Expected
         }
     }
     finally
     {
         fsDir.Dispose();
         System.IO.Directory.Delete(path.FullName, true);
     }
 }
 public virtual void TestDontCreate()
 {
     var parentFolder = CreateTempDir(this.GetType().Name.ToLowerInvariant());
     var path = new DirectoryInfo(Path.Combine(parentFolder.FullName, "doesnotexist"));
     try
     {
         Assert.IsTrue(!path.Exists);
         Directory dir = new SimpleFSDirectory(path, null);
         Assert.IsTrue(!path.Exists);
         dir.Dispose();
     }
     finally
     {
         if (path.Exists) System.IO.Directory.Delete(path.FullName, true);
     }
 }
Example #10
0
        public virtual void TestFsyncDoesntCreateNewFiles()
        {
            //File path = CreateTempDir("nocreate");
            DirectoryInfo path = new DirectoryInfo(Path.Combine(AppSettings.Get("tempDir", ""), "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)
            {
                Assert.Fail("Deletion of new Directory should never fail.");
            }

            // directory is 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 /*| NoSuchFileException*/ expected)
            {
                // ok
            }

            // directory is still empty
            Assert.AreEqual(0, fsdir.ListAll().Length);

            fsdir.Dispose();
        }
Example #11
0
 public virtual void TestDontCreate()
 {
     DirectoryInfo path = new DirectoryInfo(Path.Combine(AppSettings.Get("tmpDir", ""), "doesnotexist"));
     try
     {
         Assert.IsTrue(!path.Exists);
         Directory dir = new SimpleFSDirectory(path, null);
         Assert.IsTrue(!path.Exists);
         dir.Dispose();
     }
     finally
     {
         System.IO.Directory.Delete(path.FullName, true);
     }
 }