//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldWrapIOExceptionsCarefullyBecauseCriticalInformationIsOftenEncodedInTheirNameButMissingFromTheirMessage() throws java.io.IOException, org.neo4j.dbms.archive.IncorrectFormat //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldWrapIOExceptionsCarefullyBecauseCriticalInformationIsOftenEncodedInTheirNameButMissingFromTheirMessage() { doThrow(new FileSystemException("the-message")).when(_loader).load(any(), any(), any()); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => execute(null)); assertEquals("unable to load database: FileSystemException: the-message", commandFailed.Message); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldGiveAClearMessageIfTheDatabasesDirectoryIsNotWritable() throws java.io.IOException, org.neo4j.dbms.archive.IncorrectFormat //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldGiveAClearMessageIfTheDatabasesDirectoryIsNotWritable() { doThrow(typeof(AccessDeniedException)).when(_loader).load(any(), any(), any()); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => execute(null)); assertEquals("you do not have permission to load a database -- is Neo4j running as a different user?", commandFailed.Message); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldGiveAClearMessageIfTheDatabaseAlreadyExists() throws java.io.IOException, org.neo4j.dbms.archive.IncorrectFormat, org.neo4j.commandline.admin.IncorrectUsage //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldGiveAClearMessageIfTheDatabaseAlreadyExists() { doThrow(typeof(FileAlreadyExistsException)).when(_loader).load(any(), any(), any()); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => execute("foo.db")); assertEquals("database already exists: foo.db", commandFailed.Message); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldGiveAClearMessageIfTheArchiveDoesntExist() throws java.io.IOException, org.neo4j.dbms.archive.IncorrectFormat //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldGiveAClearMessageIfTheArchiveDoesntExist() { doThrow(new NoSuchFileException(_archive.ToString())).when(_loader).load(any(), any(), any()); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => execute(null)); assertEquals("archive does not exist: " + _archive, commandFailed.Message); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldThrowIfTheArchiveFormatIsInvalid() throws java.io.IOException, org.neo4j.dbms.archive.IncorrectFormat //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldThrowIfTheArchiveFormatIsInvalid() { doThrow(typeof(IncorrectFormat)).when(_loader).load(any(), any(), any()); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => execute(null)); assertThat(commandFailed.Message, containsString(_archive.ToString())); assertThat(commandFailed.Message, containsString("valid Neo4j archive")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void backupNeedsToBePath() internal virtual void BackupNeedsToBePath() { ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService)); Path homeDir = _testDir.directory("home").toPath(); CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService); File backupPath = new File(homeDir.toFile(), "dir/does/not/exist"); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => checkConsistencyCommand.execute(new string[] { "--backup=" + backupPath })); assertEquals("Specified backup should be a directory: " + backupPath, commandFailed.Message); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldRespectTheStoreLock() throws java.io.IOException //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"); Files.createDirectories(databaseDirectory); StoreLayout storeLayout = DatabaseLayout.of(databaseDirectory.toFile()).StoreLayout; using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), StoreLocker locker = new StoreLocker(fileSystem, storeLayout)) { locker.CheckLock(); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => execute("foo.db", "--force")); 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 void failsWhenInconsistenciesAreFound() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void FailsWhenInconsistenciesAreFound() { ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService)); Path homeDir = _testDir.directory("home").toPath(); File databasesFolder = GetDatabasesFolder(homeDir); CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService); DatabaseLayout databaseLayout = DatabaseLayout.of(databasesFolder, "mydb"); when(consistencyCheckService.runFullConsistencyCheck(eq(databaseLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(true), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.failure(new File("/the/report/path"))); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => checkConsistencyCommand.execute(new string[] { "--database=mydb", "--verbose" })); assertThat(commandFailed.Message, containsString((new File("/the/report/path")).ToString())); }