Search in sources :

Example 1 with TestCommand

use of org.neo4j.kernel.impl.api.TestCommand in project neo4j by neo4j.

the class ReversedSingleFileTransactionCursorTest method tx.

private static TransactionRepresentation tx(int size) {
    List<StorageCommand> commands = new ArrayList<>();
    for (int i = 0; i < size; i++) {
        // The type of command doesn't matter here
        commands.add(new TestCommand());
    }
    PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(commands);
    tx.setHeader(new byte[0], 0, 0, 0, 0, ANONYMOUS);
    return tx;
}
Also used : TestCommand(org.neo4j.kernel.impl.api.TestCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 2 with TestCommand

use of org.neo4j.kernel.impl.api.TestCommand in project neo4j by neo4j.

the class LogEntryParserDispatcherV6Test method shouldParserCommandsUsingAGivenFactory.

@Test
void shouldParserCommandsUsingAGivenFactory() throws IOException {
    // given
    // The record, it will be used as before and after
    TestCommand testCommand = new TestCommand(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    final LogEntryCommand command = new LogEntryCommand(version, testCommand);
    final InMemoryClosableChannel channel = new InMemoryClosableChannel();
    testCommand.serialize(channel);
    channel.getCurrentPosition(marker);
    // when
    final LogEntryParser parser = parserSet(LATEST).select(LogEntryTypeCodes.COMMAND);
    final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
    // then
    assertEquals(command, logEntry);
}
Also used : TestCommand(org.neo4j.kernel.impl.api.TestCommand) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.jupiter.api.Test)

Example 3 with TestCommand

use of org.neo4j.kernel.impl.api.TestCommand in project neo4j by neo4j.

the class TransactionLogAppendAndRotateIT method sillyTransaction.

private static TransactionRepresentation sillyTransaction(int size) {
    List<StorageCommand> commands = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        // The actual data isn't super important
        commands.add(new TestCommand(30));
        commands.add(new TestCommand(60));
    }
    PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(commands);
    tx.setHeader(new byte[0], 0, 0, 0, 0, ANONYMOUS);
    return tx;
}
Also used : TestCommand(org.neo4j.kernel.impl.api.TestCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList)

Example 4 with TestCommand

use of org.neo4j.kernel.impl.api.TestCommand in project neo4j by neo4j.

the class VersionAwareLogEntryReaderTest method shouldReadACommandLogEntry.

@Test
void shouldReadACommandLogEntry() throws IOException {
    // given
    KernelVersion version = LATEST;
    TestCommand testCommand = new TestCommand(new byte[] { 100, 101, 102 });
    final LogEntryCommand command = new LogEntryCommand(version, testCommand);
    final InMemoryClosableChannel channel = new InMemoryClosableChannel(true);
    channel.put(version.version());
    channel.put(LogEntryTypeCodes.COMMAND);
    testCommand.serialize(channel);
    // when
    final LogEntry logEntry = logEntryReader.readLogEntry(channel);
    // then
    assertEquals(command, logEntry);
}
Also used : KernelVersion(org.neo4j.kernel.KernelVersion) TestCommand(org.neo4j.kernel.impl.api.TestCommand) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.jupiter.api.Test)

Aggregations

TestCommand (org.neo4j.kernel.impl.api.TestCommand)4 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)2 StorageCommand (org.neo4j.storageengine.api.StorageCommand)2 KernelVersion (org.neo4j.kernel.KernelVersion)1 PhysicalTransactionRepresentation (org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)1