Search in sources :

Example 6 with OutsideWorld

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

the class CheckConsistencyCommandTest method shouldWriteReportFileToCurrentDirectoryByDefault.

@Test
public void shouldWriteReportFileToCurrentDirectoryByDefault() throws IOException, ConsistencyCheckIncompleteException, CommandFailed, IncorrectUsage {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    Path homeDir = testDir.directory("home").toPath();
    OutsideWorld outsideWorld = mock(OutsideWorld.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, testDir.directory("conf").toPath(), outsideWorld, consistencyCheckService);
    stub(consistencyCheckService.runFullConsistencyCheck(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyBoolean(), anyObject(), any(CheckConsistencyConfig.class))).toReturn(ConsistencyCheckService.Result.success(null));
    checkConsistencyCommand.execute(new String[] { "--database=mydb" });
    verify(consistencyCheckService).runFullConsistencyCheck(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyBoolean(), eq(new File(".").getCanonicalFile()), any(CheckConsistencyConfig.class));
}
Also used : Path(java.nio.file.Path) OutsideWorld(org.neo4j.commandline.admin.OutsideWorld) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) File(java.io.File) Test(org.junit.Test)

Example 7 with OutsideWorld

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

the class CheckConsistencyCommandTest method databaseAndBackupAreMutuallyExclusive.

@Test
public void databaseAndBackupAreMutuallyExclusive() throws Exception {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    Path homeDir = testDir.directory("home").toPath();
    OutsideWorld outsideWorld = mock(OutsideWorld.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, testDir.directory("conf").toPath(), outsideWorld, consistencyCheckService);
    stub(consistencyCheckService.runFullConsistencyCheck(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyBoolean(), any(CheckConsistencyConfig.class))).toReturn(ConsistencyCheckService.Result.success(null));
    expect.expect(IncorrectUsage.class);
    expect.expectMessage("Only one of '--database' and '--backup' can be specified.");
    checkConsistencyCommand.execute(new String[] { "--database=foo", "--backup=bar" });
}
Also used : Path(java.nio.file.Path) OutsideWorld(org.neo4j.commandline.admin.OutsideWorld) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) Test(org.junit.Test)

Example 8 with OutsideWorld

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

the class CheckConsistencyCommandTest method shouldCanonicalizeReportDirectory.

@Test
public void shouldCanonicalizeReportDirectory() throws IOException, ConsistencyCheckIncompleteException, CommandFailed, IncorrectUsage {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    Path homeDir = testDir.directory("home").toPath();
    OutsideWorld outsideWorld = mock(OutsideWorld.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, testDir.directory("conf").toPath(), outsideWorld, consistencyCheckService);
    stub(consistencyCheckService.runFullConsistencyCheck(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyBoolean(), anyObject(), any(CheckConsistencyConfig.class))).toReturn(ConsistencyCheckService.Result.success(null));
    checkConsistencyCommand.execute(new String[] { "--database=mydb", "--report-dir=" + Paths.get("..", "bar") });
    verify(consistencyCheckService).runFullConsistencyCheck(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyBoolean(), eq(new File("../bar").getCanonicalFile()), any(CheckConsistencyConfig.class));
}
Also used : Path(java.nio.file.Path) OutsideWorld(org.neo4j.commandline.admin.OutsideWorld) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) File(java.io.File) Test(org.junit.Test)

Example 9 with OutsideWorld

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

the class CheckConsistencyCommandTest method runsConsistencyChecker.

@Test
public void runsConsistencyChecker() throws Exception {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    Path homeDir = testDir.directory("home").toPath();
    OutsideWorld outsideWorld = mock(OutsideWorld.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, testDir.directory("conf").toPath(), outsideWorld, consistencyCheckService);
    File databasePath = new File(homeDir.toFile(), "data/databases/mydb");
    when(consistencyCheckService.runFullConsistencyCheck(eq(databasePath), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(false), anyObject(), any(CheckConsistencyConfig.class))).thenReturn(ConsistencyCheckService.Result.success(null));
    checkConsistencyCommand.execute(new String[] { "--database=mydb" });
    verify(consistencyCheckService).runFullConsistencyCheck(eq(databasePath), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(false), anyObject(), any(CheckConsistencyConfig.class));
}
Also used : Path(java.nio.file.Path) LogProvider(org.neo4j.logging.LogProvider) OutsideWorld(org.neo4j.commandline.admin.OutsideWorld) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) ProgressMonitorFactory(org.neo4j.helpers.progress.ProgressMonitorFactory) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) Config(org.neo4j.kernel.configuration.Config) File(java.io.File) Test(org.junit.Test)

Example 10 with OutsideWorld

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

the class CheckConsistencyCommandTest method shouldWriteReportFileToSpecifiedDirectory.

@Test
public void shouldWriteReportFileToSpecifiedDirectory() throws IOException, ConsistencyCheckIncompleteException, CommandFailed, IncorrectUsage {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    Path homeDir = testDir.directory("home").toPath();
    OutsideWorld outsideWorld = mock(OutsideWorld.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, testDir.directory("conf").toPath(), outsideWorld, consistencyCheckService);
    stub(consistencyCheckService.runFullConsistencyCheck(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyBoolean(), anyObject(), any(CheckConsistencyConfig.class))).toReturn(ConsistencyCheckService.Result.success(null));
    checkConsistencyCommand.execute(new String[] { "--database=mydb", "--report-dir=some-dir-or-other" });
    verify(consistencyCheckService).runFullConsistencyCheck(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyBoolean(), eq(new File("some-dir-or-other").getCanonicalFile()), any(CheckConsistencyConfig.class));
}
Also used : Path(java.nio.file.Path) OutsideWorld(org.neo4j.commandline.admin.OutsideWorld) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) File(java.io.File) Test(org.junit.Test)

Aggregations

OutsideWorld (org.neo4j.commandline.admin.OutsideWorld)13 Test (org.junit.Test)11 Path (java.nio.file.Path)10 File (java.io.File)9 CheckConsistencyConfig (org.neo4j.consistency.checking.full.CheckConsistencyConfig)9 Config (org.neo4j.kernel.configuration.Config)5 ProgressMonitorFactory (org.neo4j.helpers.progress.ProgressMonitorFactory)4 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)4 LogProvider (org.neo4j.logging.LogProvider)4 Before (org.junit.Before)2 Matchers.containsString (org.hamcrest.Matchers.containsString)1 CommandFailed (org.neo4j.commandline.admin.CommandFailed)1 NullOutsideWorld (org.neo4j.commandline.admin.NullOutsideWorld)1 RealOutsideWorld (org.neo4j.commandline.admin.RealOutsideWorld)1 Args (org.neo4j.helpers.Args)1 User (org.neo4j.kernel.impl.security.User)1 FileUserRepository (org.neo4j.server.security.auth.FileUserRepository)1 UserRepository (org.neo4j.server.security.auth.UserRepository)1