use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class LogEntryParserV2_1Test method shouldParseCommandsUsingAGivenFactory.
@Test
public void shouldParseCommandsUsingAGivenFactory() throws IOException {
// given
final Command.NodeCommand nodeCommand = new Command.NodeCommand(new NodeRecord(0), new NodeRecord(0));
final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
// ignored data
// identifier
channel.putInt(123);
// actual read data
nodeCommand.serialize(channel);
channel.getCurrentPosition(marker);
// when
final LogEntryParser<LogEntry> parser = version.entryParser(LogEntryByteCodes.COMMAND);
final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
// then
assertEquals(command, entryOf(logEntry));
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class LogEntryParserV2_1Test method shouldParseOnePhaseCommitEntry.
@Test
public void shouldParseOnePhaseCommitEntry() throws IOException {
// given
final LogEntryCommit commit = new OnePhaseCommit(version, 42, 21);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
// ignored data
// identifier
channel.putInt(123);
// actual read data
channel.putLong(commit.getTxId());
channel.putLong(commit.getTimeWritten());
channel.getCurrentPosition(marker);
// when
final LogEntryParser<LogEntry> parser = version.entryParser(LogEntryByteCodes.TX_1P_COMMIT);
final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
// then
assertEquals(commit, entryOf(logEntry));
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class LogEntryParserV2_1Test method shouldParseEmptyEntry.
@Test
public void shouldParseEmptyEntry() throws IOException {
// when
final LogEntryParser<LogEntry> parser = version.entryParser(LogEntryByteCodes.EMPTY);
final LogEntry logEntry = parser.parse(version, new InMemoryClosableChannel(), marker, commandReader);
// then
assertNull(logEntry);
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class LogEntryParserV2_2Test method shouldParseEmptyEntry.
@Test
public void shouldParseEmptyEntry() throws IOException {
// when
final LogEntryParser parser = version.entryParser(LogEntryByteCodes.EMPTY);
final LogEntry logEntry = parser.parse(version, new InMemoryClosableChannel(), marker, commandReader);
// then
assertNull(logEntry);
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0Test method readRelationshipCommandWithNonRequiredSecondaryUnit.
@Test
public void readRelationshipCommandWithNonRequiredSecondaryUnit() throws IOException {
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipRecord before = new RelationshipRecord(42, true, 1, 2, 3, 4, 5, 6, 7, true, true);
before.setRequiresSecondaryUnit(false);
before.setSecondaryUnitId(52);
RelationshipRecord after = new RelationshipRecord(42, true, 1, 8, 3, 4, 5, 6, 7, true, true);
new Command.RelationshipCommand(before, after).serialize(channel);
PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
Command command = reader.read(channel);
assertTrue(command instanceof Command.RelationshipCommand);
Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
assertEquals(before, relationshipCommand.getBefore());
verifySecondaryUnit(before, relationshipCommand.getBefore());
assertEquals(after, relationshipCommand.getAfter());
}
Aggregations