//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUseAlreadyOpenedFileChannel() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUseAlreadyOpenedFileChannel() { StoreChannel channel = Mockito.mock(typeof(StoreChannel)); CustomChannelFileSystemAbstraction fileSystemAbstraction = new CustomChannelFileSystemAbstraction(this, FileSystemRule.get(), channel); int numberOfCallesToOpen = 0; try { using (StoreLocker storeLocker = new StoreLocker(fileSystemAbstraction, Target.storeLayout())) { try { storeLocker.CheckLock(); fail(); } catch (StoreLockException) { numberOfCallesToOpen = fileSystemAbstraction.NumberOfCallsToOpen; // Try to grab lock a second time storeLocker.CheckLock(); } } } catch (StoreLockException) { // expected } assertEquals("Expect that number of open channels will remain the same for ", numberOfCallesToOpen, fileSystemAbstraction.NumberOfCallsToOpen); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAllowMultipleCallsToCheckLock() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAllowMultipleCallsToCheckLock() { using (StoreLocker storeLocker = new StoreLocker(FileSystemRule.get(), Target.storeLayout())) { storeLocker.CheckLock(); storeLocker.CheckLock(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void assertCanLockStore(java.nio.file.Path databaseDirectory) throws java.io.IOException private static void AssertCanLockStore(Path databaseDirectory) { using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), StoreLocker storeLocker = new StoreLocker(fileSystem, DatabaseLayout.of(databaseDirectory.toFile()).StoreLayout)) { storeLocker.CheckLock(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void forceShouldRespectStoreLock() public virtual void ForceShouldRespectStoreLock() { string databaseName = "to"; Config config = ConfigWith(databaseName, Directory.absolutePath().AbsolutePath); File fromPath = new File(Directory.absolutePath(), "from"); File toPath = config.Get(GraphDatabaseSettings.database_path); int fromNodeCount = 10; int toNodeCount = 20; CreateDbAt(fromPath, fromNodeCount); CreateDbAt(toPath, toNodeCount); FileSystemAbstraction fs = FileSystemRule.get(); try { using (StoreLocker storeLocker = new StoreLocker(fs, DatabaseLayout.of(toPath).StoreLayout)) { storeLocker.CheckLock(); (new RestoreDatabaseCommand(fs, fromPath, config, databaseName, true)).Execute(); fail("expected exception"); } } catch (Exception e) { assertThat(e.Message, equalTo("the database is in use -- stop Neo4j and try again")); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateStoreDirAndObtainLockWhenStoreDirDoesNotExist() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCreateStoreDirAndObtainLockWhenStoreDirDoesNotExist() { FileSystemAbstraction fileSystemAbstraction = new DelegatingFileSystemAbstractionAnonymousInnerClass2(this, FileSystemRule.get()); using (StoreLocker storeLocker = new StoreLocker(fileSystemAbstraction, Target.storeLayout())) { storeLocker.CheckLock(); // Ok } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldRespectTheStoreLock() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldRespectTheStoreLock() { Path databaseDirectory = _homeDir.resolve("data/databases/foo.db"); StoreLayout storeLayout = DatabaseLayout.of(databaseDirectory.toFile()).StoreLayout; using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), StoreLocker storeLocker = new StoreLocker(fileSystem, storeLayout)) { storeLocker.CheckLock(); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => execute("foo.db")); assertEquals("the database is in use -- stop Neo4j and try again", commandFailed.Message); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void shouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock() { StoreLayout storeLayout = DatabaseLayout.of(_databaseDirectory.toFile()).StoreLayout; using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), StoreLocker storeLocker = new StoreLocker(fileSystem, storeLayout)) { storeLocker.CheckLock(); using (System.IDisposable ignored = withPermissions(storeLayout.StoreLockFile().toPath(), emptySet())) { CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => execute("foo.db")); assertEquals(commandFailed.Message, "you do not have permission to dump the database -- is Neo4j running as a different user?"); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotObtainLockWhenStoreAlreadyInUse() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotObtainLockWhenStoreAlreadyInUse() { FileSystemAbstraction fileSystemAbstraction = new DelegatingFileSystemAbstractionAnonymousInnerClass5(this, FileSystemRule.get()); try { using (StoreLocker storeLocker = new StoreLocker(fileSystemAbstraction, Target.storeLayout())) { storeLocker.CheckLock(); fail(); } } catch (StoreLockException e) { assertThat(e.Message, containsString("Store and its lock file has been locked by another process")); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldObtainLockWhenStoreFileNotLocked() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldObtainLockWhenStoreFileNotLocked() { FileSystemAbstraction fileSystemAbstraction = new DelegatingFileSystemAbstractionAnonymousInnerClass(this, FileSystemRule.get()); try { using (StoreLocker storeLocker = new StoreLocker(fileSystemAbstraction, Target.storeLayout())) { storeLocker.CheckLock(); // Ok } } catch (StoreLockException) { fail(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotObtainLockWhenUnableToOpenLockFile() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotObtainLockWhenUnableToOpenLockFile() { FileSystemAbstraction fileSystemAbstraction = new DelegatingFileSystemAbstractionAnonymousInnerClass4(this, FileSystemRule.get()); StoreLayout storeLayout = Target.storeLayout(); try { using (StoreLocker storeLocker = new StoreLocker(fileSystemAbstraction, storeLayout)) { storeLocker.CheckLock(); fail(); } } catch (StoreLockException e) { string msg = format("Unable to obtain lock on store lock file: %s. " + "Please ensure no other process is using this database, and that the " + "directory is writable (required even for read-only access)", storeLayout.StoreLockFile()); assertThat(e.Message, @is(msg)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void keepLockWhenOtherTryToTakeLock() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void KeepLockWhenOtherTryToTakeLock() { StoreLayout storeLayout = Target.storeLayout(); DefaultFileSystemAbstraction fileSystemAbstraction = FileSystemRule.get(); StoreLocker storeLocker = new StoreLocker(fileSystemAbstraction, storeLayout); storeLocker.CheckLock(); try { using (StoreLocker storeLocker1 = new StoreLocker(fileSystemAbstraction, storeLayout)) { storeLocker1.CheckLock(); fail(); } } catch (StoreLockException) { // Expected } // Initial locker should still have a valid lock try { using (StoreLocker storeLocker1 = new StoreLocker(fileSystemAbstraction, storeLayout)) { storeLocker1.CheckLock(); fail(); } } catch (StoreLockException) { // Expected } storeLocker.Dispose(); }