use of org.neo4j.cli.CommandFailedException in project neo4j by neo4j.
the class LoadCommandTest method shouldGiveAClearMessageIfTheDatabasesDirectoryIsNotWritable.
@Test
void shouldGiveAClearMessageIfTheDatabasesDirectoryIsNotWritable() throws IOException, IncorrectFormat {
doThrow(AccessDeniedException.class).when(loader).load(any(), any());
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo", archive));
assertEquals("You do not have permission to load the database.", commandFailed.getMessage());
}
use of org.neo4j.cli.CommandFailedException in project neo4j by neo4j.
the class LoadCommandTest method shouldGiveAClearMessageIfTheArchiveDoesntExist.
@Test
void shouldGiveAClearMessageIfTheArchiveDoesntExist() throws IOException, IncorrectFormat {
doThrow(new NoSuchFileException(archive.toString())).when(loader).load(any(), any());
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo", archive));
assertEquals("Archive does not exist: " + archive, commandFailed.getMessage());
}
use of org.neo4j.cli.CommandFailedException in project neo4j by neo4j.
the class LoadCommandTest method shouldRespectTheDatabaseLock.
@Test
void shouldRespectTheDatabaseLock() throws IOException {
Path databaseDirectory = homeDir.resolve("data/databases/foo");
Files.createDirectories(databaseDirectory);
DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(databaseDirectory);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
Locker locker = new DatabaseLocker(fileSystem, databaseLayout)) {
locker.checkLock();
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> executeForce("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 LoadCommandTest method shouldWrapIOExceptionsCarefullyBecauseCriticalInformationIsOftenEncodedInTheirNameButMissingFromTheirMessage.
@Test
void shouldWrapIOExceptionsCarefullyBecauseCriticalInformationIsOftenEncodedInTheirNameButMissingFromTheirMessage() throws IOException, IncorrectFormat {
doThrow(new FileSystemException("the-message")).when(loader).load(any(), any());
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo", archive));
assertEquals("Unable to load database: FileSystemException: the-message", commandFailed.getMessage());
}
use of org.neo4j.cli.CommandFailedException in project neo4j by neo4j.
the class LoadCommandTest method shouldGiveAClearMessageIfTheDatabaseAlreadyExists.
@Test
void shouldGiveAClearMessageIfTheDatabaseAlreadyExists() throws IOException, IncorrectFormat {
doThrow(FileAlreadyExistsException.class).when(loader).load(any(), any());
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo", archive));
assertEquals("Database already exists: foo", commandFailed.getMessage());
}
Aggregations