Search in sources :

Example 1 with NullOutsideWorld

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

the class DatabaseImporterTest method requiresFromArgument.

@Test
public void requiresFromArgument() throws Exception {
    String[] arguments = { "--mode=database", "--database=bar" };
    try {
        new DatabaseImporter(Args.parse(arguments), Config.defaults(), new NullOutsideWorld());
        fail("Should have thrown an exception.");
    } catch (IncorrectUsage e) {
        assertThat(e.getMessage(), containsString("from"));
    }
}
Also used : NullOutsideWorld(org.neo4j.commandline.admin.NullOutsideWorld) IncorrectUsage(org.neo4j.commandline.admin.IncorrectUsage) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 2 with NullOutsideWorld

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

the class DatabaseImporterTest method copiesDatabaseFromOldLocationToNewLocation.

@Test
public void copiesDatabaseFromOldLocationToNewLocation() throws Exception {
    File home = testDir.directory("home");
    File from = provideStoreDirectory();
    File destination = new File(new File(new File(home, "data"), "databases"), "bar");
    String[] arguments = { "--mode=database", "--database=bar", "--from=" + from.getAbsolutePath() };
    DatabaseImporter importer = new DatabaseImporter(Args.parse(arguments), getConfigWith(home, "bar"), new NullOutsideWorld());
    assertThat(destination, not(isExistingDatabase()));
    importer.doImport();
    assertThat(destination, isExistingDatabase());
}
Also used : NullOutsideWorld(org.neo4j.commandline.admin.NullOutsideWorld) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 3 with NullOutsideWorld

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

the class ImportCommandTest method failIfInvalidModeSpecified.

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

Example 4 with NullOutsideWorld

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

the class DatabaseImporterTest method removesOldMessagesLog.

@Test
public void removesOldMessagesLog() throws Exception {
    File home = testDir.directory("home");
    File from = provideStoreDirectory();
    File oldMessagesLog = new File(from, "messages.log");
    assertTrue(oldMessagesLog.createNewFile());
    File destination = new File(new File(new File(home, "data"), "databases"), "bar");
    String[] arguments = { "--mode=database", "--database=bar", "--from=" + from.getAbsolutePath() };
    DatabaseImporter importer = new DatabaseImporter(Args.parse(arguments), getConfigWith(home, "bar"), new NullOutsideWorld());
    File messagesLog = new File(destination, "messages.log");
    importer.doImport();
    assertFalse(messagesLog.exists());
}
Also used : NullOutsideWorld(org.neo4j.commandline.admin.NullOutsideWorld) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 5 with NullOutsideWorld

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

the class DatabaseImporterTest method failIfSourceIsNotAStore.

@Test
public void failIfSourceIsNotAStore() throws Exception {
    File from = testDir.directory("empty");
    String[] arguments = { "--mode=database", "--database=bar", "--from=" + from.getAbsolutePath() };
    try {
        new DatabaseImporter(Args.parse(arguments), Config.defaults(), new NullOutsideWorld());
        fail("Should have thrown an exception.");
    } catch (IncorrectUsage e) {
        assertThat(e.getMessage(), containsString("does not contain a database"));
    }
}
Also used : NullOutsideWorld(org.neo4j.commandline.admin.NullOutsideWorld) IncorrectUsage(org.neo4j.commandline.admin.IncorrectUsage) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) 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