@Test
  public void shouldRefuseToUpgradeIfAllOfTheStoresWeNotShutDownCleanly() throws IOException {
    File workingDirectory =
        new File(
            "target/"
                + StoreUpgraderTestIT.class.getSimpleName()
                + "shouldRefuseToUpgradeIfAllOfTheStoresWeNotShutDownCleanly");
    File comparisonDirectory =
        new File(
            "target/"
                + StoreUpgraderTestIT.class.getSimpleName()
                + "shouldRefuseToUpgradeIfAllOfTheStoresWeNotShutDownCleanly-comparison");
    MigrationTestUtils.prepareSampleLegacyDatabase(workingDirectory);

    truncateAllFiles(workingDirectory);
    deleteRecursively(comparisonDirectory);
    copyRecursively(workingDirectory, comparisonDirectory);

    try {
      newUpgrader(
              alwaysAllowed(),
              new StoreMigrator(new SilentMigrationProgressMonitor()),
              new DatabaseFiles())
          .attemptUpgrade(new File(workingDirectory, NeoStore.DEFAULT_NAME).getPath());
      fail("Should throw exception");
    } catch (StoreUpgrader.UnableToUpgradeException e) {
      // expected
    }

    verifyFilesHaveSameContent(comparisonDirectory, workingDirectory);
  }
  @Test
  public void shouldLeaveAllFilesUntouchedIfWrongVersionNumberFound() throws IOException {
    File workingDirectory =
        new File(
            "target/"
                + StoreUpgraderTestIT.class.getSimpleName()
                + "shouldLeaveAllFilesUntouchedIfWrongVersionNumberFound");
    File comparisonDirectory =
        new File(
            "target/"
                + StoreUpgraderTestIT.class.getSimpleName()
                + "shouldLeaveAllFilesUntouchedIfWrongVersionNumberFound-comparison");
    MigrationTestUtils.prepareSampleLegacyDatabase(workingDirectory);

    changeVersionNumber(new File(workingDirectory, "neostore.nodestore.db"), "v0.9.5");
    deleteRecursively(comparisonDirectory);
    copyRecursively(workingDirectory, comparisonDirectory);

    try {
      newUpgrader(
              alwaysAllowed(),
              new StoreMigrator(new SilentMigrationProgressMonitor()),
              new DatabaseFiles())
          .attemptUpgrade(new File(workingDirectory, NeoStore.DEFAULT_NAME).getPath());
      fail("Should throw exception");
    } catch (StoreUpgrader.UnableToUpgradeException e) {
      // expected
    }

    verifyFilesHaveSameContent(comparisonDirectory, workingDirectory);
  }
  @Test
  public void shouldLeaveACopyOfOriginalStoreFilesInBackupDirectory() throws IOException {
    File workingDirectory =
        new File(
            "target/"
                + StoreUpgraderTestIT.class.getSimpleName()
                + "shouldLeaveACopyOfOriginalStoreFilesInBackupDirectory");
    MigrationTestUtils.prepareSampleLegacyDatabase(workingDirectory);

    newUpgrader(
            alwaysAllowed(),
            new StoreMigrator(new SilentMigrationProgressMonitor()),
            new DatabaseFiles())
        .attemptUpgrade(new File(workingDirectory, NeoStore.DEFAULT_NAME).getPath());

    verifyFilesHaveSameContent(
        MigrationTestUtils.findOldFormatStoreDirectory(),
        new File(workingDirectory, "upgrade_backup"));
  }