use of org.neo4j.kernel.impl.store.format.standard.PropertyKeyTokenRecordFormat in project neo4j by neo4j.
the class IdGeneratorTest method testUnsignedId.
@Test
public void testUnsignedId() {
try {
PropertyKeyTokenRecordFormat recordFormat = new PropertyKeyTokenRecordFormat();
IdGeneratorImpl.createGenerator(fs, idGeneratorFile(), 0, false);
IdGenerator idGenerator = new IdGeneratorImpl(fs, idGeneratorFile(), 1, recordFormat.getMaxId(), false, 0);
idGenerator.setHighId(recordFormat.getMaxId());
long id = idGenerator.nextId();
assertEquals(recordFormat.getMaxId(), id);
idGenerator.freeId(id);
try {
idGenerator.nextId();
fail("Shouldn't be able to get next ID");
} catch (StoreFailureException e) {
// good, capacity exceeded
}
closeIdGenerator(idGenerator);
idGenerator = new IdGeneratorImpl(fs, idGeneratorFile(), 1, recordFormat.getMaxId(), false, 0);
assertEquals(recordFormat.getMaxId() + 1, idGenerator.getHighId());
id = idGenerator.nextId();
assertEquals(recordFormat.getMaxId(), id);
try {
idGenerator.nextId();
} catch (StoreFailureException e) {
// good, capacity exceeded
}
closeIdGenerator(idGenerator);
} finally {
File file = idGeneratorFile();
if (file.exists()) {
assertTrue(file.delete());
}
}
}
Aggregations