use of org.neo4j.cli.CommandFailedException in project neo4j by neo4j.
the class CheckConsistencyCommandIT method backupNeedsToBePath.
@Test
void backupNeedsToBePath() {
ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
Path backupPath = homeDir.resolve("dir/does/not/exist");
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> {
CommandLine.populateCommand(checkConsistencyCommand, "--backup=" + backupPath);
checkConsistencyCommand.execute();
});
assertThat(commandFailed.getMessage()).contains("Report directory path doesn't exist or not a directory");
}
use of org.neo4j.cli.CommandFailedException in project neo4j by neo4j.
the class DumpCommandIT method shouldGiveAClearMessageIfTheArchivesParentDoesntExist.
@Test
void shouldGiveAClearMessageIfTheArchivesParentDoesntExist() throws Exception {
doThrow(new NoSuchFileException(archive.getParent().toString())).when(dumper).dump(any(), any(), any(), any(), any());
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo"));
assertEquals("Unable to dump database: NoSuchFileException: " + archive.getParent(), commandFailed.getMessage());
}
use of org.neo4j.cli.CommandFailedException in project neo4j by neo4j.
the class DumpCommandIT method shouldRespectTheDatabaseLock.
@Test
void shouldRespectTheDatabaseLock() throws Exception {
Path databaseDirectory = homeDir.resolve("data/databases/foo");
DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(databaseDirectory);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
Locker locker = new DatabaseLocker(fileSystem, databaseLayout)) {
locker.checkLock();
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo"));
assertEquals("The database is in use. Stop database 'foo' and try again.", commandFailed.getMessage());
}
}
use of org.neo4j.cli.CommandFailedException in project neo4j by neo4j.
the class DumpCommandIT method databaseThatRequireRecoveryIsNotDumpable.
@Test
void databaseThatRequireRecoveryIsNotDumpable() throws IOException {
LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, testDirectory.getFileSystem()).withLogVersionRepository(new SimpleLogVersionRepository()).withTransactionIdStore(new SimpleTransactionIdStore()).withCommandReaderFactory(StorageEngineFactory.defaultStorageEngine().commandReaderFactory()).withStoreId(StoreId.UNKNOWN).build();
try (Lifespan ignored = new Lifespan(logFiles)) {
LogFile logFile = logFiles.getLogFile();
LogEntryWriter writer = logFile.getTransactionLogWriter().getWriter();
writer.writeStartEntry(0x123456789ABCDEFL, logFile.getLogFileInformation().getLastEntryId() + 1, BASE_TX_CHECKSUM, new byte[] { 0 });
}
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo"));
assertThat(commandFailed.getMessage()).startsWith("Active logical log detected, this might be a source of inconsistencies.");
}
use of org.neo4j.cli.CommandFailedException in project neo4j by neo4j.
the class DumpCommandIT method shouldWrapIOExceptionsCarefullyBecauseCriticalInformationIsOftenEncodedInTheirNameButMissingFromTheirMessage.
@Test
void shouldWrapIOExceptionsCarefullyBecauseCriticalInformationIsOftenEncodedInTheirNameButMissingFromTheirMessage() throws Exception {
doThrow(new IOException("the-message")).when(dumper).dump(any(), any(), any(), any(), any());
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo"));
assertEquals("Unable to dump database: IOException: the-message", commandFailed.getMessage());
}
Aggregations