@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);
  }
Ejemplo n.º 2
0
  @Test
  public void shouldRejectStoresIfOneFileHasIncorrectVersion() throws IOException {
    changeVersionNumber(fileSystem, new File(workingDirectory, "neostore.nodestore.db"), "v0.9.5");

    assertFalse(
        new UpgradableDatabase(new StoreVersionCheck(fileSystem))
            .storeFilesUpgradeable(workingDirectory));
  }
Ejemplo n.º 3
0
  @Test
  public void shouldCommunicateWhatCausesInabilityToUpgrade() throws IOException {
    changeVersionNumber(fileSystem, new File(workingDirectory, "neostore.nodestore.db"), "v0.9.5");

    try {
      new UpgradableDatabase(new StoreVersionCheck(fileSystem)).checkUpgradeable(workingDirectory);
      fail("should not have been able to upgrade");
    } catch (StoreUpgrader.UnexpectedUpgradingStoreVersionException e) {
      assertThat(
          e.getMessage(),
          is(
              "'neostore.nodestore.db' has a store version number that we cannot upgrade "
                  + "from. Expected 'NodeStore "
                  + LEGACY_VERSION
                  + "' but file is version 'NodeStore v0.9.5'."));
    }
  }