private TransactionToApply Tx(long id, long commitTimestamp) { PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(emptyList()); representation.SetHeader(new sbyte[0], 0, 0, commitTimestamp - 10, id - 1, commitTimestamp, 0); return(new TransactionToApply(representation, id)); }
private CommittedTransactionRepresentation NewCommittedTransactionRepresentation() { const long arbitraryRecordId = 27L; Command.NodeCommand command = new Command.NodeCommand(new NodeRecord(arbitraryRecordId), new NodeRecord(arbitraryRecordId)); PhysicalTransactionRepresentation physicalTransactionRepresentation = new PhysicalTransactionRepresentation(singletonList((new LogEntryCommand(command)).Command)); physicalTransactionRepresentation.SetHeader(new sbyte[] {}, 0, 0, 0, 0, 0, 0); LogEntryStart startEntry = new LogEntryStart(0, 0, 0L, 0L, new sbyte[] {}, LogPosition.UNSPECIFIED); LogEntryCommit commitEntry = new LogEntryCommit(42, 0); return(new CommittedTransactionRepresentation(startEntry, physicalTransactionRepresentation, commitEntry)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldMarshalToSameByteIfByteBufBackedOrNot() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldMarshalToSameByteIfByteBufBackedOrNot() { PhysicalTransactionRepresentation expectedTx = new PhysicalTransactionRepresentation(Collections.singleton(new Command.NodeCommand(new NodeRecord(1), new NodeRecord(2)))); expectedTx.SetHeader(new sbyte[0], 1, 2, 3, 4, 5, 6); TransactionRepresentationReplicatedTransaction replicatedTransaction = ReplicatedTransaction.from(expectedTx); MemoryStream stream = new MemoryStream(); ByteBuf buffer = Buffers.buffer(); OutputStreamWritableChannel outputStreamWritableChannel = new OutputStreamWritableChannel(stream); NetworkWritableChannel networkWritableChannel = new NetworkWritableChannel(buffer); replicatedTransaction.Marshal(outputStreamWritableChannel); replicatedTransaction.Marshal(networkWritableChannel); sbyte[] bufferArray = Arrays.copyOf(buffer.array(), buffer.writerIndex()); Assertions.assertArrayEquals(bufferArray, stream.toByteArray()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSuccessfullyCommitTransactionWithNoCommands() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSuccessfullyCommitTransactionWithNoCommands() { // GIVEN long txId = 11; long commitTimestamp = DateTimeHelper.CurrentUnixTimeMillis(); TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore)); TransactionAppender appender = new TestableTransactionAppender(transactionIdStore); when(transactionIdStore.NextCommittingTransactionId()).thenReturn(txId); StorageEngine storageEngine = mock(typeof(StorageEngine)); TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine); PhysicalTransactionRepresentation noCommandTx = new PhysicalTransactionRepresentation(Collections.emptyList()); noCommandTx.SetHeader(new sbyte[0], -1, -1, -1, -1, -1, -1); // WHEN commitProcess.Commit(new TransactionToApply(noCommandTx), _commitEvent, INTERNAL); verify(transactionIdStore).transactionCommitted(txId, FakeCommitment.CHECKSUM, FakeCommitment.TIMESTAMP); }