//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailTransactionIfLockSessionChanges() public virtual void ShouldFailTransactionIfLockSessionChanges() { // given int initialLockSessionId = 23; TransactionToApply transactionToApply = new TransactionToApply(PhysicalTx(initialLockSessionId)); int finalLockSessionId = 24; TransactionCommitProcess localCommitProcess = mock(typeof(TransactionCommitProcess)); ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(mock(typeof(CommandIndexTracker)), LockState(finalLockSessionId), 16, NullLogProvider.Instance, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY); stateMachine.InstallCommitProcess(localCommitProcess, -1L); DirectReplicator <ReplicatedTransaction> replicator = new DirectReplicator <ReplicatedTransaction>(stateMachine); ReplicatedTransactionCommitProcess commitProcess = new ReplicatedTransactionCommitProcess(replicator); // when try { commitProcess.Commit(transactionToApply, NULL, EXTERNAL); fail("Should have thrown exception."); } catch (TransactionFailureException) { // expected } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void raftIndexIsRecorded() throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RaftIndexIsRecorded() { // given int txLockSessionId = Org.Neo4j.Kernel.impl.locking.Locks_Client_Fields.NO_LOCK_SESSION_ID; long anyTransactionId = 1234; long lastCommittedIndex = 1357; long updatedCommandIndex = 2468; // and ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(txLockSessionId), _batchSize, _logProvider, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY); ReplicatedTransaction replicatedTransaction = ReplicatedTransaction.from(PhysicalTx(txLockSessionId)); // and TransactionCommitProcess localCommitProcess = CreateFakeTransactionCommitProcess(anyTransactionId); // when stateMachine.InstallCommitProcess(localCommitProcess, lastCommittedIndex); // then assertEquals(lastCommittedIndex, _commandIndexTracker.AppliedCommandIndex); // when stateMachine.ApplyCommand(replicatedTransaction, updatedCommandIndex, result => { }); stateMachine.EnsuredApplied(); // then assertEquals(updatedCommandIndex, _commandIndexTracker.AppliedCommandIndex); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAcceptTransactionCommittedWithNoLockManager() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAcceptTransactionCommittedWithNoLockManager() { // given int txLockSessionId = Org.Neo4j.Kernel.impl.locking.Locks_Client_Fields.NO_LOCK_SESSION_ID; int currentLockSessionId = 24; long txId = 42L; ReplicatedTransaction tx = ReplicatedTransaction.from(PhysicalTx(txLockSessionId)); TransactionCommitProcess localCommitProcess = CreateFakeTransactionCommitProcess(txId); ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(currentLockSessionId), _batchSize, _logProvider, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY); stateMachine.InstallCommitProcess(localCommitProcess, -1L); AtomicBoolean called = new AtomicBoolean(); // when stateMachine.ApplyCommand(tx, 0, result => { // then called.set(true); try { assertEquals(txId, ( long )result.consume()); } catch (Exception e) { throw new Exception(e); } }); stateMachine.EnsuredApplied(); assertTrue(called.get()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailFutureForTransactionCommittedUnderWrongLockSession() public virtual void ShouldFailFutureForTransactionCommittedUnderWrongLockSession() { // given int txLockSessionId = 23; int currentLockSessionId = 24; ReplicatedTransaction tx = ReplicatedTransaction.from(PhysicalTx(txLockSessionId)); TransactionCommitProcess localCommitProcess = mock(typeof(TransactionCommitProcess)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(commandIndexTracker, lockState(currentLockSessionId), batchSize, logProvider, org.neo4j.io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.NULL, org.neo4j.io.pagecache.tracing.cursor.context.EmptyVersionContextSupplier.EMPTY); ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(currentLockSessionId), _batchSize, _logProvider, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY); stateMachine.InstallCommitProcess(localCommitProcess, -1L); AtomicBoolean called = new AtomicBoolean(); // when stateMachine.ApplyCommand(tx, 0, result => { // then called.set(true); try { result.consume(); fail("should have thrown"); } catch (TransactionFailureException tfe) { assertEquals(Status.Transaction.LockSessionExpired, tfe.status()); } catch (Exception e) { throw new Exception(e); } }); stateMachine.EnsuredApplied(); assertTrue(called.get()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCommitTransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCommitTransaction() { // given int lockSessionId = 23; ReplicatedTransaction tx = ReplicatedTransaction.from(PhysicalTx(lockSessionId)); TransactionCommitProcess localCommitProcess = mock(typeof(TransactionCommitProcess)); PageCursorTracer cursorTracer = mock(typeof(PageCursorTracer)); ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(lockSessionId), _batchSize, _logProvider, () => cursorTracer, EmptyVersionContextSupplier.EMPTY); stateMachine.InstallCommitProcess(localCommitProcess, -1L); // when stateMachine.ApplyCommand(tx, 0, r => { }); stateMachine.EnsuredApplied(); // then verify(localCommitProcess, times(1)).commit(any(typeof(TransactionToApply)), any(typeof(CommitEvent)), any(typeof(TransactionApplicationMode))); verify(cursorTracer, times(1)).reportEvents(); }