//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotIssueLocksOnNonLeader() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotIssueLocksOnNonLeader() { // given MemberId me = member(0); MemberId leader = member(1); ReplicatedLockTokenStateMachine replicatedLockStateMachine = new ReplicatedLockTokenStateMachine(new InMemoryStateStorage(new ReplicatedLockTokenState())); DirectReplicator replicator = new DirectReplicator(replicatedLockStateMachine); LeaderLocator leaderLocator = mock(typeof(LeaderLocator)); when(leaderLocator.Leader).thenReturn(leader); Locks locks = mock(typeof(Locks)); Org.Neo4j.Kernel.impl.locking.Locks_Client client = mock(typeof(Org.Neo4j.Kernel.impl.locking.Locks_Client)); when(locks.NewClient()).thenReturn(client); LeaderOnlyLockManager lockManager = new LeaderOnlyLockManager(me, replicator, leaderLocator, locks, replicatedLockStateMachine); // when Org.Neo4j.Kernel.impl.locking.Locks_Client lockClient = lockManager.NewClient(); try { lockClient.AcquireExclusive(LockTracer.NONE, ResourceTypes.NODE, 0L); fail("Should have thrown exception"); } catch (AcquireLockTimeoutException) { // expected } }
//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 shouldIssueLocksOnLeader() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldIssueLocksOnLeader() { // given MemberId me = member(0); ReplicatedLockTokenStateMachine replicatedLockStateMachine = new ReplicatedLockTokenStateMachine(new InMemoryStateStorage(new ReplicatedLockTokenState())); DirectReplicator replicator = new DirectReplicator(replicatedLockStateMachine); LeaderLocator leaderLocator = mock(typeof(LeaderLocator)); when(leaderLocator.Leader).thenReturn(me); Locks locks = mock(typeof(Locks)); Org.Neo4j.Kernel.impl.locking.Locks_Client client = mock(typeof(Org.Neo4j.Kernel.impl.locking.Locks_Client)); when(locks.NewClient()).thenReturn(client); LeaderOnlyLockManager lockManager = new LeaderOnlyLockManager(me, replicator, leaderLocator, locks, replicatedLockStateMachine); // when lockManager.NewClient().acquireExclusive(LockTracer.NONE, ResourceTypes.NODE, 0L); // then }
private void InitializeInstanceFields() { _replicator = new DirectReplicator <ReplicatedIdAllocationRequest>(_idAllocationStateMachine); }