Search in sources :

Example 1 with OutsideWorld

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

the class CheckConsistencyCommandTest method passesOnCheckParameters.

@Test
public void passesOnCheckParameters() 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(), anyObject(), any(CheckConsistencyConfig.class))).toReturn(ConsistencyCheckService.Result.success(null));
    checkConsistencyCommand.execute(new String[] { "--database=mydb", "--check-graph=false", "--check-indexes=false", "--check-label-scan-store=false", "--check-property-owners=true" });
    verify(consistencyCheckService).runFullConsistencyCheck(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyBoolean(), anyObject(), eq(new CheckConsistencyConfig(false, false, false, true)));
}
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 2 with OutsideWorld

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

the class CheckConsistencyCommandTest method failsWhenInconsistenciesAreFound.

@Test
public void failsWhenInconsistenciesAreFound() 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(true), anyObject(), any(CheckConsistencyConfig.class))).thenReturn(ConsistencyCheckService.Result.failure(new File("/the/report/path")));
    try {
        checkConsistencyCommand.execute(new String[] { "--database=mydb", "--verbose" });
    } catch (CommandFailed e) {
        assertThat(e.getMessage(), containsString(new File("/the/report/path").toString()));
    }
}
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) CommandFailed(org.neo4j.commandline.admin.CommandFailed) File(java.io.File) Test(org.junit.Test)

Example 3 with OutsideWorld

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

the class CheckConsistencyCommandTest method enablesVerbosity.

@Test
public void enablesVerbosity() 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(true), anyObject(), any(CheckConsistencyConfig.class))).thenReturn(ConsistencyCheckService.Result.success(null));
    checkConsistencyCommand.execute(new String[] { "--database=mydb", "--verbose" });
    verify(consistencyCheckService).runFullConsistencyCheck(eq(databasePath), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(true), 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 4 with OutsideWorld

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

the class CheckConsistencyCommandTest method canRunOnBackup.

@Test
public void canRunOnBackup() throws Exception {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    Path backupDir = testDir.directory("backup").toPath();
    Path homeDir = testDir.directory("home").toPath();
    OutsideWorld outsideWorld = mock(OutsideWorld.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, testDir.directory("conf").toPath(), outsideWorld, consistencyCheckService);
    when(consistencyCheckService.runFullConsistencyCheck(eq(backupDir.toFile()), 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[] { "--backup=" + backupDir });
    verify(consistencyCheckService).runFullConsistencyCheck(eq(backupDir.toFile()), 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) Test(org.junit.Test)

Example 5 with OutsideWorld

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

the class CheckConsistencyCommandTest method backupNeedsToBePath.

@Test
public void backupNeedsToBePath() 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 backupPath = new File(homeDir.toFile(), "dir/does/not/exist");
    expect.expect(CommandFailed.class);
    expect.expectMessage("Specified backup should be a directory: " + backupPath);
    checkConsistencyCommand.execute(new String[] { "--backup=" + backupPath });
}
Also used : Path(java.nio.file.Path) OutsideWorld(org.neo4j.commandline.admin.OutsideWorld) 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