Search in sources :

Example 6 with NullOutsideWorld

use of org.neo4j.commandline.admin.NullOutsideWorld in project neo4j by neo4j.

the class ImportCommandTest method failIfDestinationDatabaseAlreadyExists.

@Test
public void failIfDestinationDatabaseAlreadyExists() throws Exception {
    try (NullOutsideWorld outsideWorld = new NullOutsideWorld()) {
        Path homeDir = testDir.directory("home").toPath();
        ImportCommand importCommand = new ImportCommand(homeDir, testDir.directory("conf").toPath(), outsideWorld);
        putStoreInDirectory(homeDir.resolve("data").resolve("databases").resolve("existing.db"));
        String[] arguments = { "--mode=csv", "--database=existing.db" };
        try {
            importCommand.execute(arguments);
            fail("Should have thrown an exception.");
        } catch (Exception e) {
            assertThat(e.getMessage(), containsString("already contains a database"));
        }
    }
}
Also used : Path(java.nio.file.Path) NullOutsideWorld(org.neo4j.commandline.admin.NullOutsideWorld) Matchers.containsString(org.hamcrest.Matchers.containsString) IOException(java.io.IOException) Test(org.junit.Test)

Example 7 with NullOutsideWorld

use of org.neo4j.commandline.admin.NullOutsideWorld in project neo4j by neo4j.

the class ImportCommandTest method requiresDatabaseArgument.

@Test
public void requiresDatabaseArgument() throws Exception {
    try (NullOutsideWorld outsideWorld = new NullOutsideWorld()) {
        ImportCommand importCommand = new ImportCommand(testDir.directory("home").toPath(), testDir.directory("conf").toPath(), outsideWorld);
        String[] arguments = { "--mode=database", "--from=bar" };
        try {
            importCommand.execute(arguments);
            fail("Should have thrown an exception.");
        } catch (IncorrectUsage e) {
            assertThat(e.getMessage(), containsString("database"));
        }
    }
}
Also used : NullOutsideWorld(org.neo4j.commandline.admin.NullOutsideWorld) IncorrectUsage(org.neo4j.commandline.admin.IncorrectUsage) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

Matchers.containsString (org.hamcrest.Matchers.containsString)7 Test (org.junit.Test)7 NullOutsideWorld (org.neo4j.commandline.admin.NullOutsideWorld)7 IncorrectUsage (org.neo4j.commandline.admin.IncorrectUsage)4 File (java.io.File)3 IOException (java.io.IOException)1 Path (java.nio.file.Path)1