public virtual void TestNativeFSLockFactory() { NativeFSLockFactory f = new NativeFSLockFactory(SupportClass.AppSettings.Get("tempDir", System.IO.Path.GetTempPath())); 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, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(l.IsLocked()); Assert.IsTrue(l2.IsLocked()); l.Release(); Assert.IsFalse(l.IsLocked()); Assert.IsFalse(l2.IsLocked()); }
public virtual void TestNativeFSLockFactory() { var f = new NativeFSLockFactory(CreateTempDir("testNativeFsLockFactory")); f.LockPrefix = "test"; var l = f.MakeLock("commit"); var l2 = f.MakeLock("commit"); Assert.IsTrue(l.Obtain(), "failed to obtain lock, got exception: {0}", l.FailureReason); Assert.IsTrue(!l2.Obtain(), "succeeded in obtaining lock twice"); l.Dispose(); Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed, got exception: {0}", l2.FailureReason); l2.Dispose(); // Make sure we can obtain first one again, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock, got exception: {0}", l.FailureReason); Assert.IsTrue(l.Locked); Assert.IsTrue(l2.Locked); l.Dispose(); Assert.IsFalse(l.Locked); Assert.IsFalse(l2.Locked); }
public virtual void TestNativeFSLockFactory() { //NativeFSLockFactory f = new NativeFSLockFactory(CreateTempDir(LuceneTestCase.TestClass.SimpleName)); NativeFSLockFactory f = new NativeFSLockFactory(AppSettings.Get("tempDir", Path.GetTempPath())); f.LockPrefix = "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.Dispose(); Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed"); l2.Dispose(); // Make sure we can obtain first one again, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(l.Locked); Assert.IsTrue(l2.Locked); l.Dispose(); Assert.IsFalse(l.Locked); Assert.IsFalse(l2.Locked); }
public virtual void TestNativeFSLockFactory() { //NativeFSLockFactory f = new NativeFSLockFactory(CreateTempDir(LuceneTestCase.TestClass.SimpleName)); NativeFSLockFactory f = new NativeFSLockFactory(AppSettings.Get("tempDir", Path.GetTempPath())); f.LockPrefix = "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.Dispose(); Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed"); l2.Dispose(); // Make sure we can obtain first one again, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(l.Locked); Assert.IsTrue(l2.Locked); l.Dispose(); Assert.IsFalse(l.Locked); Assert.IsFalse(l2.Locked); }
public virtual void TestNativeFSLockFactory() { var f = new NativeFSLockFactory(CreateTempDir("testNativeFsLockFactory")); f.LockPrefix = "test"; var l = f.MakeLock("commit"); var l2 = f.MakeLock("commit"); Assert.IsTrue(l.Obtain(), "failed to obtain lock, got exception: {0}", l.FailureReason); Assert.IsTrue(!l2.Obtain(), "succeeded in obtaining lock twice"); l.Dispose(); Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed, got exception: {0}", l2.FailureReason); l2.Dispose(); // Make sure we can obtain first one again, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock, got exception: {0}", l.FailureReason); Assert.IsTrue(l.Locked); Assert.IsTrue(l2.Locked); l.Dispose(); Assert.IsFalse(l.Locked); Assert.IsFalse(l2.Locked); }
public virtual void TestNativeFSLockFactory() { NativeFSLockFactory f = new NativeFSLockFactory(SupportClass.AppSettings.Get("tempDir", System.IO.Path.GetTempPath())); 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, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(l.IsLocked()); Assert.IsTrue(l2.IsLocked()); l.Release(); Assert.IsFalse(l.IsLocked()); Assert.IsFalse(l2.IsLocked()); }