use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class SchemaRuleCommandTest method shouldRecreateSchemaRuleWhenDeleteCommandReadFromDisk.
@Test
public void shouldRecreateSchemaRuleWhenDeleteCommandReadFromDisk() throws Exception {
// GIVEN
SchemaRecord beforeRecords = serialize(rule, id, true, true);
SchemaRecord afterRecords = serialize(rule, id, false, false);
SchemaRuleCommand command = new SchemaRuleCommand(beforeRecords, afterRecords, rule);
InMemoryClosableChannel buffer = new InMemoryClosableChannel();
when(neoStores.getSchemaStore()).thenReturn(schemaStore);
// WHEN
command.serialize(buffer);
Command readCommand = reader.read(buffer);
// THEN
assertThat(readCommand, instanceOf(SchemaRuleCommand.class));
assertSchemaRule((SchemaRuleCommand) readCommand);
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class IndexDefineCommandTest method shouldFailToWriteIndexDefineCommandIfMapIsLargerThanShort.
@Test
public void shouldFailToWriteIndexDefineCommandIfMapIsLargerThanShort() throws IOException {
// GIVEN
InMemoryClosableChannel channel = new InMemoryClosableChannel(1000);
IndexDefineCommand command = mock(IndexDefineCommand.class);
Map<String, Integer> largeMap = initMap(0xFFFF + 1);
when(command.getIndexNameIdRange()).thenReturn(largeMap);
when(command.getKeyIdRange()).thenReturn(largeMap);
// WHEN
try {
command.serialize(channel);
fail("Expected an AssertionError");
} catch (AssertionError e) {
// THEN Fine
}
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class InMemoryCountsStoreSnapshotDeserializerTest method correctlyDeserializeIndexSample.
@Test
public void correctlyDeserializeIndexSample() throws IOException {
//GIVEN
long indexId = 1;
serializedBytes = ByteBuffer.allocate(1000);
InMemoryClosableChannel logChannel = new InMemoryClosableChannel(serializedBytes.array(), false);
writeSimpleHeader(logChannel);
logChannel.put(INDEX_SAMPLE.code);
logChannel.putLong(indexId);
logChannel.putLong(1);
logChannel.putLong(1);
//WHEN
IndexSampleKey expectedNode = CountsKeyFactory.indexSampleKey(indexId);
CountsSnapshot countsSnapshot = deserialize(logChannel);
//THEN
assertNotNull(countsSnapshot.getMap().get(expectedNode));
assertArrayEquals(new long[] { 1, 1 }, countsSnapshot.getMap().get(expectedNode));
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class InMemoryCountsStoreSnapshotDeserializerTest method correctlyDeserializeEntityRelationship.
@Test
public void correctlyDeserializeEntityRelationship() throws IOException {
//GIVEN
serializedBytes = ByteBuffer.allocate(1000);
InMemoryClosableChannel logChannel = new InMemoryClosableChannel(serializedBytes.array(), false);
writeSimpleHeader(logChannel);
logChannel.put(ENTITY_RELATIONSHIP.code);
logChannel.putInt(1);
logChannel.putInt(1);
logChannel.putInt(1);
logChannel.putLong(1);
//WHEN
RelationshipKey expectedNode = CountsKeyFactory.relationshipKey(1, 1, 1);
CountsSnapshot countsSnapshot = deserialize(logChannel);
//THEN
assertNotNull(countsSnapshot.getMap().get(expectedNode));
assertArrayEquals(new long[] { 1 }, countsSnapshot.getMap().get(expectedNode));
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class InMemoryCountsStoreSnapshotDeserializerTest method correctlyDeserializeTxId.
@Test
public void correctlyDeserializeTxId() throws IOException {
//GIVEN
serializedBytes = ByteBuffer.allocate(1000);
InMemoryClosableChannel logChannel = new InMemoryClosableChannel(serializedBytes.array(), false);
logChannel.putLong(72);
logChannel.putInt(0);
//WHEN
CountsSnapshot countsSnapshot = deserialize(logChannel);
//THEN
assertEquals(72, countsSnapshot.getTxId());
}
Aggregations