Exemplo n.º 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();
  }
Exemplo n.º 2
0
 @Before
 public void setUpNeoStore() throws Exception {
   targetDirectory = TargetDirectory.forTest(fs.get(), getClass());
   path = targetDirectory.directory("dir", true);
   Config config = new Config(new HashMap<String, String>(), GraphDatabaseSettings.class);
   StoreFactory sf =
       new StoreFactory(
           config,
           new DefaultIdGeneratorFactory(),
           new DefaultWindowPoolFactory(),
           fs.get(),
           StringLogger.DEV_NULL,
           null);
   sf.createNeoStore(file(NeoStore.DEFAULT_NAME)).close();
 }
Exemplo n.º 3
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();
  }
Exemplo n.º 4
0
  @Test
  public void testSetBlockSize() throws Exception {
    targetDirectory.cleanup();

    Config config =
        new Config(
            MapUtil.stringMap("string_block_size", "62", "array_block_size", "302"),
            GraphDatabaseSettings.class);
    StoreFactory sf =
        new StoreFactory(
            config,
            new DefaultIdGeneratorFactory(),
            new DefaultWindowPoolFactory(),
            fs.get(),
            StringLogger.DEV_NULL,
            null);
    sf.createNeoStore(file("neo")).close();

    initializeStores();
    assertEquals(62 + AbstractDynamicStore.BLOCK_HEADER_SIZE, pStore.getStringBlockSize());
    assertEquals(302 + AbstractDynamicStore.BLOCK_HEADER_SIZE, pStore.getArrayBlockSize());
    ds.stop();
  }