Search in sources :

Example 1 with PropertyKeyTokenRecordFormat

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());
        }
    }
}
Also used : PropertyKeyTokenRecordFormat(org.neo4j.kernel.impl.store.format.standard.PropertyKeyTokenRecordFormat) IdGeneratorImpl(org.neo4j.kernel.impl.store.id.IdGeneratorImpl) IdGenerator(org.neo4j.kernel.impl.store.id.IdGenerator) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 Test (org.junit.Test)1 PropertyKeyTokenRecordFormat (org.neo4j.kernel.impl.store.format.standard.PropertyKeyTokenRecordFormat)1 IdGenerator (org.neo4j.kernel.impl.store.id.IdGenerator)1 IdGeneratorImpl (org.neo4j.kernel.impl.store.id.IdGeneratorImpl)1