Example #1
0
  @Test
  public void testSetLatestConstraintTx() throws Exception {
    // given
    new GraphDatabaseFactory().newEmbeddedDatabase(testDir.absolutePath()).shutdown();
    StoreFactory sf =
        new StoreFactory(
            new Config(new HashMap<String, String>(), GraphDatabaseSettings.class),
            new DefaultIdGeneratorFactory(),
            new DefaultWindowPoolFactory(),
            new DefaultFileSystemAbstraction(),
            StringLogger.DEV_NULL,
            null);

    // when
    NeoStore neoStore = sf.newNeoStore(new File(testDir.absolutePath(), NeoStore.DEFAULT_NAME));

    // then the default is 0
    assertEquals(0l, neoStore.getLatestConstraintIntroducingTx());

    // when
    neoStore.setLatestConstraintIntroducingTx(10l);

    // then
    assertEquals(10l, neoStore.getLatestConstraintIntroducingTx());

    // when
    neoStore.flushAll();
    neoStore.close();
    neoStore = sf.newNeoStore(new File(testDir.absolutePath(), NeoStore.DEFAULT_NAME));

    // then the value should have been stored
    assertEquals(10l, neoStore.getLatestConstraintIntroducingTx());
    neoStore.close();
  }
Example #2
0
  @Test
  public void setVersion() throws Exception {
    String storeDir = "target/test-data/set-version";
    new TestGraphDatabaseFactory()
        .setFileSystem(fs.get())
        .newImpermanentDatabase(storeDir)
        .shutdown();
    assertEquals(1, NeoStore.setVersion(fs.get(), new File(storeDir, NeoStore.DEFAULT_NAME), 10));
    assertEquals(10, NeoStore.setVersion(fs.get(), new File(storeDir, NeoStore.DEFAULT_NAME), 12));

    StoreFactory sf =
        new StoreFactory(
            new Config(new HashMap<String, String>(), GraphDatabaseSettings.class),
            new DefaultIdGeneratorFactory(),
            new DefaultWindowPoolFactory(),
            fs.get(),
            StringLogger.DEV_NULL,
            null);

    NeoStore neoStore = sf.newNeoStore(new File(storeDir, NeoStore.DEFAULT_NAME));
    assertEquals(12, neoStore.getVersion());
    neoStore.close();
  }